abbot.editor
Class ScriptModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by abbot.editor.ScriptModel
All Implemented Interfaces:
Serializable, TableModel

 class ScriptModel
extends AbstractTableModel

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.


Field Summary
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
ScriptModel()
           
ScriptModel(Script script)
           
 
Method Summary
 Class getColumnClass(int col)
           
 int getColumnCount()
           
 String getColumnName(int col)
           
 int getNestingDepthAt(int row)
           
 Sequence getParent(Step step)
          Return the parent sequence of the given step.
 int getRowCount()
           
 int getRowOf(Step step)
          Returns -1 if the step is not found or not visible.
 Script getScript()
           
 Script getScriptOf(int row)
           
 Step getStepAt(int row)
           
 Object getValueAt(int row, int col)
          Returns the step at the given row.
 void insertStep(Sequence parent, Step step, int index)
          Insert the given step at the given index in its parent.
 void insertSteps(Sequence parent, List steps, int index)
          Insert the steps into the given sequence at the given index.
 boolean isOpen(int row)
          Return whether the given row is "open".
 boolean isOpen(Step step)
           
 void moveSteps(Sequence parent, List steps, int index)
          Move the given steps and all between them to the new location.
 void removeStep(Step step)
          Remove the given step from the script.
 void removeSteps(List steps)
          Remove all the given steps.
 void setScript(Script script)
          Set the script to display.
 void setValueAt(Object value, int row, int col)
          Assumes value is XML for a script 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
 

Constructor Detail

ScriptModel

public ScriptModel()

ScriptModel

public ScriptModel(Script script)
Method Detail

removeStep

public void removeStep(Step step)
Remove the given step from the script.


removeSteps

public void removeSteps(List steps)
Remove all the given steps. If any are not found, an exception is thrown before any changes are made.


insertStep

public void insertStep(Sequence parent,
                       Step step,
                       int index)
Insert the given step at the given index in its parent.


insertSteps

public void insertSteps(Sequence parent,
                        List steps,
                        int index)
Insert the steps into the given sequence at the given index.


getRowOf

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


isOpen

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


isOpen

public boolean isOpen(Step step)

toggle

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


setScript

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


getRowCount

public int getRowCount()

getColumnCount

public int getColumnCount()

getStepAt

public Step getStepAt(int row)

getValueAt

public Object getValueAt(int row,
                         int col)
Returns the step at the given row.


setValueAt

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

Specified by:
setValueAt in interface TableModel
Overrides:
setValueAt in class AbstractTableModel

getColumnName

public String getColumnName(int col)
Specified by:
getColumnName in interface TableModel
Overrides:
getColumnName in class AbstractTableModel

getColumnClass

public Class getColumnClass(int col)
Specified by:
getColumnClass in interface TableModel
Overrides:
getColumnClass in class AbstractTableModel

getScript

public Script getScript()

getNestingDepthAt

public int getNestingDepthAt(int row)

getScriptOf

public Script getScriptOf(int row)

getParent

public Sequence getParent(Step step)
Return the parent sequence of the given step.


moveSteps

public void moveSteps(Sequence parent,
                      List steps,
                      int index)
Move the given steps and all between them to the new location. If the steps are being moved later in the same sequence, the index represents the target index before the move.



Copyright © 2002-2008 Timothy Wall. All Rights Reserved.
Abbot is hosted on

SourceForge