Page 1 of 1

Load Layout on editorOpened

Posted: Wed Jul 01, 2015 1:38 am
by dvezina
Hello,
I hope this is not a duplicate as I lost my browser earlier.

I'm writing an OxygenWorkspaceAccessPlugin / Oxygen 17.0

I know how to impose a layout on applicationStarted.

I want to take it a step further and switch the layout based on the document type. That is, call Load Layout passing it the name of my custom layout in the editorOpened() method in my WSEditorChangeListener.

Is this possible?
Thanks

Re: Load Layout on editorOpened

Posted: Wed Jul 01, 2015 3:38 pm
by Radu
Hi Deanna,

I'm not sure that will work or not but you could try it.
But the end users will possibly not like very much to see the entire interface of Oxygen flicker and change, show/hide views and toolbars every time an XML document is opened.

If you want to show/hide specific views/toolbars you can also call:

Code: Select all

StandalonePluginWorkspace.showView(String, boolean)
StandalonePluginWorkspace.hideView(String)
StandalonePluginWorkspace.showToolbar(String)
StandalonePluginWorkspace.hideToolbar(String)
Regards,
Radu

Re: Load Layout on editorOpened

Posted: Wed Jul 01, 2015 5:10 pm
by dvezina
Hi Radu,

Rather than doing it this way - one toolbar and view at a time, is there a way to invoke the "Load Layout" action? Similar to the user clicking on Window > Load Layout > Custom ... > "name of my layout"

This behaviour wouldn't be something that happens all the time - only when the user chooses to switch between different "modes". They would expect things to flicker.

Thanks
D

Re: Load Layout on editorOpened

Posted: Thu Jul 02, 2015 8:46 am
by Radu
Hi Deanna,

Sorry, I forgot to tell you about the actual way to load a custom layout.

You could set the fixed layout in the Oxygen Global preferences using the API like:

Code: Select all


File layoutFile = new File(baseDir, "application.layout");
if (layoutFile.exists()) {
ro.sync.exml.options.PerspectivesLayoutInfo info = new PerspectivesLayoutInfo(true, false, "", layoutFile.getAbsolutePath());
pluginWorkspaceAccess.setGlobalObjectProperty("perspectives.layout.info", info);
}
Ideally you would call this code on a javax.swing.SwingUtilities.invokeLater(Runnable).

Regards,
Radu

Re: Load Layout on editorOpened

Posted: Thu Jul 02, 2015 6:31 pm
by dvezina
Hi Radu,

This brings up a point I forgot to share with you.

This code works in 15.2 but when I switched to 17, it throws a JavaNullPointer at setGlobalObjectProperty the first time a layout is loaded.

Open Oxygen
Window > Load Layout > Default
Close Oxygen

Open Oxygen
>> Exception Thrown
Close Oxygen

Open Oxygen
>> No Exception going forward until you load another layout

Code: Select all


com.vasont.plugin.oxygen.workspace.OxygenWorkspaceAccessPluginExtension$layoutLoader.run(OxygenWorkspaceAccessPluginExtension.java:1908)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

Re: Load Layout on editorOpened

Posted: Fri Jul 03, 2015 11:07 am
by Radu
Hi Deanna,

I managed to reproduce the NPE and we'll work to fix it, thanks for telling us about it.
I will try to add a fix for it in the next Oxygen 17.0 minor bug fix release (in a week or two).

Regards,
Radu

Re: Load Layout on editorOpened

Posted: Fri Jul 31, 2015 6:18 pm
by dvezina
Hi,
Is there a fix for this yet?
Thanks

Re: Load Layout on editorOpened

Posted: Fri Jul 31, 2015 8:05 pm
by Costin
Hello,

I am happy to inform you that this was already fixed in a maintenance build of oXygen XML v17.0.
Therefore, installing the latest build available on our website should avoid the exception from recurring.
According to the build-notes:
Oxygen SDK/API: Fixed NullPointerException error that appeared when loading a layout via API.
Best Regards,
Costin