Search in sources :

Example 6 with IProcessMessage

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

the class TraceDebugProcessComposite method addPerlMark.

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) ProcessMessage(org.talend.designer.runprocess.ProcessMessage) IProcessMessage(org.talend.designer.runprocess.IProcessMessage) Point(org.eclipse.swt.graphics.Point)

Example 7 with IProcessMessage

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

the class TraceDebugProcessComposite method runProcessContextChanged.

private void runProcessContextChanged(final PropertyChangeEvent evt) {
    String propName = evt.getPropertyName();
    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)) {
        getShell().getDisplay().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)) {
        getShell().getDisplay().asyncExec(new Runnable() {

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

Example 8 with IProcessMessage

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

the class ProcessComposite method processNextMessage.

protected void processNextMessage() {
    // don't try to display once the list to display is not finished to handle.
    if (messagesToDisplay.isEmpty() && !newMessages.isEmpty()) {
        IProcessMessage message = newMessages.poll();
        if (message == null) {
            return;
        }
        messagesToDisplay.add(message);
        getDisplay().asyncExec(new Runnable() {

            @Override
            public void run() {
                List<IProcessMessage> messages = new ArrayList<IProcessMessage>();
                // only do a peek here, to get the first message, but without remove it (to make sure nothing else
                // call the appendConsole)
                IProcessMessage msg = messagesToDisplay.peek();
                if (msg != null) {
                    messages.add(msg);
                    doAppendToConsole(messages);
                    scrollToEnd();
                }
                // do a poll here to remove the first element that we just displayed.
                messagesToDisplay.poll();
            }
        });
    }
}
Also used : IProcessMessage(org.talend.designer.runprocess.IProcessMessage) ArrayList(java.util.ArrayList) List(java.util.List)

Example 9 with IProcessMessage

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

the class ProcessErrorUtil method getAllErrorMess.

public static HashMap<String, IProcessMessage> getAllErrorMess(IProcessMessage psMess, RunProcessContext processContext) {
    HashMap<String, IProcessMessage> errorMessMap = new HashMap<String, IProcessMessage>();
    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)+\\s*\\((\\w)+\\)$");
            Matcher m = pattern.matcher(linemess);
            if (m.find()) {
                //$NON-NLS-1$
                String[] allwords = linemess.split("\\s");
                if (allwords.length == 5) {
                    String componentName = allwords[3];
                    tRunJobName = allwords[4].substring(1, allwords[4].length() - 1);
                    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);
                        }
                    }
                }
            }
        }
    }
    return errorMessMap;
}
Also used : Pattern(java.util.regex.Pattern) IProcessMessage(org.talend.designer.runprocess.IProcessMessage) HashMap(java.util.HashMap) Matcher(java.util.regex.Matcher) IProcessMessage(org.talend.designer.runprocess.IProcessMessage) ProcessMessage(org.talend.designer.runprocess.ProcessMessage)

Example 10 with IProcessMessage

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

the class ProcessErrorUtilTest method testGetAllErrorMess.

/**
     * Test method for
     * {@link org.talend.designer.runprocess.ui.ProcessComposite#getAllErrorMess(org.talend.designer.runprocess.IProcessMessage)}
     * .
     */
@Test
public void testGetAllErrorMess() {
    Property property1 = PropertiesFactory.eINSTANCE.createProperty();
    //$NON-NLS-1$
    property1.setId("property1");
    //$NON-NLS-1$
    property1.setVersion("0.1");
    //$NON-NLS-1$
    property1.setLabel("ParentJob");
    Process process = new Process(property1);
    IComponent tOracleSPComponent = ComponentsFactoryProvider.getInstance().get("tOracleSP", ComponentCategory.CATEGORY_4_DI.getName());
    Node tOracleSP_1 = new Node(tOracleSPComponent, process);
    process.addNodeContainer(new NodeContainer(tOracleSP_1));
    RunProcessContext context = new RunProcessContext(process);
    String errorMessage1 = "Exception in component tOracleSP_1 (ParentJob)\njava.sql.SQLException: ORA-20000: Failed to execute one or more sql statements";
    ProcessMessage message1 = new ProcessMessage(MsgType.STD_ERR, errorMessage1);
    HashMap<String, IProcessMessage> errorMessMap = ProcessErrorUtil.getAllErrorMess(message1, context);
    Assert.assertEquals(errorMessMap.get(tOracleSP_1.getUniqueName()).getContent(), errorMessage1);
    String errorMessage2 = "Exception in component tOracleSP_1 (ChildJob)\njava.sql.SQLException: ORA-20000: Failed to execute one or more sql statements";
    ProcessMessage message2 = new ProcessMessage(MsgType.STD_ERR, errorMessage2);
    HashMap<String, IProcessMessage> errorMessMap2 = ProcessErrorUtil.getAllErrorMess(message2, context);
    Assert.assertNull(errorMessMap2.get(tOracleSP_1.getUniqueName()));
}
Also used : RunProcessContext(org.talend.designer.runprocess.RunProcessContext) IProcessMessage(org.talend.designer.runprocess.IProcessMessage) IComponent(org.talend.core.model.components.IComponent) Node(org.talend.designer.core.ui.editor.nodes.Node) IProcessMessage(org.talend.designer.runprocess.IProcessMessage) ProcessMessage(org.talend.designer.runprocess.ProcessMessage) Process(org.talend.designer.core.ui.editor.process.Process) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) Property(org.talend.core.model.properties.Property) Test(org.junit.Test)

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