public class SnapApp extends Object
SnapApp
is a facade for SNAP Desktop applications. There is only a single instance of
a SNAP application which is retrieved by
SnapApp app = SnapApp.getDefault();
SnapApp
is 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 { ... }
SelectionSupport
,
SelectionSupport.Handler
Modifier and Type | Class and Description |
---|---|
static class |
SnapApp.ActionContextExtender
This non-API class is public as an implementation detail.
|
static class |
SnapApp.MaybeStopOp
This non-API class is public as an implementation detail.
|
static class |
SnapApp.SelectionSourceHint
Provides a hint to
getSelectedProduct(SelectionSourceHint) } which selection provider should be used as primary selection source |
static class |
SnapApp.ShowingOp
This non-API class is public as an implementation detail.
|
static class |
SnapApp.StartOp
This non-API class is public as an implementation detail.
|
static class |
SnapApp.StopOp
This non-API class is public as an implementation detail.
|
Constructor and Description |
---|
SnapApp()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
AppContext |
getAppContext()
Gets an
AppContext representation of the SNAP application. |
String |
getAppName()
Deprecated.
|
static SnapApp |
getDefault()
Gets the SNAP application singleton which provides access to various SNAP APIs and resources.
|
org.esa.snap.netbeans.docwin.DocumentWindowManager |
getDocumentWindowManager()
Gets SNAP's global document window manager.
|
String |
getInstanceName() |
Logger |
getLogger() |
Frame |
getMainFrame() |
Preferences |
getPreferences() |
PropertyMap |
getPreferencesPropertyMap()
Deprecated.
Use
getPreferences() or Config.preferences() instead. |
ProductManager |
getProductManager()
Gets SNAP's global data product manager.
|
Product |
getSelectedProduct(SnapApp.SelectionSourceHint hint)
Return the currently selected product.
|
ProductNode |
getSelectedProductNode(SnapApp.SelectionSourceHint hint)
Return the currently selected product node.
|
ProductSceneView |
getSelectedProductSceneView() |
<T> SelectionSupport<T> |
getSelectionSupport(Class<T> type)
Provides a
SelectionSupport instance for object selections. |
org.openide.awt.UndoRedo.Manager |
getUndoManager(Product product) |
void |
handleError(String message,
Throwable t)
Handles an error.
|
void |
onShowing()
Called if SNAP is showing on the user's desktop.
|
void |
onStart()
Called if SNAP starts up.
|
void |
onStop()
Called if SNAP shuts down.
|
boolean |
onTryStop()
Called if SNAP is about to shut down.
|
void |
setStatusBarMessage(String message)
Sets the current status bar message.
|
public SnapApp()
As this class is a registered service, the constructor is not supposed to be called directly.
public static SnapApp getDefault()
The the method basically returns
Lookup.getDefault().lookup(SnapApp.class)
public org.esa.snap.netbeans.docwin.DocumentWindowManager getDocumentWindowManager()
public ProductManager getProductManager()
public org.openide.awt.UndoRedo.Manager getUndoManager(Product product)
public Frame getMainFrame()
public void setStatusBarMessage(String message)
message
- The new status bar message.@Deprecated public String getAppName()
getInstanceName()
public String getInstanceName()
"SNAP"
.public Preferences getPreferences()
@Deprecated public PropertyMap getPreferencesPropertyMap()
getPreferences()
or Config.preferences()
instead.preferences
wrapped by a PropertyMap
.
Its main use is to provide compatibility for SNAP heritage GUI code (from BEAM & NEST) which used
the PropertyMap
interface.
PropertyMap
instance.public Logger getLogger()
public void handleError(String message, Throwable t)
message
- An error message.t
- An exception or null
.public <T> SelectionSupport<T> getSelectionSupport(Class<T> type)
SelectionSupport
instance for object selections.type
- The type of selected objects whose selection state to observe.null
.public ProductSceneView getSelectedProductSceneView()
null
.public ProductNode getSelectedProductNode(SnapApp.SelectionSourceHint hint)
The hint
defines what is the primary and secondary selection source. Source is either the
scene view
or the product explorer
. If it is set to
SnapApp.SelectionSourceHint.AUTO
the algorithm tries to make a good guess, checking which component has the focus.
null
.public Product getSelectedProduct(SnapApp.SelectionSourceHint hint)
The hint
defines what is the primary and secondary selection source. Source is either the
scene view
or the product explorer
. If it is set to
SnapApp.SelectionSourceHint.AUTO
the algorithm tries to make a good guess, checking which component has the focus.
hint
- gives a hint to the implementation which selection source should be preferred.null
.public AppContext getAppContext()
AppContext
representation of the SNAP application.
Its main use is to provide compatibility for SNAP heritage GUI code (from BEAM & NEST) which used
the AppContext
interface.
AppContext
representation of this SnapApp
.public void onStart()
Overrides should call super.onStart()
as a first step unless they know what they are doing.
public void onStop()
Overrides should call super.onStop()
in a final step unless they know what they are doing.
public void onShowing()
Overrides should call super.onShowing()
as a first step unless they know whet they are doing.
public boolean onTryStop()
Overrides should call super.onTryStop()()
unless they know whet they are doing. The method should return
immediately false
if the super call returns false
.
false
if the shutdown process shall be cancelled immediately. true
, if it is ok
to continue shut down.Copyright © 2014–2015 European Space Agency (ESA). All rights reserved.