Search in sources :

Example 71 with EditPart

use of org.eclipse.gef.EditPart in project cubrid-manager by CUBRID.

the class AbstractBasicPart method handleChildChange.

protected void handleChildChange(PropertyChangeEvent evt) {
    Object newValue = evt.getNewValue();
    Object oldValue = evt.getOldValue();
    if ((oldValue == null) && (newValue == null)) {
        throw new IllegalStateException(Messages.errOldNewValueBothNull);
    }
    if (oldValue != null) {
        List children = getChildren();
        EditPart partToRemove = null;
        for (Iterator iter = children.iterator(); iter.hasNext(); ) {
            EditPart part = (EditPart) iter.next();
            if (part.getModel() instanceof PropertyChangeProvider && oldValue instanceof PropertyChangeProvider) {
                PropertyChangeProvider model = (PropertyChangeProvider) part.getModel();
                PropertyChangeProvider old = (PropertyChangeProvider) oldValue;
                PropertyChangeProvider newV = (PropertyChangeProvider) newValue;
                if (newV != null && model.getName().equals(newV.getName())) {
                    return;
                }
                if (model.getName().equals(old.getName())) {
                    partToRemove = part;
                    break;
                }
            } else if (part.getModel().equals(oldValue)) {
                partToRemove = part;
                break;
            }
        }
        if (partToRemove != null) {
            removeChild(partToRemove);
        }
    }
    if (newValue != null) {
        EditPart editPart = createChild(newValue);
        int modelIndex = getModelChildren().indexOf(newValue);
        addChild(editPart, modelIndex);
    }
}
Also used : PropertyChangeProvider(com.cubrid.common.ui.er.model.PropertyChangeProvider) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) ConnectionEditPart(org.eclipse.gef.ConnectionEditPart) Iterator(java.util.Iterator) List(java.util.List)

Example 72 with EditPart

use of org.eclipse.gef.EditPart in project cubrid-manager by CUBRID.

the class AbstractSelectionAction method getSelectedNode.

/**
	 * Get the first selected node.
	 * 
	 * @return
	 */
protected PropertyChangeProvider getSelectedNode() {
    List objects = getSelectedObjects();
    if (objects.isEmpty()) {
        return null;
    }
    if (!(objects.get(0) instanceof EditPart)) {
        return null;
    }
    EditPart part = (EditPart) objects.get(0);
    return (PropertyChangeProvider) part.getModel();
}
Also used : PropertyChangeProvider(com.cubrid.common.ui.er.model.PropertyChangeProvider) EditPart(org.eclipse.gef.EditPart) List(java.util.List)

Example 73 with EditPart

use of org.eclipse.gef.EditPart in project cubrid-manager by CUBRID.

the class SchemaDiagramPart 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 TablePart) {
            TablePart tablePart = (TablePart) part;
            tablePart.handleRelationMapChange(evt);
        }
    }
}
Also used : ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart) EditPart(org.eclipse.gef.EditPart)

Example 74 with EditPart

use of org.eclipse.gef.EditPart in project cubrid-manager by CUBRID.

the class TablePart method setRelationLinesSyncColor.

/**
	 * Set all relation line same color by the table border color,if the table
	 * border color is not its default.
	 * 
	 * @param checkRelatedSelectedTable if it is true, the line color should be
	 *        effected by related table border color.
	 */
public void setRelationLinesSyncColor(boolean checkRelatedSelectedTable) {
    List<EditPart> sourceConnPartList = (List<EditPart>) getSourceConnections();
    for (EditPart connPart : sourceConnPartList) {
        RelationshipPart linePart = (RelationshipPart) connPart;
        linePart.setSyncColorWithTable(this);
        if (checkRelatedSelectedTable) {
            linePart.setSelectedTableColor();
        }
    }
    List<EditPart> targetConnPartList = (List<EditPart>) getTargetConnections();
    for (EditPart connPart : targetConnPartList) {
        RelationshipPart linePart = (RelationshipPart) connPart;
        linePart.setSyncColorWithTable(this);
        if (checkRelatedSelectedTable) {
            linePart.setSelectedTableColor();
        }
    }
}
Also used : ConnectionEditPart(org.eclipse.gef.ConnectionEditPart) NodeEditPart(org.eclipse.gef.NodeEditPart) EditPart(org.eclipse.gef.EditPart) List(java.util.List)

Example 75 with EditPart

use of org.eclipse.gef.EditPart in project cubrid-manager by CUBRID.

the class TablePart method setRelationLinesFocus.

/**
	 * If the checkRelatedTableState is true, then check other end table whether
	 * is selected, if selected, the connection line should not be set "false"
	 * focus.
	 * 
	 * @param connPartList
	 * @param focus
	 * @param checkRelatedSelectedTable
	 */
private void setRelationLinesFocus(List<EditPart> connPartList, boolean focus, boolean checkRelatedSelectedTable) {
    for (EditPart connPart : connPartList) {
        RelationshipPart linePart = (RelationshipPart) connPart;
        if (linePart.getSource() == null || linePart.getTarget() == null) {
            continue;
        }
        connPart.setFocus(focus);
        if (!focus && checkRelatedSelectedTable) {
            if (((TablePart) linePart.getSource()).isSelected() || ((TablePart) linePart.getTarget()).isSelected()) {
                continue;
            }
        }
        linePart.setRelationColumnProtrude(focus);
    }
}
Also used : ConnectionEditPart(org.eclipse.gef.ConnectionEditPart) NodeEditPart(org.eclipse.gef.NodeEditPart) EditPart(org.eclipse.gef.EditPart)

Aggregations

EditPart (org.eclipse.gef.EditPart)132 List (java.util.List)50 ArrayList (java.util.ArrayList)37 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)26 NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)20 ProcessPart (org.talend.designer.core.ui.editor.process.ProcessPart)19 SubjobContainerPart (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)18 Point (org.eclipse.draw2d.geometry.Point)17 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)17 Command (org.eclipse.gef.commands.Command)16 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)16 ConnectionEditPart (org.eclipse.gef.ConnectionEditPart)15 ConnectionContainerEditPart (org.knime.workbench.editor2.editparts.ConnectionContainerEditPart)14 Node (org.talend.designer.core.ui.editor.nodes.Node)13 RootEditPart (org.eclipse.gef.RootEditPart)11 ConnLabelEditPart (org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)11 NodeContainerPart (org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart)11 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)10 ScalableFreeformRootEditPart (org.eclipse.gef.editparts.ScalableFreeformRootEditPart)10 INode (org.talend.core.model.process.INode)10