Search in sources :

Example 21 with ERTableColumn

use of com.cubrid.common.ui.er.model.ERTableColumn in project cubrid-manager by CUBRID.

the class AbstractSelectionAction method getERTable.

protected ERTable getERTable() {
    ERTable table = null;
    PropertyChangeProvider node = getSelectedNode();
    if (node instanceof ERTable) {
        table = (ERTable) node;
    } else if (node instanceof ERTableColumn) {
        ERTableColumn col = (ERTableColumn) node;
        table = col.getTable();
    }
    return table;
}
Also used : PropertyChangeProvider(com.cubrid.common.ui.er.model.PropertyChangeProvider) ERTableColumn(com.cubrid.common.ui.er.model.ERTableColumn) ERTable(com.cubrid.common.ui.er.model.ERTable)

Example 22 with ERTableColumn

use of com.cubrid.common.ui.er.model.ERTableColumn in project cubrid-manager by CUBRID.

the class ColumnDirectEditPolicy method getDirectEditCommand.

@Override
protected Command getDirectEditCommand(DirectEditRequest request) {
    ERTableColumn column = (ERTableColumn) getHost().getModel();
    ModifyColumnLabelCommand cmd = new ModifyColumnLabelCommand(column);
    CellEditor cellEditor = request.getCellEditor();
    cmd.changeNameType((String) cellEditor.getValue());
    return cmd;
}
Also used : CellEditor(org.eclipse.jface.viewers.CellEditor) ERTableColumn(com.cubrid.common.ui.er.model.ERTableColumn) ModifyColumnLabelCommand(com.cubrid.common.ui.er.commands.ModifyColumnLabelCommand)

Example 23 with ERTableColumn

use of com.cubrid.common.ui.er.model.ERTableColumn in project cubrid-manager by CUBRID.

the class TableLayoutEditPolicy method createAddCommand.

@Override
protected Command createAddCommand(EditPart child, EditPart after) {
    if (!(child instanceof ColumnPart) || !(after instanceof ColumnPart)) {
        return null;
    }
    ERTableColumn toMove = (ERTableColumn) child.getModel();
    ERTableColumn afterModel = (ERTableColumn) after.getModel();
    TablePart originalTablePart = (TablePart) child.getParent();
    ERTable originalTable = (ERTable) originalTablePart.getModel();
    TablePart newTablePart = (TablePart) after.getParent();
    ERTable newTable = newTablePart.getTable();
    int oldIndex = originalTablePart.getChildren().indexOf(child);
    int newIndex = newTablePart.getChildren().indexOf(after);
    return new TransferColumnCommand(toMove, afterModel, originalTable, newTable, oldIndex, newIndex);
}
Also used : ERTableColumn(com.cubrid.common.ui.er.model.ERTableColumn) TablePart(com.cubrid.common.ui.er.part.TablePart) TransferColumnCommand(com.cubrid.common.ui.er.commands.TransferColumnCommand) ColumnPart(com.cubrid.common.ui.er.part.ColumnPart) ERTable(com.cubrid.common.ui.er.model.ERTable)

Example 24 with ERTableColumn

use of com.cubrid.common.ui.er.model.ERTableColumn in project cubrid-manager by CUBRID.

the class ExportERwinDataController method exportData.

public boolean exportData(Shell parentShell, boolean isDirectSave) {
    String fileFullName;
    if (!isDirectSave || latestFileFullName == null) {
        FileDialog dialog = new FileDialog(parentShell, SWT.SAVE | SWT.APPLICATION_MODAL);
        dialog.setFilterExtensions(new String[] { "*.xml" });
        fileFullName = dialog.open();
    } else {
        fileFullName = latestFileFullName;
    }
    if (fileFullName == null) {
        return false;
    }
    if (fileFullName.trim().length() == 0) {
        CommonUITool.openErrorBox(Messages.errFileNameIsEmpty);
        return false;
    }
    TaskExecutor executor = new TaskExecutor() {

        @Override
        public boolean exec(IProgressMonitor monitor) {
            for (ITask task : taskList) {
                if (task instanceof ExportSchemaTask) {
                    ExportSchemaTask eTask = (ExportSchemaTask) task;
                    try {
                        eTask.initMarshaller();
                    } catch (JAXBException e) {
                        e.printStackTrace();
                        eTask.cancel();
                        return false;
                    }
                    monitor.setTaskName(Messages.msgGenerateInfo);
                    monitor.worked(50);
                    eTask.execute();
                    monitor.setTaskName(Messages.msgFinished);
                    monitor.worked(100);
                    monitor.done();
                }
            }
            return true;
        }
    };
    ExportSchemaTask task = new ExportSchemaTask(getERSchema().getAllSchemaInfo(), fileFullName);
    List<ERTable> tables = getERSchema().getTables();
    Map<String, String> tablePLMap = new HashMap<String, String>();
    Map<String, Map<String, List>> tablesPhysicalLogicalMap = new HashMap<String, Map<String, List>>();
    for (ERTable table : tables) {
        tablePLMap.put(table.getName(true), table.getName(false));
        Map<String, List> columnsPLMap = new HashMap<String, List>();
        tablesPhysicalLogicalMap.put(table.getName(true), columnsPLMap);
        List<ERTableColumn> columns = table.getColumns();
        for (ERTableColumn column : columns) {
            List<String> logicalNameAndType = new LinkedList<String>();
            columnsPLMap.put(column.getName(true), logicalNameAndType);
            logicalNameAndType.add(column.getName(false));
            logicalNameAndType.add(column.getShowType(false));
        }
    }
    task.setTablePLMap(tablePLMap);
    task.setTablesPhysicalLogicalMap(tablesPhysicalLogicalMap);
    executor.addTask(task);
    new ExecTaskWithProgress(executor).busyCursorWhile();
    if (executor.isSuccess()) {
        latestFileFullName = fileFullName;
        CommonUITool.openInformationBox(com.cubrid.common.ui.er.Messages.titleExport, Messages.bind(com.cubrid.common.ui.er.Messages.msgExportSuccess, fileFullName));
    }
    return executor.isSuccess();
}
Also used : ITask(com.cubrid.common.core.task.ITask) HashMap(java.util.HashMap) JAXBException(javax.xml.bind.JAXBException) ERTable(com.cubrid.common.ui.er.model.ERTable) ExportSchemaTask(com.cubrid.common.ui.cubrid.database.erwin.task.ExportSchemaTask) LinkedList(java.util.LinkedList) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ERTableColumn(com.cubrid.common.ui.er.model.ERTableColumn) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) List(java.util.List) LinkedList(java.util.LinkedList) FileDialog(org.eclipse.swt.widgets.FileDialog) HashMap(java.util.HashMap) Map(java.util.Map)

Example 25 with ERTableColumn

use of com.cubrid.common.ui.er.model.ERTableColumn in project cubrid-manager by CUBRID.

the class ImportERwinDataController method buildERDSchema.

private void buildERDSchema(ERSchema erSchema, Map<String, ERWinSchemaInfo> schemaInfos) {
    String message = "";
    CubridTableParser tableParser = new CubridTableParser(erSchema);
    Set<SchemaInfo> dbSchemaInfos = new HashSet<SchemaInfo>();
    Collection<ERWinSchemaInfo> erwinSchemas = schemaInfos.values();
    for (ERWinSchemaInfo erwinSchema : erwinSchemas) {
        SchemaInfo schemaInfo = (SchemaInfo) erwinSchema;
        dbSchemaInfos.add(schemaInfo);
    }
    tableParser.buildERTables(dbSchemaInfos, -1, -1, true);
    tableParser.appendLogicalInfo(schemaInfos);
    List<ERTable> successTables = tableParser.getSuccessTables();
    for (ERTable table : successTables) {
        ERWinSchemaInfo savedTable = schemaInfos.get(table.getName());
        table.setLogicalName(savedTable.getLogicalName());
        List<ERTableColumn> columns = table.getColumns();
        for (ERTableColumn column : columns) {
            String colName = column.getName();
            ERWinDBAttribute savedDBAttr = savedTable.getERWinDBAttr(colName);
            column.setLogicalName(savedDBAttr.getLogicalName());
            column.setLogicalType(savedDBAttr.getLogicalDataType());
        }
    }
    erSchema.FireAddedTable(successTables);
    Map<String, Exception> failedTables = tableParser.getFailedTables();
    Map<String, List<Constraint>> removedFKs = tableParser.getRemovedFKConstraints();
    if (failedTables.size() > 0) {
        message = Messages.bind(com.cubrid.common.ui.er.Messages.errorAddTables, failedTables.keySet());
    }
    if (removedFKs.size() > 0) {
        if (!message.equals("")) {
            message += "\n";
        }
        message += Messages.bind(com.cubrid.common.ui.er.Messages.cannotBeBuiltFK, tableParser.getOneRemovedFK().getName());
        if (tableParser.getRemovedFKCount() > 1) {
            message += ", ...";
        }
    }
    if (!message.equals("")) {
        CommonUITool.openErrorBox(message);
    }
}
Also used : CubridTableParser(com.cubrid.common.ui.er.model.CubridTableParser) ERTable(com.cubrid.common.ui.er.model.ERTable) ERTableColumn(com.cubrid.common.ui.er.model.ERTableColumn) ERWinSchemaInfo(com.cubrid.common.ui.cubrid.database.erwin.model.ERWinSchemaInfo) List(java.util.List) ERWinDBAttribute(com.cubrid.common.ui.cubrid.database.erwin.model.ERWinDBAttribute) HashSet(java.util.HashSet) SchemaInfo(com.cubrid.common.core.common.model.SchemaInfo) ERWinSchemaInfo(com.cubrid.common.ui.cubrid.database.erwin.model.ERWinSchemaInfo)

Aggregations

ERTableColumn (com.cubrid.common.ui.er.model.ERTableColumn)32 DBAttribute (com.cubrid.common.core.common.model.DBAttribute)11 ERTable (com.cubrid.common.ui.er.model.ERTable)11 SchemaInfo (com.cubrid.common.core.common.model.SchemaInfo)10 Constraint (com.cubrid.common.core.common.model.Constraint)9 List (java.util.List)6 EditableLabel (com.cubrid.common.ui.er.figures.EditableLabel)5 CubridTableParser (com.cubrid.common.ui.er.model.CubridTableParser)4 ArrayList (java.util.ArrayList)4 SerialInfo (com.cubrid.common.core.common.model.SerialInfo)3 ERSchema (com.cubrid.common.ui.er.model.ERSchema)3 Relationship (com.cubrid.common.ui.er.model.Relationship)3 EditPart (org.eclipse.gef.EditPart)3 TableItem (org.eclipse.swt.widgets.TableItem)3 TablePart (com.cubrid.common.ui.er.part.TablePart)2 HashSet (java.util.HashSet)2 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)2 ITask (com.cubrid.common.core.task.ITask)1 ERWinDBAttribute (com.cubrid.common.ui.cubrid.database.erwin.model.ERWinDBAttribute)1 ERWinSchemaInfo (com.cubrid.common.ui.cubrid.database.erwin.model.ERWinSchemaInfo)1