use of com.cubrid.common.ui.er.dialog.AddColumnDialog in project cubrid-manager by CUBRID.
the class AddColumnAction method run.
public void run() {
ERTable table = this.getERTable();
List<String> names = new ArrayList<String>();
List<ERTableColumn> columns = table.getColumns();
for (ERTableColumn column : columns) {
names.add(column.getName());
}
AddColumnDialog dlg = new AddColumnDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), table.getName(), true, names, getERSchema());
int ret = dlg.open();
if (ret == IDialogConstants.OK_ID) {
boolean isPhysical = table.getERSchema().isPhysicModel();
String newName = dlg.getNewColumnName();
String type = dlg.getDataType();
String realType = null;
String enumeration = null;
if (isPhysical) {
realType = DataType.getRealType(type);
} else {
String upPhysicalShowType = type;
realType = DataType.getRealType(upPhysicalShowType);
}
if (DataType.DATATYPE_ENUM.equals(type)) {
realType = DataType.getUpperEnumType().toLowerCase();
enumeration = "('" + DataType.ENUM_DAFAULT_VALUE + "')";
}
DBAttribute addAttribute = new DBAttribute(newName, realType, table.getName(), false, false, false, false, null, Collation.DEFAULT_COLLATION);
addAttribute.setEnumeration(enumeration);
ERTableColumn col = new ERTableColumn(table, addAttribute, false);
if (DataType.DATATYPE_STRING.equals(type)) {
col.setLogicalType(DataType.DATATYPE_STRING);
}
table.addColumnAndFire(col);
}
}
Aggregations