Search in sources :

Example 1 with NodeContainer

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

the class JobletContainerPart method propertyChange.

/*
     * (non-Javadoc)
     * 
     * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
     */
@Override
public void propertyChange(PropertyChangeEvent changeEvent) {
    String prop = changeEvent.getPropertyName();
    boolean needUpdateSubjob = false;
    if (prop.equals(EParameterName.HINT.getName())) {
        Node node = ((NodeContainer) getModel()).getNode();
    // ((JobletContainerFigure) figure).setInfoHint(node.getShowHintText());
    } else if (JobletContainer.UPDATE_JOBLET_CONTENT.equals(prop)) {
        refresh();
        List<AbstractGraphicalEditPart> childrens = getChildren();
        for (AbstractGraphicalEditPart part : childrens) {
            part.refresh();
        }
        needUpdateSubjob = true;
    } else if (JobletContainer.UPDATE_JOBLET_CONNECTIONS.equals(prop)) {
        refreshSourceConnections();
    } else if (JobletContainer.UPDATE_JOBLET_TITLE_COLOR.equals(prop)) {
        if (getFigure() instanceof JobletContainerFigure) {
            ((JobletContainerFigure) getFigure()).updateJobletContainerColor();
            refreshVisuals();
        }
    } else if (JobletContainer.UPDATE_JOBLET_DISPLAY.equals(prop)) {
        if (getFigure() instanceof JobletContainerFigure) {
            ((JobletContainerFigure) getFigure()).updateJobletContainerColor();
            refreshVisuals();
        }
        needUpdateSubjob = true;
    } else if (changeEvent.getPropertyName().equals("UPDATE_STATUS")) {
        // ((JobletContainer) getModel()).updateJobletNodes(true);
        if (getFigure() instanceof JobletContainerFigure) {
            String newValue = (String) changeEvent.getNewValue();
            if (newValue != null && newValue.equals("CLEAR")) {
                ((JobletContainerFigure) getFigure()).refreshNodes(true);
            } else {
                ((JobletContainerFigure) getFigure()).refreshNodes(false);
            }
            if (((JobletContainer) getModel()).getNode().isMapReduce()) {
                JobletContainer jCon = (JobletContainer) getModel();
                if (jCon.getNode().isMapReduceStart()) {
                    jCon.updateJobletNodes(true);
                    ((JobletContainerFigure) getFigure()).updateData();
                } else if (jCon.getMrStartContainer() != null) {
                    jCon.getMrStartContainer().updateJobletNodes(true);
                }
            }
        }
        refreshVisuals();
    } else if (changeEvent.getPropertyName().equals("UPDATE_MR_STATUS")) {
        if (getFigure() instanceof JobletContainerFigure) {
            ((JobletContainerFigure) getFigure()).refreshMRstatus();
        }
        refreshVisuals();
    } else {
        // can only be UPDATE_SUBJOB_DATA, need to modify if some others are added
        if (getFigure() instanceof JobletContainerFigure) {
            if (((JobletContainer) getModel()).getNode().isMapReduce()) {
                JobletContainer jCon = (JobletContainer) getModel();
                if (jCon.getNode().isMapReduceStart()) {
                    jCon.updateJobletNodes(true);
                } else if (jCon.getMrStartContainer() != null) {
                    jCon.getMrStartContainer().updateJobletNodes(true);
                }
            }
            ((JobletContainerFigure) getFigure()).updateData();
            refreshVisuals();
        }
    }
    if (changeEvent.getPropertyName().equals(EParameterName.ACTIVATE.getName())) {
        Node node = ((NodeContainer) getModel()).getNode();
        if (node.isActivate()) {
            // ((JobletContainerFigure) figure).setAlpha(-1);
            ((JobletContainerFigure) figure).repaint();
            refreshVisuals();
        } else {
            // ((JobletContainerFigure) figure).setAlpha(Node.ALPHA_VALUE);
            ((JobletContainerFigure) figure).repaint();
            refreshVisuals();
        }
    }
    if (changeEvent.getPropertyName().equals(Node.PERFORMANCE_DATA)) {
        refreshVisuals();
    }
    if (needUpdateSubjob) {
        EditPart editPart = getParent();
        if (editPart != null) {
            while ((!(editPart instanceof ProcessPart)) && (!(editPart instanceof SubjobContainerPart))) {
                editPart = editPart.getParent();
            }
            Node node = ((NodeContainer) getModel()).getNode();
            List<ISubjobContainer> proSubList = new ArrayList<ISubjobContainer>(((IProcess2) node.getProcess()).getSubjobContainers());
            if (editPart instanceof SubjobContainerPart) {
                // Node node = ((NodeContainer) getModel()).getNode();
                JobletContainer nc = (JobletContainer) this.getModel();
                // Rectangle rec = new Rectangle(node.getLocation(), node.getSize());
                boolean isCollapse = nc.isCollapsed() && !nc.getNode().isMapReduceStart();
                int rightChangewidth = nc.getRightChangeWidth();
                int downChangeheight = nc.getDownChangeHeight();
                int leftChangewidth = nc.getLeftChangeWidth();
                int upChangeheight = nc.getUpChangeHeight();
                if (nc.getNode().isJoblet()) {
                    if (editPart instanceof SubjobContainerPart) {
                        ((SubjobContainer) ((SubjobContainerPart) editPart).getModel()).refreshNodesLocation(isCollapse, nc, rightChangewidth, downChangeheight, leftChangewidth, upChangeheight);
                    }
                // for (ISubjobContainer sb : proSubList) {
                // ((SubjobContainer) sb).refreshNodesLocation(isCollapse, nc, rightChangewidth,
                // downChangeheight,
                // leftChangewidth, upChangeheight);
                // }
                }
                editPart.refresh();
            }
        }
    }
    if (changeEvent.getPropertyName().equals(Node.UPDATE_STATUS)) {
        Node node = ((NodeContainer) getModel()).getNode();
        if (node != null && node.isMapReduce()) {
            ((JobletContainerFigure) this.getFigure()).updateErrorFlag(node.isErrorFlag());
            ((JobletContainerFigure) this.getFigure()).setShowCompareMark(node.isCompareFlag() && !node.isErrorFlag());
            IElementParameter param = node.getElementParameter(EParameterName.INFORMATION.getName());
            if (param != null) {
                boolean showInfoFlag = Boolean.TRUE.equals(param.getValue());
                if (changeEvent.getNewValue() instanceof Integer) {
                    Integer status = (Integer) changeEvent.getNewValue();
                    if (status != null) {
                        ((JobletContainerFigure) this.getFigure()).updateStatus(status, showInfoFlag);
                    }
                    ((JobletContainerFigure) this.getFigure()).setInfoHint(node.getShowHintText());
                }
                refreshVisuals();
            }
        } else {
            ((JobletContainerFigure) getFigure()).updateStatus(node.getStatus());
        }
    }
}
Also used : Node(org.talend.designer.core.ui.editor.nodes.Node) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) TalendScalableFreeformRootEditPart(org.talend.designer.core.ui.editor.TalendScalableFreeformRootEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) ArrayList(java.util.ArrayList) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) ISubjobContainer(org.talend.core.model.process.ISubjobContainer) SubjobContainer(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer) ISubjobContainer(org.talend.core.model.process.ISubjobContainer) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) IElementParameter(org.talend.core.model.process.IElementParameter) ArrayList(java.util.ArrayList) List(java.util.List) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart)

Example 2 with NodeContainer

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

the class JobletUtil method getModifyMap.

public Map<String, List<AbstractJobletContainer>> getModifyMap(List<Element> elem) {
    Map<String, List<AbstractJobletContainer>> jobletNodeMap = new HashMap<String, List<AbstractJobletContainer>>();
    for (Element element : elem) {
        if (element instanceof SubjobContainer) {
            for (NodeContainer container : ((SubjobContainer) element).getNodeContainers()) {
                if (container instanceof AbstractJobletContainer) {
                    String processID = container.getNode().getProcess().getId();
                    if (!jobletNodeMap.containsKey(processID)) {
                        List<AbstractJobletContainer> nodeList = new ArrayList<AbstractJobletContainer>();
                        nodeList.add((AbstractJobletContainer) container);
                        jobletNodeMap.put(processID, nodeList);
                    } else {
                        jobletNodeMap.get(processID).add((AbstractJobletContainer) container);
                    }
                }
            }
        }
    }
    return jobletNodeMap;
}
Also used : HashMap(java.util.HashMap) SubjobContainer(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer) ISubjobContainer(org.talend.core.model.process.ISubjobContainer) Element(org.talend.core.model.process.Element) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)

Example 3 with NodeContainer

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

the class JobletUtil method getConnSubjob.

public List<SubjobContainer> getConnSubjob(SubjobContainer sub, List<ISubjobContainer> proSubList) {
    List<SubjobContainer> subList = new ArrayList<SubjobContainer>();
    if (!proSubList.contains(sub)) {
        return subList;
    }
    for (NodeContainer container : sub.getNodeContainers()) {
        List<IConnection> inList = new ArrayList<IConnection>();
        List<IConnection> outList = new ArrayList<IConnection>();
        if ((container instanceof AbstractJobletContainer)) {
            // && ((JobletContainer) container).isCollapsed()
            inList.addAll(((JobletContainer) container).getInputs());
            outList.addAll(((JobletContainer) container).getOutputs());
        } else {
            inList.addAll(container.getNode().getIncomingConnections());
            outList.addAll(container.getNode().getOutgoingConnections());
        }
        for (IConnection conn : inList) {
            INode source = conn.getSource();
            if (source instanceof Node) {
                SubjobContainer tem = ((Node) conn.getSource()).getNodeContainer().getSubjobContainer();
                if (tem != null && sub != tem) {
                    if (subList.contains(tem) || !proSubList.contains(tem)) {
                        continue;
                    }
                    subList.add(tem);
                    proSubList.remove(tem);
                    subList.addAll(getConnSubjob(tem, proSubList));
                }
            }
        }
        for (IConnection conn : outList) {
            INode target = conn.getTarget();
            if (target instanceof Node) {
                SubjobContainer tem = ((Node) conn.getTarget()).getNodeContainer().getSubjobContainer();
                if (tem != null && sub != tem) {
                    if (subList.contains(tem) || !proSubList.contains(tem)) {
                        continue;
                    }
                    subList.add(tem);
                    proSubList.remove(tem);
                    subList.addAll(getConnSubjob(tem, proSubList));
                }
            }
        }
    }
    return subList;
}
Also used : INode(org.talend.core.model.process.INode) SubjobContainer(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer) ISubjobContainer(org.talend.core.model.process.ISubjobContainer) Node(org.talend.designer.core.ui.editor.nodes.Node) IExternalNode(org.talend.core.model.process.IExternalNode) INode(org.talend.core.model.process.INode) JobletNode(org.talend.designer.joblet.model.JobletNode) ArrayList(java.util.ArrayList) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) IConnection(org.talend.core.model.process.IConnection)

Example 4 with NodeContainer

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

the class NodeErrorEditPart method refreshVisuals.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.editparts.AbstractEditPart#refreshVisuals()
     */
@Override
protected void refreshVisuals() {
    Node node = ((NodeContainer) ((NodeContainerPart) getParent()).getModel()).getNode();
    NodeLabel nodeLabel = node.getNodeLabel();
    NodeErrorFigure errorFig = (NodeErrorFigure) this.getFigure();
    Point loc = node.getLocation().getCopy();
    Dimension size = errorFig.getSize();
    loc.x = loc.x + (node.getSize().width - size.width) / 2;
    loc.y = loc.y + node.getSize().height + (nodeLabel.getLabelSize().height);
    Rectangle rectangle = new Rectangle(loc, size);
    ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), rectangle);
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart)

Example 5 with NodeContainer

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

the class NodeErrorEditPart method propertyChange.

/*
     * (non-Javadoc)
     * 
     * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
     */
public void propertyChange(final PropertyChangeEvent evt) {
    String request = evt.getPropertyName();
    if (request.equals("UPDATE_STATUS")) {
        //$NON-NLS-1$
        NodeErrorFigure figure = (NodeErrorFigure) this.getFigure();
        Node node = ((NodeContainer) ((NodeContainerPart) getParent()).getModel()).getNode();
        figure.updateVisible(node.isErrorFlag(), node.getErrorInfo());
        ((NodeError) getModel()).setErrorSize((figure).getSize());
        refreshVisuals();
    }
    if (request.equals(NodeError.LOCATION)) {
        //$NON-NLS-1$
        refreshVisuals();
        getParent().refresh();
    }
    if (request.equals(EParameterName.ACTIVATE.getName())) {
        if (((NodeError) getModel()).isActivate()) {
            ((NodeErrorFigure) figure).setAlpha(-1);
            ((NodeErrorFigure) figure).repaint();
            refreshVisuals();
        } else {
            ((NodeErrorFigure) figure).setAlpha(Node.ALPHA_VALUE);
            ((NodeErrorFigure) 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

NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)60 Node (org.talend.designer.core.ui.editor.nodes.Node)43 ArrayList (java.util.ArrayList)23 INode (org.talend.core.model.process.INode)23 List (java.util.List)20 Process (org.talend.designer.core.ui.editor.process.Process)20 Point (org.eclipse.draw2d.geometry.Point)17 IComponent (org.talend.core.model.components.IComponent)13 IConnection (org.talend.core.model.process.IConnection)12 SubjobContainerPart (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)12 Rectangle (org.eclipse.draw2d.geometry.Rectangle)11 IProcess (org.talend.core.model.process.IProcess)11 Connection (org.talend.designer.core.ui.editor.connections.Connection)11 IElementParameter (org.talend.core.model.process.IElementParameter)10 EditPart (org.eclipse.gef.EditPart)9 IExternalNode (org.talend.core.model.process.IExternalNode)9 IGraphicalNode (org.talend.core.ui.process.IGraphicalNode)9 CreateNodeContainerCommand (org.talend.designer.core.ui.editor.cmd.CreateNodeContainerCommand)9 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)9 HashMap (java.util.HashMap)8