Search in sources :

Example 51 with IProcess2

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

the class OpenExistVersionProcessAction method checkUnLoadedNodeForProcess.

private void checkUnLoadedNodeForProcess(JobEditorInput fileEditorInput) {
    if (fileEditorInput == null || fileEditorInput.getLoadedProcess() == null) {
        return;
    }
    IProcess2 loadedProcess = fileEditorInput.getLoadedProcess();
    List<NodeType> unloadedNode = loadedProcess.getUnloadedNode();
    if (unloadedNode != null && !unloadedNode.isEmpty()) {
        String message = "Some Component are not loaded:\n";
        for (int i = 0; i < unloadedNode.size(); i++) {
            message = message + unloadedNode.get(i).getComponentName() + "\n";
        }
        if (!CommonsPlugin.isHeadless() && PlatformUI.isWorkbenchRunning()) {
            Display display = Display.getCurrent();
            if (display == null) {
                display = Display.getDefault();
            }
            if (display != null) {
                final Display tmpDis = display;
                final String tmpMess = message;
                display.syncExec(new Runnable() {

                    @Override
                    public void run() {
                        Shell shell = null;
                        final IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
                        if (activeWorkbenchWindow != null) {
                            shell = activeWorkbenchWindow.getShell();
                        } else {
                            if (tmpDis != null) {
                                shell = tmpDis.getActiveShell();
                            } else {
                                shell = new Shell();
                            }
                        }
                        MessageDialog.openWarning(shell, "Warning", tmpMess);
                    }
                });
            }
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) Shell(org.eclipse.swt.widgets.Shell) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) IProcess2(org.talend.core.model.process.IProcess2) Display(org.eclipse.swt.widgets.Display)

Example 52 with IProcess2

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

the class JobletContainer method refreshJobletNodes.

public void refreshJobletNodes(boolean update, boolean coll) {
    if (this.node.isJoblet()) {
        if (!coll || update) {
            boolean componentUpdated = false;
            IComponent oldComponent = node.getComponent();
            if (GlobalServiceRegister.getDefault().isServiceRegistered(IJobletProviderService.class)) {
                IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
                IComponent newComponent = service.getUpdatedJobletComponent(oldComponent);
                if (oldComponent != newComponent) {
                    node.setComponent(newComponent);
                    componentUpdated = true;
                }
            }
            JobletUtil util = new JobletUtil();
            IProcess jobletProcess = this.getNode().getComponent().getProcess();
            Set<IConnection> conns = new HashSet<IConnection>();
            List<? extends INode> jobletNodes = jobletProcess.getGraphicalNodes();
            boolean lockByOther = false;
            if (jobletProcess instanceof IProcess2) {
                lockByOther = util.lockByOthers(((IProcess2) jobletProcess).getProperty().getItem());
            }
            Map<String, List<? extends IElementParameter>> paraMap = new HashMap<String, List<? extends IElementParameter>>();
            // List<NodeContainer> temList = new ArrayList<NodeContainer>(nodeContainers);
            if (!componentUpdated) {
                for (NodeContainer nc : nodeContainers) {
                    if (this.node.getProcess() instanceof IProcess2) {
                        if (!update) {
                            paraMap.put(nc.getNode().getJoblet_unique_name(), nc.getNode().getElementParameters());
                        }
                        ((IProcess2) this.node.getProcess()).removeUniqueNodeName(nc.getNode().getUniqueName());
                    }
                }
            }
            nodeContainers.clear();
            jobletElements.clear();
            // boolean canRemove = false;
            for (INode inode : jobletNodes) {
                // canAdd = util.canAdd(temList, inode);
                if ((inode instanceof Node)) {
                    Node temNode = (Node) inode;
                    // if (canAdd) {
                    conns.addAll(temNode.getIncomingConnections());
                    conns.addAll(temNode.getOutgoingConnections());
                    Node jnode = util.cloneNode(temNode, this.node.getProcess(), paraMap, lockByOther);
                    if (!this.node.isActivate()) {
                        jnode.setActivate(this.node.isActivate());
                    }
                    NodeContainer nodeContainer = util.cloneNodeContainer(temNode.getNodeContainer(), jnode);
                    jnode.setJobletnode(this.node);
                    jnode.setJoblet_unique_name(temNode.getUniqueName());
                    this.nodeContainers.add(nodeContainer);
                    this.jobletElements.add(jnode);
                    this.jobletElements.add(jnode.getNodeLabel());
                    this.jobletElements.add(jnode.getNodeError());
                    this.jobletElements.add(jnode.getNodeProgressBar());
                // } else if (update) {
                // for (NodeContainer nodeC : nodeContainers) {
                // if (nodeC.getNode().getJoblet_unique_name().equals(temNode.getUniqueName())) {
                // util.updateNode(nodeC.getNode(), temNode);
                // break;
                // }
                // }
                // }
                }
            }
            // }
            for (IConnection con : conns) {
                String sourceName = con.getSource().getUniqueName();
                String targetName = con.getTarget().getUniqueName();
                Node sourceNode = null;
                Node targetNode = null;
                for (NodeContainer nodeC : nodeContainers) {
                    Node connNode = nodeC.getNode();
                    if (connNode.getJoblet_unique_name().equals(sourceName)) {
                        sourceNode = connNode;
                    }
                    if (connNode.getJoblet_unique_name().equals(targetName)) {
                        targetNode = connNode;
                    }
                    if (sourceNode != null && targetNode != null) {
                        util.cloneConnection(con, sourceNode, targetNode);
                        break;
                    }
                }
            }
        }
    } else if (this.node.isMapReduceStart()) {
        Integer mrGroupId = node.getMrGroupId();
        List<? extends INode> mapReduceNodes = this.node.getProcess().getGraphicalNodes();
        List<Node> nodeList = new ArrayList<Node>();
        if (node.getNodeContainer().getSubjobContainer() != null && node.getNodeContainer().getSubjobContainer().isCollapsed()) {
            nodeList.add(node);
        } else {
            for (INode inode : mapReduceNodes) {
                if ((inode instanceof Node)) {
                    Node temNode = (Node) inode;
                    if (temNode.getMrGroupId() != null && mrGroupId != null && temNode.getMrGroupId().equals(mrGroupId)) {
                        nodeList.add(temNode);
                    }
                }
            }
        }
        nodeContainers.clear();
        jobletElements.clear();
        for (Node inode : nodeList) {
            if (!inode.isActivate()) {
                continue;
            }
            NodeContainer nodeContainer = inode.getNodeContainer();
            // inode.setJoblet_unique_name(inode.getUniqueName());
            if (nodeContainer instanceof JobletContainer) {
                ((JobletContainer) nodeContainer).setMrStartContainer(this);
            }
            this.nodeContainers.add(nodeContainer);
            this.jobletElements.add(inode);
            this.jobletElements.add(inode.getNodeLabel());
            this.jobletElements.add(inode.getNodeError());
            this.jobletElements.add(inode.getNodeProgressBar());
        }
    }
}
Also used : INode(org.talend.core.model.process.INode) HashMap(java.util.HashMap) IComponent(org.talend.core.model.components.IComponent) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) IConnection(org.talend.core.model.process.IConnection) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) IJobletProviderService(org.talend.core.ui.IJobletProviderService) IProcess2(org.talend.core.model.process.IProcess2) IElementParameter(org.talend.core.model.process.IElementParameter) ArrayList(java.util.ArrayList) List(java.util.List) IProcess(org.talend.core.model.process.IProcess) HashSet(java.util.HashSet)

Example 53 with IProcess2

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

the class JobletContainerFigure method reSelection.

private void reSelection() {
    // select the start node.
    if (jobletContainer.isCollapsed()) {
        IProcess2 process = jobletContainer.getProcess();
        if (process == null) {
            return;
        }
        AbstractMultiPageTalendEditor editor = (AbstractMultiPageTalendEditor) process.getEditor();
        Node startNode = jobletContainer.getJobletStartNode();
        if (startNode != null && editor != null) {
            editor.selectNode(startNode);
        }
    }
}
Also used : AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) Node(org.talend.designer.core.ui.editor.nodes.Node) IProcess2(org.talend.core.model.process.IProcess2)

Example 54 with IProcess2

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

the class ContextsView method handleDropContext.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.core.ui.context.view.AbstractContextView#handleDrop(org.talend.core.model.properties.ContextItem,
     * java.util.Set, org.eclipse.ui.IEditorInput)
     */
@Override
protected boolean handleDropContext(ContextItem contextItem, Set<String> contextSet, IEditorInput editorInput) {
    boolean created = false;
    if (editorInput instanceof JobEditorInput) {
        JobEditorInput jobInput = (JobEditorInput) editorInput;
        IProcess2 process = jobInput.getLoadedProcess();
        IContextManager contextManager = process.getContextManager();
        // context group will reflect absolutely if no context variable in contextViewer
        if (!ConnectionContextHelper.containsVariable(contextManager)) {
            // for bug 15608
            ConnectionContextHelper.addContextVarForJob(process, contextItem, contextManager);
            // ConnectionContextHelper.checkAndAddContextsVarDND(contextItem,
            // contextManager);
            created = true;
        } else {
            Set<String> addedContext = ConnectionContextHelper.checkAndAddContextVariables(contextItem, contextSet, contextManager, false);
            if (addedContext != null && addedContext.size() > 0) {
                ConnectionContextHelper.addContextVarForJob(process, contextItem, contextSet);
                created = true;
            }
        }
    }
    return created;
}
Also used : JobEditorInput(org.talend.core.ui.editor.JobEditorInput) IProcess2(org.talend.core.model.process.IProcess2) IContextManager(org.talend.core.model.process.IContextManager)

Example 55 with IProcess2

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

the class SaveJobBeforeRunAction method run.

@Override
public void run() {
    List<? extends INode> nodes = activeProcess.getGraphicalNodes();
    if (nodes.isEmpty()) {
        return;
    }
    IEditorPart part = null;
    if (activeProcess instanceof IProcess2) {
        // save the editor directly.
        part = ((IProcess2) activeProcess).getEditor();
    } else {
        // try to save current active editor
        part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    }
    if (part != null && part.isDirty()) {
        if (part != null && part instanceof AbstractMultiPageTalendEditor) {
            AbstractMultiPageTalendEditor editor = (AbstractMultiPageTalendEditor) part;
            editor.doSave(new NullProgressMonitor());
        }
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) IProcess2(org.talend.core.model.process.IProcess2) IEditorPart(org.eclipse.ui.IEditorPart)

Aggregations

IProcess2 (org.talend.core.model.process.IProcess2)115 INode (org.talend.core.model.process.INode)31 Node (org.talend.designer.core.ui.editor.nodes.Node)31 ArrayList (java.util.ArrayList)30 ProcessItem (org.talend.core.model.properties.ProcessItem)30 Item (org.talend.core.model.properties.Item)28 IProcess (org.talend.core.model.process.IProcess)24 PersistenceException (org.talend.commons.exception.PersistenceException)22 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)21 JobletProcessItem (org.talend.core.model.properties.JobletProcessItem)19 List (java.util.List)17 IElementParameter (org.talend.core.model.process.IElementParameter)15 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)14 Property (org.talend.core.model.properties.Property)14 CoreException (org.eclipse.core.runtime.CoreException)12 IConnection (org.talend.core.model.process.IConnection)11 HashSet (java.util.HashSet)10 IEditorReference (org.eclipse.ui.IEditorReference)10 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)10 InvocationTargetException (java.lang.reflect.InvocationTargetException)7