Class SnapUtils

java.lang.Object
org.esa.snap.rcp.scripting.SnapUtils

public class SnapUtils extends Object
Provides various utility functions allowing scripting clients to register actions and windows for the SNAP Desktop application.

The following methods can be used to dynamically add/remove actions and action references to/from the SNAP Desktop application:

The addAction() methods all return "file objects" which live in the NetBeans Platform's virtual file system. These object can be used to create references to the actions they represent in various places such as menus and tool bars:

To open a new window in the SNAP Desktop application, the following methods can be used:

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.openide.filesystems.FileObject
    addAction(Action action)
    Adds an action into the folder Menu/Tools of the SNAP Desktop / NetBeans file system.
    static org.openide.filesystems.FileObject
    addAction(Action action, String path)
    Adds an action into the folder given by path of the SNAP Desktop / NetBeans file system.
    static org.openide.filesystems.FileObject
    addAction(Action action, String path, Integer position)
    Adds an action into the folder given by path of the SNAP Desktop / NetBeans file system at the given position.
    static org.openide.filesystems.FileObject
    addActionReference(org.openide.filesystems.FileObject instanceFile, String path, Integer position)
    Adds an action references into the folder given by path of the SNAP Desktop / NetBeans file system at the given position.
    static void
    openWindow(org.openide.windows.TopComponent window)
    Opens a new window in SNAP Desktop in the "explorer" location.
    static void
    openWindow(org.openide.windows.TopComponent window, boolean requestActive)
    Opens a new window in SNAP Desktop in the "explorer" location.
    static void
    openWindow(org.openide.windows.TopComponent window, String location)
    Opens a new window in SNAP Desktop at the given location.
    static void
    openWindow(org.openide.windows.TopComponent window, String location, boolean requestActive)
    Opens a new window in SNAP Desktop.
    static boolean
    removeAction(org.openide.filesystems.FileObject actionFile)
     
    static boolean
    removeActionReference(org.openide.filesystems.FileObject actionReferenceFile)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SnapUtils

      public SnapUtils()
  • Method Details

    • addAction

      public static org.openide.filesystems.FileObject addAction(Action action)
      Adds an action into the folder Menu/Tools of the SNAP Desktop / NetBeans file system.
      Parameters:
      action - The action.
      Returns:
      The file object representing the action.
    • addAction

      public static org.openide.filesystems.FileObject addAction(Action action, String path)
      Adds an action into the folder given by path of the SNAP Desktop / NetBeans file system.
      Parameters:
      action - The action.
      path - The folder path.
      Returns:
      The file object representing the action.
    • addAction

      public static org.openide.filesystems.FileObject addAction(Action action, String path, Integer position)
      Adds an action into the folder given by path of the SNAP Desktop / NetBeans file system at the given position.
      Parameters:
      action - The action.
      path - The folder path.
      position - The position within the folder. May be null.
      Returns:
      The file object representing the action.
    • addActionReference

      public static org.openide.filesystems.FileObject addActionReference(org.openide.filesystems.FileObject instanceFile, String path, Integer position)
      Adds an action references into the folder given by path of the SNAP Desktop / NetBeans file system at the given position. The following are standard folders in SNAP Desktop/NetBeans where actions and action references may be placed to become visible:
      1. Menu/* - the main menu
      2. Toolbars/* - the main tool bar
      Parameters:
      instanceFile - The file object representing an action instance.
      path - The folder path.
      position - The position within the folder. May be null.
      Returns:
      The file object representing the action reference.
    • removeAction

      public static boolean removeAction(org.openide.filesystems.FileObject actionFile)
    • removeActionReference

      public static boolean removeActionReference(org.openide.filesystems.FileObject actionReferenceFile)
    • openWindow

      public static void openWindow(org.openide.windows.TopComponent window)
      Opens a new window in SNAP Desktop in the "explorer" location.
      Parameters:
      window - The window which must must be an instance of TopComponent.
      See Also:
    • openWindow

      public static void openWindow(org.openide.windows.TopComponent window, boolean requestActive)
      Opens a new window in SNAP Desktop in the "explorer" location.
      Parameters:
      window - The window which must must be an instance of TopComponent.
      requestActive - true if a request will be made to activate the window after opening it.
      See Also:
    • openWindow

      public static void openWindow(org.openide.windows.TopComponent window, String location)
      Opens a new window in SNAP Desktop at the given location.
      Parameters:
      window - The window which must must be an instance of TopComponent.
      location - The location where the window should appear when it is first opened.
      See Also:
    • openWindow

      public static void openWindow(org.openide.windows.TopComponent window, String location, boolean requestActive)
      Opens a new window in SNAP Desktop.
      Parameters:
      window - The window which must must be an instance of TopComponent.
      location - The location where the window should appear when it is first opened. Possible docking areas are "explorer" (upper left), "navigator" (lower left), "properties" (upper right), "output" (bottom). You may choose "floating" to not dock the window at all. Note that this mode requires explicitly setting the window's position and size.
      requestActive - true if a request will be made to activate the window after opening it.