Search in sources :

Example 21 with ProcessPart

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

the class TalendBorderItemRectilinearRouter method manualHorizontalScrolBarCase.

private boolean manualHorizontalScrolBarCase(Connection conn) {
    PointList points = conn.getPoints();
    Point start = getStartPoint(conn);
    Point end = getEndPoint(conn);
    boolean handle = false;
    boolean processHandle = false;
    if ((request != null) && (request instanceof CreateConnectionRequest)) {
        start = conn.getSourceAnchor().getReferencePoint();
        CreateConnectionRequest createRequest = (CreateConnectionRequest) request;
        if (createRequest.getTargetEditPart() != null && createRequest.getTargetEditPart() != createRequest.getSourceEditPart() && createRequest.getTargetEditPart().getModel() instanceof Node) {
            PointList pointList = new PointList();
            conn.translateToRelative(start);
            pointList.addPoint(start);
            Point targetPoint = conn.getTargetAnchor().getReferencePoint();
            conn.translateToRelative(targetPoint);
            pointList.addPoint(targetPoint);
            conn.setPoints(pointList);
            handle = true;
        } else if (createRequest.getTargetEditPart() != null && createRequest.getTargetEditPart() != createRequest.getSourceEditPart() && createRequest.getTargetEditPart() instanceof ProcessPart) {
            processHandle = true;
        }
    }
    if (conn instanceof ConnectionFigure) {
        IConnection connection = ((ConnectionFigure) conn).getConnection();
        EConnectionType lineStyle = connection.getLineStyle();
        EConnectionCategory category = lineStyle.getCategory();
        if (category == EConnectionCategory.OTHER && (lineStyle == EConnectionType.ON_COMPONENT_ERROR || lineStyle == EConnectionType.ON_COMPONENT_OK || lineStyle == EConnectionType.ON_SUBJOB_ERROR || lineStyle == EConnectionType.ON_SUBJOB_OK || lineStyle == EConnectionType.RUN_IF)) {
            return handle || processHandle;
        }
    }
    if (!handle) {
        conn.translateToRelative(start);
        points.setPoint(start, 0);
        conn.translateToRelative(end);
        points.setPoint(end, points.size() - 1);
        conn.setPoints(points);
    }
    return handle || processHandle;
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList) Node(org.talend.designer.core.ui.editor.nodes.Node) IConnection(org.talend.core.model.process.IConnection) EConnectionCategory(org.talend.core.model.process.EConnectionCategory) Point(org.eclipse.draw2d.geometry.Point) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) CreateConnectionRequest(org.eclipse.gef.requests.CreateConnectionRequest) EConnectionType(org.talend.core.model.process.EConnectionType)

Example 22 with ProcessPart

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

the class AbstractMultiPageTalendEditor method selectNode.

/**
     * DOC bqian Comment method "selectNode".
     * 
     * @param node
     */
@SuppressWarnings("unchecked")
public void selectNode(String nodeName) {
    GraphicalViewer viewer = designerEditor.getViewer();
    Object object = viewer.getRootEditPart().getChildren().get(0);
    if (object instanceof ProcessPart) {
        // ProcessPart < SubjobContainerPart < NodeContainerPart < NodePart
        for (EditPart editPart : (List<EditPart>) ((ProcessPart) object).getChildren()) {
            if (editPart instanceof SubjobContainerPart) {
                SubjobContainerPart subjobPart = (SubjobContainerPart) editPart;
                for (EditPart part : (List<EditPart>) subjobPart.getChildren()) {
                    if (part instanceof NodeContainerPart) {
                        EditPart nodePart = (EditPart) part.getChildren().get(0);
                        if (nodePart instanceof NodePart) {
                            if (((Node) ((NodePart) nodePart).getModel()).getLabel().equals(nodeName)) {
                                viewer.select(nodePart);
                                return;
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : GraphicalViewer(org.eclipse.gef.GraphicalViewer) NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) 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) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Example 23 with ProcessPart

use of org.talend.designer.core.ui.editor.process.ProcessPart 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 24 with ProcessPart

use of org.talend.designer.core.ui.editor.process.ProcessPart 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 25 with ProcessPart

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

the class NodeProgressBarPart method propertyChange.

/*
     * (non-Javadoc)
     * 
     * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
     */
public void propertyChange(final PropertyChangeEvent evt) {
    String request = evt.getPropertyName();
    Double extent = new Double(0);
    if (evt.getNewValue() instanceof Double) {
        extent = (Double) evt.getNewValue();
    }
    if (request.equals("UPDATE_STATUS")) {
        //$NON-NLS-1$
        NodeProgressBarFigure figure = (NodeProgressBarFigure) this.getFigure();
        Node node = ((NodeContainer) ((NodeContainerPart) getParent()).getModel()).getNode();
        // figure.updateVisible(true);
        figure.setProgressData(extent);
        ((NodeProgressBar) getModel()).setProgressSize((figure).getSize());
        refreshVisuals();
    }
    if (request.equals(NodeProgressBar.LOCATION)) {
        //$NON-NLS-1$
        refreshVisuals();
        getParent().refresh();
    }
    if (request.equals(EParameterName.ACTIVATE.getName())) {
        if (((NodeProgressBar) getModel()).isActivate()) {
            ((NodeProgressBarFigure) figure).setAlpha(-1);
            ((NodeProgressBarFigure) figure).repaint();
            refreshVisuals();
        } else {
            ((NodeProgressBarFigure) figure).setAlpha(Node.ALPHA_VALUE);
            ((NodeProgressBarFigure) figure).repaint();
            refreshVisuals();
        }
    }
    EditPart editPart = getParent();
    if (editPart != null) {
        while ((!(editPart instanceof ProcessPart)) && (!(editPart instanceof SubjobContainerPart))) {
            editPart = editPart.getParent();
        }
        if (editPart instanceof SubjobContainerPart) {
            editPart.refresh();
        }
    }
}
Also used : AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)

Aggregations

ProcessPart (org.talend.designer.core.ui.editor.process.ProcessPart)29 EditPart (org.eclipse.gef.EditPart)19 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)17 List (java.util.List)15 SubjobContainerPart (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)15 ArrayList (java.util.ArrayList)13 Node (org.talend.designer.core.ui.editor.nodes.Node)12 NodeContainerPart (org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart)9 NoteEditPart (org.talend.designer.core.ui.editor.notes.NoteEditPart)9 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)8 NodeLabelEditPart (org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart)8 GraphicalViewer (org.eclipse.gef.GraphicalViewer)7 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)7 ConnLabelEditPart (org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)7 ConnectionPart (org.talend.designer.core.ui.editor.connections.ConnectionPart)7 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)6 INode (org.talend.core.model.process.INode)6 Process (org.talend.designer.core.ui.editor.process.Process)6 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)5 NodeTreeEditPart (org.talend.designer.core.ui.editor.outline.NodeTreeEditPart)5