Workspace Access Plugin Extension

This plugin type allows you to contribute actions to the main menu and toolbars, create custom views and 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 opened 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 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 plugin interface and allows you to contribute your own plugin-specific actions. The following attributes are supported:

    • id - Unique identifier for the plugin toolbar.
    • initialSide - Specifies the place where the toolbar is initially displayed. The allowed values are NORTH and SOUTH.
    • 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 of 1.

    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 plugin 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, and WEST.
    • initialRow - Specifies the initial row on the specified side where the view is displayed. For example, in Oxygen XML Editor plugin, the Project view has an initial row of 0 and the Outline view has an initial row of 1. 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, and floating. 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 opened editors can be done by first getting access to all URLs opened in the workspace using the StandalonePluginWorkspace.getAllEditorLocations(int editingArea) API method. Using the URL of an opened 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).

To be notified when editors are opened, selected, and closed, you can use the StandalonePluginWorkspace.addEditorChangeListener API method to add a listener.

Was this helpful?