Page 1 of 1

New Actions Toolbar

Posted: Mon May 02, 2016 5:55 pm
by Konstantin
Hello !!!
I use Oxygen WebApp 18.0.0
I need create new custom toolbar for my actions.
Could you say how can I do it ?

Re: New Actions Toolbar

Posted: Wed May 04, 2016 8:55 am
by cristi_talau
Hello,

You can find here [1] a tutorial about implementing a new action. In order to add a new toolbar you have to listen for the "sync.api.Workspace.EventType.BEFORE_EDITOR_LOADED" event [2] and modify the "actionsConfiguration" field of the event to match the desired structure for your toolbars.

Best,
Cristian

[1] https://www.oxygenxml.com/maven/com/oxy ... ction.html
[2] https://www.oxygenxml.com/maven/com/oxy ... Event.html

Re: New Actions Toolbar

Posted: Mon Jun 20, 2016 1:33 pm
by Konstantin
Is there able to customize toolbars and actions from Java ?
I tried do it thru plugin WorkspaceAccessPluginExtension

Adding plugin:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!-- The plugin.dtd file is located in the OXYGEN_INSATALL_DIR/plugins directory -->
<!DOCTYPE plugin SYSTEM "../plugin.dtd">

<plugin
id="webapp.customworkspace.WorkspacePlugin"
name="WorkspaceAccess"
description="Plugin adds contextual menu action to DITA Maps Manager pop-up menu."
version="${project.version}"
vendor="SyncRO"
class="webapp.customworkspace.WorkspacePlugin"
classLoaderType="preferReferencedResources">

<runtime>
<library name="lib/${project.build.finalName}.jar"/>
</runtime>

<extension type="WorkspaceAccess" class="webapp.customworkspace.WorkspacePluginExtension"/>

<view id="xproject-view" initialSide="WEST" initialRow="0"/>

</plugin>
Plugin:

Code: Select all

public class WorkspacePluginExtension implements WorkspaceAccessPluginExtension {

@Override
public boolean applicationClosing() {
return false;
}

@Override
public void applicationStarted(final StandalonePluginWorkspace workspace) {
// add new toolbar
workspace.addToolbarComponentsCustomizer(new ToolbarComponentsCustomizer() {

@Override
public void customizeToolbar(final ToolbarInfo toolbarInfo) {

// if toolbar is our custom toolbar (referenced by ID in plugin.xml)
if (toolbarInfo.getToolbarID().equals("CustomToolbar")) {

final JButton demoButton = new JButton("Demo Button");
demoButton.addActionListener(new ActionListener() {

@Override
public void actionPerformed(final ActionEvent e) {
JOptionPane.showMessageDialog(new JFrame(),
"Toolbar ID: " + toolbarInfo.getToolbarID(),
"Window Title",
JOptionPane.INFORMATION_MESSAGE);
}
});

// Add demoButton to toolbar
final List<JComponent> comps = new ArrayList<JComponent>();
comps.add(demoButton);
toolbarInfo.setComponents(comps.toArray(new JComponent[0]));

// Set toolbar title
toolbarInfo.setTitle("Custom Demo Toolbar");
}
}
});
}

}
But whene I start tomcat I get error:

Code: Select all

Initializing log4j with: file:/home/konstantin/soft/tomcat8/webapps/oxygen-editor/WEB-INF/log4j.properties
0 [localhost-startStop-1] INFO ro.sync.servlet.StartupServlet - Loading frameworks from folder: /home/konstantin/soft/tomcat8/work/Catalina/localhost/oxygen-editor/frameworks-v18.0.0
57 [localhost-startStop-1] INFO ro.sync.servlet.StartupServlet - Loading plugins from: /home/konstantin/soft/tomcat8/work/Catalina/localhost/oxygen-editor/plugins-v18.0.0
123 [localhost-startStop-1] WARN ro.sync.exml.plugin.PluginManager - Attribute "type" with value "AuthorStylesheet" must have a value from the list "selectionProcessor WebappServlet documentProcessor generalExtension URLStreamHandler URLHandler TargetedURLHandler URLChooser URLChooserToolbar componentsValidator OpenRedirect WorkspaceAccess LockHandlerFactory StylesFilter OptionPage RefactoringOperationsProvider AuthorCSS ".
123 [localhost-startStop-1] WARN ro.sync.exml.plugin.PluginManager - Attribute "href" is not allowed to appear in element "extension".
124 [localhost-startStop-1] WARN ro.sync.exml.plugin.PluginManager - Attribute "type" with value "WebappStaticResourcesFolder" must have a value from the list "selectionProcessor WebappServlet documentProcessor generalExtension URLStreamHandler URLHandler TargetedURLHandler URLChooser URLChooserToolbar componentsValidator OpenRedirect WorkspaceAccess LockHandlerFactory StylesFilter OptionPage RefactoringOperationsProvider AuthorCSS ".
124 [localhost-startStop-1] WARN ro.sync.exml.plugin.PluginManager - Attribute "path" is not allowed to appear in element "extension".
124 [localhost-startStop-1] WARN ro.sync.exml.plugin.PluginManager - Attribute "href" is not allowed to appear in element "extension".
130 [localhost-startStop-1] WARN ro.sync.exml.plugin.PluginManager - Attribute "type" with value "AuthorStylesheet" must have a value from the list "selectionProcessor WebappServlet documentProcessor generalExtension URLStreamHandler URLHandler TargetedURLHandler URLChooser URLChooserToolbar componentsValidator OpenRedirect WorkspaceAccess LockHandlerFactory StylesFilter OptionPage RefactoringOperationsProvider AuthorCSS ".
130 [localhost-startStop-1] WARN ro.sync.exml.plugin.PluginManager - Attribute "href" is not allowed to appear in element "extension".
146 [localhost-startStop-1] WARN ro.sync.exml.workspace.api.PluginWorkspace - Errors starting plugin WorkspaceAccess. It will be disabled.
java.lang.UnsupportedOperationException: In oXygen XML WebApp, the toolbar is a client-side component, use the JavaScript "sync.api.Editor.ActionsLoadedEvent" event to change the toolbar configuration.
at ro.sync.ecss.webapp.access.h.b(Unknown Source)
at ro.sync.ecss.webapp.access.h.addToolbarComponentsCustomizer(Unknown Source)
at webapp.customworkspace.WorkspacePluginExtension.applicationStarted(WorkspacePluginExtension.java:28)
at ro.sync.ecss.webapp.n.f(Unknown Source)
at ro.sync.ecss.webapp.n.b(Unknown Source)
at ro.sync.ecss.extensions.api.webapp.WebappAuthorDocumentFactory.setPlugins(Unknown Source)
at ro.sync.servlet.StartupServlet.loadPlugins(StartupServlet.java:196)
at ro.sync.servlet.StartupServlet.prepareWebappFactory(StartupServlet.java:145)
at ro.sync.servlet.StartupServlet.contextInitialized(StartupServlet.java:424)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4812)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5255)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:939)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1812)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
157 [localhost-startStop-1] INFO ro.sync.servlet.StartupServlet - oXygen XML WebApp initialized successfully.
20-Jun-2016 13:29:07.610 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive /home/konstantin/soft/tomcat8/webapps/oxygen-editor.war has finished in 4,549 ms
20-Jun-2016 13:29:07.610 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /home/konstantin/soft/tomcat8/webapps/manager
20-Jun-2016 13:29:07.629 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /home/konstantin/soft/tomcat8/webapps/manager has finished in 19 ms
20-Jun-2016 13:29:07.629 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /home/konstantin/soft/tomcat8/webapps/examples
20-Jun-2016 13:29:07.779 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /home/konstantin/soft/tomcat8/webapps/examples has finished in 150 ms
20-Jun-2016 13:29:07.779 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /home/konstantin/soft/tomcat8/webapps/ROOT
It is happen when I try use workspace.addToolbarComponentsCustomizer method.

Re: New Actions Toolbar

Posted: Mon Jun 20, 2016 2:22 pm
by alex_jitianu
Hello,

In oXygen XML WebApp the toolbar is a client-side component. Because of that you'll have to use our Javascript API to customize it (as my colleague Cristian advised you). This Javascript code can reside in a number of predefined locations: https://www.oxygenxml.com/doc/versions/ ... ng_js.html

The ToolbarComponentsCustomizer Java API works only in the Desktop distribution of Oxygen XML Editor.

ToolbarComponentsCustomizer

Best regards,
Alex

Re: New Actions Toolbar

Posted: Mon Jun 20, 2016 3:01 pm
by Konstantin
Ok, thanks !!!