Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

abbot.editor
Class ScriptModel  view ScriptModel download ScriptModel.java

java.lang.Object
  extended byjavax.swing.table.AbstractTableModel
      extended byabbot.editor.ScriptModel
All Implemented Interfaces:
abbot.editor.i18n.Resources, java.io.Serializable, abbot.editor.editors.StepChangeListener, abbot.script.StepListener, abbot.editor.i18n.Strings, javax.swing.table.TableModel

class ScriptModel
extends javax.swing.table.AbstractTableModel
implements abbot.script.StepListener, abbot.editor.editors.StepChangeListener, abbot.editor.i18n.Strings

Formats a Script for display in a table. Keeps track of "open" nodes to create a tree-like display NOTE: this is a brute-force implementation with no attempts at optimization. But it's a very simple tree+table implementation.


Nested Class Summary
 class ScriptModel.Entry
          Encapsulate information we need to manipulate the row.
 
Nested classes inherited from class abbot.editor.i18n.Resources
abbot.editor.i18n.Resources.ResourceLoader
 
Field Summary
private  java.util.HashSet openSequences
           
private  java.util.ArrayList rows
           
private  abbot.script.Script script
           
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Fields inherited from interface abbot.editor.i18n.Strings
FMT_AssertProperty, FMT_AssertPropertyTip, FMT_ComponentReference, FMT_ComponentReferenceX, FMT_Dialog, FMT_EditingScript, FMT_Error, FMT_Failure, FMT_FixtureDuplicated, FMT_InStep, FMT_RecorderCanceledX, FMT_Running, FMT_RunningStep, FMT_Saved, FMT_Saving, FMT_ScriptRename, FMT_ScriptSaved, FMT_Title, FMT_Tooltip, FMT_WaitProperty, FMT_Warning
 
Fields inherited from interface abbot.editor.i18n.Resources
bundle, STRINGS_BUNDLE
 
Constructor Summary
(package private) ScriptModel()
           
 
Method Summary
private  void addSubRows(abbot.script.Sequence seq, int level)
          Add the contents of the given sequence, if it's "open".
 boolean canMove(int row, boolean up)
           
 void doLayout()
          Scan the layout to initialize the row entries.
private  void fireLayoutChange()
           
 java.lang.Class getColumnClass(int col)
          Returns the Class for all Object instances in the specified column.
 int getColumnCount()
          Returns the number of columns in the model.
 java.lang.String getColumnName(int col)
          Returns the name of the specified column.
 ScriptModel.Entry getEntry(int row)
           
private  ScriptModel.Entry getNextNonchildEntry(int row)
          Return the next visible row (as an Entry) that is not a child of the given entry.
 int getRowCount()
          Returns the number of rows in the model.
 int getRowOf(abbot.script.Step step)
          Returns -1 if the step is not found.
 abbot.script.Script getScript()
           
 abbot.script.Step getStepAt(int row)
           
 java.lang.Object getValueAt(int row, int column)
          Returns the entry object at the given row.
 void insertStep(abbot.script.Step step, int row, boolean after)
          Insert the given step at the given row, either before or after the step currently existing at that row.
 boolean isOpen(int row)
          Return whether the given row is "open".
 void moveRowDown(int row)
          Move the step at the current row past its next sibling.
 void moveRowUp(int row)
          Move row up one.
 void setScript(abbot.script.Script script)
          Set the script to display.
 void setValueAt(java.lang.Object value, int row, int col)
          Assumes value is XML for a script step.
 void stateChanged(abbot.script.StepEvent ev)
           
 void stepChanged(abbot.script.Step step)
           
 void toggle(int row)
          Toggle the open state of the node, if it's a sequence.
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

openSequences

private java.util.HashSet openSequences

script

private abbot.script.Script script

rows

private java.util.ArrayList rows
Constructor Detail

ScriptModel

ScriptModel()
Method Detail

addSubRows

private void addSubRows(abbot.script.Sequence seq,
                        int level)
Add the contents of the given sequence, if it's "open".


insertStep

public void insertStep(abbot.script.Step step,
                       int row,
                       boolean after)
Insert the given step at the given row, either before or after the step currently existing at that row. If placed after an open sequence, place within that sequence.


moveRowUp

public void moveRowUp(int row)
Move row up one. If previous sibling is a sequence AND open, move into that sequence. If first element in a sequence, move prior to the sequence (changes parent). If first step in script, has no effect.


moveRowDown

public void moveRowDown(int row)
Move the step at the current row past its next sibling. If next sibling is a sequence AND open, move into that sequence. If last element in a sequence, move after the sequence (changes parent). If last step in script, has no effect.


fireLayoutChange

private void fireLayoutChange()

doLayout

public void doLayout()
Scan the layout to initialize the row entries.


getEntry

public ScriptModel.Entry getEntry(int row)

getRowOf

public int getRowOf(abbot.script.Step step)
Returns -1 if the step is not found.


isOpen

public boolean isOpen(int row)
Return whether the given row is "open".


toggle

public void toggle(int row)
Toggle the open state of the node, if it's a sequence.


setScript

public void setScript(abbot.script.Script script)
Set the script to display. Don't allow any model accesses until this method has completed.


getRowCount

public int getRowCount()
Description copied from interface: javax.swing.table.TableModel
Returns the number of rows in the model.

Specified by:
getRowCount in interface javax.swing.table.TableModel

getColumnCount

public int getColumnCount()
Description copied from interface: javax.swing.table.TableModel
Returns the number of columns in the model.

Specified by:
getColumnCount in interface javax.swing.table.TableModel

getStepAt

public abbot.script.Step getStepAt(int row)

getValueAt

public java.lang.Object getValueAt(int row,
                                   int column)
Returns the entry object at the given row.

Specified by:
getValueAt in interface javax.swing.table.TableModel

setValueAt

public void setValueAt(java.lang.Object value,
                       int row,
                       int col)
Assumes value is XML for a script step.

Specified by:
setValueAt in interface javax.swing.table.TableModel

getColumnName

public java.lang.String getColumnName(int col)
Description copied from class: javax.swing.table.AbstractTableModel
Returns the name of the specified column. This method generates default names in a sequence (starting with column 0): A, B, C, ..., Z, AA, AB, AC, ..., AZ, BA, BB, BC, and so on. Subclasses may override this method to allow column names to be specified on some other basis.

Specified by:
getColumnName in interface javax.swing.table.TableModel

getColumnClass

public java.lang.Class getColumnClass(int col)
Description copied from class: javax.swing.table.AbstractTableModel
Returns the Class for all Object instances in the specified column.

Specified by:
getColumnClass in interface javax.swing.table.TableModel

getScript

public abbot.script.Script getScript()

stateChanged

public void stateChanged(abbot.script.StepEvent ev)
Specified by:
stateChanged in interface abbot.script.StepListener

stepChanged

public void stepChanged(abbot.script.Step step)
Specified by:
stepChanged in interface abbot.editor.editors.StepChangeListener

canMove

public boolean canMove(int row,
                       boolean up)

getNextNonchildEntry

private ScriptModel.Entry getNextNonchildEntry(int row)
Return the next visible row (as an Entry) that is not a child of the given entry.