Package org.esa.snap.rcp.scripting
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:
TheaddAction()
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 SnapUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.openide.filesystems.FileObject
addAction(Action action)
Adds an action into the folderMenu/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 bypath
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 bypath
of the SNAP Desktop / NetBeans file system at the givenposition
.static org.openide.filesystems.FileObject
addActionReference(org.openide.filesystems.FileObject instanceFile, String path, Integer position)
Adds an action references into the folder given bypath
of the SNAP Desktop / NetBeans file system at the givenposition
.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)
-
-
-
Method Detail
-
addAction
public static org.openide.filesystems.FileObject addAction(Action action)
Adds an action into the folderMenu/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 bypath
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 bypath
of the SNAP Desktop / NetBeans file system at the givenposition
.- Parameters:
action
- The action.path
- The folder path.position
- The position within the folder. May benull
.- 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 bypath
of the SNAP Desktop / NetBeans file system at the givenposition
. The following are standard folders in SNAP Desktop/NetBeans where actions and action references may be placed to become visible:Menu/*
- the main menuToolbars/*
- the main tool bar
- Parameters:
instanceFile
- The file object representing an action instance.path
- The folder path.position
- The position within the folder. May benull
.- 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 ofTopComponent
.- See Also:
openWindow(TopComponent, String, boolean)
-
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 ofTopComponent
.requestActive
-true
if a request will be made to activate the window after opening it.- See Also:
openWindow(TopComponent, String, boolean)
-
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 ofTopComponent
.location
- The location where the window should appear when it is first opened.- See Also:
openWindow(TopComponent, String, boolean)
-
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 ofTopComponent
.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.
-
-