Page 1 of 1
Removing certain menu options from framework menu
Posted: Thu Jul 21, 2011 6:48 pm
by cnevins
Hi,
It looks like the Refresh, Tags Display Mode, and Profiling/Conditional Text menu options are added to the end of every Associated Document Type Framework menu - both my custom document types and the ones that come with Oxygen. How can I suppress or hide these menu options? I'm not seeing anything in the Document Type author menu customization options. Can I use a plugin that extends the ComponentsValidatorPlugin to remove these on startup? Is there a better method?
Thanks!
-Cole
Re: Removing certain menu options from framework menu
Posted: Fri Jul 22, 2011 11:09 am
by Radu
Hi Cole,
You have basically two ways to approach this:
1) Using a components validator plugin implementation you can remove the actions (but the main menu entries in the framework menu will remain). So you can remove the
Refresh references and
Refresh actions but the menu
Refresh will remain with no child menu items to display.
Example:
Code: Select all
public boolean validateAccelAction(String category, String tag) {
if("Author".equals(category) && "Refresh_references".equals(tag)) {
return false;
}
if("Author".equals(category) && "Reload".equals(tag)) {
return false;
}
System.err.println("cate " + category + " tag:" + tag) ;
return true;
}
2) You can use a WorkspaceAccess plugin implementation which has methods to add a
MenuBarCustomizer like:
Code: Select all
pluginWorkspaceAccess.addMenuBarCustomizer(new MenuBarCustomizer() {
/**
* @see ro.sync.exml.workspace.api.standalone.MenuBarCustomizer#customizeMainMenu(javax.swing.JMenuBar)
*/
public void customizeMainMenu(JMenuBar mainMenuBar) {
..................
The problem is that the framework specific menu is created automatically only when an editor gets selected.
So you must keep a reference to the main JMenuBar received from the customizer.
Then you can add a WSEditorChangeListener like:
Code: Select all
pluginWorkspaceAccess.addEditorChangeListener(
new WSEditorChangeListener() {
@Override
public void editorSelected(URL editorLocation) {
//Here you can recurse the main JMenuBar and remove the items if they exist in the framework menu
};
......................
Re: Removing certain menu options from framework menu
Posted: Mon Sep 30, 2013 12:50 pm
by yann1806
Hi guys,
following to this question - how can I implement hiding or showing menu options when the user takes an arbitrary action? In my case, when my user logs in to a remote repository (via my plugin), I want to show extra menus.
But of course the listeners has methods for editor opened, editor closed, etc, not for my own plugin actions. What's the best way to implement something like that?
Thanks
Yann
Re: Removing certain menu options from framework menu
Posted: Mon Sep 30, 2013 2:13 pm
by Radu
Hi Yann,
If you add a MenuBarCustomizer as in my example above, you will be able to store in a field the main JMenuBar (or your own menu added to the main JMenuBar).
When your action gets called you could update the menu which you have contributed.
Regards,
Radu