Workspace Access Plugin Extension
This type of plugin allows you to contribute actions to the main menu and toolbars, create custom views, interact with the application workspace, make modifications to opened documents, and add listeners for various events.
Many complex integrations (such as integrations with Content Management Systems) usually requires access to some workspace resources such as toolbars, menus, views, and editors. This type of plugin is also useful because it allows you to make modifications to the XML content of an open editor.
The plugin must implement the ro.sync.exml.plugin.workspace.WorkspaceAccessPluginExtension interface. The callback method applicationStarted of this interface allows access to a parameter of the ro.sync.exml.workspace.api.standalone.StandalonePluginWorkspace type (allows for API access to the application workspace).
The StandalonePluginWorkspace interface has three methods that can be called to customize toolbars, menus, and views:
- addToolbarComponentsCustomizer
-
Contributes to or modifies existing toolbars. You can specify additional toolbar IDs in the associated plugin.xml descriptor file using the following construct:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plugin SYSTEM "../plugin.dtd"> <plugin name="CustomWorkspaceAccess" ..............> <runtime> ........ </runtime> <extension type="WorkspaceAccess" .............../> ............... <toolbar id="SampleID" initialSide="NORTH" initialRow="1"/> </plugin>
The<toolbar>
element adds a toolbar in the Oxygen XML Editor interface and allows you to contribute your own plugin-specific actions. The following attributes are supported:- id - Unique identifier for the toolbar.
- initialSide - Specifies the place where the toolbar is initially
displayed. The allowed values are
NORTH
andSOUTH
. - initialRow - Specifies the initial row on the specified side where the
toolbar is displayed. For example, the first toolbar has an initial row of
0
and the next toolbar has an initial row of1
.
The ro.sync.exml.workspace.api.standalone.ToolbarInfo toolbar component information with the specified ID will be provided to you by the customizer interface. Therefore, you will be able to provide Swing components that will appear on the toolbar when the application starts.
- addViewComponentCustomizer
-
Contributes to or modifies existing views, or contributes to the reserved custom view. You can specify additional view IDs in the associated plugin.xml descriptor using the following construct:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plugin SYSTEM "../plugin.dtd"> <plugin name="CustomWorkspaceAccess" ..............> <runtime> ........ </runtime> <extension type="WorkspaceAccess" .............../> ............... <view id="SampleID" initialSide="WEST" initialRow="0"/> </plugin>
The<view>
element adds a view in the Oxygen XML Editor interface and allows you to contribute your own plugin-specific UI components. The following attributes are supported:- id - Unique identifier of the view component.
- initialSide - Specifies the place where the view is initially displayed.
The allowed values are:
NORTH
,SOUTH
,EAST
, andWEST
. - initialRow - Specifies the initial row on the specified side where the
view is displayed. For example, in Oxygen XML Editor, the Project view has an initial row of
0
and the Outline view has an initial row of1
. Both views are in the WEST part of the workbench. - initialState - Specifies the initial state of the view. The allows values
are:
hidden
,docked
,autohide
, andfloating
. By default, the view is visible and docked.
The<view>
element also supports an optional<perspective>
child element so that you can show or hide a certain view for a specified perspective. The<perspective>
element supports the following attributes:- id (required) - Unique identifier for the perspective. The possible
values are:
editor
,dita
,xslt_debugger
,xquery_debugger
, anddatabase
. - initState (optional) - Specifies the initial state of the perspective.
The allows values are:
hidden
,docked
,autohide
, andfloating
. By default, the view is visible and docked.
The ro.sync.exml.workspace.api.standalone.ViewInfo view component information with the specified ID will be provided to you by the customizer interface. Therefore, you will be able to provide Swing components that will appear on the view when the application starts.
- addMenuBarCustomizer
- Contributes to or modifies existing menu components.
Access to the open editors can be done by first getting access to all URLs opened in the workspace using the StandalonePluginWorkspace.getAllEditorLocations(int editingArea) API method. There are two available editing areas: the DITA Maps Manager editing area and the main editing area. Using the URL of an open resource, you can gain access to it using the StandalonePluginWorkspace.getEditorAccess(URL location, int editingArea) API method. A ro.sync.exml.workspace.api.editor.WSEditor then allows access to the current editing page.
A special editing API is supported for the Text mode (ro.sync.exml.workspace.api.editor.page.text.WSTextEditorPage) and the Author mode (ro.sync.exml.workspace.api.editor.page.author.WSAuthorEditorPage).
To be notified when editors are opened, selected, and closed, you can use the StandalonePluginWorkspace.addEditorChangeListener API method to add a listener.
- A simple Maven-based sample of a workspace access plugin is available here: https://github.com/oxygenxml/sample-plugin-workspace-access.
- A more complex sample of a workspace access plugin mimicking a CMS integration is available in the Author SDK: https://www.oxygenxml.com/oxygen_sdk.html.