org.opensourcephysics.tools
Class LaunchBuilder

java.lang.Object
  extended by org.opensourcephysics.tools.Launcher
      extended by org.opensourcephysics.tools.LaunchBuilder

public class LaunchBuilder
extends Launcher

This provides a GUI for building LaunchNode and LaunchSet xml files.

Version:
1.2
Author:
Douglas Brown

Nested Class Summary
 
Nested classes/interfaces inherited from class org.opensourcephysics.tools.Launcher
Launcher.HTMLPane, Launcher.LaunchSet
 
Field Summary
 
Fields inherited from class org.opensourcephysics.tools.Launcher
aboutItem, activeNode, authorInfoItem, backButton, backItem, baseMenuFontSize, changedFiles, chooser, classChooser, classPath, closeAllItem, closeTabItem, contentPane, creditsLabel, defaultFileName, defaultIcon, defaultLFItem, diagnosticMenu, displayMenu, divider, editItem, editorEnabled, ejsIcon, existingFrames, exitItem, extractExtensions, fileMenu, forwardButton, frame, frameFinder, genericLFGroup, ghostFileIcon, greenFileIcon, greenFolderIcon, helpMenu, hideItem, hInit, htmlIcon, htmlTabList, inspectItem, jarBasePath, javaLFItem, languageItems, languageMenu, launchedIcon, launchEmptyIcon, launcherFileFilter, launchIcon, linkIcon, linkListener, logItem, lookAndFeel, lookFeelItem, lookFeelMenu, magentaFileIcon, navbar, navbarAddOns, navButton, navClosedIcon, navigationVisible, navOpenIcon, navSpacer, newNodeSelected, noFileIcon, openFromJarMenu, openItem, openPaths, password, popup, postEdits, previewing, previousNode, pwRequiredToLoad, redFileIcon, redFolderIcon, releaseDate, resourcesPath, saveState, selectedNode, selfContained, showText, singleAppItem, singleAppMode, singletonIcon, singletonMode, sizeDownItem, sizeUpItem, spawner, specificLFGroup, splashDialog, splashPathLabel, splashTimer, splashTitleLabel, systemLFItem, tabbedPane, tableInspector, tabListener, tabs, tabSetBasePath, tabSetName, textPane, textScroller, title, undoManager, undoSupport, version, whiteFileIcon, whiteFolderIcon, wInit, xmlFileFilter, xmlInspector, xsetFileFilter, yellowFileIcon, yellowFolderIcon
 
Constructor Summary
LaunchBuilder()
          No-arg constructor.
LaunchBuilder(boolean splash)
          Constructs a builder with or without a splash screen.
LaunchBuilder(java.lang.String fileName)
          Constructs a builder and loads the specified file.
LaunchBuilder(java.lang.String fileName, boolean splash)
          Constructs a builder and loads the specified file with or without splash.
 
Method Summary
 void addChildToSelectedNode(LaunchNode child)
          Adds a child node to the selected node.
 boolean addTab(LaunchNode root)
          Creates a LaunchPanel with the specified root and adds it to a new tab.
protected  void createActions()
          Creates the actions.
protected  void createGUI(boolean splash)
          Creates the GUI.
protected  void exit()
          Overrides Launcher exit method.
protected  java.util.Map<LaunchPanel,LaunchNode> getClones(LaunchNode node)
          Returns clones containing a specified node in a tab-to-node map.
protected static javax.swing.JFileChooser getFileChooser()
          Gets a file chooser.
protected static javax.swing.JFileChooser getHTMLChooser()
          Gets a file chooser for selecting html files.
protected static javax.swing.JFileChooser getJARChooser()
          Gets a file chooser for selecting jar files.
protected  void handleMousePressed(java.awt.event.MouseEvent e, LaunchPanel tab)
          Handles a mouse pressed event.
protected  boolean isNodeWritable(LaunchNode node)
          Returns true if node is writable.
protected  boolean isTabSetWritable()
          Returns true if tabset is writable.
static void main(java.lang.String[] args)
          Main entry point when used as application.
protected  void refreshClones(LaunchNode node)
          Replaces clones of a specified node with new clones.
protected  void refreshGUI()
          Refreshes the GUI.
protected  void refreshNode(LaunchNode node)
          Refreshes the specified node with data from the input fields.
protected  void refreshSelectedNode()
          Refreshes the selected node.
protected  void refreshStringResources()
          Refreshes string resources.
protected  boolean removeAllTabs()
          Removes all tabs and closes the tabset.
 void removeSelectedNode()
          Removes the selected node.
 boolean removeSelectedTab()
          Removes the selected tab.
protected  void replaceClones(LaunchNode node, java.util.Map<LaunchPanel,LaunchNode> clones)
          Replaces nodes with clones of the specified node.
 java.lang.String save(LaunchNode node, java.lang.String fileName)
          Saves a node to the specified file.
protected  boolean saveAllChanges()
          Offers to save all changes, if any.
 java.lang.String saveAs(LaunchNode node)
          Saves a node to an xml file selected with a chooser.
protected  boolean saveChanges(LaunchPanel tab)
          Offers to save changes, if any, to the specified tab.
protected  boolean saveOwnedNodes(LaunchNode node)
          Saves the owned nodes of the specified node.
 boolean saveTabs()
          Saves tabs.
 java.lang.String saveTabSet()
          Saves the current tabset.
protected  java.lang.String saveTabSetAs()
          Saves a tabset to a file selected with a chooser.
protected  void setFontLevel(int level)
          Sets the font level.
protected  void showAboutDialog()
          Shows the about dialog.
 
Methods inherited from class org.opensourcephysics.tools.Launcher
clearHistory, getClassChooser, getContentPane, getDefaultJar, getDisplayName, getDivider, getFileIcon, getHTMLTab, getNodeAndPage, getOpenPaths, getRootNode, getSelectedNode, getSelectedTab, getSize, getTab, getTabCount, getXMLChooser, hasEJSModel, isLaunchable, isLaunchable, isLink, isVisible, launch, launch, launch, loadIcon, open, open, open, setDivider, setEditorEnabled, setHyperlinksEnabled, setHyperlinksEnabled, setJarsOnly, setLinksEnabled, setLookAndFeel, setNavbarRightEndComponents, setNavigationVisible, setSelectedNode, setSelectedNode, setSelectedNode, setSelectedNodeByKey, setSelectedTab, setSelectedTab, setSize, setVisible, showAuthorInformation, showButtonView, showTabbedPaneView, terminateApps
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LaunchBuilder

public LaunchBuilder()
No-arg constructor.


LaunchBuilder

public LaunchBuilder(java.lang.String fileName)
Constructs a builder and loads the specified file.

Parameters:
fileName - the file name

LaunchBuilder

public LaunchBuilder(boolean splash)
Constructs a builder with or without a splash screen.

Parameters:
splash - true to show the splash screen

LaunchBuilder

public LaunchBuilder(java.lang.String fileName,
                     boolean splash)
Constructs a builder and loads the specified file with or without splash.

Parameters:
fileName - the file name
splash - true to show the splash screen
Method Detail

main

public static void main(java.lang.String[] args)
Main entry point when used as application.

Parameters:
args - args[0] may be an xml file name

save

public java.lang.String save(LaunchNode node,
                             java.lang.String fileName)
Saves a node to the specified file.

Parameters:
node - the node
fileName - the desired name of the file
Returns:
the name of the saved file, or null if not saved

saveAs

public java.lang.String saveAs(LaunchNode node)
Saves a node to an xml file selected with a chooser.

Parameters:
node - the node
Returns:
the name of the file

saveOwnedNodes

protected boolean saveOwnedNodes(LaunchNode node)
Saves the owned nodes of the specified node.

Parameters:
node - the node
Returns:
true unless cancelled by user

saveTabSetAs

protected java.lang.String saveTabSetAs()
Saves a tabset to a file selected with a chooser.

Returns:
the absolute path of the tabset file

saveTabSet

public java.lang.String saveTabSet()
Saves the current tabset.

Returns:
the full path to the saved file, or null if not saved

saveTabs

public boolean saveTabs()
Saves tabs.

Returns:
true unless cancelled by user

refreshSelectedNode

protected void refreshSelectedNode()
Refreshes the selected node.


refreshNode

protected void refreshNode(LaunchNode node)
Refreshes the specified node with data from the input fields.

Parameters:
node - the node to refresh

addTab

public boolean addTab(LaunchNode root)
Creates a LaunchPanel with the specified root and adds it to a new tab.

Overrides:
addTab in class Launcher
Parameters:
root - the root node
Returns:
true if tab successfully added

removeSelectedTab

public boolean removeSelectedTab()
Removes the selected tab. Overrides Launcher method.

Overrides:
removeSelectedTab in class Launcher
Returns:
true if the tab was removed

saveChanges

protected boolean saveChanges(LaunchPanel tab)
Offers to save changes, if any, to the specified tab.

Parameters:
tab - the tab
Returns:
true unless cancelled by user

removeAllTabs

protected boolean removeAllTabs()
Removes all tabs and closes the tabset.

Overrides:
removeAllTabs in class Launcher
Returns:
true if all tabs were removed

saveAllChanges

protected boolean saveAllChanges()
Offers to save all changes, if any.

Returns:
true unless cancelled by user

refreshStringResources

protected void refreshStringResources()
Refreshes string resources.

Overrides:
refreshStringResources in class Launcher

refreshGUI

protected void refreshGUI()
Refreshes the GUI.

Overrides:
refreshGUI in class Launcher

createGUI

protected void createGUI(boolean splash)
Creates the GUI.

Overrides:
createGUI in class Launcher
Parameters:
splash - true to show the splash screen

setFontLevel

protected void setFontLevel(int level)
Sets the font level.

Overrides:
setFontLevel in class Launcher
Parameters:
level - the level

createActions

protected void createActions()
Creates the actions.


removeSelectedNode

public void removeSelectedNode()
Removes the selected node.


addChildToSelectedNode

public void addChildToSelectedNode(LaunchNode child)
Adds a child node to the selected node.

Parameters:
child - the child node to add

refreshClones

protected void refreshClones(LaunchNode node)
Replaces clones of a specified node with new clones.

Parameters:
node - the current version of the node to clone

replaceClones

protected void replaceClones(LaunchNode node,
                             java.util.Map<LaunchPanel,LaunchNode> clones)
Replaces nodes with clones of the specified node.

Parameters:
node - the current version of the node to clone
clones - the current clones to replace

getClones

protected java.util.Map<LaunchPanel,LaunchNode> getClones(LaunchNode node)
Returns clones containing a specified node in a tab-to-node map.

Parameters:
node - the node
Returns:
the tab-to-node map

showAboutDialog

protected void showAboutDialog()
Shows the about dialog.

Overrides:
showAboutDialog in class Launcher

getJARChooser

protected static javax.swing.JFileChooser getJARChooser()
Gets a file chooser for selecting jar files.

Returns:
the jar chooser

getHTMLChooser

protected static javax.swing.JFileChooser getHTMLChooser()
Gets a file chooser for selecting html files.

Returns:
the html chooser

getFileChooser

protected static javax.swing.JFileChooser getFileChooser()
Gets a file chooser.

Returns:
the file chooser

handleMousePressed

protected void handleMousePressed(java.awt.event.MouseEvent e,
                                  LaunchPanel tab)
Handles a mouse pressed event.

Overrides:
handleMousePressed in class Launcher
Parameters:
e - the mouse event
tab - the launch panel triggering the event

exit

protected void exit()
Overrides Launcher exit method.

Overrides:
exit in class Launcher

isTabSetWritable

protected boolean isTabSetWritable()
Returns true if tabset is writable.

Returns:
true if writable

isNodeWritable

protected boolean isNodeWritable(LaunchNode node)
Returns true if node is writable.

Parameters:
node - the node
Returns:
true if writable