Search in sources :

Example 1 with IProcessMessage

use of org.talend.designer.runprocess.IProcessMessage in project tdi-studio-se by Talend.

the class DebugProcessTosComposite method fillConsole.

@Override
protected void fillConsole(Collection<IProcessMessage> messages) {
    //$NON-NLS-1$
    consoleText.setText("");
    for (IProcessMessage processMessage : messages) {
        doAppendToConsole(processMessage);
    }
    scrollToEnd();
}
Also used : IProcessMessage(org.talend.designer.runprocess.IProcessMessage)

Example 2 with IProcessMessage

use of org.talend.designer.runprocess.IProcessMessage in project tdi-studio-se by Talend.

the class DebugProcessTosComposite method addPerlMark.

@Override
protected void addPerlMark(IProcessMessage psMess) {
    if (psMess.getType().equals(MsgType.STD_ERR)) {
        String content = psMess.getContent();
        String path = null;
        String uniName = null;
        int lineNo = -1;
        //$NON-NLS-1$
        Pattern errorPattern = Pattern.compile("(.*) at (\\S+) line (\\d+)[\\.,]");
        Matcher m = errorPattern.matcher(content);
        String matchContent = null;
        while (m.find()) {
            path = m.group(2);
            lineNo = parseInt(m.group(3));
            matchContent = m.group();
            if ((!("".equals(path)) && path != null) && lineNo > 0) {
                //$NON-NLS-1$ 
                uniName = Problems.setErrorMark(path, lineNo);
            }
            if (uniName != null) {
                if (!errorMessMap.containsKey(uniName)) {
                    errorMessMap.put(uniName, new ProcessMessage(MsgType.STD_ERR, matchContent));
                } else {
                    String uniMess = errorMessMap.get(uniName).getContent();
                    errorMessMap.put(uniName, new ProcessMessage(MsgType.STD_ERR, uniMess.concat(matchContent)));
                }
            }
        }
    }
    refreshNode(psMess);
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) IProcessMessage(org.talend.designer.runprocess.IProcessMessage) ProcessMessage(org.talend.designer.runprocess.ProcessMessage) Point(org.eclipse.swt.graphics.Point)

Example 3 with IProcessMessage

use of org.talend.designer.runprocess.IProcessMessage in project tdi-studio-se by Talend.

the class DebugProcessTosComposite method runProcessContextChanged.

private void runProcessContextChanged(final PropertyChangeEvent evt) {
    String propName = evt.getPropertyName();
    Display dis = Display.getCurrent();
    if (dis == null) {
        dis = Display.getDefault();
    }
    if (ProcessMessageManager.PROP_MESSAGE_ADD.equals(propName) || ProcessMessageManager.PROP_DEBUG_MESSAGE_ADD.equals(propName)) {
        IProcessMessage psMess = (IProcessMessage) evt.getNewValue();
        if (errorMessMap.size() <= CorePlugin.getDefault().getPreferenceStore().getInt(ITalendCorePrefConstants.PREVIEW_LIMIT)) {
            if (!(LanguageManager.getCurrentLanguage().equals(ECodeLanguage.PERL))) {
                getAllErrorMess(psMess);
            } else {
                addPerlMark(psMess);
            }
        }
        appendToConsole(psMess);
    } else if (ProcessMessageManager.PROP_MESSAGE_CLEAR.equals(propName)) {
        dis.asyncExec(new Runnable() {

            @Override
            public void run() {
                if (!consoleText.isDisposed()) {
                    //$NON-NLS-1$
                    consoleText.setText("");
                }
            }
        });
    } else if (RunProcessContext.PROP_MONITOR.equals(propName)) {
    // perfBtn.setSelection(((Boolean) evt.getNewValue()).booleanValue());
    } else if (RunProcessContext.TRACE_MONITOR.equals(propName)) {
    // traceBtn.setSelection(((Boolean) evt.getNewValue()).booleanValue());
    } else if (RunProcessContext.PROP_RUNNING.equals(propName)) {
        dis.asyncExec(new Runnable() {

            @Override
            public void run() {
                if (isDisposed()) {
                    return;
                }
                boolean running = ((Boolean) evt.getNewValue()).booleanValue();
                setRunnable(!running);
                if (!killBtn.isDisposed() && killBtn != null) {
                    killBtn.setEnabled(running);
                }
                isRuning = false;
            // previousRow.setEnabled(running);
            // nextRow.setEnabled(running);
            // nextBreakPoint.setEnabled(running);
            }
        });
    }
}
Also used : IProcessMessage(org.talend.designer.runprocess.IProcessMessage) Display(org.eclipse.swt.widgets.Display)

Example 4 with IProcessMessage

use of org.talend.designer.runprocess.IProcessMessage in project tdi-studio-se by Talend.

the class ExecuteSystemCommandCommand method execute.

@Override
public void execute() {
    if (commandsList == null || commandsList.isEmpty()) {
        return;
    }
    List<IProcessMessage> consoleMessList = new ArrayList<IProcessMessage>();
    final Shell shell = PlatformUI.getWorkbench().getDisplay().getActiveShell();
    CommandProgressDialog progressDialog = new CommandProgressDialog(shell, commandsList, consoleMessList);
    try {
        progressDialog.executeProcess();
    } catch (InvocationTargetException e) {
        addCommandMessages(consoleMessList, CommandMsgType.CORE_ERR, e.toString());
    } catch (InterruptedException e) {
        addCommandMessages(consoleMessList, CommandMsgType.CORE_ERR, e.toString());
    }
    if (!consoleMessList.isEmpty()) {
        ShowCommandMessage show = new ShowCommandMessage(shell, progressDialog.getCommands(), consoleMessList);
        show.open();
    }
}
Also used : IProcessMessage(org.talend.designer.runprocess.IProcessMessage) Shell(org.eclipse.swt.widgets.Shell) ArrayList(java.util.ArrayList) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 5 with IProcessMessage

use of org.talend.designer.runprocess.IProcessMessage in project tdi-studio-se by Talend.

the class TraceDebugProcessComposite method getAllErrorMess.

public void getAllErrorMess(IProcessMessage psMess) {
    if (psMess.getType().equals(MsgType.STD_ERR)) {
        String mess = psMess.getContent();
        //$NON-NLS-1$
        String[] linesMess = mess.split("\n");
        StringBuffer currentMess = new StringBuffer();
        String currenctJobName = processContext.getProcess().getName();
        for (int i = 0; i < linesMess.length; i++) {
            String tRunJobName = currenctJobName;
            String linemess = linesMess[i].trim();
            //$NON-NLS-1$
            Pattern pattern = Pattern.compile("^Exception\\s*in\\s*component\\s*(\\w)+_\\d$");
            Matcher m = pattern.matcher(linemess);
            if (m.find()) {
                List<Node> runjobList = getTRunjobList(processContext.getProcess());
                //$NON-NLS-1$
                String[] allwords = linemess.split("\\s");
                String componentName = allwords[allwords.length - 1];
                if (runjobList.size() > 0) {
                    int currentI = i;
                    if (currentI + 1 < linesMess.length - 1) {
                        // && currentI < linesMess.length - 1);
                        for (int j = currentI + 1; j < linesMess.length - 1; j++) {
                            tRunJobName = linesMess[j];
                            if ((tRunJobName.contains(componentName))) {
                                break;
                            }
                        }
                        if (tRunJobName.lastIndexOf("(") != -1 && tRunJobName.lastIndexOf(".java") != -1) {
                            tRunJobName = tRunJobName.substring(tRunJobName.lastIndexOf("(") + 1, tRunJobName.lastIndexOf(".java"));
                        } else {
                            tRunJobName = currenctJobName;
                        }
                    }
                }
                if (tRunJobName != null && tRunJobName.equals(currenctJobName)) {
                    if (i == 0) {
                        errorMessMap.put(componentName, psMess);
                    } else {
                        for (int j = i; j < linesMess.length; j++) {
                            //$NON-NLS-1$
                            currentMess.append(linesMess[j] + "\n");
                        }
                        IProcessMessage currentProMess = new ProcessMessage(MsgType.STD_ERR, currentMess.toString());
                        errorMessMap.put(componentName, currentProMess);
                    }
                }
            // break;
            }
        }
    }
    refreshNode(psMess);
}
Also used : Pattern(java.util.regex.Pattern) IProcessMessage(org.talend.designer.runprocess.IProcessMessage) Matcher(java.util.regex.Matcher) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) ProcessMessage(org.talend.designer.runprocess.ProcessMessage) IProcessMessage(org.talend.designer.runprocess.IProcessMessage) Point(org.eclipse.swt.graphics.Point)

Aggregations

IProcessMessage (org.talend.designer.runprocess.IProcessMessage)15 ProcessMessage (org.talend.designer.runprocess.ProcessMessage)9 Point (org.eclipse.swt.graphics.Point)7 Matcher (java.util.regex.Matcher)6 Pattern (java.util.regex.Pattern)6 ArrayList (java.util.ArrayList)3 Node (org.talend.designer.core.ui.editor.nodes.Node)3 INode (org.talend.core.model.process.INode)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 HashMap (java.util.HashMap)1 List (java.util.List)1 IStreamListener (org.eclipse.debug.core.IStreamListener)1 IStreamMonitor (org.eclipse.debug.core.model.IStreamMonitor)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 IPropertyChangeListener (org.eclipse.jface.util.IPropertyChangeListener)1 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)1 StyleRange (org.eclipse.swt.custom.StyleRange)1 StyledText (org.eclipse.swt.custom.StyledText)1