Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Contributing to the graphical user interface basically works analogous to standard Eclipse — see the Eclipse Platform Developers' Guide for more information on that. This section lists some of the TextGridLab specifics.

Contributing to Menus and Toolbars

The TextGridLab features a Tools menu and a corresponding toolbar in which your tool should appear. To do so, you should contribute a command that opens your tool in some way – typically this means switching to a dedicated perspective and maybe opening some parts. Contribute your command to the menu tools and to the perspectives bar. plugin.xml excerpts, as examples from the CollateX plugin (you'll want to use Eclipse's graphical editor for the plugin.xml to create these entries!):

Code Block
languagexml
<menuContribution
 allPopups="false"
 locationURI="toolbar:perspectivesbar">
 <command
 commandId="info.textgrid.lab.collatex.openPerspective"
 style="push">
 </command>
</menuContribution>
<menuContribution
 allPopups="false"
 locationURI="toolbar:perspectivesbar">
 <command
 commandId="info.textgrid.lab.collatex.openPerspective"
 style="push">
 </command>
</menuContribution>

 

Another typical use case is to add a command to the context menu of TextGrid objects, e.g., in the navigator or in the search results view. To do so, you can use Eclipse's expression syntax for the plugin.xml and check for adaptability to TextGridObjects. Here is an excerpt from the import tool's plugin.xml that adds entries to context menus whenever one or more TextGrid objects are selected:

Code Block
languagexml
<extension
 point="org.eclipse.ui.menus">
  <menuContribution
 allPopups="false"
 locationURI="menu:file?after=file.anchor6">
     <command
 commandId="info.textgrid.lab.core.importexport.import"
 mnemonic="%command.mnemonic.import"
 style="push">
     </command>
     <command
 commandId="info.textgrid.lab.core.importexport.export"
 mnemonic="%command.mnemonic.export"
 style="push">
     </command>
  </menuContribution>
  <menuContribution
 locationURI="popup:org.eclipse.ui.popup.any?after=popup.anchor2">
     <command
 commandId="info.textgrid.lab.core.importexport.export"
 mnemonic="%command.mnemonic.export.1"
 style="push">
    <visibleWhen>
       <iterate
 ifEmpty="false"
 operator="or">
          <or>
         <adapt
 type="info.textgrid.lab.core.model.TextGridObject">
         </adapt>
         <adapt
 type="info.textgrid.lab.core.aggregations.ui.model.Aggregation">
         </adapt>
          </or>
       </iterate>
    </visibleWhen>
     </command>
  </menuContribution>
</extension>

 

In the associated handler, you can then get the selection from the event and adapt the contents of the IStructuredSelection to TextGridObject in order to deal with them. An examplary handler that deals with quite some cases is the one from the Export tool. This handler already contains quite some complex handling: It first checks whether the selected object is an Import/Export specification (and if so, just opens it in the Export editor). Otherwise, it checks whether we already have an export editor open: If so, the selected objects are added to that, otherwise, a new editor is created and the selected objects are added.

Dealing with your own kind of object

If your use case includes to offer an own, project specific kind of object and the appropriate tools to edit these objects, then you'll probably want to define your own TextGrid content type (similar to a MIME type), a corresponding Eclipse content type and an editor that deals with that.

...

If possible, you should define your editor as a standard EditorPart that deals with IFileEditorInputs. If you do so, you will also get appropriate locking behaviour without having to do anything for that.

Locking

While your user works on an object, that object should be locked. As long as a user holds a lock on the object, other users' attempts to lock the object fail with a message indicating the user who has the lock, and other users will not be able to modify the object.

...