Ejemplo n.º 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++;
   }
 }
Ejemplo n.º 2
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. */
  }