use of org.eclipse.gef.EditPart in project cubrid-manager by CUBRID.
the class NodeResizableEditPolicy method isDragAllowed.
/**
* Returns true if this EditPolicy allows its EditPart to be dragged.
*
* @return true if the EditPart can be dragged.
*/
@Override
public boolean isDragAllowed() {
EditPart part = this.getHost();
Object obj = part.getModel();
if (obj instanceof PropertyChangeProvider) {
PropertyChangeProvider model = (PropertyChangeProvider) obj;
return model.getERSchema().isLayoutManualDesired();
}
return super.isDragAllowed();
}
use of org.eclipse.gef.EditPart 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 org.eclipse.gef.EditPart 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);
}
}
}
}
use of org.eclipse.gef.EditPart in project cubrid-manager by CUBRID.
the class TablePart method handleViewModelChange.
@Override
protected void handleViewModelChange(PropertyChangeEvent evt) {
Object newValue = evt.getNewValue();
Object oldValue = evt.getOldValue();
if (oldValue == null || newValue == null) {
throw new IllegalStateException(Messages.errOldNewValueBothNull);
}
if (newValue.equals(oldValue)) {
return;
}
ERTable table = getTable();
if (newValue.equals(PropertyChangeProvider.LOGIC_MODEL)) {
setName(table.getLogicName());
} else if (newValue.equals(PropertyChangeProvider.PHYSICAL_MODEL)) {
setName(table.getName());
}
List<EditPart> children = getChildren();
for (EditPart part : children) {
if (part instanceof ColumnPart) {
ColumnPart columnPart = (ColumnPart) part;
columnPart.handleViewModelChange(evt);
}
}
refreshVisuals();
}
use of org.eclipse.gef.EditPart in project cubrid-manager by CUBRID.
the class TablePart method handleRelationMapChange.
/* (non-Javadoc)
* @see com.cubrid.common.ui.er.part.BasicPart#handleRelationMapChange(java.beans.PropertyChangeEvent)
*/
@Override
protected void handleRelationMapChange(PropertyChangeEvent evt) {
List<EditPart> children = getChildren();
for (EditPart part : children) {
if (part instanceof ColumnPart) {
ColumnPart columnPart = (ColumnPart) part;
columnPart.handleRelationMapChange(evt);
}
}
refreshVisuals();
}
Aggregations