Implementing addMenuBarCustomizer
Post here questions and problems related to editing and publishing DITA content.
-
- Posts: 4
- Joined: Thu Apr 02, 2015 4:45 am
Implementing addMenuBarCustomizer
Post by glen.graebner »
Hi Everyone,
I would like to create a plugin that allows for pre-processing of XML documents before transforming them into DITA topics. My thought was to add a set of menu items to act on the document that is currently open. I am using eclipse with oxygen-sdk-16.1.2-all connected to Oxygen Author using this guidance - https://www.oxygenxml.com/doc/ug-editor ... lugin.html.
So Oxygen Author opens while running eclipse in debug mode, but no menu item is added. Here are the classes I'm writing (at this point they are pretty basic I'm getting back into Java after several years). Any advise would be greatly appreciated. Thank you!
*************************************************
package gehc;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
import ro.sync.exml.plugin.workspace.WorkspaceAccessPluginExtension;
import ro.sync.exml.workspace.api.standalone.MenuBarCustomizer;
import ro.sync.exml.workspace.api.standalone.StandalonePluginWorkspace;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.net.URL;
public class CustomGEHCPluginExtension implements WorkspaceAccessPluginExtension {
private StandalonePluginWorkspace instance = null;
private boolean runPlugin;
public boolean applicationClosing() {
try{
} finally {
return true;
}
}
public void applicationStarted(final StandalonePluginWorkspace pluginWorkspaceAccess) {
pluginWorkspaceAccess.addMenuBarCustomizer(new MenuBarCustomizer() {
final Action showSettingsWindow = new AbstractAction() {
public void actionPerformed(ActionEvent e) {
Integer i = 0;
//processor.showSettingsDialog();
}
};
public void customizeMainMenu(JMenuBar mainMenuBar) {
JMenu menuCMS = new JMenu();
final JMenuItem oneMenuItem = new JMenuItem(showSettingsWindow);
oneMenuItem.setText("GEHC");
menuCMS.add(oneMenuItem);
menuCMS.setText("GEHC");
mainMenuBar.add(menuCMS, mainMenuBar.getMenuCount() - 1);
}
});
}
}
*************************************************
package gehc;
import ro.sync.exml.plugin.Plugin;
import ro.sync.exml.plugin.PluginDescriptor;
public class CustomGEHCPlugin extends Plugin {
/**
* The static plugin instance.
*/
private static CustomGEHCPlugin instance = null;
/**
* Constructs the plugin.
*
* @param descriptor The plugin descriptor
*/
public CustomGEHCPlugin(PluginDescriptor descriptor) {
super(descriptor);
if (instance != null) {
throw new IllegalStateException("Already instantiated!");
}
instance = this;
}
/**
* Get the plugin instance.
*
* @return the shared plugin instance.
*/
public static CustomGEHCPlugin getInstance() {
return instance;
}
}
I would like to create a plugin that allows for pre-processing of XML documents before transforming them into DITA topics. My thought was to add a set of menu items to act on the document that is currently open. I am using eclipse with oxygen-sdk-16.1.2-all connected to Oxygen Author using this guidance - https://www.oxygenxml.com/doc/ug-editor ... lugin.html.
So Oxygen Author opens while running eclipse in debug mode, but no menu item is added. Here are the classes I'm writing (at this point they are pretty basic I'm getting back into Java after several years). Any advise would be greatly appreciated. Thank you!
*************************************************
package gehc;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
import ro.sync.exml.plugin.workspace.WorkspaceAccessPluginExtension;
import ro.sync.exml.workspace.api.standalone.MenuBarCustomizer;
import ro.sync.exml.workspace.api.standalone.StandalonePluginWorkspace;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.net.URL;
public class CustomGEHCPluginExtension implements WorkspaceAccessPluginExtension {
private StandalonePluginWorkspace instance = null;
private boolean runPlugin;
public boolean applicationClosing() {
try{
} finally {
return true;
}
}
public void applicationStarted(final StandalonePluginWorkspace pluginWorkspaceAccess) {
pluginWorkspaceAccess.addMenuBarCustomizer(new MenuBarCustomizer() {
final Action showSettingsWindow = new AbstractAction() {
public void actionPerformed(ActionEvent e) {
Integer i = 0;
//processor.showSettingsDialog();
}
};
public void customizeMainMenu(JMenuBar mainMenuBar) {
JMenu menuCMS = new JMenu();
final JMenuItem oneMenuItem = new JMenuItem(showSettingsWindow);
oneMenuItem.setText("GEHC");
menuCMS.add(oneMenuItem);
menuCMS.setText("GEHC");
mainMenuBar.add(menuCMS, mainMenuBar.getMenuCount() - 1);
}
});
}
}
*************************************************
package gehc;
import ro.sync.exml.plugin.Plugin;
import ro.sync.exml.plugin.PluginDescriptor;
public class CustomGEHCPlugin extends Plugin {
/**
* The static plugin instance.
*/
private static CustomGEHCPlugin instance = null;
/**
* Constructs the plugin.
*
* @param descriptor The plugin descriptor
*/
public CustomGEHCPlugin(PluginDescriptor descriptor) {
super(descriptor);
if (instance != null) {
throw new IllegalStateException("Already instantiated!");
}
instance = this;
}
/**
* Get the plugin instance.
*
* @return the shared plugin instance.
*/
public static CustomGEHCPlugin getInstance() {
return instance;
}
}
-
- Posts: 1016
- Joined: Wed Nov 16, 2005 11:11 am
Re: Implementing addMenuBarCustomizer
Post by alex_jitianu »
Hello,
I've tested the code you provided by changing the oxygen-sample-plugin-workspace-access project from the SDK. Afterwards I've created the plugin package by running *mvn install* and unzipped the package in the plugins folder of an Oxygen installation. The menu appeared in the menu bar so the code is fine.
The conclusion would be that a step from the debug procedure is incorrect. Can you provide a screenshot with the Arguments tab of the configuration created at step 7? There are two arguments areas there, so you should make sure you contributed to the one labeled VM arguments. Another thing to inspect is the value for the parameter -Dcom.oxygenxml.editor.plugins.dir to point to the Eclipse project directory.
If your file structure looks something like this:
the value of the property should be -Dcom.oxygenxml.editor.plugins.dir=D:\workspaceDir\myProjectDir
Best regards,
Alex
I've tested the code you provided by changing the oxygen-sample-plugin-workspace-access project from the SDK. Afterwards I've created the plugin package by running *mvn install* and unzipped the package in the plugins folder of an Oxygen installation. The menu appeared in the menu bar so the code is fine.
The conclusion would be that a step from the debug procedure is incorrect. Can you provide a screenshot with the Arguments tab of the configuration created at step 7? There are two arguments areas there, so you should make sure you contributed to the one labeled VM arguments. Another thing to inspect is the value for the parameter -Dcom.oxygenxml.editor.plugins.dir to point to the Eclipse project directory.
If your file structure looks something like this:
Code: Select all
D:\workspaceDir
- myProjectDir
---src
---plugin.xml
---plugin.dtd
Best regards,
Alex
-
- Posts: 4
- Joined: Thu Apr 02, 2015 4:45 am
Re: Implementing addMenuBarCustomizer
Post by glen.graebner »
Hi Alex,
How should I upload the image?
Also, I could not follow the link.
Thank you,
Glen
How should I upload the image?
Also, I could not follow the link.
Thank you,
Glen
-
- Posts: 4
- Joined: Thu Apr 02, 2015 4:45 am
Re: Implementing addMenuBarCustomizer
Post by glen.graebner »
I see that the link has an extra "." on it.
I did refer to that help page when I set up eclipse...
Glen

I did refer to that help page when I set up eclipse...
Glen
-
- Posts: 1016
- Joined: Wed Nov 16, 2005 11:11 am
Re: Implementing addMenuBarCustomizer
Post by alex_jitianu »
Hi Glen,
Please send it on support@oxygenxml.com. You could also send the zipped Eclipse project folder so I can make sure it has the correct structure. You can rest assure that I will use it only to look for the issue and remove it afterwards.
Best regards,
Alex
Please send it on support@oxygenxml.com. You could also send the zipped Eclipse project folder so I can make sure it has the correct structure. You can rest assure that I will use it only to look for the issue and remove it afterwards.
Best regards,
Alex
-
- Posts: 4
- Joined: Thu Apr 02, 2015 4:45 am
Re: Implementing addMenuBarCustomizer
Post by glen.graebner »
Hi Alex,
I sent the .zip file of the eclipse project to you via Gmail (gdgraebner@gmail.com).
Thanks,
Glen
I sent the .zip file of the eclipse project to you via Gmail (gdgraebner@gmail.com).
Thanks,
Glen
Return to “DITA (Editing and Publishing DITA Content)”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ 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