Search in sources :

Example 6 with ConnLabelEditPart

use of org.talend.designer.core.ui.editor.connections.ConnLabelEditPart in project tdi-studio-se by Talend.

the class AbstractTraceAction method run.

@Override
public void run() {
    List selection = getSelectedObjects();
    Object input = selection.get(0);
    if (input instanceof ConnectionPart) {
        ConnectionPart connPart = (ConnectionPart) input;
        List childParts = connPart.getChildren();
        for (Object part : childParts) {
            if (part != null && part instanceof ConnectionTraceEditPart) {
                ConnectionTraceEditPart tracePart = (ConnectionTraceEditPart) part;
                Connection conn = (Connection) connPart.getModel();
                execute(new PropertyChangeCommand(conn, EParameterName.TRACES_CONNECTION_ENABLE.getName(), isEnableAction()));
                tracePart.refresh();
                break;
            }
        }
    }
    if (input instanceof ConnLabelEditPart) {
        ConnLabelEditPart labelPart = (ConnLabelEditPart) input;
        ConnectionPart connPart = (ConnectionPart) labelPart.getParent();
        List childParts = connPart.getChildren();
        for (Object part : childParts) {
            if (part != null && part instanceof ConnectionTraceEditPart) {
                ConnectionTraceEditPart tracePart = (ConnectionTraceEditPart) part;
                Connection conn = (Connection) connPart.getModel();
                execute(new PropertyChangeCommand(conn, EParameterName.TRACES_CONNECTION_ENABLE.getName(), isEnableAction()));
                tracePart.refresh();
                break;
            }
        }
    }
    if (input instanceof ConnectionTraceEditPart) {
        ConnectionTraceEditPart tracePart = (ConnectionTraceEditPart) input;
        ConnectionPart connPart = (ConnectionPart) tracePart.getParent();
        Connection conn = (Connection) connPart.getModel();
        execute(new PropertyChangeCommand(conn, EParameterName.TRACES_CONNECTION_ENABLE.getName(), isEnableAction()));
        tracePart.refresh();
    }
}
Also used : ConnectionTraceEditPart(org.talend.designer.core.ui.editor.connections.ConnectionTraceEditPart) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) Connection(org.talend.designer.core.ui.editor.connections.Connection) List(java.util.List) ConnectionPart(org.talend.designer.core.ui.editor.connections.ConnectionPart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)

Example 7 with ConnLabelEditPart

use of org.talend.designer.core.ui.editor.connections.ConnLabelEditPart in project tdi-studio-se by Talend.

the class ActivateElementAction method canPerformAction.

/**
     * Test if the selected item is a node.
     * 
     * @return true / false
     */
private boolean canPerformAction() {
    if (getSelectedObjects().isEmpty()) {
        return false;
    }
    List parts = getSelectedObjects();
    if (parts.size() >= 1) {
        Object o = parts.get(0);
        nodeList = new ArrayList<Node>();
        for (int i = 0; i < parts.size(); i++) {
            if (parts.get(i) instanceof NodePart) {
                Node node = ((Node) ((NodePart) parts.get(i)).getModel());
                if ((!node.isReadOnly()) && (node.getPropertyValue(EParameterName.ACTIVATE.getName()) != null)) {
                    nodeList.add(node);
                }
            }
        }
        connectionList = new ArrayList<Connection>();
        for (int i = 0; i < parts.size(); i++) {
            if (parts.get(i) instanceof ConnectionPart) {
                Connection connection = ((Connection) ((ConnectionPart) parts.get(i)).getModel());
                if (!connection.isReadOnly() && connection.getSource().isActivate() && connection.getTarget().isActivate()) {
                    connectionList.add(connection);
                }
            }
            if (parts.get(i) instanceof ConnLabelEditPart) {
                Connection connection = ((ConnectionLabel) ((ConnLabelEditPart) parts.get(i)).getModel()).getConnection();
                if (!connection.isReadOnly() && connection.getSource().isActivate() && connection.getTarget().isActivate()) {
                    connectionList.add(connection);
                }
            }
        }
        if ((nodeList.size() == 0) && (connectionList.size() == 0)) {
            return false;
        }
        for (Node node : nodeList) {
            if (node.getJobletNode() != null) {
                return false;
            }
        }
        for (Connection conn : connectionList) {
            if (conn.getTarget().getJobletNode() != null && conn.getSource().getJobletNode() != null) {
                return false;
            }
        }
        if (nodeList.size() != 0) {
            if (nodeList.get(0).isActivate()) {
                if (nodeList.size() == 1) {
                    //$NON-NLS-1$
                    setText(TEXT_REM_ACTIVATE + " " + nodeList.get(0).getLabel());
                } else {
                    setText(TEXT_REM_ACTIVATE);
                }
            } else {
                if (nodeList.size() == 1) {
                    //$NON-NLS-1$
                    setText(TEXT_SET_ACTIVATE + " " + nodeList.get(0).getLabel());
                } else {
                    setText(TEXT_SET_ACTIVATE);
                }
                activate = true;
            }
        } else {
            // connections only
            if (connectionList.get(0).isActivate()) {
                if (connectionList.size() == 1) {
                    //$NON-NLS-1$
                    setText(TEXT_REM_ACTIVATE + " " + connectionList.get(0).getName());
                } else {
                    setText(TEXT_REM_ACTIVATE);
                }
            } else {
                if (connectionList.size() == 1) {
                    //$NON-NLS-1$
                    setText(TEXT_SET_ACTIVATE + " " + connectionList.get(0).getName());
                } else {
                    setText(TEXT_SET_ACTIVATE);
                }
                activate = true;
            }
        }
        return true;
    }
    return false;
}
Also used : Node(org.talend.designer.core.ui.editor.nodes.Node) Connection(org.talend.designer.core.ui.editor.connections.Connection) ArrayList(java.util.ArrayList) List(java.util.List) ConnectionPart(org.talend.designer.core.ui.editor.connections.ConnectionPart) ConnectionLabel(org.talend.designer.core.ui.editor.connections.ConnectionLabel) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)

Example 8 with ConnLabelEditPart

use of org.talend.designer.core.ui.editor.connections.ConnLabelEditPart in project tdi-studio-se by Talend.

the class GefEditorLabelProvider method getImage.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
     */
public Image getImage(Object objects) {
    Node node = null;
    if (objects == null || objects.equals(StructuredSelection.EMPTY)) {
        return null;
    }
    if (!(objects instanceof IStructuredSelection)) {
        return null;
    }
    final boolean[] multiple = { false };
    Object object = getObject(objects, multiple);
    if (object == null) {
        return null;
    }
    if ((object instanceof NodeTreeEditPart)) {
        node = (Node) ((NodeTreeEditPart) object).getModel();
    } else {
        if (object instanceof NodeReturnsTreeEditPart) {
            node = lastNode;
        } else {
            if (object instanceof ProcessPart) {
                return ImageProvider.getImage(ECoreImage.PROCESS_ICON);
            }
            if (object instanceof ConnectionPart) {
                return ImageProvider.getImage(EImage.RIGHT_ICON);
            }
            if (object instanceof NoteEditPart) {
                return ImageProvider.getImage(ECoreImage.CODE_ICON);
            }
            if (object instanceof ConnLabelEditPart) {
                return ImageProvider.getImage(EImage.RIGHT_ICON);
            }
            if ((object instanceof NodeLabelEditPart)) {
                node = ((NodeContainer) ((NodeLabelEditPart) object).getParent().getModel()).getNode();
            }
            if (!(object instanceof NodePart)) {
                return null;
            }
            if (node == null) {
                node = (Node) ((NodePart) object).getModel();
            }
        }
    }
    if (lastNode != node) {
        lastNode = node;
    }
    return CoreImageProvider.getComponentIcon(node.getComponent(), ICON_SIZE.ICON_24);
}
Also used : NodeTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeTreeEditPart) Node(org.talend.designer.core.ui.editor.nodes.Node) NodeReturnsTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeReturnsTreeEditPart) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) NodeLabelEditPart(org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) ConnectionPart(org.talend.designer.core.ui.editor.connections.ConnectionPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)

Example 9 with ConnLabelEditPart

use of org.talend.designer.core.ui.editor.connections.ConnLabelEditPart in project tdi-studio-se by Talend.

the class GefEditorLabelProvider method getText.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
     */
public String getText(Object objects) {
    Node node = null;
    if (objects == null || objects.equals(StructuredSelection.EMPTY)) {
        //$NON-NLS-1$
        return "No items selected";
    }
    if (!(objects instanceof IStructuredSelection)) {
        return null;
    }
    final boolean[] multiple = { false };
    Object object = getObject(objects, multiple);
    if (object == null) /* || ((IStructuredSelection) objects).size() > 1 */
    {
        //$NON-NLS-1$
        return "No items selected";
    } else {
        if (object instanceof NodeContainerPart) {
            NodeContainerPart nContainer = (NodeContainerPart) object;
            Process process = (Process) nContainer.getParent().getModel();
            return process.getName();
        } else if (object instanceof ProcessPart) {
            Process process = (Process) ((ProcessPart) object).getModel();
            return process.getLabel();
        } else if (object instanceof ProcessTreeEditPart) {
            Process process = (Process) ((ProcessTreeEditPart) object).getModel();
            return process.getName();
        }
        if (object instanceof ConnectionPart) {
            Connection conn = (Connection) ((ConnectionPart) object).getModel();
            return conn.getName();
        }
        if (object instanceof NoteEditPart) {
            return Note.class.getSimpleName();
        }
        if (object instanceof ConnLabelEditPart) {
            Connection conn = (Connection) ((ConnectionLabel) ((ConnLabelEditPart) object).getModel()).getConnection();
            return conn.getName();
        }
        if (object instanceof NodeTreeEditPart) {
            node = (Node) ((NodeTreeEditPart) object).getModel();
        } else {
            if (object instanceof NodeReturnsTreeEditPart) {
                node = lastNode;
            } else {
                if (object instanceof NodeLabelEditPart) {
                    node = ((NodeContainer) ((NodeLabelEditPart) object).getParent().getModel()).getNode();
                }
                if (!(object instanceof NodePart)) {
                    return null;
                }
                if (node == null) {
                    node = (Node) ((NodePart) object).getModel();
                }
            }
        }
        if (lastNode != node) {
            lastNode = node;
        }
        String name = node.getUniqueName();
        // }
        return name;
    }
}
Also used : NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) NodeTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeTreeEditPart) Node(org.talend.designer.core.ui.editor.nodes.Node) Connection(org.talend.designer.core.ui.editor.connections.Connection) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) NodeLabelEditPart(org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart) Process(org.talend.designer.core.ui.editor.process.Process) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ConnectionPart(org.talend.designer.core.ui.editor.connections.ConnectionPart) ProcessTreeEditPart(org.talend.designer.core.ui.editor.outline.ProcessTreeEditPart) NodeReturnsTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeReturnsTreeEditPart) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)

Example 10 with ConnLabelEditPart

use of org.talend.designer.core.ui.editor.connections.ConnLabelEditPart in project tdi-studio-se by Talend.

the class TalendEditorComponentCreationAssist method highlightOveredConnection.

private void highlightOveredConnection(org.eclipse.swt.graphics.Point cursorRelativePosition) {
    if (overedConnection != null) {
        overedConnection.setLineWidth(1);
        overedConnection = null;
    }
    EditPart findObjectAt = graphicViewer.findObjectAt(new Point(cursorRelativePosition.x, cursorRelativePosition.y));
    if (findObjectAt instanceof ConnectionPart) {
        overedConnection = (ConnectionFigure) ((ConnectionPart) findObjectAt).getFigure();
    } else if (findObjectAt instanceof ConnLabelEditPart) {
        overedConnection = (ConnectionFigure) ((ConnectionPart) ((ConnLabelEditPart) findObjectAt).getParent()).getFigure();
    }
    if (overedConnection != null) {
        overedConnection.setLineWidth(2);
    }
}
Also used : ConnectionFigure(org.talend.designer.core.ui.editor.connections.ConnectionFigure) EditPart(org.eclipse.gef.EditPart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart) Point(org.eclipse.draw2d.geometry.Point) ConnectionPart(org.talend.designer.core.ui.editor.connections.ConnectionPart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)

Aggregations

ConnLabelEditPart (org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)20 ConnectionPart (org.talend.designer.core.ui.editor.connections.ConnectionPart)16 List (java.util.List)15 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)12 NoteEditPart (org.talend.designer.core.ui.editor.notes.NoteEditPart)10 Connection (org.talend.designer.core.ui.editor.connections.Connection)9 Node (org.talend.designer.core.ui.editor.nodes.Node)8 NodeLabelEditPart (org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart)8 ArrayList (java.util.ArrayList)7 EditPart (org.eclipse.gef.EditPart)7 SubjobContainerPart (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)7 ProcessPart (org.talend.designer.core.ui.editor.process.ProcessPart)6 Clipboard (org.eclipse.gef.ui.actions.Clipboard)4 ConnectionTraceEditPart (org.talend.designer.core.ui.editor.connections.ConnectionTraceEditPart)4 NodeContainerPart (org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 Text (org.eclipse.swt.widgets.Text)3 IElementParameter (org.talend.core.model.process.IElementParameter)3 INode (org.talend.core.model.process.INode)3 AbstractProcessProvider (org.talend.designer.core.model.process.AbstractProcessProvider)3