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++;
   }
 }
  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]);
    }
  }
  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. */
  }
  private void populateAvailableTable(JTable table) {
    DatabaseObjectInfoTableModel model = (DatabaseObjectInfoTableModel) table.getModel();

    try {
      String catalog = _session.getSQLConnection().getCatalog();
      SQLDatabaseMetaData metaData = _session.getSQLConnection().getSQLMetaData();

      int i;

      /* add the tables. */
      ITableInfo[] tables =
          _session
              .getSchemaInfo()
              .getITableInfos(catalog, null, new ObjFilterMatcher(), new String[] {"TABLE"});
      for (i = 0; i < tables.length; i++) model.addElement(tables[i]);

      /* add the views. */
      ITableInfo[] views =
          _session
              .getSchemaInfo()
              .getITableInfos(catalog, null, new ObjFilterMatcher(), new String[] {"VIEW"});
      for (i = 0; i < views.length; i++) model.addElement(views[i]);

      /* add the procedures. */
      // IProcedureInfo[] procs = metaData.getProcedures(catalog,null,null);
      IProcedureInfo[] procs =
          _session.getSchemaInfo().getStoredProceduresInfos(catalog, null, new ObjFilterMatcher());
      for (i = 0; i < procs.length; i++)
        if (!procs[i].getSimpleName().startsWith("dt_")) model.addElement(procs[i]);

      /* add the UDTs. */
      IUDTInfo[] udts = metaData.getUDTs(catalog, null, null, null);
      for (i = 0; i < udts.length; i++) model.addElement(udts[i]);
    } catch (SQLException ex) {
      _session.getApplication().showErrorDialog(ex.getMessage(), ex);
    }
  }