org.opensourcephysics.tools
Class LaunchNode

java.lang.Object
  extended byjavax.swing.tree.DefaultMutableTreeNode
      extended byorg.opensourcephysics.tools.LaunchNode
All Implemented Interfaces:
java.lang.Cloneable, javax.swing.tree.MutableTreeNode, java.io.Serializable, javax.swing.tree.TreeNode

public class LaunchNode
extends javax.swing.tree.DefaultMutableTreeNode

This is a tree node that can describe and launch an application.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
 
Constructor Summary
LaunchNode(java.lang.String name)
          Contructs a node with the specified name.
 
Method Summary
 void addMenuItemsTo(javax.swing.JComponent menu)
          Adds menu item to a JPopupMenu or JMenu.
 void addTerminateAction(javax.swing.Action action)
          Adds an action to this node's actions collection.
 boolean exists()
          Determines whether a resource exists for this node.
 LaunchNode[] getAllOwnedNodes()
          Returns all descendents of this node with non-null file names.
 java.lang.String getAuthor()
          Gets the author.
 LaunchNode getChildNode(java.lang.String childFileName)
          Gets a child node specified by fileName.
 LaunchNode[] getChildOwnedNodes()
          Returns the nearest descendents of this node with non-null file names.
 java.lang.String getClassPath()
          Gets the complete class path in node-to-root order.
 java.io.File getFile()
          Return an existing file with current file name and specified base.
 java.lang.String getFileName()
          Gets the fileName.
 java.lang.String getID()
          Gets the unique ID string for this node.
 java.lang.Class getLaunchClass()
          Gets the launch class for this node.
 java.lang.Object getLaunchObject()
          Gets the launch object.
static XML.ObjectLoader getLoader()
          Returns the XML.ObjectLoader for this class.
 java.util.logging.Level getLogLevel()
          Gets the log level.
 LaunchNode getOwner()
          Returns the nearest ancestor with a non-null file name.
 java.lang.String getPathString()
          Gets the string path to this node, starting from the root.
 Resource getResource()
          Gets the resource, if any, for this node
 boolean isButtonView()
          Gets the buttonView value.
 boolean isClearLog()
          Gets the clearLog value.
 boolean isHiddenInLauncher()
          Gets the hiddenInLauncher value.
 boolean isParentSelfContained()
          Gets the parentSelfContained flag.
 boolean isPreviewing()
          Gets the previewing flag.
 boolean isSavingHiddenNodes()
          Gets the saveHiddenNodes flag.
 boolean isSelfContained()
          Gets the selfContained flag.
 boolean isShowLog()
          Gets the showLog value.
 boolean isSingleApp()
          Gets the singleApp value.
 boolean isSingleton()
          Gets the singleton value.
 boolean isSingleVM()
          Gets the singleVM flag.
 void launch()
          Launches this node.
 void launch(LaunchPanel tab)
          Launches this node from the specified launch panel.
 boolean matches(LaunchNode node)
          Determines if this node matches another node.
 void removeTerminateAction(javax.swing.Action action)
          Removes an action from this node's actions collection.
protected  void removeThread(java.lang.Runnable runner)
           
 void setArgs(java.lang.String[] args)
          Sets the launch arguments of this node.
 void setButtonView(boolean buttonView)
          Sets the buttonView flag.
 void setClassPath(java.lang.String jarNames)
          Sets the class path (jar file names separated by colons or semicolons).
 void setClearLog(boolean clear)
          Sets the showLog flag.
 void setDescription(java.lang.String desc)
          Sets the description of this node.
 java.lang.String setFileName(java.lang.String path)
          Sets the fileName.
 void setHiddenInLauncher(boolean hide)
          Sets the hiddenInLauncher flag.
 void setHiddenWhenRoot(boolean hide)
          Sets the hiddenWhenRoot flag.
 boolean setLaunchClass(java.lang.String className)
          Sets the launch class for this node.
 void setLaunchObject(java.lang.Object obj)
          Sets the launch object.
 void setLogLevel(java.util.logging.Level level)
          Sets the log level.
protected  void setMinimumArgLength(int n)
           
 void setName(java.lang.String name)
          Sets the name of this node.
 void setSelfContained(boolean selfContained)
          Sets the selfContained flag.
 void setShowLog(boolean show)
          Sets the showLog flag.
 void setSingleApp(boolean singleApp)
          Sets the singleApp flag.
 void setSingleton(boolean singleton)
          Sets the singleton flag.
 void setSingleVM(boolean singleVM)
          Sets the single VM flag.
 java.net.URL setURL(java.lang.String path)
          Sets the url.
 void terminate(javax.swing.Action action)
          Removes an action from this node's actions collection.
 void terminateAll()
          Terminates all apps launched by this node.
 void threadRunning(boolean starting)
          Signals that a launch thread for this node is about to start or end.
 java.lang.String toString()
          Returns a string used as a display name for this node.
 
Methods inherited from class javax.swing.tree.DefaultMutableTreeNode
add, breadthFirstEnumeration, children, clone, depthFirstEnumeration, getAllowsChildren, getChildAfter, getChildAt, getChildBefore, getChildCount, getDepth, getFirstChild, getFirstLeaf, getIndex, getLastChild, getLastLeaf, getLeafCount, getLevel, getNextLeaf, getNextNode, getNextSibling, getParent, getPath, getPathToRoot, getPreviousLeaf, getPreviousNode, getPreviousSibling, getRoot, getSharedAncestor, getSiblingCount, getUserObject, getUserObjectPath, insert, isLeaf, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, remove, remove, removeAllChildren, removeFromParent, setAllowsChildren, setParent, setUserObject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LaunchNode

public LaunchNode(java.lang.String name)
Contructs a node with the specified name.

Parameters:
name - the name
Method Detail

threadRunning

public void threadRunning(boolean starting)
Signals that a launch thread for this node is about to start or end.

Parameters:
starting - true if the thread is starting

launch

public void launch()
Launches this node.


launch

public void launch(LaunchPanel tab)
Launches this node from the specified launch panel.

Parameters:
tab - the launch panel

getOwner

public LaunchNode getOwner()
Returns the nearest ancestor with a non-null file name. This node is returned if it has a non-null file name.

Returns:
the file node

getAllOwnedNodes

public LaunchNode[] getAllOwnedNodes()
Returns all descendents of this node with non-null file names. This node is not included.

Returns:
an array of launch nodes

getChildOwnedNodes

public LaunchNode[] getChildOwnedNodes()
Returns the nearest descendents of this node with non-null file names. This node is not included.

Returns:
an array of launch nodes

toString

public java.lang.String toString()
Returns a string used as a display name for this node.

Returns:
the string name of this node

getID

public java.lang.String getID()
Gets the unique ID string for this node.

Returns:
the ID string

setName

public void setName(java.lang.String name)
Sets the name of this node.

Parameters:
name - the name

setDescription

public void setDescription(java.lang.String desc)
Sets the description of this node.

Parameters:
desc - the description

setArgs

public void setArgs(java.lang.String[] args)
Sets the launch arguments of this node.

Parameters:
args - the arguments

getClassPath

public java.lang.String getClassPath()
Gets the complete class path in node-to-root order. If Launcher is running from a jar, that jar is in every classpath.

Returns:
the class path

setClassPath

public void setClassPath(java.lang.String jarNames)
Sets the class path (jar file names separated by colons or semicolons).

Parameters:
jarNames - the class path

setLaunchClass

public boolean setLaunchClass(java.lang.String className)
Sets the launch class for this node.

Parameters:
className - the name of the class
Returns:
true if the class was successfully loaded for the first time

getLaunchClass

public java.lang.Class getLaunchClass()
Gets the launch class for this node.

Returns:
the launch class

getLaunchObject

public java.lang.Object getLaunchObject()
Gets the launch object. May be null.

Returns:
the launch object

setLaunchObject

public void setLaunchObject(java.lang.Object obj)
Sets the launch object.

Parameters:
obj - the launch object

setURL

public java.net.URL setURL(java.lang.String path)
Sets the url.

Parameters:
path - the path of the url
Returns:
the url

getFileName

public java.lang.String getFileName()
Gets the fileName.

Returns:
the fileName, assumed to be a relative path

getPathString

public java.lang.String getPathString()
Gets the string path to this node, starting from the root. This returns the names of the nodes in the path, separated by "/".

Returns:
the path

setFileName

public java.lang.String setFileName(java.lang.String path)
Sets the fileName. Accepts relative paths or will convert absolute paths to relative.

Parameters:
path - the path to the file
Returns:
the file name

isParentSelfContained

public boolean isParentSelfContained()
Gets the parentSelfContained flag.

Returns:
true if parentSelfContained is true for this or an ancestor

isSelfContained

public boolean isSelfContained()
Gets the selfContained flag.

Returns:
true if selfContained is true for this or an ancestor

isPreviewing

public boolean isPreviewing()
Gets the previewing flag.

Returns:
true if previewing is true for this or an ancestor

isSavingHiddenNodes

public boolean isSavingHiddenNodes()
Gets the saveHiddenNodes flag.

Returns:
true if saveHiddenNodes is true for this or an ancestor

setSelfContained

public void setSelfContained(boolean selfContained)
Sets the selfContained flag.

Parameters:
selfContained - true if self contained

isSingleVM

public boolean isSingleVM()
Gets the singleVM flag.

Returns:
true if singleVM is true for this or an ancestor

setSingleVM

public void setSingleVM(boolean singleVM)
Sets the single VM flag.

Parameters:
singleVM - true if single vm

isShowLog

public boolean isShowLog()
Gets the showLog value.

Returns:
true if showLog is true for this or an ancestor

setShowLog

public void setShowLog(boolean show)
Sets the showLog flag.

Parameters:
show - true to show the OSPLog (single vm only)

isClearLog

public boolean isClearLog()
Gets the clearLog value.

Returns:
true if clearLog is true for this or an ancestor

setClearLog

public void setClearLog(boolean clear)
Sets the showLog flag.

Parameters:
clear - true to clear the OSPLog (single vm only)

getLogLevel

public java.util.logging.Level getLogLevel()
Gets the log level.

Returns:
the level

setLogLevel

public void setLogLevel(java.util.logging.Level level)
Sets the log level.

Parameters:
level - the level

isSingleApp

public boolean isSingleApp()
Gets the singleApp value.

Returns:
true if singleApp is true for this or an ancestor

setSingleApp

public void setSingleApp(boolean singleApp)
Sets the singleApp flag.

Parameters:
singleApp - true to close other apps when launching new app (single vm only)

setHiddenWhenRoot

public void setHiddenWhenRoot(boolean hide)
Sets the hiddenWhenRoot flag.

Parameters:
hide - true to hide node when at root

isButtonView

public boolean isButtonView()
Gets the buttonView value.

Returns:
true if buttonView is true for this or an ancestor

setButtonView

public void setButtonView(boolean buttonView)
Sets the buttonView flag.

Parameters:
buttonView - true to display in buttonView

isSingleton

public boolean isSingleton()
Gets the singleton value.

Returns:
true if singleApp is true for this or an ancestor

setSingleton

public void setSingleton(boolean singleton)
Sets the singleton flag.

Parameters:
singleton - true to allow single instance when in separate vm

isHiddenInLauncher

public boolean isHiddenInLauncher()
Gets the hiddenInLauncher value.

Returns:
true if hiddenInLauncher is true for this or an ancestor

setHiddenInLauncher

public void setHiddenInLauncher(boolean hide)
Sets the hiddenInLauncher flag.

Parameters:
hide - true to hide this node in Launcher

getAuthor

public java.lang.String getAuthor()
Gets the author.

Returns:
the first non-null author of this or an ancestor

getResource

public Resource getResource()
Gets the resource, if any, for this node

Returns:
the resource

exists

public boolean exists()
Determines whether a resource exists for this node.

Returns:
true if a resource exists

getFile

public java.io.File getFile()
Return an existing file with current file name and specified base. May return null.

Returns:
existing file, or null

matches

public boolean matches(LaunchNode node)
Determines if this node matches another node.

Parameters:
node - the node to match
Returns:
true if the nodes match

getChildNode

public LaunchNode getChildNode(java.lang.String childFileName)
Gets a child node specified by fileName.

Parameters:
childFileName - the file name of the child
Returns:
the first child found, or null

addMenuItemsTo

public void addMenuItemsTo(javax.swing.JComponent menu)
Adds menu item to a JPopupMenu or JMenu.

Parameters:
menu - the menu

addTerminateAction

public void addTerminateAction(javax.swing.Action action)
Adds an action to this node's actions collection.

Parameters:
action - the action to add

removeTerminateAction

public void removeTerminateAction(javax.swing.Action action)
Removes an action from this node's actions collection.

Parameters:
action - the action to remove

terminate

public void terminate(javax.swing.Action action)
Removes an action from this node's actions collection.

Parameters:
action - the action to remove

terminateAll

public void terminateAll()
Terminates all apps launched by this node.


getLoader

public static XML.ObjectLoader getLoader()
Returns the XML.ObjectLoader for this class.

Returns:
the object loader

setMinimumArgLength

protected void setMinimumArgLength(int n)

removeThread

protected void removeThread(java.lang.Runnable runner)