Пример #1
0
 private void transferObjectsOfType(
     int mssqlType, DatabaseObjectInfoTableModel fromModel, DatabaseObjectInfoTableModel toModel) {
   int i = 0;
   while (i < fromModel.getRowCount()) {
     IDatabaseObjectInfo oi = (IDatabaseObjectInfo) fromModel.getValueAt(i, 0);
     if (mssqlType == 0 || MssqlIntrospector.getObjectInfoType(oi) == mssqlType) {
       if (fromModel.removeElement(oi)) toModel.addElement(oi);
       // don't increment i if you're removing something; otherwise, you'd skip the next item.
     } else i++;
   }
 }
Пример #2
0
  public void preselectObjects(IDatabaseObjectInfo[] objs) {
    /* this works because all the IDatabaseObjectInfo objects come from the same source, so
     * their references are equal. */

    DatabaseObjectInfoTableModel fromModel =
        (DatabaseObjectInfoTableModel) _availableTable.getModel();
    DatabaseObjectInfoTableModel toModel = (DatabaseObjectInfoTableModel) _selectedTable.getModel();

    for (int i = 0; i < objs.length; i++) {
      if (fromModel.removeElement(objs[i])) toModel.addElement(objs[i]);
    }
  }
Пример #3
0
  private void transferSelectedItems(JTable fromTable, JTable toTable) {
    DatabaseObjectInfoTableModel fromModel = (DatabaseObjectInfoTableModel) fromTable.getModel();
    DatabaseObjectInfoTableModel toModel = (DatabaseObjectInfoTableModel) toTable.getModel();
    int[] selectedRows = fromTable.getSelectedRows();

    /* we must iterate through this in descending order to avoid removing, say, item #2, making
     * item #4 into item #3, inadvertently removing item #5. */
    for (int i = selectedRows.length - 1; i >= 0; i--) {
      IDatabaseObjectInfo oi = (IDatabaseObjectInfo) fromModel.getValueAt(selectedRows[i], 0);
      if (fromModel.removeElement(oi)) toModel.addElement(oi);
    }

    /* TODO: sort the list. */
  }