Search in sources :

Example 71 with Process

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

the class AbstractTalendEditor method dispose.

@Override
public void dispose() {
    ProcessorUtilities.editorClosed(this);
    talendPaletteViewerProvider = null;
    // achen modify to fix bug 0006107
    // if (!getParent().isKeepPropertyLocked()) {
    // JobResourceManager manager = JobResourceManager.getInstance();
    // manager.removeProtection(this);
    // for (JobResource r : protectedJobs.values()) {
    // manager.deleteResource(r);
    // }
    // }
    ComponentSettingsView viewer = (ComponentSettingsView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(ComponentSettingsView.ID);
    if (viewer != null) {
        viewer.cleanDisplay();
    }
    for (Iterator iterator = getSelectionActions().iterator(); iterator.hasNext(); ) {
        String actionID = (String) iterator.next();
        IAction action = getActionRegistry().getAction(actionID);
        if (action != null) {
            fActivationCodeTrigger.unregisterActionFromKeyActivation(action);
            getActionRegistry().removeAction(action);
            if (action instanceof Disposable) {
                ((Disposable) action).dispose();
            }
        }
    }
    fActivationCodeTrigger.uninstall();
    fActivationCodeTrigger = null;
    getSelectionActions().clear();
    getGraphicalViewer().removeDropTargetListener(talendEditorDropTargetListener);
    if (getGraphicalViewer().getContents() != null) {
        getGraphicalViewer().getContents().deactivate();
        getGraphicalViewer().getContents().removeNotify();
        getGraphicalViewer().getRootEditPart().deactivate();
        getGraphicalViewer().getRootEditPart().removeNotify();
    }
    getGraphicalViewer().setEditPartFactory(null);
    getGraphicalViewer().setContextMenu(null);
    getGraphicalViewer().setContents(null);
    if (sharedKeyHandler != null) {
        sharedKeyHandler.remove(KeyStroke.getPressed(SWT.F1, 0));
        sharedKeyHandler.remove(KeyStroke.getPressed(SWT.DEL, 0));
    }
    // super.setInput(null);
    // getGraphicalViewer().setContents(null);
    // if (getGraphicalViewer().getControl() != null && !getGraphicalViewer().getControl().isDisposed()) {
    // getGraphicalViewer().getControl().dispose();
    // }
    talendEditorDropTargetListener.setEditor(null);
    talendEditorDropTargetListener = null;
    // TalendScalableFreeformRootEditPart rootEditPart = (TalendScalableFreeformRootEditPart) getGraphicalViewer()
    // .getRootEditPart();
    // rootEditPart.setEditorInput(null);
    // rootEditPart.deactivate();
    super.dispose();
    if (!getParent().isKeepPropertyLocked()) {
        ((Process) getProcess()).dispose();
    }
    // process = null;
    parent = null;
    getEditDomain().getCommandStack().dispose();
    getEditDomain().setActiveTool(null);
    getEditDomain().setPaletteRoot(null);
    getEditDomain().setPaletteViewer(null);
    getEditDomain().setCommandStack(null);
    getEditDomain().setDefaultTool(null);
    getSelectionSynchronizer().removeViewer(getGraphicalViewer());
    getSite().setSelectionProvider(null);
}
Also used : Disposable(org.eclipse.gef.Disposable) IAction(org.eclipse.jface.action.IAction) Iterator(java.util.Iterator) IProcess(org.talend.core.model.process.IProcess) Process(org.talend.designer.core.ui.editor.process.Process) IComponentSettingsView(org.talend.core.views.IComponentSettingsView) ComponentSettingsView(org.talend.designer.core.ui.views.properties.ComponentSettingsView)

Example 72 with Process

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

the class JobletContainerLayoutEditPolicy method getCreateCommand.

@Override
protected Command getCreateCommand(CreateRequest request) {
    Rectangle constraint = (Rectangle) getConstraintFor(request);
    Process linkedProcess = (Process) ((JobletContainer) getHost().getModel()).getNode().getProcess();
    Command command = null;
    if (Note.class.equals(request.getNewObjectType())) {
        command = new CreateNoteCommand(linkedProcess, (Note) request.getNewObject(), constraint.getLocation());
    } else if (request.getNewObject() instanceof Node) {
        Node node = (Node) request.getNewObject();
        NodeContainer nodeContainer = ((Process) node.getProcess()).loadNodeContainer(node, false);
        command = new CreateNodeContainerCommand(linkedProcess, nodeContainer, constraint.getLocation());
    }
    return command;
}
Also used : CreateNodeContainerCommand(org.talend.designer.core.ui.editor.cmd.CreateNodeContainerCommand) CreateNodeContainerCommand(org.talend.designer.core.ui.editor.cmd.CreateNodeContainerCommand) CreateNoteCommand(org.talend.designer.core.ui.editor.cmd.CreateNoteCommand) Command(org.eclipse.gef.commands.Command) Note(org.talend.designer.core.ui.editor.notes.Note) Node(org.talend.designer.core.ui.editor.nodes.Node) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Process(org.talend.designer.core.ui.editor.process.Process) CreateNoteCommand(org.talend.designer.core.ui.editor.cmd.CreateNoteCommand) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)

Example 73 with Process

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

the class ProcessComposite method debug.

public void debug() {
    setHideconsoleLine(false);
    if ((processContext.getProcess()) instanceof org.talend.designer.core.ui.editor.process.Process) {
        ((org.talend.designer.core.ui.editor.process.Process) processContext.getProcess()).checkDifferenceWithRepository();
    }
    // final IPreferenceStore preferenceStore = DebugUIPlugin.getDefault().getPreferenceStore();
    final IPreferenceStore preferenceStore = DebugUITools.getPreferenceStore();
    final boolean oldValueConsoleOnOut = preferenceStore.getBoolean(IDebugPreferenceConstants.CONSOLE_OPEN_ON_OUT);
    final boolean oldValueConsoleOnErr = preferenceStore.getBoolean(IDebugPreferenceConstants.CONSOLE_OPEN_ON_ERR);
    preferenceStore.setValue(IDebugPreferenceConstants.CONSOLE_OPEN_ON_OUT, false);
    preferenceStore.setValue(IDebugPreferenceConstants.CONSOLE_OPEN_ON_ERR, false);
    checkSaveBeforeRunSelection();
    if (contextComposite.promptConfirmLauch()) {
        setRunnable(false);
        final IContext context = contextComposite.getSelectedContext();
        IRunnableWithProgress worker = new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) {
                IProcessor processor = ProcessorUtilities.getProcessor(processContext.getProcess(), processContext.getProcess().getProperty(), context);
                //$NON-NLS-1$
                monitor.beginTask("Launching debugger", IProgressMonitor.UNKNOWN);
                try {
                    // use this function to generate childrens also.
                    ProcessorUtilities.generateCode(processContext.getProcess(), context, false, false, true, monitor);
                    ILaunchConfiguration config = ((Processor) processor).getDebugConfiguration(processContext.getStatisticsPort(), processContext.getTracesPort(), null);
                    // code is correct before launching
                    if (!JobErrorsChecker.hasErrors(ProcessComposite.this.getShell())) {
                        if (config != null) {
                            // PlatformUI.getWorkbench().
                            // getActiveWorkbenchWindow
                            // ().addPerspectiveListener(new
                            // DebugInNewWindowListener());
                            DebugUITools.launch(config, ILaunchManager.DEBUG_MODE);
                        } else {
                            //$NON-NLS-1$
                            MessageDialog.openInformation(//$NON-NLS-1$
                            getShell(), //$NON-NLS-1$
                            Messages.getString("ProcessDebugDialog.debugBtn"), //$NON-NLS-1$ 
                            Messages.getString("ProcessDebugDialog.errortext"));
                        }
                    }
                } catch (ProcessorException e) {
                    IStatus status = new Status(IStatus.ERROR, RunProcessPlugin.PLUGIN_ID, IStatus.OK, "Debug launch failed.", //$NON-NLS-1$
                    e);
                    RunProcessPlugin.getDefault().getLog().log(status);
                    //$NON-NLS-1$ //$NON-NLS-2$
                    MessageDialog.openError(getShell(), Messages.getString("ProcessDebugDialog.debugBtn"), "");
                } finally {
                    monitor.done();
                }
            }
        };
        IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
        try {
            progressService.runInUI(PlatformUI.getWorkbench().getProgressService(), worker, ResourcesPlugin.getWorkspace().getRoot());
        } catch (InvocationTargetException e) {
            // e.printStackTrace();
            ExceptionHandler.process(e);
        } catch (InterruptedException e) {
            // e.printStackTrace();
            ExceptionHandler.process(e);
        }
    }
    debugMode = true;
    try {
        Thread thread = new Thread() {

            @Override
            public void run() {
                while (debugMode) {
                    final IProcess process = DebugUITools.getCurrentProcess();
                    if (process != null && process.isTerminated()) {
                        getDisplay().asyncExec(new Runnable() {

                            @Override
                            public void run() {
                                setRunnable(true);
                                killBtn.setEnabled(false);
                                preferenceStore.setValue(IDebugPreferenceConstants.CONSOLE_OPEN_ON_OUT, oldValueConsoleOnOut);
                                preferenceStore.setValue(IDebugPreferenceConstants.CONSOLE_OPEN_ON_ERR, oldValueConsoleOnErr);
                                if (isAddedStreamListener) {
                                    process.getStreamsProxy().getOutputStreamMonitor().removeListener(streamListener);
                                    isAddedStreamListener = false;
                                    if (processContext.isRunning()) {
                                        //$NON-NLS-1$
                                        final String endingPattern = Messages.getString("ProcessComposite.endPattern");
                                        MessageFormat mf = new MessageFormat(endingPattern);
                                        String byeMsg;
                                        try {
                                            byeMsg = //$NON-NLS-1$
                                            "\n" + mf.format(new Object[] { processContext.getProcess().getName(), new Date(), new Integer(process.getExitValue()) });
                                            processContext.addDebugResultToConsole(new ProcessMessage(MsgType.CORE_OUT, byeMsg));
                                        } catch (DebugException e) {
                                            // e.printStackTrace();
                                            ExceptionHandler.process(e);
                                        }
                                        processContext.setRunning(false);
                                    }
                                }
                                debugMode = false;
                            }
                        });
                    } else {
                        if (process != null) {
                            // (one at leat) process
                            // still running
                            getDisplay().asyncExec(new Runnable() {

                                @Override
                                public void run() {
                                    setRunnable(false);
                                    killBtn.setEnabled(true);
                                    processContext.setRunning(true);
                                    processContext.setDebugProcess(process);
                                    if (!isAddedStreamListener) {
                                        process.getStreamsProxy().getOutputStreamMonitor().addListener(streamListener);
                                        // if (clearBeforeExec.getSelection()) {
                                        // processContext.clearMessages();
                                        // }
                                        // if (watchBtn.getSelection()) {
                                        // processContext.switchTime();
                                        // }
                                        ClearPerformanceAction clearPerfAction = new ClearPerformanceAction();
                                        clearPerfAction.setProcess(processContext.getProcess());
                                        clearPerfAction.run();
                                        ClearTraceAction clearTraceAction = new ClearTraceAction();
                                        clearTraceAction.setProcess(processContext.getProcess());
                                        clearTraceAction.run();
                                        isAddedStreamListener = true;
                                        //$NON-NLS-1$
                                        final String startingPattern = Messages.getString("ProcessComposite.startPattern");
                                        MessageFormat mf = new MessageFormat(startingPattern);
                                        String welcomeMsg = mf.format(new Object[] { processContext.getProcess().getName(), new Date() });
                                        processContext.addDebugResultToConsole(new ProcessMessage(MsgType.CORE_OUT, //$NON-NLS-1$
                                        welcomeMsg + "\r\n"));
                                    }
                                }
                            });
                        } else {
                            // no process running
                            getDisplay().asyncExec(new Runnable() {

                                @Override
                                public void run() {
                                    setRunnable(true);
                                    killBtn.setEnabled(false);
                                }
                            });
                        }
                    }
                    try {
                        Thread.sleep(2000);
                    } catch (InterruptedException e) {
                        // e.printStackTrace();
                        ExceptionHandler.process(e);
                    }
                }
            }
        };
        thread.start();
    } catch (Exception e) {
        ExceptionHandler.process(e);
        processContext.addErrorMessage(e);
        kill();
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) IContext(org.talend.core.model.process.IContext) IProcessor(org.talend.designer.runprocess.IProcessor) Processor(org.talend.designer.core.runprocess.Processor) ClearTraceAction(org.talend.designer.runprocess.ui.actions.ClearTraceAction) IProcess(org.eclipse.debug.core.model.IProcess) Process(org.talend.designer.core.ui.editor.process.Process) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressService(org.eclipse.ui.progress.IProgressService) IProcessMessage(org.talend.designer.runprocess.IProcessMessage) ProcessMessage(org.talend.designer.runprocess.ProcessMessage) IProcess(org.eclipse.debug.core.model.IProcess) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ProcessorException(org.talend.designer.runprocess.ProcessorException) MessageFormat(java.text.MessageFormat) IProcessor(org.talend.designer.runprocess.IProcessor) DebugException(org.eclipse.debug.core.DebugException) InvocationTargetException(java.lang.reflect.InvocationTargetException) Date(java.util.Date) DebugException(org.eclipse.debug.core.DebugException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ProcessorException(org.talend.designer.runprocess.ProcessorException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ClearPerformanceAction(org.talend.designer.runprocess.ui.actions.ClearPerformanceAction) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Example 74 with Process

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

the class ProcessComposite method getTRunjobList.

private List<Node> getTRunjobList(org.talend.core.model.process.IProcess process) {
    List<Node> trunjobList = new ArrayList<Node>();
    if (!(process instanceof Process)) {
        return trunjobList;
    }
    List<INode> nodeList = (List<INode>) ((Process) process).getGraphicalNodes();
    for (INode node : nodeList) {
        if (node.getComponent().getName().equals("tRunJob")) {
            //$NON-NLS-1$
            if (node instanceof Node) {
                trunjobList.add((Node) node);
            }
        }
    }
    return trunjobList;
}
Also used : INode(org.talend.core.model.process.INode) INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) ArrayList(java.util.ArrayList) IProcess(org.eclipse.debug.core.model.IProcess) Process(org.talend.designer.core.ui.editor.process.Process) ArrayList(java.util.ArrayList) List(java.util.List)

Example 75 with Process

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

the class NodeTest method testGetNodeConnectorsShowIf2FlowConnectorWithName.

@Test
public void testGetNodeConnectorsShowIf2FlowConnectorWithName() {
    Process process = new Process(new FakePropertyImpl());
    IComponent sourceCom = ComponentsFactoryProvider.getInstance().get("tMysqlInput", ComponentCategory.CATEGORY_4_DI.getName());
    Node node = new Node(sourceCom, process);
    // create node connector for test
    List<INodeConnector> listConnector = new ArrayList<>();
    NodeConnector connector1 = new NodeConnector(node);
    connector1.setDefaultConnectionType(EConnectionType.FLOW_MAIN);
    connector1.setName("FILTER");
    listConnector.add(connector1);
    connector1.setShowIf("SHOW_FLOW_CONNECTOR == 'true'");
    NodeConnector connector2 = new NodeConnector(node);
    connector2.setDefaultConnectionType(EConnectionType.FLOW_MAIN);
    connector2.setName("REJECT");
    connector2.setShowIf("SHOW_FLOW_CONNECTOR == 'true'");
    listConnector.add(connector2);
    node.setListConnector(listConnector);
    // create a test param with default value 'false'
    IElementParameter param = addShowIfParam(node);
    Assert.assertEquals(node.getConnectorsFromType(EConnectionType.FLOW_MAIN).size(), 0);
    // make connector show if to 'true'
    param.setValue(true);
    Assert.assertTrue(node.getConnectorFromName("FILTER") == connector1);
    Assert.assertTrue(node.getConnectorFromName("REJECT") == connector2);
    Assert.assertEquals(node.getConnectorsFromType(EConnectionType.FLOW_MAIN).size(), 2);
    // set CurLinkNbInput/Output should not affact other connector with same type but different name
    connector1.setCurLinkNbInput(10);
    connector1.setCurLinkNbOutput(100);
    Assert.assertEquals(connector1.getCurLinkNbInput(), 10);
    Assert.assertEquals(connector1.getCurLinkNbOutput(), 100);
    Assert.assertEquals(connector2.getCurLinkNbInput(), 0);
    Assert.assertEquals(connector2.getCurLinkNbOutput(), 0);
}
Also used : FakePropertyImpl(org.talend.core.model.repository.FakePropertyImpl) INodeConnector(org.talend.core.model.process.INodeConnector) NodeConnector(org.talend.designer.core.model.components.NodeConnector) IComponent(org.talend.core.model.components.IComponent) ArrayList(java.util.ArrayList) IElementParameter(org.talend.core.model.process.IElementParameter) Process(org.talend.designer.core.ui.editor.process.Process) INodeConnector(org.talend.core.model.process.INodeConnector) Test(org.junit.Test)

Aggregations

Process (org.talend.designer.core.ui.editor.process.Process)119 Node (org.talend.designer.core.ui.editor.nodes.Node)69 INode (org.talend.core.model.process.INode)48 ArrayList (java.util.ArrayList)45 IComponent (org.talend.core.model.components.IComponent)36 IElementParameter (org.talend.core.model.process.IElementParameter)28 Test (org.junit.Test)26 List (java.util.List)25 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)25 IProcess (org.talend.core.model.process.IProcess)24 Connection (org.talend.designer.core.ui.editor.connections.Connection)24 Property (org.talend.core.model.properties.Property)23 INodeConnector (org.talend.core.model.process.INodeConnector)22 IConnection (org.talend.core.model.process.IConnection)20 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)20 FakePropertyImpl (org.talend.core.model.repository.FakePropertyImpl)15 ProcessItem (org.talend.core.model.properties.ProcessItem)12 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)11 HashMap (java.util.HashMap)10 Before (org.junit.Before)9