Search in sources :

Example 1 with IStreamListener

use of org.eclipse.debug.core.IStreamListener in project titan.EclipsePlug-ins by eclipse.

the class CliExecutor method startSession.

/**
 * Initializes the Executor by starting the mctr_cli and connecting to it.
 *
 * @param arg2 the launch configuration to take the setup data from
 */
@Override
public void startSession(final ILaunch arg2) {
    ProcessBuilder pb = new ProcessBuilder();
    Map<String, String> env = pb.environment();
    if (!appendEnvironmentalVariables) {
        env.clear();
    }
    if (null != environmentalVariables) {
        try {
            EnvironmentHelper.resolveVariables(env, environmentalVariables);
        } catch (CoreException e) {
            ErrorReporter.logExceptionStackTrace(e);
        }
    }
    EnvironmentHelper.setTitanPath(env);
    EnvironmentHelper.set_LICENSE_FILE_PATH(env);
    String mctrCliPath = getMctrPath(env);
    List<String> command = new ArrayList<String>();
    command.add("sh");
    command.add("-c");
    if (addConfigFilePath(mctrCliPath, command)) {
        return;
    }
    printCommandToTitanConsole(command);
    pb.command(command);
    pb.redirectErrorStream(true);
    if (null != workingdirectoryPath) {
        File workingDir = new File(workingdirectoryPath);
        if (!workingDir.exists()) {
            Display.getDefault().syncExec(new Runnable() {

                @Override
                public void run() {
                    MessageDialog.openError(null, "Execution failed", "The working directory `" + workingdirectoryPath + "' does not exist.");
                }
            });
        }
        pb.directory(workingDir);
    }
    Process proc;
    try {
        proc = pb.start();
        final InputStream inputstream = proc.getInputStream();
        if (inputstream.markSupported()) {
            inputstream.mark(40000);
        }
        BufferedReader stdout = new BufferedReader(new InputStreamReader(inputstream));
        processWelcomeScreen(stdout);
        if (inputstream.markSupported()) {
            inputstream.reset();
        }
    } catch (IOException e) {
        ErrorReporter.logExceptionStackTrace(e);
        proc = null;
    }
    if (null != proc) {
        process = DebugPlugin.newProcess(arg2, proc, MAIN_CONTROLLER);
        IStreamsProxy proxy = process.getStreamsProxy();
        if (null != proxy) {
            IStreamMonitor outputStreamMonitor = proxy.getOutputStreamMonitor();
            IStreamListener outputListener = new IStreamListener() {

                @Override
                public void streamAppended(final String text, final IStreamMonitor monitor) {
                    processConsoleOutput(text);
                }
            };
            if (null != outputStreamMonitor) {
                processConsoleOutput(outputStreamMonitor.getContents());
                outputStreamMonitor.addListener(outputListener);
            }
        }
        info();
    }
    super.startSession(arg2);
    if (null == proc || null == process || process.isTerminated()) {
        terminate(true);
    }
    if (null != Activator.getMainView()) {
        Activator.getMainView().refreshAll();
    }
    if (null != thread) {
        thread.start();
    }
}
Also used : IStreamListener(org.eclipse.debug.core.IStreamListener) InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) IProcess(org.eclipse.debug.core.model.IProcess) IOException(java.io.IOException) IStreamMonitor(org.eclipse.debug.core.model.IStreamMonitor) CoreException(org.eclipse.core.runtime.CoreException) BufferedReader(java.io.BufferedReader) IStreamsProxy(org.eclipse.debug.core.model.IStreamsProxy) File(java.io.File)

Example 2 with IStreamListener

use of org.eclipse.debug.core.IStreamListener in project titan.EclipsePlug-ins by eclipse.

the class HostJob method run.

@Override
protected IStatus run(final IProgressMonitor monitor) {
    IProcess process = DebugPlugin.newProcess(executor.getLaunchStarted(), proc, getName());
    final IStreamsProxy proxy = process.getStreamsProxy();
    if (null != proxy) {
        final IStreamMonitor outputStreamMonitor = proxy.getOutputStreamMonitor();
        final IStreamListener listener = new IStreamListener() {

            @Override
            public void streamAppended(final String text, final IStreamMonitor monitor) {
                processConsoleOutput(text);
            }
        };
        if (null != outputStreamMonitor) {
            final String temp = outputStreamMonitor.getContents();
            processConsoleOutput(temp);
            outputStreamMonitor.addListener(listener);
        }
    }
    final MessageConsoleStream stream = TITANConsole.getConsole().newMessageStream();
    String line;
    final BufferedReader stdout = new BufferedReader(new InputStreamReader(proc.getInputStream()));
    final BufferedReader stderr = new BufferedReader(new InputStreamReader(proc.getErrorStream()));
    try {
        final int exitVal = proc.waitFor();
        if (0 == exitVal) {
            executor.addNotification(new Notification((new Formatter()).format(BaseExecutor.PADDEDDATETIMEFORMAT, new Date()).toString(), EMPTY, EMPTY, "Host Controller executed successfully"));
        } else {
            if (stderr.ready()) {
                final String tempDate = (new Formatter()).format(BaseExecutor.PADDEDDATETIMEFORMAT, new Date()).toString();
                executor.addNotification(new Notification(tempDate, EMPTY, EMPTY, "Host Controller execution failed"));
                executor.addNotification(new Notification(tempDate, EMPTY, EMPTY, "  returned with value:" + exitVal));
                executor.addNotification(new Notification(tempDate, EMPTY, EMPTY, "Sent the following error messages:"));
                line = stderr.readLine();
                while (null != line) {
                    executor.addNotification(new Notification(tempDate, EMPTY, EMPTY, line));
                    line = stderr.readLine();
                }
            }
        }
        proc.destroy();
    } catch (IOException e) {
        stream.println("execution failed beacuse of interrupion");
        ErrorReporter.logExceptionStackTrace(e);
        return Status.CANCEL_STATUS;
    } catch (InterruptedException e) {
        stream.println("execution failed beacuse of interrupion");
        ErrorReporter.logExceptionStackTrace(e);
        return Status.CANCEL_STATUS;
    } finally {
        try {
            stdout.close();
        } catch (IOException e) {
            ErrorReporter.logExceptionStackTrace(e);
        }
        try {
            stderr.close();
        } catch (IOException e) {
            ErrorReporter.logExceptionStackTrace(e);
        }
    }
    return Status.OK_STATUS;
}
Also used : IStreamListener(org.eclipse.debug.core.IStreamListener) InputStreamReader(java.io.InputStreamReader) Formatter(java.util.Formatter) MessageConsoleStream(org.eclipse.ui.console.MessageConsoleStream) IOException(java.io.IOException) Notification(org.eclipse.titan.executor.views.notification.Notification) Date(java.util.Date) IStreamMonitor(org.eclipse.debug.core.model.IStreamMonitor) BufferedReader(java.io.BufferedReader) IStreamsProxy(org.eclipse.debug.core.model.IStreamsProxy) IProcess(org.eclipse.debug.core.model.IProcess)

Example 3 with IStreamListener

use of org.eclipse.debug.core.IStreamListener in project mdw-designer by CenturyLinkCloud.

the class GherkinTestCaseLaunch method run.

@Override
public void run() {
    synchronized (lock) {
        try {
            launchConfig = getLaunchConfiguration();
            IDebugEventSetListener listener = new IDebugEventSetListener() {

                public void handleDebugEvents(DebugEvent[] events) {
                    for (DebugEvent event : events) {
                        if (event.getSource() instanceof IProcess) {
                            IProcess process = (IProcess) event.getSource();
                            if (event.getKind() == DebugEvent.CREATE) {
                                process.getStreamsProxy().getOutputStreamMonitor().addListener(new IStreamListener() {

                                    public void streamAppended(String text, IStreamMonitor monitor) {
                                        log.print(text);
                                        if (text.equals("===== execute case " + getTestCase().getCaseName() + "\r\n"))
                                            getTestCase().setStatus(TestCase.STATUS_RUNNING);
                                        getTestCase().setStartDate(new Date());
                                    }
                                });
                                process.getStreamsProxy().getErrorStreamMonitor().addListener(new IStreamListener() {

                                    public void streamAppended(String text, IStreamMonitor monitor) {
                                        log.print(text);
                                    }
                                });
                            } else if (event.getKind() == DebugEvent.TERMINATE && process.getLaunch().getLaunchConfiguration().equals(launchConfig) && process.isTerminated() && true) {
                                getTestCase().setEndDate(new Date());
                                try {
                                    if (process.getExitValue() == 0) {
                                        getTestCase().setStatus(TestCase.STATUS_PASS);
                                    } else {
                                        String exitMsg = "Cucumber exit code: " + process.getExitValue();
                                        log.println(exitMsg);
                                        // TODO why
                                        setMessage(exitMsg);
                                        // not
                                        // displayed?
                                        getTestCase().setStatus(TestCase.STATUS_FAIL);
                                    }
                                    if (log != System.out)
                                        log.close();
                                } catch (DebugException ex) {
                                    PluginMessages.log(ex);
                                    ex.printStackTrace(log);
                                    getTestCase().setStatus(TestCase.STATUS_ERROR);
                                    if (log != System.out)
                                        log.close();
                                }
                            }
                        }
                    }
                }
            };
            DebugPlugin.getDefault().addDebugEventListener(listener);
            DebugUITools.launch(launchConfig, ILaunchManager.RUN_MODE);
        } catch (Throwable ex) {
            PluginMessages.log(ex);
            ex.printStackTrace(log);
            getTestCase().setStatus(TestCase.STATUS_ERROR);
            getTestCase().setEndDate(new Date());
            if (log != System.out)
                log.close();
        }
    }
}
Also used : IStreamListener(org.eclipse.debug.core.IStreamListener) IStreamMonitor(org.eclipse.debug.core.model.IStreamMonitor) IDebugEventSetListener(org.eclipse.debug.core.IDebugEventSetListener) DebugEvent(org.eclipse.debug.core.DebugEvent) DebugException(org.eclipse.debug.core.DebugException) IProcess(org.eclipse.debug.core.model.IProcess) Date(java.util.Date)

Example 4 with IStreamListener

use of org.eclipse.debug.core.IStreamListener in project mdw-designer by CenturyLinkCloud.

the class CucumberLaunchListener method handleDebugEvents.

public void handleDebugEvents(DebugEvent[] events) {
    for (DebugEvent event : events) {
        if (event.getSource() instanceof IProcess) {
            IProcess process = (IProcess) event.getSource();
            if (event.getKind() == DebugEvent.CREATE) {
                process.getStreamsProxy().getOutputStreamMonitor().addListener(new IStreamListener() {

                    public void streamAppended(String text, IStreamMonitor monitor) {
                        System.out.print(text);
                        if (!running) {
                            running = true;
                            start = new Date();
                        }
                    }
                });
                process.getStreamsProxy().getErrorStreamMonitor().addListener(new IStreamListener() {

                    public void streamAppended(String text, IStreamMonitor monitor) {
                        System.out.print(text);
                    }
                });
            } else if (event.getKind() == DebugEvent.TERMINATE && process.getLaunch().getLaunchConfiguration().equals(launchConfig) && process.isTerminated() && true) {
                end = new Date();
                try {
                    int exitCode = process.getExitValue();
                    if (exitCode == 0) {
                        status = TestCase.STATUS_PASS;
                    } else {
                        status = TestCase.STATUS_FAIL;
                    }
                } catch (DebugException ex) {
                    PluginMessages.log(ex);
                    status = TestCase.STATUS_ERROR;
                }
            }
        }
    }
}
Also used : IStreamListener(org.eclipse.debug.core.IStreamListener) IStreamMonitor(org.eclipse.debug.core.model.IStreamMonitor) DebugEvent(org.eclipse.debug.core.DebugEvent) DebugException(org.eclipse.debug.core.DebugException) IProcess(org.eclipse.debug.core.model.IProcess) Date(java.util.Date)

Example 5 with IStreamListener

use of org.eclipse.debug.core.IStreamListener in project tdi-studio-se by Talend.

the class ProcessComposite method initGraphicComponents.

/**
     * DOC amaumont Comment method "initGraphicComponents".
     * 
     * @param parent
     */
private void initGraphicComponents(Composite parent) {
    setExpandHorizontal(true);
    setExpandVertical(true);
    this.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
    FormData layouData = new FormData();
    layouData.left = new FormAttachment(0, 0);
    layouData.right = new FormAttachment(100, 0);
    layouData.top = new FormAttachment(0, 0);
    layouData.bottom = new FormAttachment(100, 0);
    setLayoutData(layouData);
    this.setLayout(new FormLayout());
    final Composite panel = new Composite(this, SWT.NONE);
    setContent(panel);
    // panel.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_DARK_RED));
    FormLayout layout2 = new FormLayout();
    layout2.marginWidth = 5 + 2;
    layout2.marginHeight = 4;
    layout2.spacing = 6 + 1;
    panel.setLayout(layout2);
    GridData data;
    GridLayout layout = new GridLayout();
    // panel.setLayout(layout);
    // Splitter
    // sash = new SashForm(this, SWT.HORIZONTAL | SWT.SMOOTH);
    // sash.setLayoutData(new GridData(GridData.FILL_BOTH));
    //
    // layout = new GridLayout();
    // sash.setLayout(layout);
    //
    // // group Button
    // // qli,see the feature 6366.
    //
    // Composite buttonComposite = new Composite(sash, SWT.ERROR);
    // buttonComposite.setLayout(new GridLayout());
    //
    // moveButton = new Button(buttonComposite, SWT.PUSH);
    //        moveButton.setText("<<"); //$NON-NLS-1$
    //        moveButton.setToolTipText(Messages.getString("ProcessComposite.hideContext")); //$NON-NLS-1$
    //
    // final GridData layoutData = new GridData();
    // layoutData.verticalAlignment = GridData.CENTER;
    // layoutData.horizontalAlignment = GridData.CENTER;
    // layoutData.grabExcessHorizontalSpace = true;
    // layoutData.grabExcessVerticalSpace = true;
    // moveButton.setLayoutData(layoutData);
    // Group execution
    Group execGroup = new Group(panel, SWT.NONE);
    //$NON-NLS-1$
    execGroup.setText(Messages.getString("ProcessComposite.execGroup"));
    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    execGroup.setLayout(layout);
    FormData layouDatag = new FormData();
    layouDatag.left = new FormAttachment(0, 0);
    layouDatag.right = new FormAttachment(100, 0);
    layouDatag.top = new FormAttachment(0, 0);
    layouDatag.bottom = new FormAttachment(100, 0);
    execGroup.setLayoutData(layouDatag);
    // leftTabFolder = new CTabFolder(this, SWT.BORDER);
    // leftTabFolder.setSimple(false);
    // //
    // leftTabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
    // //
    // // // Group context
    // //
    // CTabItem contextTabItem = new CTabItem(leftTabFolder, SWT.BORDER);
    //        contextTabItem.setText(Messages.getString("ProcessComposite.contextTab")); //$NON-NLS-1$
    // // contextComposite = new ProcessContextComposite(this, SWT.NONE);
    // // contextComposite.setBackground(leftTabFolder.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    // // contextTabItem.setControl(contextComposite);
    // //
    // Composite targetExecutionComposite = createTargetExecutionComposite(leftTabFolder);
    // targetExecutionComposite.setBackground(leftTabFolder.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    // //
    // targetExecutionTabItem = new CTabItem(leftTabFolder, SWT.BORDER);
    //        targetExecutionTabItem.setText(Messages.getString("ProcessComposite.targetExecutionTab")); //$NON-NLS-1$
    // targetExecutionTabItem.setToolTipText(Messages.getString("ProcessComposite.targetExecutionTabTooltipAvailable"));
    // targetExecutionTabItem.setControl(targetExecutionComposite);
    // //
    // // // Job Run VM Arguments Tab if language is java.
    // if (LanguageManager.getCurrentLanguage() == ECodeLanguage.JAVA) {
    // jobVMTabItem = new CTabItem(leftTabFolder, SWT.BORDER);
    //            jobVMTabItem.setText(Messages.getString("ProcessComposite.JVMTab")); //$NON-NLS-1$
    // argumentsComposite = new Composite(leftTabFolder, SWT.NONE);
    // argumentsComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    // GridLayout gridLayoutArguments = new GridLayout(1, false);
    // argumentsComposite.setLayout(gridLayoutArguments);
    // argumentsViewer = new JobVMArgumentsComposite("vmarguments", Messages
    //                    .getString("RunProcessPreferencePage.vmArgument"), //$NON-NLS-1$
    // argumentsComposite);
    // // argumentsViewer.setEnabled(false, argumentsComposite);
    // jobVMTabItem.setControl(argumentsComposite);
    // }
    ScrolledComposite execScroll = new ScrolledComposite(execGroup, SWT.V_SCROLL | SWT.H_SCROLL);
    execScroll.setExpandHorizontal(true);
    execScroll.setExpandVertical(true);
    execScroll.setLayoutData(new GridData(GridData.FILL_BOTH));
    Composite execContent = new Composite(execScroll, SWT.NONE);
    layout = new GridLayout();
    execContent.setLayout(new FormLayout());
    execScroll.setContent(execContent);
    Composite execHeader = new Composite(execContent, SWT.NONE);
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = 7;
    formLayout.marginHeight = 4;
    formLayout.spacing = 7;
    execHeader.setLayout(formLayout);
    FormData layoutData = new FormData();
    layoutData.left = new FormAttachment(0, 0);
    layoutData.right = new FormAttachment(100, 0);
    layoutData.top = new FormAttachment(0, 0);
    layoutData.bottom = new FormAttachment(0, 50);
    // new GridData(GridData.FILL_HORIZONTAL)
    execHeader.setLayoutData(layoutData);
    // qli
    // see the feature 6366
    run = new Button(execHeader, SWT.PUSH);
    // itemDropDown = new ToolItem(toolBar, SWT.ARROW);
    //$NON-NLS-1$//$NON-NLS-2$
    run.setText(" " + Messages.getString("ProcessComposite.exec"));
    run.setData(ProcessView.EXEC_ID);
    //$NON-NLS-1$
    run.setToolTipText(Messages.getString("ProcessComposite.execHint"));
    run.setImage(ImageProvider.getImage(ERunprocessImages.RUN_PROCESS_ACTION));
    // final Menu menu = new Menu(execHeader);
    run.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            execRun();
        }
    });
    // Run
    // final MenuItem menuItem1 = new MenuItem(menu, SWT.PUSH);
    //        menuItem1.setText(" " + Messages.getString("ProcessComposite.exec"));//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
    // menuItem1.setImage(ImageProvider.getImage(ERunprocessImages.RUN_PROCESS_ACTION));
    // menuItem1.setData(ProcessView.EXEC_ID);
    // menuItem1.addSelectionListener(new SelectionAdapter() {
    //
    // public void widgetSelected(SelectionEvent event) {
    // if (!itemDropDown.getData().equals(ProcessView.PAUSE_ID) &&
    // !itemDropDown.getData().equals(ProcessView.RESUME_ID)) {
    // itemDropDown.setText(menuItem1.getText());
    // itemDropDown.setData(ProcessView.EXEC_ID);
    // itemDropDown.setImage(ImageProvider.getImage(ERunprocessImages.RUN_PROCESS_ACTION));
    //                    itemDropDown.setToolTipText(Messages.getString("ProcessComposite.execHint"));//$NON-NLS-1$
    // toolBar.getParent().layout();
    // }
    // }
    // });
    IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
    // }
    if (processContext == null) {
        run.setEnabled(false);
    }
    // toolBar.setEnabled(false);
    FormData formData = new FormData();
    // see the feature 6366,qli comment.
    // make a judge when the text change in diffrent languages.
    Point debugSize = null;
    Point execSize = null;
    formData.left = new FormAttachment(0);
    // if (brandingService.getBrandingConfiguration().isAllowDebugMode()) {
    // // set debug text to judge size
    // itemDropDown.setText(debugMenuItem.getText());
    // debugSize = computeSize(itemDropDown.getText());
    //
    // // set exec text to judge size
    // itemDropDown.setText(menuItem1.getText());
    // execSize = computeSize(itemDropDown.getText());
    // if (debugSize.x > execSize.x) {
    // formData.right = new FormAttachment(0, debugSize.x + 70);
    // } else {
    // formData.right = new FormAttachment(0, execSize.x + 70);
    // }
    // } else {
    // set exec text to judge size
    execSize = computeSize(run.getText());
    formData.right = new FormAttachment(0, execSize.x + 70);
    formData.height = 30;
    // }
    run.setLayoutData(formData);
    killBtn = new Button(execHeader, SWT.PUSH);
    //$NON-NLS-1$
    killBtn.setText(Messages.getString("ProcessComposite.kill"));
    //$NON-NLS-1$
    killBtn.setToolTipText(Messages.getString("ProcessComposite.killHint"));
    killBtn.setImage(ImageProvider.getImage(ERunprocessImages.KILL_PROCESS_ACTION));
    setButtonLayoutData(killBtn);
    killBtn.setEnabled(false);
    formData = new FormData();
    formData.top = new FormAttachment(run, 0, SWT.TOP);
    formData.left = new FormAttachment(run, 0, SWT.RIGHT);
    // qli modified to fix the bug "7302".
    Point killSize = computeSize(killBtn.getText());
    // if (brandingService.getBrandingConfiguration().isAllowDebugMode()) {
    // if ((killSize.x > debugSize.x) && (killSize.x > execSize.x)) {
    // formData.right = new FormAttachment(toolBar, killSize.x + 70, SWT.RIGHT);
    // } else if (debugSize.x > execSize.x) {
    // formData.right = new FormAttachment(toolBar, debugSize.x + 70, SWT.RIGHT);
    // } else {
    // formData.right = new FormAttachment(toolBar, execSize.x + 70, SWT.RIGHT);
    // }
    // } else {
    // if (killSize.x > execSize.x) {
    // formData.right = new FormAttachment(toolBar, killSize.x + 70, SWT.RIGHT);
    // } else {
    // formData.right = new FormAttachment(toolBar, execSize.x + 70, SWT.RIGHT);
    // }
    // }
    formData.right = new FormAttachment(run, 30 + 70, SWT.RIGHT);
    formData.height = 30;
    killBtn.setLayoutData(formData);
    // saveJobBeforeRunButton = new Button(execHeader, SWT.CHECK);
    //        saveJobBeforeRunButton.setText(Messages.getString("ProcessComposite.saveBeforeRun")); //$NON-NLS-1$
    //        saveJobBeforeRunButton.setToolTipText(Messages.getString("ProcessComposite.saveBeforeRunHint")); //$NON-NLS-1$
    // // saveJobBeforeRunButton.setEnabled(false);
    // saveJobBeforeRunButton.setSelection(RunProcessPlugin.getDefault().getPreferenceStore().getBoolean(
    // RunProcessPrefsConstants.ISSAVEBEFORERUN));
    // data = new GridData();
    // data.horizontalSpan = 2;
    // data.horizontalAlignment = SWT.END;
    // saveJobBeforeRunButton.setLayoutData(data);
    // formData = new FormData();
    // formData.top = new FormAttachment(toolBar, 0, SWT.BOTTOM);
    // formData.left = new FormAttachment(toolBar, 0, SWT.LEFT);
    // saveJobBeforeRunButton.setLayoutData(formData);
    // clearBeforeExec = new Button(execHeader, SWT.CHECK);
    //        clearBeforeExec.setText(Messages.getString("ProcessComposite.clearBefore")); //$NON-NLS-1$
    //        clearBeforeExec.setToolTipText(Messages.getString("ProcessComposite.clearBeforeHint")); //$NON-NLS-1$
    // // clearBeforeExec.setEnabled(false);
    // clearBeforeExec.setSelection(RunProcessPlugin.getDefault().getPreferenceStore().getBoolean(
    // RunProcessPrefsConstants.ISCLEARBEFORERUN));
    // data = new GridData();
    // data.horizontalSpan = 2;
    // data.horizontalAlignment = SWT.END;
    // clearBeforeExec.setLayoutData(data);
    // formData = new FormData();
    // formData.top = new FormAttachment(toolBar, 0, SWT.BOTTOM);
    // formData.left = new FormAttachment(saveJobBeforeRunButton, 0, SWT.RIGHT);
    // clearBeforeExec.setLayoutData(formData);
    //
    // watchBtn = new Button(execHeader, SWT.CHECK);
    //        watchBtn.setText(Messages.getString("ProcessComposite.execTime")); //$NON-NLS-1$
    //        watchBtn.setToolTipText(Messages.getString("ProcessComposite.execTimeHint")); //$NON-NLS-1$
    // watchBtn.setEnabled(false);
    // watchBtn.setSelection(RunProcessPlugin.getDefault().getPreferenceStore().getBoolean(
    // RunProcessPrefsConstants.ISEXECTIMERUN));
    // data = new GridData();
    // data.horizontalSpan = 2;
    // data.horizontalAlignment = SWT.END;
    // watchBtn.setLayoutData(data);
    // formData = new FormData();
    // formData.top = new FormAttachment(killBtn, 0, SWT.BOTTOM);
    // formData.left = new FormAttachment(clearBeforeExec, 0, SWT.RIGHT);
    // watchBtn.setLayoutData(formData);
    //
    // Group statisticsComposite = new Group(execHeader, SWT.NONE);
    //        statisticsComposite.setText(Messages.getString("ProcessComposite2.statsComposite")); //$NON-NLS-1$
    // layout = new GridLayout(3, false);
    // layout.marginWidth = 0;
    // statisticsComposite.setLayout(layout);
    // formData = new FormData();
    // // formData.right = new FormAttachment(100, 0);
    // / formData.left = new FormAttachment(watchBtn, 0, SWT.RIGHT);
    // statisticsComposite.setLayoutData(formData);
    //
    // Composite statisticsButtonComposite = new Composite(statisticsComposite, SWT.NONE);
    // layout = new GridLayout(1, false);
    // layout.marginWidth = 0;
    // statisticsButtonComposite.setLayout(layout);
    // statisticsButtonComposite.setLayoutData(new GridData(GridData.FILL_VERTICAL));
    // perfBtn = new Button(statisticsButtonComposite, SWT.CHECK);
    //        perfBtn.setText(Messages.getString("ProcessComposite.stat")); //$NON-NLS-1$
    //        perfBtn.setToolTipText(Messages.getString("ProcessComposite.statHint")); //$NON-NLS-1$
    // perfBtn.setEnabled(false);
    // perfBtn.setSelection(RunProcessPlugin.getDefault().getPreferenceStore().getBoolean(
    // RunProcessPrefsConstants.ISSTATISTICSRUN));
    // traceBtn = new Button(statisticsButtonComposite, SWT.CHECK);
    //        traceBtn.setText(Messages.getString("ProcessComposite.trace")); //$NON-NLS-1$
    //        traceBtn.setToolTipText(Messages.getString("ProcessComposite.traceHint")); //$NON-NLS-1$
    // traceBtn.setEnabled(false);
    // traceBtn
    // .setSelection(RunProcessPlugin.getDefault().getPreferenceStore().getBoolean(RunProcessPrefsConstants.ISTRACESRUN));
    clearTracePerfBtn = new Button(execHeader, SWT.PUSH);
    //$NON-NLS-1$
    clearTracePerfBtn.setText(Messages.getString("ProcessComposite.clear"));
    //$NON-NLS-1$
    clearTracePerfBtn.setToolTipText(Messages.getString("ProcessComposite.clearHint"));
    clearTracePerfBtn.setImage(ImageProvider.getImage(RunProcessPlugin.imageDescriptorFromPlugin(RunProcessPlugin.PLUGIN_ID, //$NON-NLS-1$
    "icons/process_stat_clear.gif")));
    clearTracePerfBtn.setEnabled(false);
    formData = new FormData();
    formData.top = new FormAttachment(killBtn, 0, SWT.TOP);
    formData.left = new FormAttachment(killBtn, 0, SWT.RIGHT);
    formData.right = new FormAttachment(killBtn, 10 + 70, SWT.RIGHT);
    formData.height = 30;
    clearTracePerfBtn.setLayoutData(formData);
    consoleText = new StyledText(execContent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY);
    consoleText.setWordWrap(true);
    data = new GridData(GridData.FILL_BOTH);
    data.horizontalSpan = 2;
    data.minimumHeight = MINIMUM_HEIGHT;
    data.minimumWidth = MINIMUM_WIDTH;
    layouData = new FormData();
    layouData.left = new FormAttachment(0, 10);
    layouData.right = new FormAttachment(100, 0);
    layouData.top = new FormAttachment(0, 50);
    layouData.bottom = new FormAttachment(100, -30);
    consoleText.setLayoutData(layouData);
    // feature 6875, add searching capability, nma
    consoleText.addKeyListener(new KeyListener() {

        @Override
        public void keyPressed(KeyEvent evt) {
            // select all
            if ((evt.stateMask == SWT.CTRL) && (evt.keyCode == 'a')) {
                if (consoleText.getText().length() > 0) {
                    consoleText.setSelection(0, (consoleText.getText().length() - 1));
                }
            } else // search special string value
            if ((evt.stateMask == SWT.CTRL) && (evt.keyCode == 'f')) {
                FindDialog td = new FindDialog(Display.getCurrent().getActiveShell());
                td.setConsoleText(consoleText);
                td.setBlockOnOpen(true);
                td.open();
            }
        }

        @Override
        public void keyReleased(KeyEvent arg0) {
        }
    });
    // see feature 0004895: Font size of the output console are very small
    setConsoleFont();
    IPreferenceStore preferenceStore = CorePlugin.getDefault().getPreferenceStore();
    preferenceStore.addPropertyChangeListener(new IPropertyChangeListener() {

        @Override
        public void propertyChange(org.eclipse.jface.util.PropertyChangeEvent event) {
            if (TalendDesignerPrefConstants.CONSOLT_TEXT_FONT.endsWith(event.getProperty())) {
                setConsoleFont();
            }
        }
    });
    // execScroll.setMinSize(execContent.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    // sash.setSashWidth(1);
    // sash.setWeights(new int[] { 7, 1, H_WEIGHT });
    pcl = new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            runProcessContextChanged(evt);
        }
    };
    streamListener = new IStreamListener() {

        @Override
        public void streamAppended(String text, IStreamMonitor monitor) {
            IProcessMessage message = new ProcessMessage(ProcessMessage.MsgType.STD_OUT, text);
            processContext.addDebugResultToConsole(message);
        }
    };
    addListeners();
    createLineLimitedControl(execContent);
}
Also used : IStreamListener(org.eclipse.debug.core.IStreamListener) Group(org.eclipse.swt.widgets.Group) PropertyChangeListener(java.beans.PropertyChangeListener) IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) IProcessMessage(org.talend.designer.runprocess.IProcessMessage) ProcessMessage(org.talend.designer.runprocess.ProcessMessage) FormAttachment(org.eclipse.swt.layout.FormAttachment) FormData(org.eclipse.swt.layout.FormData) FormLayout(org.eclipse.swt.layout.FormLayout) IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) PropertyChangeEvent(java.beans.PropertyChangeEvent) StyledText(org.eclipse.swt.custom.StyledText) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) IBrandingService(org.talend.core.ui.branding.IBrandingService) Point(org.eclipse.swt.graphics.Point) IStreamMonitor(org.eclipse.debug.core.model.IStreamMonitor) IProcessMessage(org.talend.designer.runprocess.IProcessMessage) GridData(org.eclipse.swt.layout.GridData) KeyListener(org.eclipse.swt.events.KeyListener) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Aggregations

IStreamListener (org.eclipse.debug.core.IStreamListener)9 IStreamMonitor (org.eclipse.debug.core.model.IStreamMonitor)9 IProcess (org.eclipse.debug.core.model.IProcess)5 IStreamsProxy (org.eclipse.debug.core.model.IStreamsProxy)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 CoreException (org.eclipse.core.runtime.CoreException)3 BufferedReader (java.io.BufferedReader)2 File (java.io.File)2 InputStreamReader (java.io.InputStreamReader)2 DebugEvent (org.eclipse.debug.core.DebugEvent)2 DebugException (org.eclipse.debug.core.DebugException)2 ILaunch (org.eclipse.debug.core.ILaunch)2 MessageConsoleStream (org.eclipse.ui.console.MessageConsoleStream)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 InputStream (java.io.InputStream)1 Formatter (java.util.Formatter)1 List (java.util.List)1