Example #1
0
  /**
   * adds the <code>variable</code> at <code>position</code>
   *
   * @param variable the variable to add
   * @param position the position at which to add the variable
   */
  public void add(Variable<? extends TrickViewFluent> variable, Position position) {
    if (!variablesHashSet.contains(variable)) {
      int index = 0;
      int selectedRow = getSelectedRow();

      switch (position) {
        case Top:
          break;
        case Before:
          if (selectedRow != -1) {
            index = convertRowIndexToModel(selectedRow);
          }
          break;
        case After:
          if (selectedRow == -1) {
            index = model.getRowCount();
          } else {
            index = convertRowIndexToModel(selectedRow) + 1;
          }
          break;
        case Bottom:
          index = model.getRowCount();
          break;
      }

      variables.add(index, variable);
      variablesHashSet.add(variable);
      model.fireTableRowsInserted(index, index);
    }
  }
Example #2
0
 /** removes all variables */
 public void clear() {
   int rowCount = model.getRowCount();
   if (rowCount > 0) {
     variablesHashSet.clear();
     variables.clear();
     model.fireTableRowsDeleted(0, rowCount - 1);
   }
 }
Example #3
0
 /** updates all rows */
 public void update() {
   int rowCount = model.getRowCount();
   if (rowCount > 0) {
     model.fireTableRowsUpdated(0, rowCount - 1);
   }
 }
Example #4
0
 /**
  * removes the variable at index <code>i</code>
  *
  * @param i the index
  * @return the removed variable, or <code>null</code> if none exists
  */
 public Variable<? extends TrickViewFluent> removeVariable(int i) {
   variablesHashSet.remove(variables.get(i));
   Variable<? extends TrickViewFluent> variable = variables.remove(i);
   model.fireTableRowsDeleted(i, i);
   return variable;
 }