Search in sources :

Example 1 with AddColumnDialog

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);
    }
}
Also used : AddColumnDialog(com.cubrid.common.ui.er.dialog.AddColumnDialog) DBAttribute(com.cubrid.common.core.common.model.DBAttribute) ERTableColumn(com.cubrid.common.ui.er.model.ERTableColumn) ArrayList(java.util.ArrayList) ERTable(com.cubrid.common.ui.er.model.ERTable)

Aggregations

DBAttribute (com.cubrid.common.core.common.model.DBAttribute)1 AddColumnDialog (com.cubrid.common.ui.er.dialog.AddColumnDialog)1 ERTable (com.cubrid.common.ui.er.model.ERTable)1 ERTableColumn (com.cubrid.common.ui.er.model.ERTableColumn)1 ArrayList (java.util.ArrayList)1