oxygen plugin and we want to add the menu iteam to the exisitn Jpopup Menu when the prspective as .xpr project

Post here questions and problems related to oXygen frameworks/document types.
vishwavaranasi
Posts: 174
Joined: Fri Feb 28, 2020 4:02 pm

oxygen plugin and we want to add the menu iteam to the exisitn Jpopup Menu when the prspective as .xpr project

Post by vishwavaranasi »

Hello Team ,
We have a oxygen plugin and we want to add the menu item to the exisitn Jpopup Menu when the prspective as .xpr project
we want to add new Menu Item to the below exsitng
image.png
please point us the APIs to implement the same.

Thanks,
Vishwa
You do not have the required permissions to view the files attached to this post.
Thanks,
vishwa
Radu
Posts: 9487
Joined: Fri Jul 09, 2004 5:18 pm

Re: oxygen plugin and we want to add the menu iteam to the exisitn Jpopup Menu when the prspective as .xpr project

Post by Radu »

Hi VIshwa,
If you already implemented an Oxygen Workspace Access plugin extension, maybe you can use the API ro.sync.exml.workspace.api.standalone.StandalonePluginWorkspace.getProjectManager().
The project controller has APIs to add a popup menu customizer "ro.sync.exml.workspace.api.standalone.project.ProjectController.addPopUpMenuCustomizer(ProjectPopupMenuCustomizer)".
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
vishwavaranasi
Posts: 174
Joined: Fri Feb 28, 2020 4:02 pm

Re: oxygen plugin and we want to add the menu iteam to the exisitn Jpopup Menu when the prspective as .xpr project

Post by vishwavaranasi »

Thanks Radu ,API ro.sync.exml.workspace.api.standalone.project.ProjectController.addPopUpMenuCustomizer(ProjectPopupMenuCustomizer) worked for me to create popup menu on the project files
my plugin has below
I have Jframe opens with the Jpopmenu Item Action , and am using the below code

Code: Select all

Action MyNewProjectAction = new AbstractAction() {
                    @Override
                    public void actionPerformed(ActionEvent e) {

                      //  System.setProperty("swing.defaultlaf", UIManager.getCrossPlatformLookAndFeelClassName());

                        try {
                            System.out.println("set LAF as windows");
                            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                        } catch (Exception eee) {
                            eee.printStackTrace();
                        }
                        SwingUtilities.invokeLater(() -> {

                          /*  try {
                                UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
                            } catch (ClassNotFoundException | InstantiationException | IllegalAccessException |
                                     UnsupportedLookAndFeelException exception) {
                                System.err.println("Error setting system look and feel: " + exception.getMessage());
                            } */
                            MyFrame frame = new MyFrame("Test",pluginWorkspaceAccess);
                            frame.setTitle("MyFrame)");
                            frame.pack();
                            frame.setResizable(false);
                            frame.setLocationRelativeTo((Component) pluginWorkspaceAccess.getParentFrame());
                            frame.setVisible(true);

                        });

                    }

                };
I have installed plugin , the frame is opened on the click newly created popup menu , and in MyFrame there is a button to perform some task , but on click of button it is thrwoing me

Code: Select all

Exception in thread "AWT-EventQueue-0" java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessClassInPackage.com.sun.java.swing.plaf.windows")
        at java.base/java.security.AccessControlContext.checkPermission(AccessControlContext.java:485)
        at java.base/java.security.AccessController.checkPermission(AccessController.java:1068)
        at java.base/java.lang.SecurityManager.checkPermission(SecurityManager.java:416)
        at ro.sync.security.manager.SandboxSecurityManager.checkPermissionInternal(SandboxSecurityManager.java:295)
        at ro.sync.security.manager.SandboxSecurityManager.checkPermission(SandboxSecurityManager.java:246)
        at java.base/java.lang.SecurityManager.checkPackageAccess(SecurityManager.java:1332)
        at java.base/sun.reflect.misc.ReflectUtil.checkPackageAccess(ReflectUtil.java:158)
        at java.desktop/javax.swing.UIDefaults.getUIClass(UIDefaults.java:714)
        at java.desktop/javax.swing.UIDefaults.getUI(UIDefaults.java:789)
        at java.desktop/javax.swing.UIManager.getUI(UIManager.java:1073)
        at java.desktop/javax.swing.JLabel.updateUI(JLabel.java:288)
        at java.desktop/javax.swing.JLabel.<init>(JLabel.java:180)
        at java.desktop/javax.swing.JLabel.<init>(JLabel.java:199)
        at java.desktop/javax.swing.plaf.basic.BasicOptionPaneUI.addMessageComponents(BasicOptionPaneUI.java:489)
        at java.desktop/javax.swing.plaf.basic.BasicOptionPaneUI.createMessageArea(BasicOptionPaneUI.java:376)
        at java.desktop/javax.swing.plaf.basic.BasicOptionPaneUI.installComponents(BasicOptionPaneUI.java:199)
        at java.desktop/javax.swing.plaf.basic.BasicOptionPaneUI.installUI(BasicOptionPaneUI.java:159)
     
- My plugin Compiled with java 11 and am using oxygen 27.1
Thanks,
vishwa
Radu
Posts: 9487
Joined: Fri Jul 09, 2004 5:18 pm

Re: oxygen plugin and we want to add the menu iteam to the exisitn Jpopup Menu when the prspective as .xpr project

Post by Radu »

Hi,
Your "UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());" code attempts to change the look and feel for the entire started process, including the Oxygen main frame, please do not do that, this is not supported.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
vishwavaranasi
Posts: 174
Joined: Fri Feb 28, 2020 4:02 pm

Re: oxygen plugin and we want to add the menu iteam to the exisitn Jpopup Menu when the prspective as .xpr project

Post by vishwavaranasi »

Radu , I have removed the following code , but i still see the same security error.

Code: Select all

 try {
                            System.out.println("set LAF as windows");
                            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                        } catch (Exception eee) {
                            eee.printStackTrace();
                        }
furthur analysis
my code is calling somewhere

Code: Select all

String tempDirectory = "my_temp";

Files.createTempDirectory(tempDirectory).toFile().getAbsolutePath()
TempFileHelper.java of JDK has the block of code where it is throwing the SecurityException with the message
"Unable to create temporary file or directory"

https://github.com/frohoff/jdk8u-jdk/bl ... elper.java
has this code
catch (SecurityException e) {
// don't reveal temporary directory location
if (dir == tmpdir && sm != null)
throw new SecurityException("Unable to create temporary file or directory");
throw e;
} catch (FileAlreadyExistsException e) {
// ignore
}
please help me here
Thanks,
vishwa
Radu
Posts: 9487
Joined: Fri Jul 09, 2004 5:18 pm

Re: oxygen plugin and we want to add the menu iteam to the exisitn Jpopup Menu when the prspective as .xpr project

Post by Radu »

Hi,
Strange...
With what version of Java are you starting Oxygen?
How are you starting Oxygen? Using one of our command line executables from the Oxygen installation folder like "oxygen.bat"? Or with your own command line? If so how does your command line look like?
Do you have other parts in your code where you attempt to set a security manager to the Java VM?
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
vishwavaranasi
Posts: 174
Joined: Fri Feb 28, 2020 4:02 pm

Re: oxygen plugin and we want to add the menu iteam to the exisitn Jpopup Menu when the prspective as .xpr project

Post by vishwavaranasi »

Yes Radu , am starting with using oxygen.bat file.
on start of oxygen editor i could see the cmd prompt log

Code: Select all

NOTE: Picked up JDK_JAVA_OPTIONS: --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.regex=ALL-UNNAMED --add-opens=java.base/sun.net.util=ALL-UNNAMED --add-opens=java.base/sun.net.www.protocol.http=ALL-UNNAMED --add-opens=java.base/sun.net.www.protocol.https=ALL-UNNAMED --add-opens=java.desktop/java.awt=ALL-UNNAMED --add-opens=java.desktop/java.awt.dnd=ALL-UNNAMED --add-opens=java.desktop/javax.swing=ALL-UNNAMED --add-opens=java.desktop/javax.swing.text=ALL-UNNAMED --add-opens=java.desktop/javax.swing.plaf.basic=ALL-UNNAMED --add-opens=java.desktop/com.sun.java.swing.plaf.windows=ALL-UNNAMED --add-opens=java.xml/com.sun.org.apache.xerces.internal.xni=ALL-UNNAMED --add-opens=javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED --add-opens=javafx.web/javafx.scene.web=ALL-UNNAMED --add-opens=javafx.web/com.sun.javafx.webkit=ALL-UNNAMED
WARNING: A terminally deprecated method in java.lang.System has been called
WARNING: System::setSecurityManager has been called by ro.sync.security.manager.SandboxSecurityManagerInstaller (file:/C:/Program%20Files/Oxygen%20XML%20Editor%2027_1/lib/oxygen-sandbox.jar)
WARNING: Please consider reporting this to the maintainers of ro.sync.security.manager.SandboxSecurityManagerInstaller
WARNING: System::setSecurityManager will be removed in a future release
No where my code is attempting to use security manager , infact no idea what it does.
Thanks,
vishwa
Radu
Posts: 9487
Joined: Fri Jul 09, 2004 5:18 pm

Re: oxygen plugin and we want to add the menu iteam to the exisitn Jpopup Menu when the prspective as .xpr project

Post by Radu »

Hi,
If you look in the main Oxygen menu in the "Help->About" dialog there is a "System settings" tag, there is a property there named "java.version", what value does it have for you?
Could you create a minimal Oxygen plugin which I could use on my side to reproduce the problem? So no confidential code, just a minimal plugin which shows a frame using a similar action and with which you can still reproduce the problem.
Then you can send over the zipped sample plugin using this form:
https://www.oxygenxml.com/techSupport.html
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
vishwavaranasi
Posts: 174
Joined: Fri Feb 28, 2020 4:02 pm

Re: oxygen plugin and we want to add the menu iteam to the exisitn Jpopup Menu when the prspective as .xpr project

Post by vishwavaranasi »

sure Radu , i will try creatig sample plugin with what am doing , will send you soon.
image.png
You do not have the required permissions to view the files attached to this post.
Thanks,
vishwa
Post Reply