Page 1 of 1

Implementing addMenuBarCustomizer

Posted: Thu Apr 02, 2015 5:00 am
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;

}

}

Re: Implementing addMenuBarCustomizer

Posted: Thu Apr 02, 2015 10:02 am
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:

Code: Select all


D:\workspaceDir
- myProjectDir
---src
---plugin.xml
---plugin.dtd
the value of the property should be -Dcom.oxygenxml.editor.plugins.dir=D:\workspaceDir\myProjectDir
Best regards,
Alex

Re: Implementing addMenuBarCustomizer

Posted: Thu Apr 02, 2015 2:44 pm
by glen.graebner
Hi Alex,

How should I upload the image?
Also, I could not follow the link.

Thank you,
Glen

Re: Implementing addMenuBarCustomizer

Posted: Thu Apr 02, 2015 2:47 pm
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

Re: Implementing addMenuBarCustomizer

Posted: Thu Apr 02, 2015 3:08 pm
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

Re: Implementing addMenuBarCustomizer

Posted: Thu Apr 02, 2015 5:00 pm
by glen.graebner
Hi Alex,

I sent the .zip file of the eclipse project to you via Gmail (gdgraebner@gmail.com).

Thanks,
Glen