Class SnapApp
- java.lang.Object
-
- org.esa.snap.rcp.SnapApp
-
public class SnapApp extends Object
The classSnapAppis a facade for SNAP Desktop applications. There is only a single instance of a SNAP application which is retrieved bySnapApp app = SnapApp.getDefault();SnapAppis the main entry point for most SNAP Desktop extensions. An extension might want to be informed about selection changes in the application. Here are some examples:app.getSelectionSupport(Product.class).addHandler(myProductSelectionHandler); app.getSelectionSupport(ProductNode.class).addHandler(myProductNodeSelectionHandler); app.getSelectionSupport(RasterDataNode.class).addHandler(myRasterDataNodeSelectionHandler); app.getSelectionSupport(ProductSceneView.class).addHandler(myViewSelectionHandler);Or might want to retrieve the currently selected objects:Product product = app.getSelectedProduct(); ProductNode productNode = getSelectedProductNode(); ProductSceneView view = app.getSelectedProductSceneView(); // For any other type of selected object, use: Figure figure = Utilities.actionsGlobalContext().lookup(Figure.class);If you want to alter the behaviour of the default implementation of the SNAP Desktop application, then register your derived class as a service using
@ServiceProvider(service = MoonApp.class, supersedes = "SnapApp") public class MoonApp extends SnapApp { ... }- Since:
- 2.0
- See Also:
SelectionSupport,SelectionSupport.Handler
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSnapApp.ActionContextExtenderThis non-API class is public as an implementation detail.static classSnapApp.MaybeStopOpThis non-API class is public as an implementation detail.static classSnapApp.SelectionSourceHintProvides a hint togetSelectedProduct(SelectionSourceHint)} which selection provider should be used as primary selection sourcestatic classSnapApp.ShowingOpThis non-API class is public as an implementation detail.static classSnapApp.StartOpThis non-API class is public as an implementation detail.static classSnapApp.StopOpThis non-API class is public as an implementation detail.
-
Constructor Summary
Constructors Constructor Description SnapApp()Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description AppContextgetAppContext()Gets anAppContextrepresentation of the SNAP application.StringgetAppName()Deprecated.static SnapAppgetDefault()Gets the SNAP application singleton which provides access to various SNAP APIs and resources.eu.esa.snap.netbeans.docwin.DocumentWindowManagergetDocumentWindowManager()Gets SNAP's global document window manager.StringgetInstanceName()LoggergetLogger()FramegetMainFrame()PreferencesgetPreferences()PropertyMapgetPreferencesPropertyMap()Deprecated.UsegetPreferences()orConfig.preferences()instead.ProductManagergetProductManager()Gets SNAP's global data product manager.ProductgetSelectedProduct(SnapApp.SelectionSourceHint hint)Return the currently selected product.ProductNodegetSelectedProductNode(SnapApp.SelectionSourceHint hint)Return the currently selected product node.ProductSceneViewgetSelectedProductSceneView()<T> SelectionSupport<T>getSelectionSupport(Class<T> type)Provides aSelectionSupportinstance for object selections.org.openide.awt.UndoRedo.ManagergetUndoManager(Product product)voidhandleError(String message, Throwable t)Handles an error.voidonShowing()Called if SNAP is showing on the user's desktop.voidonStart()Called if SNAP starts up.voidonStop()Called if SNAP shuts down.booleanonTryStop()Called if SNAP is about to shut down.voidsetStatusBarMessage(String message)Sets the current status bar message.
-
-
-
Method Detail
-
getDefault
public static SnapApp getDefault()
Gets the SNAP application singleton which provides access to various SNAP APIs and resources.The the method basically returns
Lookup.getDefault().lookup(SnapApp.class)- Returns:
- The SNAP applications global singleton instance.
-
getDocumentWindowManager
public eu.esa.snap.netbeans.docwin.DocumentWindowManager getDocumentWindowManager()
Gets SNAP's global document window manager. Use it to open your own document windows, or register a listener to be notified on window events such as opening, closing, selection, deselection.- Returns:
- SNAP's global document window manager.
-
getProductManager
public ProductManager getProductManager()
Gets SNAP's global data product manager. Use it to add your own data product instances, or register a listener to be notified on product addition and removal events.- Returns:
- SNAP's global product manager.
-
getUndoManager
public org.openide.awt.UndoRedo.Manager getUndoManager(Product product)
- Returns:
- SNAP's global undo / redo manager.
-
getMainFrame
public Frame getMainFrame()
- Returns:
- SNAP's main frame window.
-
setStatusBarMessage
public void setStatusBarMessage(String message)
Sets the current status bar message.- Parameters:
message- The new status bar message.
-
getAppName
@Deprecated public String getAppName()
Deprecated.- Returns:
- The (display) name of this application.
-
getInstanceName
public String getInstanceName()
- Returns:
- The SNAP application's name. The default is
"SNAP".
-
getPreferences
public Preferences getPreferences()
- Returns:
- The user's application preferences.
-
getPreferencesPropertyMap
@Deprecated public PropertyMap getPreferencesPropertyMap()
Deprecated.UsegetPreferences()orConfig.preferences()instead.Gets thepreferenceswrapped by aPropertyMap.Its main use is to provide compatibility for SNAP heritage GUI code (from BEAM & NEST) which used the
PropertyMapinterface.- Returns:
- The user's application preferences as
PropertyMapinstance.
-
getLogger
public Logger getLogger()
- Returns:
- The SNAP logger.
-
handleError
public void handleError(String message, Throwable t)
Handles an error.- Parameters:
message- An error message.t- An exception ornull.
-
getSelectionSupport
public <T> SelectionSupport<T> getSelectionSupport(Class<T> type)
Provides aSelectionSupportinstance for object selections.- Parameters:
type- The type of selected objects whose selection state to observe.- Returns:
- A selection support instance for the given object type, or
null.
-
getSelectedProductSceneView
public ProductSceneView getSelectedProductSceneView()
- Returns:
- The currently selected product scene view, or
null.
-
getSelectedProductNode
public ProductNode getSelectedProductNode(SnapApp.SelectionSourceHint hint)
Return the currently selected product node.The
hintdefines what is the primary and secondary selection source. Source is either thescene viewor theproduct explorer. If it is set toSnapApp.SelectionSourceHint.AUTOthe algorithm tries to make a good guess, checking which component has the focus.- Returns:
- The currently selected product node, or
null.
-
getSelectedProduct
public Product getSelectedProduct(SnapApp.SelectionSourceHint hint)
Return the currently selected product.The
hintdefines what is the primary and secondary selection source. Source is either thescene viewor theproduct explorer. If it is set toSnapApp.SelectionSourceHint.AUTOthe algorithm tries to make a good guess, checking which component has the focus.- Parameters:
hint- gives a hint to the implementation which selection source should be preferred.- Returns:
- The currently selected product or
null.
-
getAppContext
public AppContext getAppContext()
Gets anAppContextrepresentation of the SNAP application.Its main use is to provide compatibility for SNAP heritage GUI code (from BEAM & NEST) which used the
AppContextinterface.- Returns:
- An
AppContextrepresentation of thisSnapApp.
-
onStart
public void onStart()
Called if SNAP starts up. The method is not supposed to be called by clients directly.Overrides should call
super.onStart()as a first step unless they know what they are doing.
-
onStop
public void onStop()
Called if SNAP shuts down. The method is not supposed to be called by clients directly.Overrides should call
super.onStop()in a final step unless they know what they are doing.
-
onShowing
public void onShowing()
Called if SNAP is showing on the user's desktop. The method is not supposed to be called by clients directly.Overrides should call
super.onShowing()as a first step unless they know whet they are doing.
-
onTryStop
public boolean onTryStop()
Called if SNAP is about to shut down. The method is not supposed to be called by clients directly.Overrides should call
super.onTryStop()()unless they know whet they are doing. The method should return immediatelyfalseif the super call returnsfalse.- Returns:
falseif the shutdown process shall be cancelled immediately.true, if it is ok to continue shut down.
-
-