Search in sources :

Example 1 with SubjobContainer

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

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

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

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

the class ComponentSettingsView method getCategories.

/**
     * yzhang Comment method "getCategories".
     * 
     * @param elem
     * @return
     */
private EComponentCategory[] getCategories(Element elem) {
    if (elem instanceof Connection) {
        EComponentCategory[] categories = EElementType.CONNECTION.getCategories();
        if (PluginChecker.isTeamEdition()) {
            Object propertyValue = elem.getPropertyValue(Connection.LINESTYLE_PROP);
            if (propertyValue instanceof EConnectionType && ((EConnectionType) propertyValue).hasConnectionCategory(IConnectionCategory.FLOW)) {
                // if (((Connection) elem).checkTraceShowEnable()) {
                final List<EComponentCategory> list = new ArrayList<EComponentCategory>(Arrays.asList(categories));
                boolean isMRProcess = false;
                IProcess process = ((Connection) elem).getSource().getProcess();
                if (process instanceof IProcess2) {
                    IProcess2 process2 = (IProcess2) process;
                    if (ComponentCategory.CATEGORY_4_MAPREDUCE.getName().equals(process2.getComponentsType())) {
                        isMRProcess = true;
                    }
                }
                boolean isStormProcess = false;
                process = ((Connection) elem).getSource().getProcess();
                if (process instanceof IProcess2) {
                    IProcess2 process2 = (IProcess2) process;
                    if (ComponentCategory.CATEGORY_4_STORM.getName().equals(process2.getComponentsType())) {
                        isStormProcess = true;
                    }
                }
                // mrjob and stormjob not add breakpoint
                if (!isStormProcess && !isMRProcess) {
                    list.add(EComponentCategory.BREAKPOINT);
                }
                if (elem.getElementParameter(EParameterName.DEPARTITIONER.getName()) != null || elem.getElementParameter(EParameterName.PARTITIONER.getName()) != null || elem.getElementParameter(EParameterName.REPARTITIONER.getName()) != null) {
                    list.add(EComponentCategory.PARALLELIZATION);
                }
                // if it mr group line then add errorRecovery
                if (isMRProcess && isMrGroupLine(elem)) {
                    list.add(EComponentCategory.RESUMING);
                }
                return list.toArray(new EComponentCategory[0]);
            // }
            } else if (propertyValue.equals(EConnectionType.ON_COMPONENT_OK) || propertyValue.equals(EConnectionType.ON_COMPONENT_ERROR) || propertyValue.equals(EConnectionType.RUN_IF) || propertyValue.equals(EConnectionType.ON_SUBJOB_OK) || propertyValue.equals(EConnectionType.ON_SUBJOB_ERROR) || propertyValue.equals(EConnectionType.ROUTE_WHEN) || propertyValue.equals(EConnectionType.ROUTE_CATCH) || propertyValue.equals(EConnectionType.STARTS)) {
                boolean isMRProcess = false;
                IProcess process = ((Connection) elem).getSource().getProcess();
                if (process instanceof IProcess2) {
                    IProcess2 process2 = (IProcess2) process;
                    if (ComponentCategory.CATEGORY_4_MAPREDUCE.getName().equals(process2.getComponentsType())) {
                        isMRProcess = true;
                    }
                }
                boolean isStormProcess = false;
                process = ((Connection) elem).getSource().getProcess();
                if (process instanceof IProcess2) {
                    IProcess2 process2 = (IProcess2) process;
                    if (ComponentCategory.CATEGORY_4_STORM.getName().equals(process2.getComponentsType())) {
                        isStormProcess = true;
                    }
                }
                int length = categories.length;
                EComponentCategory[] newCategories;
                boolean isNormalJobNeedRecovery = (!isMRProcess && !isStormProcess && !isAvoidRecoveryByConditions(elem));
                boolean isMrStormJobNeedRecovery = isMRProcess || isStormProcess;
                if (isNeedRecoveryCategory(propertyValue, isNormalJobNeedRecovery, isMrStormJobNeedRecovery)) {
                    newCategories = new EComponentCategory[length + 1];
                    for (int i = 0; i < length; i++) {
                        newCategories[i] = categories[i];
                    }
                    EComponentCategory resuming = EComponentCategory.RESUMING;
                    newCategories[length] = resuming;
                } else {
                    newCategories = new EComponentCategory[length];
                    for (int i = 0; i < length; i++) {
                        newCategories[i] = categories[i];
                    }
                }
                return newCategories;
            }
        }
        return categories;
    } else if (elem instanceof Node) {
        // if (isAdvancedType(elem)) {
        if (((Node) elem).isELTComponent()) {
            if (//$NON-NLS-1$
            !((Node) elem).getComponent().getName().endsWith("Output") && //$NON-NLS-1$
            !((Node) elem).getComponent().getName().endsWith("Input") && //$NON-NLS-1$
            !((Node) elem).getComponent().getName().endsWith("Map") && //$NON-NLS-1$
            !((Node) elem).getComponent().getName().endsWith("TableList") && !((Node) elem).getComponent().getName().endsWith("ColumnList")) {
                //$NON-NLS-1$
                return EElementType.ELT_NODE.getCategories();
            }
        }
        EComponentCategory[] categories = EElementType.ADVANCED_NODE.getCategories();
        // add for bug TDI-8476
        if (((Node) elem).getComponent() != null) {
            String paletteType = ((Node) elem).getComponent().getPaletteType();
            if (ComponentCategory.CATEGORY_4_CAMEL.getName().equals(paletteType)) {
                categories = EElementType.NODE.getCategories();
            }
        }
        if (PluginChecker.isValidationrulesPluginLoaded() && isSupportValidationRuleNode((Node) elem)) {
            // show
            EComponentCategory[] newCategories = new EComponentCategory[categories.length + 1];
            System.arraycopy(categories, 0, newCategories, 0, categories.length);
            newCategories[categories.length] = EComponentCategory.VALIDATION_RULES;
            return newCategories;
        }
        return categories;
    } else if (elem instanceof Note) {
        return EElementType.NOTE.getCategories();
    } else if (elem instanceof SubjobContainer) {
        return EElementType.SUBJOB.getCategories();
    } else if (elem instanceof ConnectionLabel) {
        return getCategories(((ConnectionLabel) elem).getConnection());
    }
    return null;
}
Also used : Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) Connection(org.talend.designer.core.ui.editor.connections.Connection) IConnection(org.talend.core.model.process.IConnection) ArrayList(java.util.ArrayList) ConnectionLabel(org.talend.designer.core.ui.editor.connections.ConnectionLabel) SubjobContainer(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer) Note(org.talend.designer.core.ui.editor.notes.Note) IProcess2(org.talend.core.model.process.IProcess2) EConnectionType(org.talend.core.model.process.EConnectionType) IProcess(org.talend.core.model.process.IProcess) EComponentCategory(org.talend.core.model.process.EComponentCategory)

Example 5 with SubjobContainer

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

the class NodePartKeyHander method getNavigationSiblings.

@Override
protected List getNavigationSiblings() {
    EditPart focusPart = getFocusEditPart();
    boolean displayVa = true;
    if (focusPart.getParent() != null) {
        if (focusPart instanceof SubjobContainerPart) {
            // return getNodePart((SubjobContainerPart) focusPart);
            SubjobContainerPart subConPart = (SubjobContainerPart) focusPart;
            List subList = focusPart.getParent().getChildren();
            for (int j = 0; j < subList.size(); j++) {
                if (subList.get(j) instanceof SubjobContainerPart) {
                    subConPart = (SubjobContainerPart) subList.get(j);
                    SubjobContainer subContainer = (SubjobContainer) subConPart.getModel();
                    if (subContainer.isDisplayed() == false) {
                        displayVa = false;
                    }
                } else if (subList.get(j) instanceof NoteEditPart) {
                    NoteEditPart notePart = (NoteEditPart) subList.get(j);
                    return getNodePart((ProcessPart) notePart.getParent());
                } else if (subList.get(j) instanceof NodePart) {
                    NodePart node = (NodePart) subList.get(j);
                    return getNodePart((ProcessPart) node.getParent().getParent().getParent());
                }
            }
            if (displayVa == false) {
                return getNodePart((ProcessPart) focusPart.getParent());
            }
        } else if (focusPart instanceof NodePart) {
            // get all node part for a job.
            return getNodePart((ProcessPart) focusPart.getParent().getParent().getParent());
        // return getNodePart((SubjobContainerPart) focusPart.getParent().getParent());
        } else if (focusPart instanceof NoteEditPart) {
            return getNodePart((ProcessPart) focusPart.getParent());
        }
        return focusPart.getParent().getChildren();
    }
    List list = new ArrayList();
    list.add(focusPart);
    return list;
}
Also used : SubjobContainer(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer) EditPart(org.eclipse.gef.EditPart) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) ArrayList(java.util.ArrayList) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) List(java.util.List) ArrayList(java.util.ArrayList) 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)

Aggregations

SubjobContainer (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer)21 Node (org.talend.designer.core.ui.editor.nodes.Node)17 List (java.util.List)11 SubjobContainerPart (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)10 ArrayList (java.util.ArrayList)9 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)9 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)8 IConnection (org.talend.core.model.process.IConnection)7 INode (org.talend.core.model.process.INode)7 Connection (org.talend.designer.core.ui.editor.connections.Connection)7 Note (org.talend.designer.core.ui.editor.notes.Note)5 HashMap (java.util.HashMap)4 EditPart (org.eclipse.gef.EditPart)4 ConnectionLabel (org.talend.designer.core.ui.editor.connections.ConnectionLabel)4 NoteEditPart (org.talend.designer.core.ui.editor.notes.NoteEditPart)4 ProcessPart (org.talend.designer.core.ui.editor.process.ProcessPart)4 Point (org.eclipse.draw2d.geometry.Point)3 IComponent (org.talend.core.model.components.IComponent)3 ISubjobContainer (org.talend.core.model.process.ISubjobContainer)3 IGraphicalNode (org.talend.core.ui.process.IGraphicalNode)3