Arranging Toolbars

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

Arranging Toolbars

Post by dvezina »

Hi,

I've written a Workspace Access Plugin. On applicationStarted() I hide the toolbars that I do not want.

The toolbars I do want are awkwardly placed in the first three rows.

From the plugin I would like to specify the toolbar position, pack them and then turn off Rearrangeable, Hidable, Floating properties.

Is this possible?

Thanks
Radu
Posts: 9057
Joined: Fri Jul 09, 2004 5:18 pm

Re: Arranging Toolbars

Post by Radu »

Hi Deanna,

Right now the plugin's plugin.xml can specify that a new defined toolbar ID has an initial side (either north or south) or an initial row. If all your toolbars have the same initial row, they should be placed by default on the same row. What initial row did you set on each added toolbar? It should probably be set to "1" for all of them.
I'm afraid we do not have any more API on this side, for example we do not have API to disable the hidable, rearangeable and floating properties, I'll look into what it takes to implement this.
Maybe if you send us a screenshot with how the things look right now and how you would like them to look we could try to add more API in this area.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
dvezina
Posts: 23
Joined: Sat Mar 08, 2014 12:10 am

Re: Arranging Toolbars

Post by dvezina »

Hi Radu,

I tried that but it seems to only work with custom toolbars. Trying to position an Oxygen toolbar throws an error:

Code: Select all

[ AWT-EventQueue-0 ]  -  java.lang.IllegalArgumentException: The DockableBar exists with name "Search". Please specify a new name for the dockable bar.
java.lang.IllegalArgumentException: The DockableBar exists with name "Search". Please specify a new name for the dockable bar.
at com.jidesoft.action.DefaultDockableBarManager.wj(Unknown Source)
at com.jidesoft.action.DefaultDockableBarManager.addDockableBar(Unknown Source)

Code: Select all

	<toolbar id="pluginToolbarUpdateVasont" initialSide="NORTH" initialRow="1"/>
<toolbar id="pluginToolbarReview" initialSide="NORTH" initialRow="1"/>
<toolbar id="Search" initialSide="NORTH" initialRow="1"/>
How do I get around this?
Thanks
Radu
Posts: 9057
Joined: Fri Jul 09, 2004 5:18 pm

Re: Arranging Toolbars

Post by Radu »

Hi Deanna,

A toolbar's ID needs to be unique in the application.

The error means that Oxygen already provides a toolbar with the ID "Search" so you will have to provide another ID for your search toolbar, something like:

Code: Select all

<toolbar id="Search_Vasont" initialSide="NORTH" initialRow="1"/>
and then from the Java code of the Workspace Access plugin search for it accordingly.
The ID of a toolbar is not a display name, it should not appear anywhere.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
dvezina
Posts: 23
Joined: Sat Mar 08, 2014 12:10 am

Re: Arranging Toolbars

Post by dvezina »

Hi Radu,

Correct. I'm trying to position the Oxygen Search toolbar and set its properties "Hidable, Rearrangable, Floatable".

My question is how do I position Oxygen stock toolbars like Search, File, Edit, Author_review, etc from the plugin.

I have no difficulty with my own toolbars.

Thanks,

Dee
Radu
Posts: 9057
Joined: Fri Jul 09, 2004 5:18 pm

Re: Arranging Toolbars

Post by Radu »

Hi Deanna,

There is no direct Java API for this.
You can move things around in your Oxygen installation and then choose Window->Save layout to save the custom layout to disk.

Then in a workspace access plugin extension (which you already have) when the application started callback is received you can force the layout file to be used by the application.

In our Plugins SDK Maven sub-project we have the source code for an Impose Options plugin (a plugin which imposes both global options and a layout file located in the plugin's installation folder to the user). For your convenience I'm pasting its code below:

Code: Select all

  /**
* @see ro.sync.exml.plugin.workspace.WorkspaceAccessPluginExtension#applicationStarted(ro.sync.exml.workspace.api.standalone.StandalonePluginWorkspace)
*/
@Override
public void applicationStarted(final StandalonePluginWorkspace pluginWorkspaceAccess) {
boolean impose = true;
File baseDir = WorkspaceAccessPlugin.getInstance().getDescriptor().getBaseDir();
String imposedTS = pluginWorkspaceAccess.getOptionsStorage().getOption(OPTIONS_IMPOSED_KEY,
null);
if (imposedTS != null) {
if (imposedTS.equals(WorkspaceAccessPlugin.getInstance().getDescriptor().getVersion())) {
//We have already imposed them.
impose = false;
}
}
//We remember we have already set certain options for this version of the plugin.
pluginWorkspaceAccess.getOptionsStorage().setOption(OPTIONS_IMPOSED_KEY,
WorkspaceAccessPlugin.getInstance().getDescriptor().getVersion());
if (impose) {
//Global options file.
File optionsFile = new File(baseDir, "options.xml");
if (optionsFile.exists()) {
//One approach with having an options.xml would be the issue of having references to certain resources.
//These references should be somehow redirected to the current plugin's installation folder.
try {
StringBuilder content = new StringBuilder(Math.max((int) optionsFile.length(), 100));
InputStreamReader reader = new InputStreamReader(new FileInputStream(optionsFile),
"UTF-8");
char[] buf = new char[1024];
int len = -1;
while ((len = reader.read(buf)) != -1) {
content.append(buf, 0, len);
}
reader.close();
if (content.indexOf("OXY_PLUGIN_REPLACEMENT_PATH") != -1) {
String replacedContent = content.toString();
replacedContent = replacedContent.replaceAll("OXY_PLUGIN_REPLACEMENT_PATH_DIR",
baseDir.getAbsolutePath());
replacedContent = replacedContent.replaceAll("OXY_PLUGIN_REPLACEMENT_PATH_URL", baseDir
.toURI().toASCIIString());

//And use it with the variables replaced.
optionsFile = File.createTempFile("tempOxygenOptions", ".xml");
optionsFile.deleteOnExit();
OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(optionsFile),
"UTF-8");
osw.write(replacedContent);
osw.close();
}
} catch (Exception e) {
e.printStackTrace();
}
pluginWorkspaceAccess.importGlobalOptions(optionsFile);
}

File templatesDir = new File(baseDir, "templates");
if (templatesDir.exists()) {
//Impose folder for templates dir
pluginWorkspaceAccess.setGlobalObjectProperty("user.custom.templates.directories",
new String[] { templatesDir.getAbsolutePath() });
}
//Application layout.
File layoutFile = new File(baseDir, "application.layout");
if (layoutFile.exists()) {
PerspectivesLayoutInfo info = new PerspectivesLayoutInfo(true, false, "",
layoutFile.getAbsolutePath());
pluginWorkspaceAccess.setGlobalObjectProperty("perspectives.layout.info", info);
pluginWorkspaceAccess
.showInformationMessage("Predefined window layout was loaded. Please restart the application to apply it.");
}

}
}
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
dvezina
Posts: 23
Joined: Sat Mar 08, 2014 12:10 am

Re: Arranging Toolbars

Post by dvezina »

Thanks. This is what I was after.
Best regards
LBarth
Posts: 26
Joined: Mon Mar 04, 2013 1:42 pm

Re: Arranging Toolbars

Post by LBarth »

Hi,

I have no "OXY_PLUGIN_REPLACEMENT_PATH" in my options.xml file (made from version 17.0), what is it usefull for ?

And I have a lot of absolute paths 'file:/Users/lbarth/…', can I use editor variables instead ?

Best regards,
Lionel
Radu
Posts: 9057
Joined: Fri Jul 09, 2004 5:18 pm

Re: Arranging Toolbars

Post by Radu »

Hi Lionel,

Do you want this for the author component or for the standalone Oxygen version?
Could you tell me more about your usecase?

This thread is a discussion for implementing a plugin for the standalone Oxygen which imports options the first time it starts.

That OXY_PLUGIN_REPLACEMENT_PATH token usage was an example in which if the options.xml was edited by the developer who replaced all those absolute references with this fixed token, in the plugin Java code the developer could process the entire file contents, replace again the token with a reference to the current plugin folder. In this particular case the plugin folder would have also contained a layout file which needed to be set as a fixed layout by specifying this in the options.xml.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
LBarth
Posts: 26
Joined: Mon Mar 04, 2013 1:42 pm

Re: Arranging Toolbars

Post by LBarth »

Hi Radu,

It is for the standalone Oxygen version. We have developped a plugin in wich I would like to ensure the preferences and layout at start up.

I have realized I can use the OXY_PLUGIN_REPLACEMENT_PATH mecanism to use editors variables in my options.xml file.

I have noticed when I import a global options file I just exported few minutes ago I have a message "The file you are importing may not contain settings for all <oXygen/> options. This operation will only override the options included in the imported file."
Is there a way to export/import all settings or to know which are not ?
Should I have a minimal options.xml file to speed up the import process ?

Best regards,
Lionel
Radu
Posts: 9057
Joined: Fri Jul 09, 2004 5:18 pm

Re: Arranging Toolbars

Post by Radu »

Hi Lionel,

Please see some answers below:
Is there a way to export/import all settings or to know which are not ?
The options export in Oxygen 17 automatically removes certain keys from being exported. Those keys are very user specific (like the current user name) and it would make no sense importing them in another user's application. So we considered that the main use case for exporting settings was to import them on other user's machines.
The XML options file in which the Oxygen application saves all its preferences is available in the user preferences folder which is located in various places depending on the operating system in which Oxygen runs:

http://www.oxygenxml.com/doc/versions/1 ... ation.html
Should I have a minimal options.xml file to speed up the import process ?
You can manually remove from the file keys which you do not consider to be important to import on other user's machines. I'm not sure if this will noticeably speed up the import, probably not.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
LBarth
Posts: 26
Joined: Mon Mar 04, 2013 1:42 pm

Re: Arranging Toolbars

Post by LBarth »

Thanks a lot Radu,

Best regards,
Lionel
Post Reply