Desktop User Interface

In SNAP Desktop, functionality provided by SNAP Engine is available through Actions. An Action provides an entry in a menu or a toolbar. Upon selecting the entry, either a functionality will be performed right away, or - in most cases - a window will appear. This might either be a dialog which requires the user to set parameters before the requested function is performed, or a Tool Window. A Tool Window is a window that displays some content permanently until it is explicitly closed by the user. Examples for Tool Windows are the Scatter Plot Tool, the Pin Manager, or the Pixel Info View. Dialogs, on the other hand, are required by, e.g.,  Operators, as they provide a user the means to set required parameters before the Operator is run.

As SNAP Desktop is based on the NetBeans RCP, it makes use of its SPI system for GUI actions. An action SPI needs to provide at minimum the menu text and the actual action’s Java class name. The actual action is only instantiated and invoked once the user clicks the corresponding entry. Action SPIs can be configured in two ways: The first is to define them in an XML file as part of the GUI extension module. In the NetBeans RCP, this XML file is called layer.xml and is stored as a resource in the module’s Java archive file. The layer xml also serves to define the structure of menus or toolbars. This way is preferred if it is sufficient to use a pre-defined default action (e.g., for Product Readers or simple Operators). The second way is preferred if you need to define your own UI or prepare the calling of the functionality (e.g., first collect available data and then output it to a special format by calling the writer in question). In this case, you need to subclass Action (consider AbstractSnapAction for this purpose) and equip your action with NetBeans Annotations. To use these Annotations, the action's name and position in the menu and/or toolbar need to be set. Extending Actions brings the advantage that they can listen to the state of Products or RasterDataNodes and disable or enable their entries in the menu/toolbar, depending on whether selecting them at the given moment would be meaningful or not. 

Creating Dialogs for Actions

Dialogs are required when a user is required to set parameters before a functionality is called. Dialogs may be modal and offer a user to run or cancel the task at hand or to open a help page. SNAP offers a class AbstractDialog which might be extended. Note that for Operators there is a pre-defined dialog which expects that a source product has to be processed into a target product. This pre-defined dialog is also able to create its own UI components for Operator parameters which use primitive data types. If an Operator meets these requirements, it should delegate to the DefaultOperatorAction in the layer.xml. Likewise, Product Reader Actions should delegate to the ImportProductAction, which will open a file chooser and pass the user's file choice to the designated reader.

Creating Tool Windows

As SNAP Desktop is based on the NetBeans RCP, tool windows are based on NetBeans TopComponents. TopComponents are display windows which might be floating, but can also be tabbed or docked. Similarly to Actions, TopComponents can be annotated. Using these Annotations, it is possible to define entries in menus or toolbars, but also to specify where a TopComponent shall be positioned after it is opened. Some TopComponents might be already open at the start of the Sentinel Toolbox. The Toolbox remembers which TopComponents have been opened and where they have been placed. This configuration will be re-loaded. SNAP offers a convenience class ToolTopComponent which might be used to create Tool Windows. This class listens to changes of the ProductSceneView, as it is assumed that the information displayed in the Tool Window is directly related to the presently displayed image.