Search in sources :

Example 21 with SubjobContainerPart

use of org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart 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 22 with SubjobContainerPart

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

the class NodePartKeyHander method navigateTo.

@Override
protected void navigateTo(EditPart part, KeyEvent event) {
    // PTODO need be removed
    SubjobContainerPart subPart = null;
    NoteEditPart noPart = null;
    boolean displayVa = true;
    if (part instanceof SubjobContainerPart) {
        // NodeContainerPart
        SubjobContainerPart focusPart = (SubjobContainerPart) part;
        List subList = focusPart.getParent().getChildren();
        for (int j = 0; j < subList.size(); j++) {
            if (subList.get(j) instanceof SubjobContainerPart) {
                subPart = (SubjobContainerPart) subList.get(j);
                SubjobContainer subContainer = (SubjobContainer) subPart.getModel();
                if (subContainer.isDisplayed() == false) {
                    displayVa = false;
                }
            } else if (subList.get(j) instanceof NoteEditPart) {
                displayVa = false;
            }
        }
        if (displayVa == false) {
            part = (EditPart) part.getChildren().get(0);
            if (part != null) {
                // NodePart
                part = (EditPart) part.getChildren().get(0);
            }
            if (part == null) {
                return;
            }
        }
    }
    super.navigateTo(part, event);
}
Also used : SubjobContainer(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) List(java.util.List) ArrayList(java.util.ArrayList) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)

Example 23 with SubjobContainerPart

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

use of org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart 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)

Example 25 with SubjobContainerPart

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

the class ComponentChooseDialog method dragOver.

@Override
public void dragOver(DropTargetEvent event) {
    // multi-drag for job,context, sqlPattern.
    IStructuredSelection selection = getSelection();
    if (selection.size() > 1) {
        boolean allowed = true;
        Item temItem = null;
        Iterator iter = selection.iterator();
        while (iter.hasNext()) {
            Object next = iter.next();
            if (next instanceof RepositoryNode) {
                RepositoryNode sourceNode = (RepositoryNode) next;
                IRepositoryViewObject object = sourceNode.getObject();
                if (object != null) {
                    Item selectItem = object.getProperty().getItem();
                    if (temItem == null) {
                        temItem = selectItem;
                        continue;
                    }
                    if (selectItem instanceof ProcessItem && !(temItem instanceof ProcessItem)) {
                        allowed = false;
                    } else if (selectItem instanceof ContextItem && !(temItem instanceof ContextItem)) {
                        allowed = false;
                    } else if (selectItem instanceof SQLPatternItem && !(temItem instanceof SQLPatternItem)) {
                        allowed = false;
                    }
                }
            }
        }
        if (!allowed) {
            event.detail = DND.DROP_NONE;
        }
    } else {
        CreateRequest req = ((CreateRequest) getTargetRequest());
        Object o = null;
        try {
            o = req.getNewObject();
        } catch (Exception e) {
            return;
        }
        if (!(o instanceof Node)) {
            return;
        }
        RootEditPart rep = editor.getViewer().getRootEditPart().getRoot();
        Point viewOriginalPosition = new Point();
        if (rep instanceof ScalableFreeformRootEditPart) {
            ScalableFreeformRootEditPart root = (ScalableFreeformRootEditPart) rep;
            Viewport viewport = (Viewport) root.getFigure();
            viewOriginalPosition = viewport.getViewLocation();
        }
        org.eclipse.swt.graphics.Point swtLocation = new org.eclipse.swt.graphics.Point(event.x + viewOriginalPosition.x, event.y + viewOriginalPosition.y);
        Canvas canvas = (Canvas) editor.getViewer().getControl();
        swtLocation = canvas.toControl(swtLocation);
        // System.out.println("topLeft:" + topLeftpoint + " / event:" + swtLocation);
        org.eclipse.draw2d.geometry.Point draw2dPosition = new org.eclipse.draw2d.geometry.Point(swtLocation.x, swtLocation.y);
        double zoom = 1.0;
        if (editor.getViewer().getRootEditPart() instanceof TalendScalableFreeformRootEditPart) {
            ZoomManager zoomManager = ((TalendScalableFreeformRootEditPart) editor.getViewer().getRootEditPart()).getZoomManager();
            zoom = zoomManager.getZoom();
        }
        List<ConnectionPart> connectionParts = CreateComponentOnLinkHelper.getConnectionParts(editor.getProcessPart(), draw2dPosition, (Node) o);
        double minDistance = 1000000000;
        for (ConnectionPart part : connectionParts) {
            if (part.getFigure() instanceof PolylineConnection) {
                PolylineConnection connection = (PolylineConnection) part.getFigure();
                double distance = CreateComponentOnLinkHelper.getDistanceOrthogonal(draw2dPosition.x, draw2dPosition.y, connection, zoom);
                if (distance < minDistance) {
                    selectedConnectionPart = part;
                    minDistance = Math.min(distance, minDistance);
                }
            }
        }
        if (selectedConnectionPart != null && minDistance < 15) {
            for (Object child : editor.getProcessPart().getChildren()) {
                if (child instanceof SubjobContainerPart) {
                    CreateComponentOnLinkHelper.unselectAllConnections((SubjobContainerPart) child);
                }
            }
            CreateComponentOnLinkHelper.selectConnection(selectedConnectionPart);
        } else {
            if (selectedConnectionPart != null) {
                CreateComponentOnLinkHelper.unselectConnection(selectedConnectionPart);
            }
            selectedConnectionPart = null;
        }
    }
}
Also used : ContextItem(org.talend.core.model.properties.ContextItem) CreateRequest(org.eclipse.gef.requests.CreateRequest) INode(org.talend.core.model.process.INode) RepositoryNode(org.talend.repository.model.RepositoryNode) HL7FileNode(org.talend.core.model.metadata.builder.connection.HL7FileNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Node(org.talend.designer.core.ui.editor.nodes.Node) IExternalNode(org.talend.core.model.process.IExternalNode) XMLFileNode(org.talend.core.model.metadata.builder.connection.XMLFileNode) MapperExternalNode(org.talend.core.model.process.node.MapperExternalNode) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) ValidationRulesConnectionItem(org.talend.core.model.properties.ValidationRulesConnectionItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) MDMConnectionItem(org.talend.core.model.properties.MDMConnectionItem) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) LinkRulesItem(org.talend.core.model.properties.LinkRulesItem) SAPConnectionItem(org.talend.core.model.properties.SAPConnectionItem) ProcessItem(org.talend.core.model.properties.ProcessItem) ContextItem(org.talend.core.model.properties.ContextItem) Item(org.talend.core.model.properties.Item) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) EbcdicConnectionItem(org.talend.core.model.properties.EbcdicConnectionItem) RulesItem(org.talend.core.model.properties.RulesItem) HL7ConnectionItem(org.talend.core.model.properties.HL7ConnectionItem) FileItem(org.talend.core.model.properties.FileItem) Iterator(java.util.Iterator) Point(org.eclipse.draw2d.geometry.Point) Canvas(org.eclipse.swt.widgets.Canvas) Viewport(org.eclipse.draw2d.Viewport) Point(org.eclipse.draw2d.geometry.Point) ConnectionPart(org.talend.designer.core.ui.editor.connections.ConnectionPart) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) PersistenceException(org.talend.commons.exception.PersistenceException) PolylineConnection(org.eclipse.draw2d.PolylineConnection) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) TalendScalableFreeformRootEditPart(org.talend.designer.core.ui.editor.TalendScalableFreeformRootEditPart) ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart) TalendScalableFreeformRootEditPart(org.talend.designer.core.ui.editor.TalendScalableFreeformRootEditPart) ZoomManager(org.eclipse.gef.editparts.ZoomManager) AnimatableZoomManager(org.talend.commons.ui.gmf.draw2d.AnimatableZoomManager) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) SAPFunctionRepositoryObject(org.talend.core.repository.model.repositoryObject.SAPFunctionRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) QueryRepositoryObject(org.talend.core.repository.model.repositoryObject.QueryRepositoryObject) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) SalesforceModuleRepositoryObject(org.talend.core.repository.model.repositoryObject.SalesforceModuleRepositoryObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) SAPIDocRepositoryObject(org.talend.core.repository.model.repositoryObject.SAPIDocRepositoryObject) TalendScalableFreeformRootEditPart(org.talend.designer.core.ui.editor.TalendScalableFreeformRootEditPart) RootEditPart(org.eclipse.gef.RootEditPart) ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart)

Aggregations

SubjobContainerPart (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)34 List (java.util.List)23 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)23 Node (org.talend.designer.core.ui.editor.nodes.Node)19 ArrayList (java.util.ArrayList)18 EditPart (org.eclipse.gef.EditPart)18 ProcessPart (org.talend.designer.core.ui.editor.process.ProcessPart)15 NodeContainerPart (org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart)14 NoteEditPart (org.talend.designer.core.ui.editor.notes.NoteEditPart)13 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)12 SubjobContainer (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer)10 ConnLabelEditPart (org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)8 ConnectionPart (org.talend.designer.core.ui.editor.connections.ConnectionPart)7 NodeLabelEditPart (org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart)7 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)6 IExternalNode (org.talend.core.model.process.IExternalNode)6 INode (org.talend.core.model.process.INode)6 JobletContainerPart (org.talend.designer.core.ui.editor.jobletcontainer.JobletContainerPart)6 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)5 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)5