Search in sources :

Example 11 with ERTableColumn

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;
}
Also used : Constraint(com.cubrid.common.core.common.model.Constraint) DBAttribute(com.cubrid.common.core.common.model.DBAttribute) ERTableColumn(com.cubrid.common.ui.er.model.ERTableColumn)

Example 12 with ERTableColumn

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;
}
Also used : ERTableColumn(com.cubrid.common.ui.er.model.ERTableColumn) TablePart(com.cubrid.common.ui.er.part.TablePart) ERTable(com.cubrid.common.ui.er.model.ERTable) CreateColumnCommand(com.cubrid.common.ui.er.commands.CreateColumnCommand)

Example 13 with ERTableColumn

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);
}
Also used : ERTableColumn(com.cubrid.common.ui.er.model.ERTableColumn) ERTable(com.cubrid.common.ui.er.model.ERTable) List(java.util.List) MoveColumnCommand(com.cubrid.common.ui.er.commands.MoveColumnCommand)

Example 14 with ERTableColumn

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;
}
Also used : Relationship(com.cubrid.common.ui.er.model.Relationship) ERTableColumn(com.cubrid.common.ui.er.model.ERTableColumn) EditPart(org.eclipse.gef.EditPart) ERSchema(com.cubrid.common.ui.er.model.ERSchema) ERTable(com.cubrid.common.ui.er.model.ERTable)

Example 15 with ERTableColumn

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);
            }
        }
    }
}
Also used : EditableLabel(com.cubrid.common.ui.er.figures.EditableLabel) Relationship(com.cubrid.common.ui.er.model.Relationship) ERTableColumn(com.cubrid.common.ui.er.model.ERTableColumn) EditPart(org.eclipse.gef.EditPart)

Aggregations

ERTableColumn (com.cubrid.common.ui.er.model.ERTableColumn)32 DBAttribute (com.cubrid.common.core.common.model.DBAttribute)11 ERTable (com.cubrid.common.ui.er.model.ERTable)11 SchemaInfo (com.cubrid.common.core.common.model.SchemaInfo)10 Constraint (com.cubrid.common.core.common.model.Constraint)9 List (java.util.List)6 EditableLabel (com.cubrid.common.ui.er.figures.EditableLabel)5 CubridTableParser (com.cubrid.common.ui.er.model.CubridTableParser)4 ArrayList (java.util.ArrayList)4 SerialInfo (com.cubrid.common.core.common.model.SerialInfo)3 ERSchema (com.cubrid.common.ui.er.model.ERSchema)3 Relationship (com.cubrid.common.ui.er.model.Relationship)3 EditPart (org.eclipse.gef.EditPart)3 TableItem (org.eclipse.swt.widgets.TableItem)3 TablePart (com.cubrid.common.ui.er.part.TablePart)2 HashSet (java.util.HashSet)2 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)2 ITask (com.cubrid.common.core.task.ITask)1 ERWinDBAttribute (com.cubrid.common.ui.cubrid.database.erwin.model.ERWinDBAttribute)1 ERWinSchemaInfo (com.cubrid.common.ui.cubrid.database.erwin.model.ERWinSchemaInfo)1