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;
}
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;
}
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);
}
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();
}
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);
}
}
Aggregations