Package org.opensourcephysics.tools
Class LaunchNode
java.lang.Object
javax.swing.tree.DefaultMutableTreeNode
org.opensourcephysics.tools.LaunchNode
- All Implemented Interfaces:
Serializable
,Cloneable
,MutableTreeNode
,TreeNode
This is a tree node that can describe and launch an application.
- Version:
- 1.0
- Author:
- Douglas Brown
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddDisplayTab
(String title, String path, String[] args) Adds a display tab with the specified title and relative path.Deprecated.replaced by addDisplayTabvoid
addMenuItemsTo
(JComponent menu) Adds menu item to a JPopupMenu or JMenu.void
addTerminateAction
(Action action) Adds an action to this node's actions collection.boolean
exists()
Determines whether a resource exists for this node.Returns all descendents of this node with non-null file names.String[]
getArgs()
Gets the launch arguments of this node.Gets the author.getChildNode
(String childFileName) Gets a child node specified by fileName.Returns the nearest descendents of this node with non-null file names.Gets the complete class path in node-to-root order.Gets the comment of this node.Gets the course level of this node or ancestor.Gets the description of this node.getDisplayTab
(int n) Gets a display tab.int
Returns the number of display tabs for this node.getFile()
Return an existing file with current file name and specified base.Gets the fileName.getHTML
(int n) Deprecated.replaced by getDisplayTabint
Deprecated.replaced by getDisplayTabCountgetID()
Gets the unique ID string for this node.Gets the keywords of this node or ancestor.Gets the languages for which translations exist for this node or ancestor.Class<?>
Gets the launch class for this node.Returns the name of the class to launchprotected JScrollPane
Gets the launchModelScroller.Gets the launch object.static XML.ObjectLoader
Returns the XML.ObjectLoader for this class.Gets the log level.getName()
Gets the name of this node.getOwner()
Returns the nearest ancestor with a non-null file name.Gets the string path to this node, starting from the root.Gets the list of pdf documents associated with this node.Gets the preferred applet height of this node.Gets the preferred applet width of this node.Gets the resource, if any, for this nodeGets the tooltip of this node.getURL()
insertDisplayTab
(int n, String title, String path, String[] args) Inserts a display tab with the specified title and relative path.insertHTML
(int n, String title, String path) Deprecated.replaced by insertDisplayTabboolean
Gets the buttonView value.boolean
Gets the clearLog value.boolean
Gets the hiddenInLauncher value.boolean
Gets the parentSelfContained flag.boolean
Gets the previewing flag.boolean
Gets the saveHiddenNodes flag.boolean
Gets the selfContained flag.boolean
Gets the showLog value.boolean
Gets the singleApp value.boolean
Gets the singleton value.boolean
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.removeDisplayTab
(int n) Removes a display tab.removeHTML
(int n) Deprecated.replaced by removeDisplayTabvoid
removeTerminateAction
(Action action) Removes an action from this node's actions collection.protected void
removeThread
(Runnable runner) void
scrollToRef
(String scrollRef) void
Sets the launch arguments of this node.void
Sets the author of this nodevoid
setButtonView
(boolean buttonView) Sets the buttonView flag.void
setClassPath
(String jarNames) Sets the class path (relative jar or directory paths separated by colons or semicolons).void
setClearLog
(boolean clear) Sets the showLog flag.void
setComment
(String _comment) Sets the comment of this nodevoid
setCourseLevel
(String _level) Sets the course level of this nodevoid
setDescription
(String desc) Sets the description of this node.setDisplayTab
(int n, String title, String path, String[] args) Sets the specified display tab title and url path.setFileName
(String path) Sets the fileName.void
setHiddenInLauncher
(boolean hide) Sets the hiddenInLauncher flag.void
setHiddenWhenRoot
(boolean hide) Sets the hiddenWhenRoot flag.Deprecated.replaced by setDisplayTabvoid
setKeyword
(String _keywords) Sets the keywords of this nodevoid
setLanguages
(String _lang) Sets the languages for which translations exist for this nodeboolean
setLaunchClass
(String className) Sets the launch class for this node.void
setLaunchObject
(Object obj) Sets the launch object.void
setLogLevel
(Level level) Sets the log level.protected void
setMinimumArgLength
(int n) void
Sets the name of this node.void
setPreferredAppletHeight
(String _height) Sets the preferred applet height of this nodevoid
setPreferredAppletWidth
(String _width) Sets the preferred applet width of this nodevoid
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.void
setTooltip
(String _tooltip) Sets the tooltip of this nodevoid
void
Removes an action from this node's actions collection.void
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.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
-
Constructor Details
-
LaunchNode
Constructs a node with the specified name.- Parameters:
name
- the name
-
-
Method Details
-
setURL
-
getURL
-
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
Launches this node from the specified launch panel.- Parameters:
tab
- the launch panel
-
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
Returns all descendents of this node with non-null file names. This node is not included.- Returns:
- an array of launch nodes
-
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
Returns a string used as a display name for this node.- Overrides:
toString
in classDefaultMutableTreeNode
- Returns:
- the string name of this node
-
getID
Gets the unique ID string for this node.- Returns:
- the ID string
-
setName
Sets the name of this node.- Parameters:
name
- the name
-
getName
Gets the name of this node.- Returns:
- the name
-
setDescription
Sets the description of this node.- Parameters:
desc
- the description
-
getDescription
Gets the description of this node.- Returns:
- the description
-
setArgs
Sets the launch arguments of this node.- Parameters:
args
- the arguments
-
getArgs
Gets the launch arguments of this node.- Returns:
- the launch arguments
-
setTooltip
Sets the tooltip of this node- Parameters:
_tooltip
- the tooltip
-
getTooltip
Gets the tooltip of this node.- Returns:
- the tooltip
-
setAuthor
Sets the author of this node- Parameters:
_author
- the author
-
getAuthor
Gets the author.- Returns:
- the first non-null author of this or an ancestor
-
setKeyword
Sets the keywords of this node- Parameters:
_keywords
- the keywords
-
getKeywords
Gets the keywords of this node or ancestor.- Returns:
- the keywords
-
setComment
Sets the comment of this node- Parameters:
_comment
- the comment
-
getComment
Gets the comment of this node.- Returns:
- the comment
-
setPreferredAppletWidth
Sets the preferred applet width of this node- Parameters:
_width
- the width
-
getPreferredAppletWidth
Gets the preferred applet width of this node.- Returns:
- the width
-
setPreferredAppletHeight
Sets the preferred applet height of this node- Parameters:
_height
- the height
-
getPreferredAppletHeight
Gets the preferred applet height of this node.- Returns:
- the height
-
setCourseLevel
Sets the course level of this node- Parameters:
_level
- the level
-
getCourseLevel
Gets the course level of this node or ancestor.- Returns:
- the level
-
setLanguages
Sets the languages for which translations exist for this node- Parameters:
_lang
- the languages
-
getLanguages
Gets the languages for which translations exist for this node or ancestor.- Returns:
- the languages
-
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
Sets the class path (relative jar or directory paths separated by colons or semicolons).- Parameters:
jarNames
- the class path
-
getLaunchClassName
Returns the name of the class to launch- Returns:
- the class name
-
setLaunchClass
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
Gets the launch class for this node.- Returns:
- the launch class
-
getLaunchObject
Gets the launch object. May be null.- Returns:
- the launch object
-
setLaunchObject
Sets the launch object.- Parameters:
obj
- the launch object
-
setDisplayTab
Sets the specified display tab title and url path. Specifying a tab number greater than the current tab count adds a new tab. Setting a path to null removes the tab.- Parameters:
n
- the tab numbertitle
- the tab titlepath
- the path.args
- model arguments. May be null.- Returns:
- the DisplayTab, or null if unsuccessful
-
addDisplayTab
Adds a display tab with the specified title and relative path. No tab is added if path is null or "".- Parameters:
title
- the tab title. May be null.path
- the path.args
- model arguments. May be null.- Returns:
- the newly created DisplayTab, if any
-
insertDisplayTab
Inserts a display tab with the specified title and relative path. No tab is inserted if path is null or "", or if the specified tab index is invalid.- Parameters:
n
- the insertion indextitle
- the tab title. May be null.path
- the path.args
- model arguments. May be null.- Returns:
- the newly created DisplayTab, if any
-
removeDisplayTab
Removes a display tab.- Parameters:
n
- the tab number- Returns:
- the DisplayTab removed, or null if none removed
-
getDisplayTab
Gets a display tab.- Parameters:
n
- the tab number- Returns:
- the DisplayTab, or null if none found
-
getDisplayTabCount
public int getDisplayTabCount()Returns the number of display tabs for this node.- Returns:
- the tab count
-
getPDFPaths
Gets the list of pdf documents associated with this node.- Returns:
- a list of PDF documents (may be empty)
-
getFileName
Gets the fileName.- Returns:
- the fileName, assumed to be a relative path
-
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
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
Gets the log level.- Returns:
- the level
-
setLogLevel
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
-
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
Return an existing file with current file name and specified base. May return null.- Returns:
- existing file, or null
-
matches
Determines if this node matches another node.- Parameters:
node
- the node to match- Returns:
- true if the nodes match
-
getChildNode
Gets a child node specified by fileName.- Parameters:
childFileName
- the file name of the child- Returns:
- the first child found, or null
-
addMenuItemsTo
Adds menu item to a JPopupMenu or JMenu.- Parameters:
menu
- the menu
-
addTerminateAction
Adds an action to this node's actions collection.- Parameters:
action
- the action to add
-
removeTerminateAction
Removes an action from this node's actions collection.- Parameters:
action
- the action to remove
-
terminate
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. -
getLaunchModelScroller
Gets the launchModelScroller. May return null.- Returns:
- the scroller containing the modelPane from the launch class
-
getLoader
Returns the XML.ObjectLoader for this class.- Returns:
- the object loader
-
setMinimumArgLength
protected void setMinimumArgLength(int n) -
removeThread
-
addHTML
Deprecated.replaced by addDisplayTabAdds an HTML tab with the specified title and relative path. -
insertHTML
Deprecated.replaced by insertDisplayTabInserts an HTML tab with the specified title and relative path. -
removeHTML
Deprecated.replaced by removeDisplayTabRemoves an HTML tab. -
getHTML
Deprecated.replaced by getDisplayTabGets an HTML tab. -
getHTMLCount
Deprecated.replaced by getDisplayTabCountReturns the number of html objects in the list. -
setHTML
Deprecated.replaced by setDisplayTabSets the specified HTML tab title and url path. -
scrollToRef
-