Search in sources :

Example 26 with IProcess2

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

the class ActiveProcessTracker method getJobFromActivatedEditor.

public IProcess2 getJobFromActivatedEditor(IWorkbenchPart part) {
    IWorkbenchPart testedPart = part;
    if (!(part instanceof AbstractMultiPageTalendEditor)) {
        testedPart = part.getSite().getWorkbenchWindow().getActivePage().getActiveEditor();
    }
    if (testedPart instanceof AbstractMultiPageTalendEditor) {
        AbstractMultiPageTalendEditor mpte = (AbstractMultiPageTalendEditor) testedPart;
        mpte.setName();
        IProcess2 process = mpte.getTalendEditor().getProcess();
        return process;
    } else {
    // No editor
    }
    return null;
}
Also used : IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) IProcess2(org.talend.core.model.process.IProcess2)

Example 27 with IProcess2

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

the class ActiveProcessTracker method partOpened.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.ui.IPartListener#partOpened(org.eclipse.ui.IWorkbenchPart)
     */
@Override
public void partOpened(IWorkbenchPart part) {
    boolean existedJobOpened = false;
    if (part instanceof AbstractMultiPageTalendEditor) {
        AbstractMultiPageTalendEditor mpte = (AbstractMultiPageTalendEditor) part;
        if (mpte.isJobAlreadyOpened()) {
            mpte.updateChildrens();
            // close the first editor and keep the new one. (so only one will remain)
            IEditorReference[] ref = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findEditors(mpte.getEditorInput(), mpte.getEditorId(), IWorkbenchPage.MATCH_INPUT);
            IEditorPart editorPart = ref[0].getEditor(false);
            editorPart.doSave(new NullProgressMonitor());
            ((AbstractMultiPageTalendEditor) editorPart).setKeepPropertyLocked(true);
            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeEditor(editorPart, false);
            existedJobOpened = true;
        }
    } else {
        if (GlobalServiceRegister.getDefault().isServiceRegistered(IDiagramModelService.class)) {
            CorePlugin.getDefault().getDiagramModelService().handleNewEditorAction(part);
        }
    }
    IProcess2 process = getJobFromActivatedEditor(part);
    if (part instanceof AbstractMultiPageTalendEditor && process instanceof Process) {
        ((Process) process).setEditor((AbstractMultiPageTalendEditor) part);
    }
    if (process != null && currentProcess != process && lastProcessOpened != process) {
        lastProcessOpened = process;
        addJobInProblemView(process);
    } else if (existedJobOpened) {
        currentProcess = process;
        for (IJobTrackerListener listener : jobTrackerListeners) {
            listener.focusOnJob(process);
        }
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IEditorReference(org.eclipse.ui.IEditorReference) IProcess2(org.talend.core.model.process.IProcess2) IProcess(org.talend.core.model.process.IProcess) Process(org.talend.designer.core.ui.editor.process.Process) IEditorPart(org.eclipse.ui.IEditorPart)

Example 28 with IProcess2

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

the class ActiveProcessTracker method partBroughtToTop.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.ui.IPartListener#partBroughtToTop(org.eclipse.ui.IWorkbenchPart)
     */
@Override
public void partBroughtToTop(IWorkbenchPart part) {
    IProcess2 process = getJobFromActivatedEditor(part);
    if (process != null && currentProcess != process) {
        changedProcess = true;
        currentProcess = process;
        Contexts.setTitle(process.getLabel());
        setContextsView(process, part);
        // setStatsAndLogsView(process);
        JobSettings.switchToCurJobSettingsView();
        refreshProcessView();
        for (IJobTrackerListener listener : jobTrackerListeners) {
            listener.focusOnJob(process);
        }
    // if (process instanceof Process) {
    // Process p = (Process) process;
    // if (!p.isReadOnly() && p.isActivate()) {
    // p.checkDifferenceWithRepository();
    // }
    // }
    }
}
Also used : IProcess2(org.talend.core.model.process.IProcess2)

Example 29 with IProcess2

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

the class AbstractMultiPageTalendEditor method covertJobscriptOnPageChange.

private void covertJobscriptOnPageChange() {
    try {
        boolean isDirty = jobletEditor.isDirty();
        jobletEditor.doSave(null);
        IProcess2 oldProcess = getProcess();
        ICreateXtextProcessService n = CorePlugin.getDefault().getCreateXtextProcessService();
        Item item = oldProcess.getProperty().getItem();
        ProcessType processType = null;
        if (item instanceof ProcessItem) {
            processType = n.convertDesignerEditorInput(((IFile) jobletEditor.getEditorInput().getAdapter(IResource.class)).getLocation().toOSString(), oldProcess.getProperty());
        } else if (item instanceof JobletProcessItem) {
            processType = n.convertJobletDesignerEditorInput(((IFile) jobletEditor.getEditorInput().getAdapter(IResource.class)).getLocation().toOSString(), oldProcess.getProperty());
        }
        if (item instanceof ProcessItem) {
            ((Process) oldProcess).updateProcess(processType);
        } else if (item instanceof JobletProcessItem) {
            ((Process) oldProcess).updateProcess(processType);
        }
        oldProcess.getUpdateManager().updateAll();
        designerEditor.setDirty(isDirty);
        List<Node> nodes = (List<Node>) oldProcess.getGraphicalNodes();
        List<Node> newNodes = new ArrayList<Node>();
        newNodes.addAll(nodes);
        for (Node node : newNodes) {
            node.getProcess().checkStartNodes();
            node.checkAndRefreshNode();
            IElementParameter ep = node.getElementParameter("ACTIVATE");
            if (ep != null && ep.getValue().equals(Boolean.FALSE)) {
                node.setPropertyValue(EParameterName.ACTIVATE.getName(), true);
                node.setPropertyValue(EParameterName.ACTIVATE.getName(), false);
            } else if (ep != null && ep.getValue().equals(Boolean.TRUE)) {
                node.setPropertyValue(EParameterName.ACTIVATE.getName(), false);
                node.setPropertyValue(EParameterName.ACTIVATE.getName(), true);
            }
            for (IElementParameter param : node.getElementParameters()) {
                if (!param.getChildParameters().isEmpty()) {
                    if (param.getValue() != null && param.getValue() instanceof String && ((String) param.getValue()).contains(":")) {
                        String[] splited = ((String) param.getValue()).split(":");
                        String childNameNeeded = splited[0].trim();
                        String valueChild = TalendQuoteUtils.removeQuotes(splited[1].trim());
                        if (param.getChildParameters().containsKey(childNameNeeded)) {
                            param.getChildParameters().get(childNameNeeded).setValue(valueChild);
                        }
                    }
                }
            }
            if (node.getNodeContainer() instanceof JobletContainer) {
                JobletContainer jc = (JobletContainer) node.getNodeContainer();
                if (node.isMapReduceStart()) {
                    //$NON-NLS-1$
                    jc.updateState("UPDATE_STATUS", "", jc.getPercentMap(), jc.getPercentReduce());
                }
            }
        }
    } catch (PersistenceException e) {
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) AbstractJobletContainer(org.talend.designer.core.ui.editor.jobletcontainer.AbstractJobletContainer) JobletContainer(org.talend.designer.core.ui.editor.jobletcontainer.JobletContainer) INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) ArrayList(java.util.ArrayList) ICreateXtextProcessService(org.talend.core.services.ICreateXtextProcessService) Process(org.talend.designer.core.ui.editor.process.Process) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) Item(org.talend.core.model.properties.Item) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) IProcess2(org.talend.core.model.process.IProcess2) PersistenceException(org.talend.commons.exception.PersistenceException) IElementParameter(org.talend.core.model.process.IElementParameter) ArrayList(java.util.ArrayList) List(java.util.List) IResource(org.eclipse.core.resources.IResource)

Example 30 with IProcess2

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

the class AbstractProcessAction method checkUnLoadedNodeForProcess.

public 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() {

                    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)

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