[oXygen-user] Buffer-related questions (when opened from plugin)
Oxygen XML Editor Support
support at oxygenxml.com
Fri Jun 15 07:26:56 CDT 2012
Hello Florent,
> So probably the best is to use a set based on object identities, with the WSEditor objects. Do we have the
> guarantee that the WSEditor object does not change between the moment
> a file is open and when it is closed? Object identity looks like more
> robust to me than URI comparison, isn't it?
No, actually the method
"ro.sync.exml.workspace.api.PluginWorkspace.getCurrentEditorAccess(int)"
returns each time a new wrapper object over our internal implementation
so you should use the URL as the key which identifies an opened editor.
Then you can use the method
"ro.sync.exml.workspace.api.PluginWorkspace.getEditorAccess(URL, int)"
each time you need the WSEditorAccess.
> BTW, shouldn't a WSEditor object be returned by Workspace.open()?
Yes, good idea, too bad we did not think of it then. We try to keep the
API as backward compatible as possible so the current method cannot be
changed anymore. But the workaround to obtain a WSEditor is simple.
> No, but that's also a requirement Is there any way to open a
> file in read-only using the API? Other than creating a dedicated
> WSEditorChangeListener of course.
There are two ways I think:
1) We have an interface called
"ro.sync.exml.plugin.urlstreamhandler.URLHandlerReadOnlyCheckerExtension" which
can be implemented in the "URLStreamHandlerPluginExtension", there is a
sample for it in the Plugins SDK.
2) On the "WSEditorChangeListener.editorOpened(URL)" callback after a
WSEditor is opened you can gain access to its current page
"ro.sync.exml.workspace.api.editor.WSEditor.getCurrentPage()" and if it
is an instance of WSTextBasedEditorPage use this method:
"WSTextBasedEditorPage.setEditable(boolean)"
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
On 6/15/2012 2:47 PM, Florent Georges wrote:
> Oxygen XML Editor Support wrote:
>
> Hi,
>
> Thank you for your detailed answer!
>
>> You could implement a HashMap in your WorkspaceAccessPluginExtension
>> which would keep that flag for a certain URL for which you wanted
>> the open operation to work.
>
> Interesting idea... Actually, that's just to keep track of the
> buffers opened by the plugin. So probably the best is to use a set
> based on object identities, with the WSEditor objects. Do we have the
> guarantee that the WSEditor object does not change between the moment
> a file is open and when it is closed? Object identity looks like more
> robust to me than URI comparison, isn't it?
>
> BTW, shouldn't a WSEditor object be returned by Workspace.open()?
>
>> Is that boolean flag somewhat related to whether the URL was opened
>> for editing or read-only by the user?
>
> No, but that's also a requirement ;-) Is there any way to open a
> file in read-only using the API? Other than creating a dedicated
> WSEditorChangeListener of course.
>
>>> 2/ to specify a method to be called before closing the buffer (kind
>>> of a buffer listener, so I can do some treatment before closing
>>> it)?
>
>> So you want some kind of a listener to notify you before an opened
>> editor is closed, right?
>
> Precisely.
>
>> WSEditorChangeListener.editorAboutToBeClosed(URL)
>> WSEditorChangeListener.editorClosed(URL)
>
> Perfect!
>
> Thank you, regards,
>
More information about the oXygen-user
mailing list