Schema Multiview

Author: Nathan Fiedler

Definitions

MultiViewElement (MVE)
The component in which a single view is displayed, such as the source view, or columns view, or instance view.
MultiViewDescription
These create the elements when they are needed by the core multiview module. For multiview elements that are not persisted, the descriptors re-create them when the IDE restarts.

Expected Behavior

  • Pressing Alt-Shift-Left should change to the MVE to the left of the current MVE (largely depends on focus).
  • Pressing Alt-Shift-Right should change to the MVE to the right of the current MVE (largely depends on focus).
  • On restart, last-shown element will be showing.

Implementation Notes

  • Source MVE persists settings, such as the caret position.
  • The other view elements do not need to persist anything, the multview descriptor always recreates the element.
  • Need to have Source MVE first in the element array so that NetBeans can find the opened editor panes.
  • Adding the DataObject to the TopComponent Lookup allows the projectui code to close our open editors when the project is closed. Likewise with deleting a document from project while the editor window is opened, so that the window is closed.

Opening the MultiView

Because the MVE that implements CloneableEditorSupport.Pane needs to be the first element in the MultiViewDescription array (in order for the search results to be able to open the editor), we need a couple of actions to get the columns view to show by default. That is, the OpenAction subclass opens the source view element by default. In order for the columns view to be the default, the DataObject DataNode has a preferred action, which shows the columns view. The (side-)effects of this are:

  • Clicking on search results shows the corresponding source
  • Opening the document from the Projects window actually opens the source view for a very brief time, then switches to the columns view.

SaveCookie

Putting the DataObject node delegate in the lookup allows it to act as one of our activated nodes, so it exposes save cookie, however we need the CookieProxyLookup hack to prevent the Node itself from being in the lookup.

Editor Titles

The editor title bar for the multiview is updated by the updateTitles() method in the DataEditorSupport subclass. The details are as follows:

  • DataEditorSupport.messageName() provides the correct display name
  • DataEditorSupport.DataNodeListener listens to the DataNode for changes and updates the open CloneableEditorSupport.Pane instances
  • DataNodeListener calls DataEditorSupport.callUpdateTitles()
  • DataEditorSupport.updateTitles() enumerates the open Pane instances and invokes Pane.updateName()
  • CloneableEditor.updateName() (via Pane) updates the editor title by calling messageName() on the editor support

Note that for the DataNodeListener to be listening to the DataNode, you must invoke the initializeCloneableEditor() method on the editor support instance. Otherwise the listener will not be called when the name of the document is changed by the user.

ActionMap in Lookup

If you are setting the Lookup on your TopComponent, then you may need to also include the ActionMap in the Lookup to ensure the actions in your window continue working.

In the case of the schema column view, however, adding the ActionMap caused the PasteAction to silently fail. This seems to be caused by the fact that the action is in the ActionMap of the SchemaColumn, which is contained inside the TopComponent. More research is needed to be certain, but you should try it both ways — with, and without, the ActionMap and determine which works best for your editor.

Closing the MultiView

As with other editors in NetBeans, the opened editors should be closed when the project they belong to is closed. This is accomplished by putting the DataObject instance in the Lookup of the TopComponent containing the editor.

Quality Criteria

The following are behaviors that should be working for all of the multiview implementations, regardless of which multiview element is showing.

Navigator
The Navigator window should be showing the top-level nodes of the XML schema that contains the selected node. For the source, instance, and analysis views, this shows the XML schema of the currently active editor. For the columns view, this will show the XML Schema containing the selected node, whether that is in the current document, or an imported/included document.
Ctrl-s (SaveAction)
This keyboard shortcut should from any view as long as the document is in a modified state. Likewise, when the document is modified, the Save action in the File menu should be enabled.
Undo/Redo
The Undo and Redo actions should work in any view that allows editing.
Properties
The Properties window should show the properties of the schema file (.xsd) being edited.
XML actions
The source view should contain the XML actions in the context menu. These consist of the Validate and Check XML actions, as well as other possible actions.
Editor closes with project
When a project is closed, the editors associated with that project should also close.
Show Source opens editor
Open a schema, run where used on a component, close the schema editor, now invoked show source from usages window -- should open the schema editor again.
No duplicate editors
Repeated invocations to show a schema component (either in source form or in the columns view) should not open duplicate editor windows.

Project Features

About this Project

XML was started in November 2009, is owned by dstrupl, and has 58 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20160708.bf2ac18). © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close