mesquite.lib
Class Snapshot

java.lang.Object
  extended bymesquite.lib.Snapshot

public class Snapshot
extends java.lang.Object

Used by modules (and sometimes other Commandables) to return commands that would restore the module to its current state on file read-in or in other contexts (e.g., cloning a window). On saving a file, a module (currently Manage Mesquite Blocks) recurses through the employee tree, collecting their Snapshots, and using them to compose a Mesquite block for a NEXUS file that will return the active modules and windows to their current state.


Constructor Summary
Snapshot()
           
 
Method Summary
 void addLine(java.lang.String commandLine)
          Add the given command to the list of commands.
 void addLine(java.lang.String command, MesquiteModule module)
          Add the given command to the list of commands.
 void addLineIfAnythingToTell(java.lang.String command, MesquiteModule module)
          Add command if there is any snapshot from module
 void dump()
          Dumps the snapshot to the system console
 java.lang.String getCommand(int index)
          Returns the given command from the list of commands.
 boolean getConditional(int index)
          Returns whether the line is conditional on anything to tell
static java.lang.String getIDSnapshotCommands(FileElementManager module, MesquiteFile file, java.lang.String spacer)
           
 java.lang.String getLine(int index)
          Returns the given command from the list of commands.
 MesquiteModule getModule(int index)
          Returns the associated module from the list of commands.
 int getNumLines()
          Returns the number of lines in the snapshot.
static java.lang.String getSnapshotCommands(MesquiteModule module, MesquiteFile file, java.lang.String spacer)
          accumulate snapshot (e.g., as for MESQUITE block of NEXUS file) beginning at the passed module, as if writing for the file indicated.
 void incorporate(Snapshot snap, boolean addTab)
          Incorporates given Snapshot into current ones, pulling in lines and modules
 boolean modulePresent(MesquiteModule module)
          Returns whether the module is associated with some command.
 void suppressCommandsToEmployee(MesquiteModule module)
          suppress commands to module; used by module that doesn't want to rehire employee
 java.lang.String toString(MesquiteFile file, java.lang.String spacer)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Snapshot

public Snapshot()
Method Detail

addLine

public void addLine(java.lang.String command,
                    MesquiteModule module)
Add the given command to the list of commands. This command should be one that hires an employee, and the current module that would represent that hiring should be passed. The command passed is only the first token (command name), not the entire command. Thus addHiringLine("setTreeDrawer", drawTreeTask) would compose a command of the sort "setTreeDrawer 'Arc Tree';".

This allows the module saving the Nexus block to insert immediately afterward the tell It... endTell block of commands that refer to that employee. (this is important to avoid ambiguity of a getEmployee command that can result if more than one employee has the same name. By placing the tell block immediately afterward, that hired employee will get the commands appropriate to just it.


addLineIfAnythingToTell

public void addLineIfAnythingToTell(java.lang.String command,
                                    MesquiteModule module)
Add command if there is any snapshot from module


suppressCommandsToEmployee

public void suppressCommandsToEmployee(MesquiteModule module)
suppress commands to module; used by module that doesn't want to rehire employee


addLine

public void addLine(java.lang.String commandLine)
Add the given command to the list of commands. The command should be the entire command line EXCEPT the semicolon.


incorporate

public void incorporate(Snapshot snap,
                        boolean addTab)
Incorporates given Snapshot into current ones, pulling in lines and modules


getLine

public java.lang.String getLine(int index)
Returns the given command from the list of commands. The line returned is the fully formatted command


getCommand

public java.lang.String getCommand(int index)
Returns the given command from the list of commands.


getModule

public MesquiteModule getModule(int index)
Returns the associated module from the list of commands.


modulePresent

public boolean modulePresent(MesquiteModule module)
Returns whether the module is associated with some command.


getConditional

public boolean getConditional(int index)
Returns whether the line is conditional on anything to tell


getNumLines

public int getNumLines()
Returns the number of lines in the snapshot.


dump

public void dump()
Dumps the snapshot to the system console


toString

public java.lang.String toString(MesquiteFile file,
                                 java.lang.String spacer)

getIDSnapshotCommands

public static java.lang.String getIDSnapshotCommands(FileElementManager module,
                                                     MesquiteFile file,
                                                     java.lang.String spacer)

getSnapshotCommands

public static java.lang.String getSnapshotCommands(MesquiteModule module,
                                                   MesquiteFile file,
                                                   java.lang.String spacer)
accumulate snapshot (e.g., as for MESQUITE block of NEXUS file) beginning at the passed module, as if writing for the file indicated. The spacer string is passed to prefix lines with tabs to give an indented organization. A problem to be solved are dependencies among modules (especially TreeContexts). If a snapshot creating a module A needed by module B is written after the snapshot creating module B, then module B on starting up will not find the needed module A.