Search in sources :

Example 96 with EditPart

use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.

the class AbstractMultiPageTalendEditor method selectNode.

/**
     * DOC bqian Comment method "selectNode".
     * 
     * @param node
     */
public void selectNode(INode node) {
    GraphicalViewer viewer = designerEditor.getViewer();
    Object object = viewer.getRootEditPart().getChildren().get(0);
    if (object instanceof ProcessPart) {
        for (EditPart editPart : (List<EditPart>) ((ProcessPart) object).getChildren()) {
            if (editPart instanceof NodePart) {
                if (((NodePart) editPart).getModel().equals(node)) {
                    viewer.select(editPart);
                }
            }
        }
    }
}
Also used : GraphicalViewer(org.eclipse.gef.GraphicalViewer) NodeLabelEditPart(org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart) EditPart(org.eclipse.gef.EditPart) NodeTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeTreeEditPart) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PlatformObject(org.eclipse.core.runtime.PlatformObject) ArrayList(java.util.ArrayList) List(java.util.List) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Example 97 with EditPart

use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.

the class TalendPaletteViewer method addFavoritesComponent.

public void addFavoritesComponent(CombinedTemplateCreationEntry component) {
    if (favoritesEditPart != null) {
        List children = favoritesEditPart.getChildren();
        int insertIndex = 0;
        boolean alreadyExist = false;
        if (children != null) {
            for (; insertIndex < children.size(); insertIndex++) {
                TalendEntryEditPart entryEditPart = (TalendEntryEditPart) children.get(insertIndex);
                CombinedTemplateCreationEntry entryModule = (CombinedTemplateCreationEntry) entryEditPart.getModel();
                int compareResult = entryModule.getLabel().toLowerCase().compareTo(component.getLabel().toLowerCase());
                if (0 == compareResult) {
                    alreadyExist = true;
                    break;
                }
                if (0 < compareResult) {
                    break;
                }
            }
        }
        if (!alreadyExist) {
            TalendEditorPaletteFactory.addNewFavoriteIntoPreference(component.getLabel());
            CombinedTemplateCreationEntry newFavorite = TalendEditorPaletteFactory.createEntryFrom(component);
            newFavorite.setParent(favoritesEditPart.getDrawer());
            EditPart child = favoritesEditPart.createChild(newFavorite);
            PaletteDrawer paletteDrawer = favoritesEditPart.getDrawer();
            if (paletteDrawer != null) {
                paletteDrawer.add(insertIndex, newFavorite);
            }
        // needn't use this, or will cause problem
        // favoritesEditPart.addChild(child, insertIndex);
        }
    }
}
Also used : EditPart(org.eclipse.gef.EditPart) PaletteDrawer(org.eclipse.gef.palette.PaletteDrawer) List(java.util.List) ArrayList(java.util.ArrayList) CombinedTemplateCreationEntry(org.eclipse.gef.palette.CombinedTemplateCreationEntry)

Example 98 with EditPart

use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.

the class NodePart method refreshTargetConnections.

@Override
protected void refreshTargetConnections() {
    int i;
    ConnectionEditPart editPart;
    Object model;
    Map mapModelToEditPart = new HashMap();
    List connections = getTargetConnections();
    for (i = 0; i < connections.size(); i++) {
        editPart = (ConnectionEditPart) connections.get(i);
        mapModelToEditPart.put(editPart.getModel(), editPart);
    }
    List modelObjects = getModelTargetConnections();
    if (modelObjects == null) {
        modelObjects = new ArrayList();
    }
    for (i = 0; i < modelObjects.size(); i++) {
        model = modelObjects.get(i);
        if (model instanceof IConnection) {
            INode sourcenode = ((IConnection) model).getSource();
            INode targetnode = ((IConnection) model).getSource();
            String connectorName = ((IConnection) model).getConnectorName();
            if (sourcenode.getConnectorFromName(connectorName) == null && targetnode.getConnectorFromName(connectorName) == null) {
                return;
            }
        }
        if (i < connections.size() && ((EditPart) connections.get(i)).getModel() == model) {
            continue;
        }
        editPart = (ConnectionEditPart) mapModelToEditPart.get(model);
        if (editPart != null) {
            reorderTargetConnection(editPart, i);
        } else {
            editPart = createOrFindConnection(model);
            addTargetConnection(editPart, i);
        }
    }
    // Remove the remaining Connection EditParts
    List trash = new ArrayList();
    for (; i < connections.size(); i++) {
        trash.add(connections.get(i));
    }
    for (i = 0; i < trash.size(); i++) {
        removeTargetConnection((ConnectionEditPart) trash.get(i));
    }
}
Also used : INode(org.talend.core.model.process.INode) ConnectionEditPart(org.eclipse.gef.ConnectionEditPart) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) RootEditPart(org.eclipse.gef.RootEditPart) ConnectionEditPart(org.eclipse.gef.ConnectionEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) NodeEditPart(org.eclipse.gef.NodeEditPart) List(java.util.List) ArrayList(java.util.ArrayList) IConnection(org.talend.core.model.process.IConnection) Map(java.util.Map) HashMap(java.util.HashMap) Point(org.eclipse.draw2d.geometry.Point)

Example 99 with EditPart

use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.

the class NodePart method propertyChange.

// ------------------------------------------------------------------------
// Abstract methods from PropertyChangeListener
/*
     * (non-Javadoc)
     * 
     * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
     */
@Override
public void propertyChange(final PropertyChangeEvent changeEvent) {
    boolean needUpdateSubjob = false;
    if (!this.isActive()) {
        return;
    }
    if (changeEvent.getPropertyName().equals(Node.LOCATION)) {
        refreshVisuals();
        needUpdateSubjob = true;
    } else if (changeEvent.getPropertyName().equals(Node.PERFORMANCE_DATA)) {
        refreshVisuals();
        getParent().refresh();
        needUpdateSubjob = true;
    } else if (changeEvent.getPropertyName().equals(Node.INPUTS)) {
        refreshTargetConnections();
        needUpdateSubjob = true;
    } else if (changeEvent.getPropertyName().equals(Node.OUTPUTS)) {
        refreshSourceConnections();
        refreshTargetConnections();
        needUpdateSubjob = true;
    } else if (changeEvent.getPropertyName().equals(Node.SIZE)) {
        refreshVisuals();
        getParent().refresh();
        needUpdateSubjob = true;
    } else if (changeEvent.getPropertyName().equals(Node.ICON_CHANGE)) {
        changeIcon((Node) changeEvent.getSource());
        refreshVisuals();
    } else if (changeEvent.getPropertyName().equals(EParameterName.ACTIVATE.getName())) {
        if (((INode) getModel()).isActivate()) {
            ((NodeFigure) figure).setDummy(((Node) getModel()).isDummy());
            ((NodeFigure) figure).setAlpha(-1);
            ((NodeFigure) figure).repaint();
            refreshVisuals();
        } else {
            ((NodeFigure) figure).setDummy(((Node) getModel()).isDummy());
            ((NodeFigure) figure).setAlpha(Node.ALPHA_VALUE);
            ((NodeFigure) figure).repaint();
            refreshVisuals();
        }
    } else if (changeEvent.getPropertyName().equals(EParameterName.DUMMY.getName())) {
        if (((INode) getModel()).isActivate()) {
            ((NodeFigure) figure).setDummy(((Node) getModel()).isDummy());
            ((NodeFigure) figure).setAlpha(-1);
        } else {
            ((NodeFigure) figure).setDummy(((Node) getModel()).isDummy());
            ((NodeFigure) figure).setAlpha(Node.ALPHA_VALUE);
        }
        ((NodeFigure) figure).repaint();
        refreshVisuals();
    } else if (changeEvent.getPropertyName().equals(EParameterName.START.getName())) {
        if (((INode) getModel()).isStart()) {
            ((NodeFigure) figure).setStart(true);
            ((NodeFigure) figure).repaint();
            refreshVisuals();
        } else {
            ((NodeFigure) figure).setStart(false);
            ((NodeFigure) figure).repaint();
            refreshVisuals();
        }
    } else if (changeEvent.getPropertyName().equals(EParameterName.HINT.getName())) {
        if (((Node) getModel()).isSetShowHint()) {
            ((NodeFigure) figure).setHint(((Node) getModel()).getShowHintText());
        } else {
            //$NON-NLS-1$ 
            ((NodeFigure) figure).setHint("");
        }
        needUpdateSubjob = true;
    } else if (changeEvent.getPropertyName().equals(EParameterName.CONNECTION_FORMAT.getName())) {
        Node node = (Node) getModel();
        for (IConnection conn : ((Node) getModel()).getOutgoingConnections()) {
            String connIdName = null;
            String oldName = conn.getUniqueName();
            if (conn instanceof Connection && conn.getLineStyle().hasConnectionCategory(IConnectionCategory.FLOW)) {
                node.getProcess().removeUniqueConnectionName(oldName);
                if (node.getProcess().checkValidConnectionName(node.getConnectionName(), false)) {
                    connIdName = node.getProcess().generateUniqueConnectionName(node.getConnectionName());
                } else {
                    //$NON-NLS-1$
                    connIdName = node.getProcess().generateUniqueConnectionName("row");
                }
                if (node.getProcess().checkValidConnectionName(connIdName)) {
                    ((Connection) conn).setUniqueName(connIdName);
                    node.getProcess().addUniqueConnectionName(connIdName);
                    ((Connection) conn).setName(connIdName);
                } else {
                    node.getProcess().addUniqueConnectionName(oldName);
                }
            }
        }
    } else if (changeEvent.getPropertyName().equals(EParameterName.REPAINT.getName())) {
        ((NodeFigure) figure).repaint();
        refreshVisuals();
        EditPart parentPart = getParent();
        if (parentPart != null) {
            parentPart.refresh();
        }
        needUpdateSubjob = true;
    }
    if (needUpdateSubjob) {
        EditPart editPart = getParent();
        if (editPart != null) {
            while ((!(editPart instanceof ProcessPart)) && (!(editPart instanceof SubjobContainerPart))) {
                editPart = editPart.getParent();
            }
            if (editPart instanceof SubjobContainerPart) {
                editPart.refresh();
            }
        }
    }
}
Also used : INode(org.talend.core.model.process.INode) IExternalNode(org.talend.core.model.process.IExternalNode) INode(org.talend.core.model.process.INode) IGraphicalNode(org.talend.core.ui.process.IGraphicalNode) Connection(org.talend.designer.core.ui.editor.connections.Connection) IConnection(org.talend.core.model.process.IConnection) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) RootEditPart(org.eclipse.gef.RootEditPart) ConnectionEditPart(org.eclipse.gef.ConnectionEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) NodeEditPart(org.eclipse.gef.NodeEditPart) IConnection(org.talend.core.model.process.IConnection) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)

Example 100 with EditPart

use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.

the class ProcessTreeEditPart method refreshChildren.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.editparts.AbstractEditPart#refreshChildren()
     */
@SuppressWarnings("unchecked")
@Override
protected void refreshChildren() {
    Map modelToEditPart = new HashMap();
    List children = getChildren();
    int i;
    for (i = 0; i < children.size(); i++) {
        EditPart editPart = (EditPart) children.get(i);
        modelToEditPart.put(editPart.getModel(), editPart);
    }
    List modelObjects = getModelChildren();
    // sort model for Outline
    Collections.sort(modelObjects, new Comparator<Node>() {

        @Override
        public int compare(Node o1, Node o2) {
            return StringUtils.compareStringDigit(o1.getUniqueName(), o2.getUniqueName());
        }
    });
    for (i = 0; i < modelObjects.size(); i++) {
        Object model = modelObjects.get(i);
        if (i >= children.size() || ((EditPart) children.get(i)).getModel() != model) {
            EditPart editPart = (EditPart) modelToEditPart.get(model);
            if (editPart != null) {
                reorderChild(editPart, i);
            } else {
                editPart = createChild(model);
                addChild(editPart, i);
            }
        }
    }
    List trash = new ArrayList();
    for (; i < children.size(); i++) {
        trash.add(children.get(i));
    }
    for (i = 0; i < trash.size(); i++) {
        EditPart ep = (EditPart) trash.get(i);
        removeChild(ep);
    }
}
Also used : HashMap(java.util.HashMap) Node(org.talend.designer.core.ui.editor.nodes.Node) AbstractTreeEditPart(org.eclipse.gef.editparts.AbstractTreeEditPart) EditPart(org.eclipse.gef.EditPart) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

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