pipe.gui
Class ModuleManager
java.lang.Object
|
+--pipe.gui.ModuleManager
- public class ModuleManager
- extends java.lang.Object
The ModuleManager class contains methods to create swing components to allow the user to load modules and execute methods within them.
To use, instantiate a ModuleManager object and use the methods to return the required components.
- Author:
- Camilla Clifford
Method Summary |
void |
addModuleToTree(javax.swing.tree.DefaultMutableTreeNode newNode)
Adds a new node to the Module subtree |
private java.util.Vector |
getModuleClassNames(java.io.File rootDir)
Finds all the fully qualified (ie: full package names) module classnames by recursively searching the rootDirectories |
private java.io.File |
getModuleDir()
Returns the root directory under which the modules will be found. |
javax.swing.JTree |
getModuleTree()
Method creates and returns a Module management tree. |
java.lang.String |
getPackageName(java.io.File dir,
java.lang.String filename)
Returns the package name based on the directory structure the class file sits in |
private javax.swing.JPopupMenu |
getPopup(java.awt.event.MouseEvent e)
|
boolean |
isModule(java.io.File dir,
java.lang.String filename)
Tests whether a file implements the module interface. |
private void |
maybeShowPopup(java.awt.event.MouseEvent e)
Displays the popup menu |
void |
removeModuleFromTree(javax.swing.tree.DefaultMutableTreeNode newNode)
Removes a node from the Module subtree |
Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait |
gui
public CreateGui gui
moduleTree
private javax.swing.JTree moduleTree
treeModel
private javax.swing.tree.DefaultTreeModel treeModel
load_modules
private javax.swing.tree.DefaultMutableTreeNode load_modules
loadNodeString
private java.lang.String loadNodeString
parent
java.awt.Component parent
ModuleManager
public ModuleManager(CreateGui _gui)
getModuleDir
private java.io.File getModuleDir()
- Returns the root directory under which the modules will be found.
At present this is the same directory in which all the classes are found - this could change.
isModule
public boolean isModule(java.io.File dir,
java.lang.String filename)
- Tests whether a file implements the module interface.
- Parameters:
dir
- Directory in which the file residesfilename
- The name of the file to be tested
getPackageName
public java.lang.String getPackageName(java.io.File dir,
java.lang.String filename)
- Returns the package name based on the directory structure the class file sits in
- Parameters:
dir
- The absolute path to the directory that the file sits infilename
- The name of the file
getModuleClassNames
private java.util.Vector getModuleClassNames(java.io.File rootDir)
- Finds all the fully qualified (ie: full package names) module classnames by recursively searching the rootDirectories
- Parameters:
rootDir
- The root directory to start searching from
getModuleTree
public javax.swing.JTree getModuleTree()
- Method creates and returns a Module management tree. This consists of two nodes, one resposible for listing all the available modules from the module directory, and another for admin options such as list refreshing. Each node of the tree has it's own user object, for class nodes this will be ModuleClass, for method nodes ModuleMethod, and another one yet to be implemented for other options. When the user clicks on a method node the method is invoked.
addModuleToTree
public void addModuleToTree(javax.swing.tree.DefaultMutableTreeNode newNode)
- Adds a new node to the Module subtree
- Parameters:
newNode
- The new node representing a new module.
removeModuleFromTree
public void removeModuleFromTree(javax.swing.tree.DefaultMutableTreeNode newNode)
- Removes a node from the Module subtree
- Parameters:
newNode
- The node to be removed.
maybeShowPopup
private void maybeShowPopup(java.awt.event.MouseEvent e)
- Displays the popup menu
getPopup
private javax.swing.JPopupMenu getPopup(java.awt.event.MouseEvent e)