Class AppChooser
- All Implemented Interfaces:
ActionListener
,MouseListener
,ImageObserver
,MenuContainer
,Serializable
,EventListener
,Accessible
,ChangeListener
,TreeSelectionListener
,RootPaneContainer
,WindowConstants
Go
button or by double-clicking
on the application name.

Drag-and-Drop
The Application Launcher menu window supports drag-and-drop operations. Data files and script files can be dropped on to the Application Launcher window to start up applications. The following file types are understood:File extension | Action |
---|---|
.bsh | Open the MapViewer application and run the script |
.csv .dbf .shp | Open the MapViewer application and open the table |
.pin | Open the Patchworks application and load the specified pin file. |
Default application properties
The user interface for the AppChooser supports viewing and setting the default application parameters. Right-click on an application name to view the default parameters.
Right-click on the 'Applications' menu item to view all default
properties. Note that there are several properties for the
launcher itself which allow custom settings to be passed
to the Java environment.
Several of the launcher properties are:
Property | Description |
---|---|
launcher.classpath | A list of one or more jar files to be included in the java class path. Separate the jar file names with semicolons. |
launcher.javaflags | A list of flags that will be passed along to the java process. |
launcher.vmsize | The heap size that will be set on the java command line. This is the same value that is shown on the AppChooser main menu. |
Application properties are stored in a text file named patchworks.ini
,
normally found within the Documents/Patchworks folder.
Although you may edit this text file take care not to introduce syntax
errors that will prevent the application from initializing.
Batch scripting
This class also contains methods useful for batch scripting. In particular theinvoke
and invokeInline
methods can be used to launch Patchworks tools from a BeanShell script.
Both of these methods start the specified applications in a new
execution process. These processes run when completed the
process will exit. Running applications in a separate execution context
provides isolation so that the data structures in one complex application
do not interfere with another applicaiton. It also allows several processes
to run simulataneously.
The invokeInline
command pauses the current script, invokes the
application in a new process, allows output from the new process to write
to the current process terminal, and waits until the new process has completed
before continuing the script.
For example:
AppChooser.invokeInline("ca.spatial.tracks.fvs.UnpackFVS", new String[] {"c:/Workspace/sample/yield/unpackConfig.yaml"});The
invoke
command does the same as the invokeInline
command,
except that a new terminal is opened to contain the application
output. Once the application has completed the terminal window can close.
It is an option that the currently running script may continue to run,
or will wait for the new process to finish.
For example:
AppChooser.invoke("ca.spatial.tracks.builder.Process", new String[] {"c:/Workspace/sample/data/fragments.dbf", "c:/Workspace/sample/tracks", "c:/Workspace/sample/tracks/forestModel.xml"}, true);
A true
argument in the third position of the invoke
command will start the application in a separate process and wait for
the application to complete before continuing with the script.
If a false
is provided as the third parameter the script will
continune to run after the application has has started, regardless of
it's ongoing status.
The invoke command returns a Process
object which
may be used to monitor the status of the application.
The Process object supports a Process.waitFor()
method that will
block until the application completes. This may be used to simultaneously
start several applications and wait for all to complete before continuing.
For example:
// Build tracks p1 = AppChooser.invoke("ca.spatial.tracks.builder.Process", new String[] {"c:/Workspace/sample/data/fragments.dbf", "c:/Workspace/sample/tracks", "c:/Workspace/sample/tracks/forestModel.xml"}, false); // Build road network p2 = AppChooser.invoke("ca.spatial.gis.vector.OutputSegments", new String[] {"c:/Workspace/sample/blocks/blocks.shp", "CLUSTER", "c:/Workspace/sample/roads/mills.shp", "HAUL", "1000", // Search threshold of 1km "ACCESS_", "c:/Workspace/sample/roads/access.shp", "c:/Workspace/sample/roads"}, false); // Build topology p3 = AppChooser.invoke("ca.spatial.gis.raster.ProximalTopology", new String[] {"c:/Workspace/sample/blocks/blocks.shp", "10", "CLUSTER", "200", "c:/Workspace/sample/blocks/blocks_topology_200r10.csv"}, false); // Wait for all to complete p1.waitFor(); p2.waitFor(); p3.waitFor(); // Carry on with the script ...The
Process
object and the waitFor
method are only useful
when the false
value has been passed in as the third argument.
When the true
value is used the process has terminated before the
script resumes control.
Command line scripting
Applications can be invoked from the command line or from within other shell tools. Since Patchworks is a Java application, it runs under the control of the Java runtime environment. The command must start with the name of the Java program (typically java) and the path to the Patchworks "jar" file. Subsequent arguments include the class name of the application to start, and any arguments that should be passed along to the program.
In the following example, the java program loads the Patchworks jar
file from thr standard location. The class name
ca.spatial.mapview.MapViewer
indicates that the MapViewer program
should be started. The myScript.bsh
is the name of a script
file to be run, located relative to the current working directory.
java -jar "C:/Program Files/Spatial Planning Systems/Patchworks/patchworks.jar" \ ca.spatial.mapview.MapViewer myScript.bshNote that although this command is shown as being wrapped over two lines, this command should probably be entered on a single line (depends on the shell program being used).
The java command will begin to execute and will not return until the MapView program has been closed. Alternately the javaw program could have been used to launch the program without waiting for it to complete.
- See Also:
- Serialized Form
-
Nested Class Summary
Nested classes/interfaces inherited from class java.awt.Window
Window.Type
Nested classes/interfaces inherited from class java.awt.Component
Component.BaselineResizeBehavior
-
Field Summary
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
-
Method Summary
Modifier and TypeMethodDescriptionvoid
static Process
This method will invoke the application.static Process
This method will invoke the application.static void
invokeInline(String initialClass, String[] args)
This method will invoke the requested class as an application.static void
Entry point to run the application launcher.void
void
void
void
void
void
void
Methods inherited from class javax.swing.JFrame
getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setTransferHandler, update
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setBackground, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setOpacity, setResizable, setShape, setState, setTitle, setUndecorated
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, setVisible, show, toBack, toFront
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, dispatchEvent, enable, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setMixingCutoutShape, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
-
Method Details
-
mousePressed
- Specified by:
mousePressed
in interfaceMouseListener
-
mouseClicked
- Specified by:
mouseClicked
in interfaceMouseListener
-
mouseEntered
- Specified by:
mouseEntered
in interfaceMouseListener
-
mouseExited
- Specified by:
mouseExited
in interfaceMouseListener
-
mouseReleased
- Specified by:
mouseReleased
in interfaceMouseListener
-
stateChanged
- Specified by:
stateChanged
in interfaceChangeListener
-
actionPerformed
- Specified by:
actionPerformed
in interfaceActionListener
-
valueChanged
- Specified by:
valueChanged
in interfaceTreeSelectionListener
-
invoke
This method will invoke the application. The invocation will be done in a separate memory context, usually using an operating system 'exec' call. This method will start the process and without waiting for it to complete. A terminal window will be opened to display printed output from the command.This command is equivalent to
AppChooser.invoke(initialClass, args, false);
- Parameters:
initialClass
- The fully qualified name of the class to be invoked.args
- A list of arguments to be passed to the main method of the class to be invoked.- Returns:
- This method returns a reference to the invoked process. The Process object may be monitor to determine when the process has completed executing.
-
invoke
This method will invoke the application. The invocation will be done in a separate process context, usually using an operating system 'exec' call. A terminal window will be opened to display printed output from the command.- Parameters:
initialClass
- The fully qualified name of the class to be invoked.args
- A list of arguments to be passed to the main method of the class to be invoked.wait
- a boolean to indicate if this method should wait for the command to complete its execution before returning- Returns:
- This method returns a reference to the invoked process.
The
Process
object may be monitored to determine when the process has completed executing.
-
invokeInline
This method will invoke the requested class as an application. The invocation will be done in a separate process context, usually using an operating system 'exec' call. The command will run to completion before this method returns. Output will be written to the current terminal window.- Parameters:
initialClass
- The fully qualified name of the class to be invoked.args
- A list of arguments to be passed to the main method of the class to be invoked.
-
main
Entry point to run the application launcher. If run without arguments it will display the Application Launcher menu. If provided with arguments the first argument is the name of the class to launch (note that this class must have astatic void main(String[] args)
method. Subsequent arguments on the command line will be passed along to the invoked class.
-