use of com.cubrid.common.core.common.model.DBAttribute in project cubrid-manager by CUBRID.
the class EditVirtualTableDialog method buildColumnTableMenu.
private void buildColumnTableMenu() {
Menu menu = new Menu(columnsTable.getShell(), SWT.POP_UP);
columnsTable.setMenu(menu);
final MenuItem deleteItem = new MenuItem(menu, SWT.PUSH);
deleteItem.setText(Messages.itemDeleteColumn);
deleteItem.setImage(CommonUIPlugin.getImageDescriptor("icons/action/table_record_delete.png").createImage());
deleteItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
deleteColumn();
}
});
menu.addMenuListener(new MenuListener() {
public void menuShown(MenuEvent e) {
TableItem[] tblItems = columnsTable.getSelection();
if (tblItems.length > 0) {
DBAttribute attr = (DBAttribute) tblItems[0].getData();
List<DBAttribute> items = getNewSchemaInfo().getAttributes();
if (!items.contains(attr)) {
deleteItem.setEnabled(false);
} else {
deleteItem.setEnabled(true);
}
}
}
public void menuHidden(MenuEvent e) {
}
});
}
use of com.cubrid.common.core.common.model.DBAttribute in project cubrid-manager by CUBRID.
the class ERDNDController method getDescInformation.
private void getDescInformation(SchemaInfo newSchemaInfo, CubridDatabase database, Connection conn) {
// FIXME move this logic to core module
try {
IDatabaseSpec dbSpec = database.getDatabaseInfo();
boolean isSupportTableComment = SchemaCommentHandler.isInstalledMetaTable(dbSpec, conn);
database.getDatabaseInfo().setSupportTableComment(isSupportTableComment);
if (isSupportTableComment && newSchemaInfo != null) {
Map<String, SchemaComment> map = SchemaCommentHandler.loadDescription(dbSpec, conn, newSchemaInfo.getClassname());
for (DBAttribute attr : newSchemaInfo.getAttributes()) {
SchemaComment schemaComment = SchemaCommentHandler.find(map, newSchemaInfo.getClassname(), attr.getName());
if (schemaComment != null) {
attr.setDescription(schemaComment.getDescription());
}
}
SchemaComment schemaComment = SchemaCommentHandler.find(map, newSchemaInfo.getClassname(), null);
if (schemaComment != null) {
newSchemaInfo.setDescription(schemaComment.getDescription());
}
}
} catch (SQLException e) {
LOGGER.error("", e);
} catch (Exception e) {
LOGGER.error("", e);
}
}
use of com.cubrid.common.core.common.model.DBAttribute in project cubrid-manager by CUBRID.
the class ERAttributeCellModifier method canModify.
public boolean canModify(Object element, String property) {
// FIXME move this logic to core module
ERTableColumn erColumn = (ERTableColumn) element;
DBAttribute attr = erColumn.getAttr();
if (!editor.isNewTableFlag() && !editor.isSupportChange() && editor.getOldSchemaInfo().getDBAttributeByName(attr.getName(), false) != null) {
return false;
}
if (StringUtil.isEqual(property, IAttributeColumn.COL_AUTO_INCREMENT)) {
DBAttribute aiAttr = editor.getNewSchemaInfo().getAutoIncrementColumn();
if (aiAttr != null && aiAttr != attr) {
return false;
} else if (!DataType.isIntegerType(attr.getType())) {
return false;
} else if (attr != null && StringUtil.isNotEmpty(attr.getDefault())) {
CommonUITool.openErrorBox(Messages.errCanNotSetAIOnDefault);
return false;
}
} else if (StringUtil.isEqual(property, IAttributeColumn.COL_NOT_NULL) || StringUtil.isEqual(property, IAttributeColumn.COL_UK)) {
Constraint pk = editor.getNewSchemaInfo().getPK();
if (pk != null && pk.getAttributes().contains(attr.getName())) {
return false;
}
} else if (StringUtil.isEqual(property, IAttributeColumn.COL_COLLATION)) {
if (attr.isNew() && DataType.canUseCollation(attr.getType())) {
return true;
} else {
return false;
}
} else if (StringUtil.isEqual(property, IAttributeColumn.COL_MEMO)) {
return editor.isSupportTableComment();
}
return true;
}
use of com.cubrid.common.core.common.model.DBAttribute in project cubrid-manager by CUBRID.
the class ERAttributeLabelProvider method getBackground.
public Color getBackground(Object element, int columnIndex) {
if (schema == null || element == null || !editableMode) {
return null;
}
ERTableColumn erColumn = (ERTableColumn) element;
DBAttribute attr = erColumn.getAttr();
String property = editorAdaptor.getColumnProperty(columnIndex);
if (StringUtil.isEqual(property, IAttributeColumn.COL_AUTO_INCREMENT)) {
DBAttribute aiAttr = schema.getAutoIncrementColumn();
if (aiAttr != null && aiAttr != attr) {
return DISABLED_COLOR;
} else if (!DataType.isIntegerType(attr.getType())) {
return DISABLED_COLOR;
}
} else if (StringUtil.isEqual(property, IAttributeColumn.COL_MEMO)) {
return editorAdaptor.isSupportTableComment() ? null : DISABLED_COLOR;
}
return null;
}
use of com.cubrid.common.core.common.model.DBAttribute in project cubrid-manager by CUBRID.
the class ERAttributeLabelProvider method getColumnText.
public String getColumnText(Object element, int columnIndex) {
if (element == null) {
return null;
}
ERTableColumn erColumn = (ERTableColumn) element;
DBAttribute dbAttribute = erColumn.getAttr();
if (dbAttribute == null || dbAttribute.getInherit() == null || schema == null) {
return null;
}
String property = editorAdaptor.getColumnProperty(columnIndex);
if (StringUtil.isEqual(property, IAttributeColumn.COL_FLAG)) {
if (StringUtil.isEmpty(dbAttribute.getName())) {
return "*";
}
} else if (StringUtil.isEqual(property, IAttributeColumn.COL_NAME)) {
return erColumn.getName(isPhysical);
} else if (StringUtil.isEqual(property, IAttributeColumn.COL_DATATYPE)) {
if (isPhysical) {
if (DataType.DATATYPE_ENUM.equalsIgnoreCase(dbAttribute.getType())) {
String type = StringUtil.toUpper(dbAttribute.getType()) + dbAttribute.getEnumeration();
return DataType.getShownType(type);
} else {
return DataType.getShownType(dbAttribute.getType());
}
} else {
return erColumn.getShowType(false).toUpperCase();
}
} else if (StringUtil.isEqual(property, IAttributeColumn.COL_DEFAULT)) {
String defaultValue = dbAttribute.getDefault();
if (defaultValue == null) {
return DataType.NULL_EXPORT_FORMAT;
}
if (defaultValue.length() == 0 && DataType.isStringType(dbAttribute.getType())) {
return "";
}
return defaultValue;
} else if (StringUtil.isEqual(property, IAttributeColumn.COL_AUTO_INCREMENT)) {
SerialInfo serial = dbAttribute.getAutoIncrement();
if (serial == null) {
return "";
}
return serial.getMinValue() + "," + serial.getIncrementValue();
} else if (StringUtil.isEqual(property, IAttributeColumn.COL_MEMO)) {
return dbAttribute.getDescription();
} else if (StringUtil.isEqual(property, IAttributeColumn.COL_COLLATION)) {
return dbAttribute.getCollation();
}
return null;
}
Aggregations