Search in sources :

Example 6 with Relationship

use of com.cubrid.common.ui.er.model.Relationship in project cubrid-manager by CUBRID.

the class RelationshipPart method handleDeleteConnection.

public void handleDeleteConnection() {
    Relationship relations = (Relationship) this.getModel();
    TablePart sourceTablePart = (TablePart) this.getSource();
    TablePart targetTablePart = (TablePart) this.getTarget();
    // set source and target columns
    if (sourceTablePart != null) {
        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();
                columnLable.setFontProtrude(false);
            }
        }
    }
    // target
    if (targetTablePart != null) {
        List<EditPart> 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();
                columnLable.setFontProtrude(false);
            }
        }
    }
}
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)

Example 7 with Relationship

use of com.cubrid.common.ui.er.model.Relationship in project cubrid-manager by CUBRID.

the class DeleteTableCommand method restoreRelationships.

private void restoreRelationships() {
    for (int i = 0; i < foreignKeyRelationships.size(); i++) {
        Relationship r = (Relationship) foreignKeyRelationships.get(i);
        r.getForeignKeyTable().addForeignKeyShipAndFire(r);
    }
    foreignKeyRelationships.clear();
    for (int i = 0; i < primaryKeyRelationships.size(); i++) {
        Relationship r = (Relationship) primaryKeyRelationships.get(i);
        r.getForeignKeyTable().addForeignKeyShipAndFire(r);
    }
    primaryKeyRelationships.clear();
}
Also used : Relationship(com.cubrid.common.ui.er.model.Relationship)

Example 8 with Relationship

use of com.cubrid.common.ui.er.model.Relationship in project cubrid-manager by CUBRID.

the class ReconnectPrimaryKeyCommand method canExecute.

@Override
public boolean canExecute() {
    boolean returnVal = true;
    ERTable foreignKeyTable = relationship.getForeignKeyTable();
    if (foreignKeyTable.equals(targetTable)) {
        returnVal = false;
    } else {
        List relationships = targetTable.getTargetedRelationships();
        for (int i = 0; i < relationships.size(); i++) {
            Relationship relationship = ((Relationship) (relationships.get(i)));
            if (relationship.getForeignKeyTable().equals(sourceTable) && relationship.getPrimaryKeyTable().equals(targetTable)) {
                returnVal = false;
                break;
            }
        }
    }
    return returnVal;
}
Also used : Relationship(com.cubrid.common.ui.er.model.Relationship) ERTable(com.cubrid.common.ui.er.model.ERTable) List(java.util.List)

Aggregations

Relationship (com.cubrid.common.ui.er.model.Relationship)8 ERTable (com.cubrid.common.ui.er.model.ERTable)4 ERTableColumn (com.cubrid.common.ui.er.model.ERTableColumn)3 EditPart (org.eclipse.gef.EditPart)3 EditableLabel (com.cubrid.common.ui.er.figures.EditableLabel)2 List (java.util.List)2 DeleteRelationshipCommand (com.cubrid.common.ui.er.commands.DeleteRelationshipCommand)1 ERSchema (com.cubrid.common.ui.er.model.ERSchema)1