Search in sources :

Example 41 with EditPart

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

Example 42 with EditPart

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;
}
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 43 with EditPart

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);
            }
        }
    }
}
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 44 with EditPart

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

Example 45 with EditPart

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();
}
Also used : ConnectionEditPart(org.eclipse.gef.ConnectionEditPart) NodeEditPart(org.eclipse.gef.NodeEditPart) EditPart(org.eclipse.gef.EditPart)

Aggregations

EditPart (org.eclipse.gef.EditPart)291 List (java.util.List)58 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)55 ArrayList (java.util.ArrayList)51 Command (org.eclipse.gef.commands.Command)32 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)27 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)27 Point (org.eclipse.draw2d.geometry.Point)26 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)26 Test (org.junit.Test)26 EmptyEditPart (com.archimatetool.editor.diagram.editparts.diagram.EmptyEditPart)21 ConnectionEditPart (org.eclipse.gef.ConnectionEditPart)21 NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)20 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)19 ProcessPart (org.talend.designer.core.ui.editor.process.ProcessPart)19 Iterator (java.util.Iterator)18 SubjobContainerPart (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)18 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)16 ConnectionContainerEditPart (org.knime.workbench.editor2.editparts.ConnectionContainerEditPart)14 DiagramConnectionEditPart (com.archimatetool.editor.diagram.editparts.DiagramConnectionEditPart)13