Search in sources :

Example 1 with ISubjobContainer

use of org.talend.core.model.process.ISubjobContainer in project tdi-studio-se by Talend.

the class AbstractTalendEditor method initializeGraphicalViewer.

// ------------------------------------------------------------------------
// Abstract methods from GraphicalEditor
@Override
protected void initializeGraphicalViewer() {
    super.initializeGraphicalViewer();
    // this uses the PartFactory set in configureGraphicalViewer
    // to create an EditPart for the diagram and sets it as the
    // content for the viewer
    IProcess2 process = getProcess();
    getGraphicalViewer().setContents(process);
    // containers are not correctly updated by default, so update them after all nodes have been added
    if (process != null) {
        for (ISubjobContainer subjobContainer : process.getSubjobContainers()) {
            subjobContainer.updateSubjobContainer();
        }
    }
    getGraphicalViewer().getControl().addMouseListener(new MouseAdapter() {

        /*
             * (non-Javadoc)
             * 
             * @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
             */
        @Override
        public void mouseUp(MouseEvent e) {
            updateActions(getSelectionActions());
        }
    });
    talendEditorDropTargetListener = new TalendEditorDropTargetListener(this);
    getGraphicalViewer().addDropTargetListener(talendEditorDropTargetListener);
}
Also used : ISubjobContainer(org.talend.core.model.process.ISubjobContainer) MouseEvent(org.eclipse.swt.events.MouseEvent) TalendEditorDropTargetListener(org.talend.designer.core.ui.editor.process.TalendEditorDropTargetListener) IProcess2(org.talend.core.model.process.IProcess2) MouseAdapter(org.eclipse.swt.events.MouseAdapter)

Example 2 with ISubjobContainer

use of org.talend.core.model.process.ISubjobContainer 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 3 with ISubjobContainer

use of org.talend.core.model.process.ISubjobContainer 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 ISubjobContainer

use of org.talend.core.model.process.ISubjobContainer in project tdi-studio-se by Talend.

the class ToggleSubjobsAction method run.

@Override
public void run() {
    boolean display = isChecked();
    getGlobalStore().setValue(TalendDesignerPrefConstants.DISPLAY_SUBJOBS, display);
    IEditorReference[] editorParts = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
    for (IEditorReference reference : editorParts) {
        if (!(reference.getId().equals(MultiPageTalendEditor.ID) || reference.getId().equals(JOBLET_ID) || MAP_REDUCE_MULTIPAGE_EDITOR_ID.equals(reference.getId()) || TEST_CASE_DI_EDITOR.equals(reference.getId()))) {
            continue;
        }
        IEditorPart editorPart = reference.getEditor(false);
        if (editorPart == null) {
            continue;
        }
        if (editorPart instanceof AbstractMultiPageTalendEditor) {
            AbstractMultiPageTalendEditor editor = (AbstractMultiPageTalendEditor) editorPart;
            IProcess2 process = editor.getTalendEditor().getProcess();
            if (process == null) {
                continue;
            }
            List<? extends ISubjobContainer> subjobs = process.getSubjobContainers();
            for (ISubjobContainer subjobContainer : subjobs) {
                subjobContainer.updateSubjobDisplay();
            }
        }
    }
}
Also used : ISubjobContainer(org.talend.core.model.process.ISubjobContainer) IEditorReference(org.eclipse.ui.IEditorReference) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) IProcess2(org.talend.core.model.process.IProcess2) IEditorPart(org.eclipse.ui.IEditorPart)

Example 5 with ISubjobContainer

use of org.talend.core.model.process.ISubjobContainer in project tdi-studio-se by Talend.

the class ProcessComposite method refreshSubjobContainer.

/*
     * This method is used to clean the Spark Streaming statistics.
     */
public void refreshSubjobContainer() {
    org.talend.core.model.process.IProcess2 process = processContext.getProcess();
    List<? extends ISubjobContainer> subjobContainers = process.getSubjobContainers();
    for (ISubjobContainer subjobContainer : subjobContainers) {
        if (subjobContainer instanceof SparkStreamingSubjobContainer) {
            ((SparkStreamingSubjobContainer) subjobContainer).updateState("UPDATE_SPARKSTREAMING_STATUS", null, 0, 0, "", "", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
            "");
        }
    }
}
Also used : ISubjobContainer(org.talend.core.model.process.ISubjobContainer) SparkStreamingSubjobContainer(org.talend.designer.core.ui.editor.subjobcontainer.sparkstreaming.SparkStreamingSubjobContainer) IProcess2(org.talend.core.model.process.IProcess2)

Aggregations

ISubjobContainer (org.talend.core.model.process.ISubjobContainer)5 IProcess2 (org.talend.core.model.process.IProcess2)3 ArrayList (java.util.ArrayList)2 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)2 Node (org.talend.designer.core.ui.editor.nodes.Node)2 SubjobContainer (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer)2 List (java.util.List)1 EditPart (org.eclipse.gef.EditPart)1 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)1 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)1 MouseAdapter (org.eclipse.swt.events.MouseAdapter)1 MouseEvent (org.eclipse.swt.events.MouseEvent)1 IEditorPart (org.eclipse.ui.IEditorPart)1 IEditorReference (org.eclipse.ui.IEditorReference)1 IConnection (org.talend.core.model.process.IConnection)1 IElementParameter (org.talend.core.model.process.IElementParameter)1 IExternalNode (org.talend.core.model.process.IExternalNode)1 INode (org.talend.core.model.process.INode)1 AbstractMultiPageTalendEditor (org.talend.designer.core.ui.AbstractMultiPageTalendEditor)1 TalendScalableFreeformRootEditPart (org.talend.designer.core.ui.editor.TalendScalableFreeformRootEditPart)1