JMenuItem at pluginWorkspaceAccess.addMenuBarCustomizer
Post here questions and problems related to oXygen frameworks/document types.
-
- Posts: 168
- Joined: Fri Feb 28, 2020 4:02 pm
JMenuItem at pluginWorkspaceAccess.addMenuBarCustomizer
Post by vishwavaranasi »
Hello Team ,
I have a menu item defined as
since my menu item has already defined the label new JMenuItem("Item1 Selection");
I have not specified anything just empty string here
return new AbstractAction("")
but the menu is not showing label "Item1 Selection" when i run the plugin? it showing empty as below
I have a menu item defined as
Code: Select all
JMenuItem Item1= new JMenuItem("Item1 Selection");
and Action as
final Action selectionSourceAction = createShowSelectionAction(pluginWorkspaceAccess);
Item1 .setAction(createShowSelectionAction);
private AbstractAction createShowSelectionAction(
final StandalonePluginWorkspace pluginWorkspaceAccess) {
return new AbstractAction("") {
}
}
I have not specified anything just empty string here
return new AbstractAction("")
but the menu is not showing label "Item1 Selection" when i run the plugin? it showing empty as below
image.png
You do not have the required permissions to view the files attached to this post.
Thanks,
vishwa
vishwa
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: JMenuItem at pluginWorkspaceAccess.addMenuBarCustomizer
Hi,
This is how the Java Swing libraries work, once you create an action and set it on a menu item, the action controls everything (menu text, code which gets performed when menu is clicked).
So this is not related with Oxygen's API, you can try to create a small java Swing application unrelated with Oxygen and see how it behaves.
Regards,
Radu
This is how the Java Swing libraries work, once you create an action and set it on a menu item, the action controls everything (menu text, code which gets performed when menu is clicked).
So this is not related with Oxygen's API, you can try to create a small java Swing application unrelated with Oxygen and see how it behaves.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 168
- Joined: Fri Feb 28, 2020 4:02 pm
Re: JMenuItem at pluginWorkspaceAccess.addMenuBarCustomizer
Post by vishwavaranasi »
Thanks Radu , we have requirement as below
and when i open a Menu Item 2 - this will open some JFRAME , once this JFRAME opened the Menu Item1 should be enabled.
and when I close the JFRAME , and go back to my custom Menu , then the Menu Item 1 should be disabled again.
How can we implement this?
I was having a instance variable inside my WorkspaceAccessPluginExtension java class ,and inside applicationStarted() method when i call the action for MenuItem2 to open Jframe am setting the value for the flag.
but next time when close that JFRAME and opening the menu , the Menu Item 1 still showing as enabled.
would you please give us some idea here?
image.png
at the plugin start - > Menu Item 1 should be disabled.and when i open a Menu Item 2 - this will open some JFRAME , once this JFRAME opened the Menu Item1 should be enabled.
and when I close the JFRAME , and go back to my custom Menu , then the Menu Item 1 should be disabled again.
How can we implement this?
I was having a instance variable inside my WorkspaceAccessPluginExtension java class ,and inside applicationStarted() method when i call the action for MenuItem2 to open Jframe am setting the value for the flag.
but next time when close that JFRAME and opening the menu , the Menu Item 1 still showing as enabled.
would you please give us some idea here?
You do not have the required permissions to view the files attached to this post.
Thanks,
vishwa
vishwa
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: JMenuItem at pluginWorkspaceAccess.addMenuBarCustomizer
Hi,
Once you create a menu item over an AbstractAction, you control the enabled state of the menu item by setting AbstractAction.setEnabled(...) directly on the action, the action controls the menu item's appearance.
I do not understand your entire setup, if you create a small Oxygen plugin exhibiting the problem without any of your custom code I could try to advice further.
Regards,
Radu
Once you create a menu item over an AbstractAction, you control the enabled state of the menu item by setting AbstractAction.setEnabled(...) directly on the action, the action controls the menu item's appearance.
I do not understand your entire setup, if you create a small Oxygen plugin exhibiting the problem without any of your custom code I could try to advice further.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 168
- Joined: Fri Feb 28, 2020 4:02 pm
Re: JMenuItem at pluginWorkspaceAccess.addMenuBarCustomizer
Post by vishwavaranasi »
Hi Radu , here am attaching the sample plugin project with my requirements.
1 . First time MenuItem1Action is disabled.
2. user click on MenuItem2Action - this will open a Jframe.
3. Now users can access MenuItem1Action.
4. Now the user closes the Jframe opened at step 2.
5. Now the expected behavior is , the MenuItem1Action should be disabled.
Would you please help me here how to achieve the same here.
1 . First time MenuItem1Action is disabled.
2. user click on MenuItem2Action - this will open a Jframe.
3. Now users can access MenuItem1Action.
4. Now the user closes the Jframe opened at step 2.
5. Now the expected behavior is , the MenuItem1Action should be disabled.
Would you please help me here how to achieve the same here.
sample-plugin-workspace-access.zip
You do not have the required permissions to view the files attached to this post.
Thanks,
vishwa
vishwa
-
- Posts: 168
- Joined: Fri Feb 28, 2020 4:02 pm
Re: JMenuItem at pluginWorkspaceAccess.addMenuBarCustomizer
Post by vishwavaranasi »
Hello Team , would you please help us when you get a chance.
Thanks,
vishwa
Thanks,
vishwa
Thanks,
vishwa
vishwa
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: JMenuItem at pluginWorkspaceAccess.addMenuBarCustomizer
Hi,
How about if you do this in the createMenuItem2Action function?
Regards,
Radu
How about if you do this in the createMenuItem2Action function?
Code: Select all
private AbstractAction createMenuItem2Action(StandalonePluginWorkspace pluginWorkspaceAccess) {
return new AbstractAction("MenuItem2Action") {
@Override
public void actionPerformed(ActionEvent e) {
JFrame toShow = new MenuItem2ActionManager();
toShow.addWindowListener(new WindowAdapter() {
@Override
public void windowClosed(WindowEvent e) {
MenuItem1Action.setEnabled(false);
}
});
toShow.setVisible(true);
}
};
}
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 168
- Joined: Fri Feb 28, 2020 4:02 pm
Re: JMenuItem at pluginWorkspaceAccess.addMenuBarCustomizer
Post by vishwavaranasi »
Thanks Radu , its worked for me.
we have another requirement where ,
We want MenuItem1Action.setEnabled(false); when the local file opened inside the oxygen main editor are read-only files
and MenuItem1Action.setEnabled(true); when the local file opened inside the oxygen main editor are writable.
This we are expecting as soon as oxygen loads the plugin and also as and when user closes and open files in the editor.
and also if i have 4 opened files ,
first file is read-only then MenuItem1Action.setEnabled(false);
if I TAB to second file - writable then MenuItem1Action.setEnabled(true);
and so on..
please help me here.
we have another requirement where ,
We want MenuItem1Action.setEnabled(false); when the local file opened inside the oxygen main editor are read-only files
and MenuItem1Action.setEnabled(true); when the local file opened inside the oxygen main editor are writable.
This we are expecting as soon as oxygen loads the plugin and also as and when user closes and open files in the editor.
and also if i have 4 opened files ,
first file is read-only then MenuItem1Action.setEnabled(false);
if I TAB to second file - writable then MenuItem1Action.setEnabled(true);
and so on..
please help me here.
Thanks,
vishwa
vishwa
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: JMenuItem at pluginWorkspaceAccess.addMenuBarCustomizer
Hi,
Using our APis you can add a listener to notify you when a document is selected in the editor area:
https://www.oxygenxml.com/InstData/Edit ... a.net.URL-
Regards,
Radu
Using our APis you can add a listener to notify you when a document is selected in the editor area:
Code: Select all
public void applicationStarted(StandalonePluginWorkspace pluginWorkspaceAccess) {
pluginWorkspaceAccess.addEditorChangeListener(new WSEditorChangeListener() {
/**
* @see ro.sync.exml.workspace.api.listeners.WSEditorChangeListener#editorSelected(java.net.URL)
*/
@Override
public void editorSelected(URL editorLocation) {
if(editorLocation != null && isReadonly(editorLocation)){
MenuItem1Action.setEnabled(false);
}
}
}, PluginWorkspace.MAIN_EDITING_AREA);
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Return to “SDK-API, Frameworks - Document Types”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service