Search in sources :

Example 21 with ERTable

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

the class TableDirectEditPolicy method getDirectEditCommand.

@Override
protected Command getDirectEditCommand(DirectEditRequest request) {
    ModifyTableNameCommand cmd = new ModifyTableNameCommand();
    ERTable erTable = (ERTable) getHost().getModel();
    cmd.setTable(erTable);
    cmd.setOldName(erTable.getShownName());
    CellEditor cellEditor = request.getCellEditor();
    String value = (String) cellEditor.getValue();
    cmd.setName(value);
    return cmd;
}
Also used : ModifyTableNameCommand(com.cubrid.common.ui.er.commands.ModifyTableNameCommand) CellEditor(org.eclipse.jface.viewers.CellEditor) ERTable(com.cubrid.common.ui.er.model.ERTable)

Example 22 with ERTable

use of com.cubrid.common.ui.er.model.ERTable 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 23 with ERTable

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

the class ERSchemaEditor method setLocateTable.

/**
	 * Set the ERD focus location onto the gave table
	 * 
	 * @param tableName
	 */
public void setLocateTable(String tableName) {
    SchemaDiagramPart schemaRootPart = getERSchemaRootPart();
    List allParts = schemaRootPart.getChildren();
    Iterator it = allParts.iterator();
    while (it.hasNext()) {
        Object obj = it.next();
        if (!(obj instanceof TablePart)) {
            continue;
        }
        TablePart tablePart = (TablePart) obj;
        ERTable erTable = tablePart.getTable();
        if (erTable.getName().equals(tableName)) {
            setLocatePoint(erTable.getBounds().x, erTable.getBounds().y);
        }
    }
}
Also used : SchemaDiagramPart(com.cubrid.common.ui.er.part.SchemaDiagramPart) Iterator(java.util.Iterator) TablePart(com.cubrid.common.ui.er.part.TablePart) ERTable(com.cubrid.common.ui.er.model.ERTable) ArrayList(java.util.ArrayList) List(java.util.List) EventObject(java.util.EventObject)

Example 24 with ERTable

use of com.cubrid.common.ui.er.model.ERTable 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 ERTable

use of com.cubrid.common.ui.er.model.ERTable 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

ERTable (com.cubrid.common.ui.er.model.ERTable)30 List (java.util.List)14 ERTableColumn (com.cubrid.common.ui.er.model.ERTableColumn)11 TableFigure (com.cubrid.common.ui.er.figures.TableFigure)6 Iterator (java.util.Iterator)6 SchemaInfo (com.cubrid.common.core.common.model.SchemaInfo)5 ERSchema (com.cubrid.common.ui.er.model.ERSchema)5 TablePart (com.cubrid.common.ui.er.part.TablePart)5 LinkedList (java.util.LinkedList)5 Rectangle (org.eclipse.draw2d.geometry.Rectangle)5 CubridTableParser (com.cubrid.common.ui.er.model.CubridTableParser)4 Relationship (com.cubrid.common.ui.er.model.Relationship)4 ArrayList (java.util.ArrayList)4 EventObject (java.util.EventObject)4 SchemaDiagramPart (com.cubrid.common.ui.er.part.SchemaDiagramPart)3 Constraint (com.cubrid.common.core.common.model.Constraint)2 DBAttribute (com.cubrid.common.core.common.model.DBAttribute)2 EditableLabel (com.cubrid.common.ui.er.figures.EditableLabel)2 PropertyChangeProvider (com.cubrid.common.ui.er.model.PropertyChangeProvider)2 Point (org.eclipse.draw2d.geometry.Point)2