EASE.Sensing.Specification
Class Specification

java.lang.Object
  |
  +--EASE.Sensing.Specification.Specification

public class Specification
extends java.lang.Object

This is the main class for the condition specification subsystem.

This class works together extensively with the class SpecExport to provide the core functionality of the condition subsystem.

It is intended that only one instance of this class is created (as a static variable in SpecExport).

The seperation between Specification and SpecExport should be things that are not needed externally are here and visa versa.


Inner Class Summary
(package private)  class Specification.ActionCoupler
          Takes either an ActionEvent or a list selection event and sends it to an action.
(package private)  class Specification.WindowCloser
          Either get rid of the window or just hide it when the close button is pressed, depends on the value of exit (true for dispose).
 
Field Summary
private  CellStore allCells
          Storage system for all the cells.
 javax.swing.JTree cellTree
           
private  javax.swing.tree.DefaultTreeModel cellTreeModel
           
private  javax.swing.tree.DefaultMutableTreeNode cellTreeRootNode
           
 javax.swing.JPanel container
           
 javax.swing.JComponent current
           
private  Debugger debugger
           
static java.lang.String DEFAULT_FILE_NAME
          Name of the Cell Tree branch holding environment Cells.
 DeleteSimpleAction deleteAction
           
 EditItemAction editItemAction
           
private  javax.swing.JMenu editM
           
 javax.swing.JPanel emptyPane
           
(package private) static EnvironmentSpecification env
           
private  javax.swing.tree.DefaultMutableTreeNode exportRootNode
           
private  javax.swing.JMenu fileM
           
 javax.swing.JFrame frame
           
private  javax.swing.tree.DefaultMutableTreeNode internalRootNode
           
 javax.swing.JPanel listPane
           
private  javax.swing.JScrollPane listScrollPane
           
 javax.swing.JSplitPane mainPane
           
 javax.swing.JScrollPane mainScrollPane
           
private  javax.swing.JMenuBar menuBar
           
 ActivationAction newActivationAction
           
 NewConstant newConstantAction
           
 NewExpressionAction newExpressionAction
           
 NewIfAction newIfAction
           
private  javax.swing.JMenu newM
           
 SatisfactionAction newSatisfactionAction
           
 NewTransitionConditionAction newTransitionConditionAction
           
 NewUnaryAction newUnaryAction
           
private  OpenFileAction openFileAction
           
private  QuitAction quitAction
           
private  SaveAction saveAction
           
 java.util.Vector sensors
           
private  SpecExport spec
           
private  TreeKeyHandler treeHandler
           
private  Specification.WindowCloser windowCloser
           
 
Constructor Summary
Specification(boolean display, java.lang.String envClass)
          The boolean argument gives the oppurtunity to turn the condition specification system on or off.
Specification(boolean display, java.lang.String envClass, boolean quitable)
          This constructor can be used by the agent specification system.
 
Method Summary
(package private)  void ()
           
(package private)  void ()
           
private  void addCellsToFormat(javax.swing.tree.DefaultMutableTreeNode node, FileFormat format)
          This function traverses the branch for a single file, adding all the cells that should be added to the given FileFormat object
 void addCellsToModels(java.io.File file, FileFormat input)
          Function that adds new cells to the Cell Tree
private  void addCellToStore(Cell c)
          Adds a Cell to the hashtable containing all the Cells.
 void addCellToTree(Cell c)
          Adds a single cell to the tree
private  void addDefaultCellsToModels()
          Add Cells that come with the Environment to the CellTree
private  void addToTree(Cell c)
          Adds a cell to a tree.
private  void addToTree(javax.swing.tree.DefaultTreeModel dtm, java.util.Vector v, javax.swing.tree.DefaultMutableTreeNode root)
          Adds a vector of cells to the model.
 void addWindowListener(java.awt.event.WindowListener w)
           
private  java.util.Vector checkNotNull(java.util.Vector v)
           
 void display()
           
 Cell getCell(CellReference cr)
          Gets a cell from a reference from the Cell Store.
 Cell getCellFromStore(java.lang.String name)
           
 java.util.Vector getCellsByCellType(java.lang.Class c)
           
 java.util.Vector getCellsByReturnType(int type)
           
 java.util.Vector getFileFormats()
          Get all the FileFormat objects for saving
This traverses the entire Cell tree to make up a Vector of File Format objects to be saved.
private  javax.swing.tree.DefaultMutableTreeNode getInsertPoint(Cell c, javax.swing.tree.DefaultMutableTreeNode root, javax.swing.tree.DefaultTreeModel dtm)
          Expects the tree path to be the path where the Cell should be attached, i.e.
 NoEditDisplay getNoEditDisplay()
          Get a no editable display.
 void hide()
           
static void main(java.lang.String[] args)
          Start up -path command line gives the list of % separated directories in which to look for condition files.
 void openFile(java.lang.String name)
          Called to open a file
private  void removeCellFromStore(Cell c)
          Removes a Cell from the hashtable containing all the Cells.
 void removeCellFromTree(Cell c)
          Removes a single cell from the cell tree
 void removeWindowListener(java.awt.event.WindowListener w)
           
 void setAllFileNames()
          Set the filenames for all the cells
The filenames are set so that an agent specification can automatically load up the appropriate condition files at runtime.
 void setAllPaths()
          Sets the tree paths for all the cells
Needed so that a correct tree can be recreated again later
 void setPath(javax.swing.tree.DefaultMutableTreeNode node)
          Sets the Tree path for a particular node Top part of the tree is excluded from the path name.
private  void setPaths(javax.swing.tree.DefaultMutableTreeNode root)
          Helper function for setAllPaths Excludes the top levels of hierachy and doesn't touch environment cells.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

debugger

private Debugger debugger

env

static EnvironmentSpecification env

sensors

public java.util.Vector sensors

spec

private SpecExport spec

newConstantAction

public NewConstant newConstantAction

newExpressionAction

public NewExpressionAction newExpressionAction

newUnaryAction

public NewUnaryAction newUnaryAction

newIfAction

public NewIfAction newIfAction

newSatisfactionAction

public SatisfactionAction newSatisfactionAction

newActivationAction

public ActivationAction newActivationAction

newTransitionConditionAction

public NewTransitionConditionAction newTransitionConditionAction

editItemAction

public EditItemAction editItemAction

deleteAction

public DeleteSimpleAction deleteAction

openFileAction

private OpenFileAction openFileAction

saveAction

private SaveAction saveAction

quitAction

private QuitAction quitAction

listScrollPane

private javax.swing.JScrollPane listScrollPane

internalRootNode

private javax.swing.tree.DefaultMutableTreeNode internalRootNode

exportRootNode

private javax.swing.tree.DefaultMutableTreeNode exportRootNode

cellTreeRootNode

private javax.swing.tree.DefaultMutableTreeNode cellTreeRootNode

cellTreeModel

private javax.swing.tree.DefaultTreeModel cellTreeModel

cellTree

public javax.swing.JTree cellTree

windowCloser

private Specification.WindowCloser windowCloser

emptyPane

public javax.swing.JPanel emptyPane

listPane

public javax.swing.JPanel listPane

mainPane

public javax.swing.JSplitPane mainPane

container

public javax.swing.JPanel container

mainScrollPane

public javax.swing.JScrollPane mainScrollPane

current

public javax.swing.JComponent current

menuBar

private javax.swing.JMenuBar menuBar

fileM

private javax.swing.JMenu fileM

newM

private javax.swing.JMenu newM

editM

private javax.swing.JMenu editM

frame

public javax.swing.JFrame frame

treeHandler

private TreeKeyHandler treeHandler

allCells

private CellStore allCells
Storage system for all the cells.


DEFAULT_FILE_NAME

public static final java.lang.String DEFAULT_FILE_NAME
Name of the Cell Tree branch holding environment Cells.

Constructor Detail

Specification

public Specification(boolean display,
                     java.lang.String envClass)
The boolean argument gives the oppurtunity to turn the condition specification system on or off.


Specification

public Specification(boolean display,
                     java.lang.String envClass,
                     boolean quitable)
This constructor can be used by the agent specification system. when quit the window will hide rather than killing the JVM.
Method Detail

main

public static void main(java.lang.String[] args)
Start up

-path command line gives the list of % separated directories in which to look for condition files.

-env name Tells EASE to use environment name. Default is TACSIEnvironment


void ()
Overrides:
in class java.lang.Object

void ()
Overrides:
in class java.lang.Object

addWindowListener

public void addWindowListener(java.awt.event.WindowListener w)

removeWindowListener

public void removeWindowListener(java.awt.event.WindowListener w)

display

public void display()

hide

public void hide()

getNoEditDisplay

public NoEditDisplay getNoEditDisplay()
Get a no editable display.

A new one is created every request so that different states in agent specification can have their own.


checkNotNull

private java.util.Vector checkNotNull(java.util.Vector v)

addCellsToModels

public void addCellsToModels(java.io.File file,
                             FileFormat input)
Function that adds new cells to the Cell Tree

addCellToTree

public void addCellToTree(Cell c)
Adds a single cell to the tree


removeCellFromTree

public void removeCellFromTree(Cell c)
Removes a single cell from the cell tree


getCell

public Cell getCell(CellReference cr)
Gets a cell from a reference from the Cell Store.


getCellFromStore

public Cell getCellFromStore(java.lang.String name)

getCellsByCellType

public java.util.Vector getCellsByCellType(java.lang.Class c)

getCellsByReturnType

public java.util.Vector getCellsByReturnType(int type)

addCellToStore

private void addCellToStore(Cell c)
Adds a Cell to the hashtable containing all the Cells.

Stores the Cell by its fullName.


removeCellFromStore

private void removeCellFromStore(Cell c)
Removes a Cell from the hashtable containing all the Cells.


setAllPaths

public void setAllPaths()
Sets the tree paths for all the cells
Needed so that a correct tree can be recreated again later


setPath

public void setPath(javax.swing.tree.DefaultMutableTreeNode node)
Sets the Tree path for a particular node

Top part of the tree is excluded from the path name.


getInsertPoint

private javax.swing.tree.DefaultMutableTreeNode getInsertPoint(Cell c,
                                                               javax.swing.tree.DefaultMutableTreeNode root,
                                                               javax.swing.tree.DefaultTreeModel dtm)
Expects the tree path to be the path where the Cell should be attached, i.e. is does not include the path for the Cell itself. Seems to be some problems with Environment cells.

addDefaultCellsToModels

private void addDefaultCellsToModels()
Add Cells that come with the Environment to the CellTree


addToTree

private void addToTree(javax.swing.tree.DefaultTreeModel dtm,
                       java.util.Vector v,
                       javax.swing.tree.DefaultMutableTreeNode root)
Adds a vector of cells to the model.

Validate as we go along.


addToTree

private void addToTree(Cell c)
Adds a cell to a tree.

If the cell has no filename then stuck into root.


setPaths

private void setPaths(javax.swing.tree.DefaultMutableTreeNode root)
Helper function for setAllPaths

Excludes the top levels of hierachy and doesn't touch environment cells.


openFile

public void openFile(java.lang.String name)
Called to open a file

setAllFileNames

public void setAllFileNames()
Set the filenames for all the cells
The filenames are set so that an agent specification can automatically load up the appropriate condition files at runtime.


getFileFormats

public java.util.Vector getFileFormats()
Get all the FileFormat objects for saving
This traverses the entire Cell tree to make up a Vector of File Format objects to be saved.
The files are found by doing a breadth first traversal of the internal root node until no more files are found.
For each file / node the corresponding node in the export tree is found, i.e. the files information in the export tree.
Both nodes are then traversed to be added to the FileFormat.

addCellsToFormat

private void addCellsToFormat(javax.swing.tree.DefaultMutableTreeNode node,
                              FileFormat format)
This function traverses the branch for a single file, adding all the cells that should be added to the given FileFormat object