Search in sources :

Example 16 with TableDetailInfo

use of com.cubrid.common.core.common.model.TableDetailInfo in project cubrid-manager by CUBRID.

the class TableSchemaCompareExtraColumnLabelProvider method getText.

public String getText(Object element) {
    TableSchemaCompareModel cm = (TableSchemaCompareModel) element;
    TableDetailInfo tableInfo = null;
    if (focus == 0) {
        if (cm.getCompareStatus() != TableSchemaCompareModel.SCHEMA_SMISS) {
            tableInfo = cm.getSourceTableDetailInfo();
        }
    } else if (focus == 1) {
        if (cm.getCompareStatus() != TableSchemaCompareModel.SCHEMA_TMISS) {
            tableInfo = cm.getTargetTableDetailInfo();
            if (tableInfo == null) {
                TableSchema tableSchema = (TableSchema) cm.getRight();
                SchemaInfo schemaInfo = cm.getTargetSchemas().get(tableSchema.getName());
                int columnCount = schemaInfo.getAttributes().size();
                int idxCount = 0;
                int pk = 0;
                for (Constraint constraint : schemaInfo.getConstraints()) {
                    if (constraint.getType().equals(ConstraintType.PRIMARYKEY.getText())) {
                        pk++;
                        continue;
                    } else {
                        idxCount++;
                    }
                }
                tableInfo = new TableDetailInfo();
                tableInfo.setPkCount(pk);
                tableInfo.setColumnsCount(columnCount);
                tableInfo.setIndexCount(idxCount);
            }
        }
    }
    if (type == RECORDS_COUNT) {
        long tableRecordCount = 0;
        if (tableInfo != null) {
            tableRecordCount = tableInfo.getRecordsCount();
        }
        if (focus == 0) {
            cm.setSourceRecords(tableRecordCount);
        } else if (focus == 1) {
            cm.setTargetRecords(tableRecordCount);
        }
        if (tableRecordCount < 0) {
            return Messages.notCount;
        }
        return String.valueOf(tableRecordCount);
    } else if (type == ATTRIBUTES_COUNT) {
        int attributeCount = 0;
        if (tableInfo != null) {
            attributeCount = tableInfo.getColumnsCount();
        }
        return String.valueOf(attributeCount);
    } else if (type == INDEX_COUNT) {
        int indexCount = 0;
        if (tableInfo != null) {
            indexCount = tableInfo.getIndexCount();
        }
        return String.valueOf(indexCount);
    } else if (type == PK_STATUS) {
        int pkCount = 0;
        if (tableInfo != null) {
            pkCount = tableInfo.getPkCount();
        }
        if (pkCount > 0) {
            return "Y";
        }
        return "";
    }
    return "";
}
Also used : TableSchemaCompareModel(com.cubrid.common.ui.compare.schema.model.TableSchemaCompareModel) TableSchema(com.cubrid.common.ui.compare.schema.model.TableSchema) Constraint(com.cubrid.common.core.common.model.Constraint) TableDetailInfo(com.cubrid.common.core.common.model.TableDetailInfo) Constraint(com.cubrid.common.core.common.model.Constraint) SchemaInfo(com.cubrid.common.core.common.model.SchemaInfo)

Example 17 with TableDetailInfo

use of com.cubrid.common.core.common.model.TableDetailInfo in project cubrid-manager by CUBRID.

the class ColumnViewerSorter method nodeChanged.

/**
	 * Perform node change event
	 */
public void nodeChanged(CubridNodeChangedEvent event) {
    if (CubridNodeChangedEventType.SERVER_DISCONNECTED.equals(event.getType())) {
        close(event, database.getServer());
    }
    if (CubridNodeChangedEventType.DATABASE_LOGOUT.equals(event.getType()) || CubridNodeChangedEventType.DATABASE_STOP.equals(event.getType())) {
        close(event, database);
    }
    ICubridNode node = event.getCubridNode();
    if (NodeType.USER_TABLE.equals(node.getType()) || NodeType.USER_PARTITIONED_TABLE.equals(node.getType())) {
        if (CubridNodeChangedEventType.NODE_ADD.equals(event.getType()) || CubridNodeChangedEventType.NODE_REFRESH.equals(event.getType())) {
            refresh(node.getName());
        }
        if (CubridNodeChangedEventType.NODE_REMOVE.equals(event.getType())) {
            TableDetailInfo tableInfo = findTableInfo(node.getName());
            if (tableInfo != null) {
                tableList.remove(tableInfo);
                tableListView.refresh();
                fireTableDetailChanged(tableInfo.getTableName());
            }
        }
        if (CubridNodeChangedEventType.NODE_REFRESH.equals(event.getType())) {
            refresh(node.getName());
            fireTableDetailChanged(node.getName());
        }
    }
}
Also used : TableDetailInfo(com.cubrid.common.core.common.model.TableDetailInfo) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode)

Example 18 with TableDetailInfo

use of com.cubrid.common.core.common.model.TableDetailInfo in project cubrid-manager by CUBRID.

the class ColumnViewerSorter method copySelectedTableNamesToClipboard.

public void copySelectedTableNamesToClipboard() {
    List<String> nameList = new ArrayList<String>();
    List<Integer> selectIndex = new ArrayList<Integer>();
    for (int i = 0; i < tableListView.getTable().getSelectionIndices().length; i++) {
        selectIndex.add(tableListView.getTable().getSelectionIndices()[i]);
    }
    for (int i = 0; i < selectIndex.size(); i++) {
        TableDetailInfo tableInfo = tableList.get(selectIndex.get(i));
        if (tableInfo == null) {
            continue;
        }
        nameList.add(tableInfo.getTableName());
    }
    copyNamesToClipboard(nameList);
}
Also used : ArrayList(java.util.ArrayList) TableDetailInfo(com.cubrid.common.core.common.model.TableDetailInfo)

Example 19 with TableDetailInfo

use of com.cubrid.common.core.common.model.TableDetailInfo in project cubrid-manager by CUBRID.

the class ColumnViewerSorter method refresh.

/**
	 * Refresh the data
	 *
	 * @param name
	 */
private void refresh(String name) {
    final LoadTableDetailInfoTask loadTableDetailInfoTask = new LoadTableDetailInfoTask(Messages.tablesDetailInfoLoadingDataTitle, database, name);
    CommonTaskExec taskExec = new CommonTaskExec(Messages.bind(Messages.tablesDetailInfoLoadingData, name));
    taskExec.addTask(loadTableDetailInfoTask);
    new ExecTaskWithProgress(taskExec).busyCursorWhile();
    if (taskExec.isSuccess()) {
        TableDetailInfo tableInfo = loadTableDetailInfoTask.getTableInfo();
        if (tableInfo != null) {
            TableDetailInfo oldTableInfo = findTableInfo(name);
            if (oldTableInfo != null) {
                TableDetailInfo.copyAllAttribute(tableInfo, oldTableInfo);
                tableListView.refresh();
            } else {
                tableList.add(tableInfo);
                tableListView.refresh();
            }
        }
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) TableDetailInfo(com.cubrid.common.core.common.model.TableDetailInfo) LoadTableDetailInfoTask(com.cubrid.common.ui.spi.progress.LoadTableDetailInfoTask)

Example 20 with TableDetailInfo

use of com.cubrid.common.core.common.model.TableDetailInfo in project cubrid-manager by CUBRID.

the class ColumnViewerSorter method getFirstSelectedNode.

/**
	 * Get first selected node
	 *
	 * @return
	 */
private ICubridNode getFirstSelectedNode() {
    TableItem[] items = tableListView.getTable().getSelection();
    if (items.length > 0) {
        TableItem item = items[0];
        TableDetailInfo tableInfo = (TableDetailInfo) item.getData();
        Set<String> typeSet = new HashSet<String>();
        typeSet.add(NodeType.USER_TABLE);
        typeSet.add(NodeType.USER_PARTITIONED_TABLE);
        ICubridNode tableNode = CommonUITool.findNode(database, typeSet, tableInfo.getTableName());
        return tableNode;
    }
    return null;
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) TableDetailInfo(com.cubrid.common.core.common.model.TableDetailInfo) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) HashSet(java.util.HashSet)

Aggregations

TableDetailInfo (com.cubrid.common.core.common.model.TableDetailInfo)27 ArrayList (java.util.ArrayList)11 Connection (java.sql.Connection)6 HashMap (java.util.HashMap)6 TableSchemaCompareModel (com.cubrid.common.ui.compare.schema.model.TableSchemaCompareModel)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 SQLException (java.sql.SQLException)5 SchemaInfo (com.cubrid.common.core.common.model.SchemaInfo)4 WrappedDatabaseInfo (com.cubrid.common.ui.cubrid.database.erwin.WrappedDatabaseInfo)4 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)4 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)4 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)4 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)4 TableItem (org.eclipse.swt.widgets.TableItem)4 PartInitException (org.eclipse.ui.PartInitException)4 AbstractUITask (com.cubrid.common.core.task.AbstractUITask)3 ITask (com.cubrid.common.core.task.ITask)3 TableSchemaModel (com.cubrid.common.ui.compare.schema.model.TableSchemaModel)3 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)3 OpenTablesDetailInfoPartProgress (com.cubrid.common.ui.spi.progress.OpenTablesDetailInfoPartProgress)3