use of com.cubrid.common.ui.er.model.ERTableColumn in project cubrid-manager by CUBRID.
the class ERAttributeLabelProvider method getColumnImage.
public Image getColumnImage(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_PK)) {
String attrName = dbAttribute.getName();
Constraint pk = schema.getPK(supers);
if (null != pk && pk.getAttributes().contains(attrName)) {
return PK_IMAGE;
}
return editableMode ? UNCHECK_IMAGE : null;
} else if (StringUtil.isEqual(property, IAttributeColumn.COL_NOT_NULL)) {
String attrName = dbAttribute.getName();
Constraint pk = schema.getPK(supers);
if (null != pk && pk.getAttributes().contains(attrName)) {
return DISABLED_CHECK_IMAGE;
}
if (dbAttribute.isNotNull()) {
return editableMode ? CHECK_IMAGE : DISABLED_CHECK_IMAGE;
} else {
return editableMode ? UNCHECK_IMAGE : null;
}
} else if (StringUtil.isEqual(property, IAttributeColumn.COL_UK)) {
String attrName = dbAttribute.getName();
Constraint pk = schema.getPK(supers);
if (null != pk && pk.getAttributes().contains(attrName)) {
return DISABLED_CHECK_IMAGE;
}
if (dbAttribute.isUnique() && schema.isAttributeUnique(dbAttribute, supers)) {
return editableMode ? CHECK_IMAGE : DISABLED_CHECK_IMAGE;
} else {
return editableMode ? UNCHECK_IMAGE : DISABLED_UNCHECK_IMAGE;
}
} else if (StringUtil.isEqual(property, IAttributeColumn.COL_SHARED)) {
if (dbAttribute.isShared()) {
return editableMode ? CHECK_IMAGE : DISABLED_CHECK_IMAGE;
} else {
return editableMode ? UNCHECK_IMAGE : null;
}
}
return null;
}
use of com.cubrid.common.ui.er.model.ERTableColumn in project cubrid-manager by CUBRID.
the class TableContainerEditPolicy method getCreateCommand.
@Override
protected Command getCreateCommand(CreateRequest request) {
Object newObject = request.getNewObject();
if (!(newObject instanceof ERTableColumn)) {
return null;
}
TablePart tablePart = (TablePart) getHost();
ERTable erTable = tablePart.getTable();
ERTableColumn column = (ERTableColumn) newObject;
CreateColumnCommand command = new CreateColumnCommand();
command.setTable(erTable);
command.setColumn(column);
return command;
}
use of com.cubrid.common.ui.er.model.ERTableColumn in project cubrid-manager by CUBRID.
the class TableLayoutEditPolicy method createMoveChildCommand.
@SuppressWarnings("rawtypes")
@Override
protected Command createMoveChildCommand(EditPart child, EditPart after) {
if (after == null) {
return null;
}
ERTableColumn childModel = (ERTableColumn) child.getModel();
ERTable parentTable = (ERTable) getHost().getModel();
List hostParts = getHost().getChildren();
int oldIndex = hostParts.indexOf(child);
int newIndex = hostParts.indexOf(after);
return new MoveColumnCommand(childModel, parentTable, oldIndex, newIndex);
}
use of com.cubrid.common.ui.er.model.ERTableColumn in project cubrid-manager by CUBRID.
the class PartFactory method createEditPart.
public EditPart createEditPart(EditPart context, Object model) {
EditPart part = null;
if (model instanceof ERSchema) {
part = new SchemaDiagramPart();
} else if (model instanceof ERTable) {
part = new TablePart();
} else if (model instanceof Relationship) {
part = new RelationshipPart();
} else if (model instanceof ERTableColumn) {
part = new ColumnPart();
}
if (null == part) {
LOGGER.error("Part is null :" + context + "," + model);
}
part.setModel(model);
return part;
}
use of com.cubrid.common.ui.er.model.ERTableColumn in project cubrid-manager by CUBRID.
the class RelationshipPart method setRelationColumnProtrude.
/**
* Set foreign columns relation with the line to be protruded.
*
* @param focus
*/
@SuppressWarnings("unchecked")
public void setRelationColumnProtrude(boolean focus) {
Relationship relations = (Relationship) this.getModel();
TablePart sourceTablePart = (TablePart) this.getSource();
TablePart targetTablePart = (TablePart) this.getTarget();
if (sourceTablePart == null || targetTablePart == null) {
return;
}
// set source and target columns
List<EditPart> children = sourceTablePart.getChildren();
for (EditPart child : children) {
if (!(child instanceof ColumnPart)) {
continue;
}
ColumnPart columnPart = (ColumnPart) child;
ERTableColumn column = (ERTableColumn) columnPart.getModel();
if (relations.getReferenceColumns().contains(column.getName())) {
EditableLabel columnLable = (EditableLabel) columnPart.getFigure();
if (this.isSelected() || sourceTablePart.isSelected() || targetTablePart.isSelected()) {
columnLable.setFontProtrude(true);
} else {
columnLable.setFontProtrude(focus);
}
}
}
// target
children = targetTablePart.getChildren();
for (EditPart child : children) {
if (!(child instanceof ColumnPart)) {
continue;
}
ColumnPart columnPart = (ColumnPart) child;
ERTableColumn column = (ERTableColumn) columnPart.getModel();
if (relations.getReferencedPKs().contains(column.getName())) {
EditableLabel columnLable = (EditableLabel) columnPart.getFigure();
if (this.isSelected() || sourceTablePart.isSelected() || targetTablePart.isSelected()) {
columnLable.setFontProtrude(true);
} else {
columnLable.setFontProtrude(focus);
}
}
}
}
Aggregations