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);
}
}
}
}
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();
}
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;
}
Aggregations