Load Layout on editorOpened

Oxygen general issues.
dvezina
Posts: 23
Joined: Sat Mar 08, 2014 12:10 am

Load Layout on editorOpened

Post 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
Radu
Posts: 9057
Joined: Fri Jul 09, 2004 5:18 pm

Re: Load Layout on editorOpened

Post 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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
dvezina
Posts: 23
Joined: Sat Mar 08, 2014 12:10 am

Re: Load Layout on editorOpened

Post 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
Radu
Posts: 9057
Joined: Fri Jul 09, 2004 5:18 pm

Re: Load Layout on editorOpened

Post 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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
dvezina
Posts: 23
Joined: Sat Mar 08, 2014 12:10 am

Re: Load Layout on editorOpened

Post 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)
Radu
Posts: 9057
Joined: Fri Jul 09, 2004 5:18 pm

Re: Load Layout on editorOpened

Post 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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
dvezina
Posts: 23
Joined: Sat Mar 08, 2014 12:10 am

Re: Load Layout on editorOpened

Post by dvezina »

Hi,
Is there a fix for this yet?
Thanks
Costin
Posts: 833
Joined: Mon Dec 05, 2011 6:04 pm

Re: Load Layout on editorOpened

Post 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
Costin Sandoi
oXygen XML Editor and Author Support
Post Reply