Question about accessing view from selection plugin

Oxygen general issues.
kwbock
Posts: 3
Joined: Mon Nov 12, 2012 9:57 pm

Question about accessing view from selection plugin

Post by kwbock »

I have a question that comes in two parts. We have two plugin extensions, a selection and a workspace access. Currently we are using the workspace access to create a menu, and the selection plugin to manage selection actions.

We would like one of those selection actions to show a customized view, and then the user will interact with that view and it will perform an action based on the selection.

I'm having trouble figuring out how to interact with that view programmatically from the selection plugin extension.

Should I just have one plugin extension that implements both the WorkspaceAccessPluginExtension and the SelectionPluginExtension interfaces or is there a way to access a view through the api?

Thank you for your help.
Radu
Posts: 9445
Joined: Fri Jul 09, 2004 5:18 pm

Re: Question about accessing view from selection plugin

Post by Radu »

Hi,

Please see some answers below:
Currently we are using the workspace access to create a menu, and the selection plugin to manage selection actions.
Actually a Workspace Access plugin can also contribute contextual menu actions to an opened Text editor, something like:

Code: Select all

    pluginWorkspaceAccess.addEditorChangeListener(new WSEditorChangeListener() {
/**
* @see ro.sync.exml.workspace.api.listeners.WSEditorChangeListener#editorOpened(java.net.URL)
*/
@Override
public void editorOpened(URL editorLocation) {
WSEditor editorAccess = pluginWorkspaceAccess.getEditorAccess(editorLocation, StandalonePluginWorkspace.MAIN_EDITING_AREA);
if(editorAccess != null && editorAccess.getCurrentPage() instanceof WSTextEditorPage) {
((WSTextEditorPage)editorAccess.getCurrentPage()).addPopUpMenuCustomizer(new ro.sync.exml.workspace.api.editor.page.text.TextPopupMenuCustomizer() {
public void customizePopUpMenu(Object popUp, WSTextEditorPage textPage) {
JPopupMenu popupMenu = (JPopupMenu) popUp;
//And you can add to it actions.
}
});
}
}
}, StandalonePluginWorkspace.MAIN_EDITING_AREA);
Basically we considered the Workspace Access plugin as a super set of all other older plugin types.
But we still kept the other plugin types.
I'm having trouble figuring out how to interact with that view programmatically from the selection plugin extension.
Should I just have one plugin extension that implements both the WorkspaceAccessPluginExtension and the SelectionPluginExtension interfaces or is there a way to access a view through the api?
If you have two separate plugins, they will have separate Java class loaders so it is hard to interact between them.

So you should have a single plugin (with a single plugin.xml) which has two extensions in it like:

Code: Select all

 <extension type="WorkspaceAccess" 
class="ro.sync.sample.plugin.workspace.CustomWorkspaceAccessPluginExtension"/>
<extension type="selectionProcessor"
class="ro.sync.sample.plugin.formwords.FormWordsPluginExtension"/>
In this way they will be in the same class loader so you will be able to give some static access to the view from the action side.

But the first solution of having everything in the Workspace Access plugin would be more elegant.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply