Search in sources :

Example 1 with IJavaBreakpoint

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

the class JavaProcessor method updateGraphicalNodeBreaking.

/**
     * yzhang Comment method "updateGraphicalNodeBreaking".
     *
     * @param breakpoint
     */
private void updateGraphicalNodeBreaking(IJavaBreakpoint breakpoint, boolean removed) {
    try {
        Integer breakLineNumber = (Integer) breakpoint.getMarker().getAttribute(IMarker.LINE_NUMBER);
        if (breakLineNumber == null || breakLineNumber == -1) {
            return;
        }
        IFile codeFile = this.getCodeProject().getFile(this.getSrcCodePath());
        if (!codeFile.exists()) {
            JDIDebugModel.removeJavaBreakpointListener(this);
            return;
        }
        LineNumberReader lineReader = new LineNumberReader(new InputStreamReader(codeFile.getContents()));
        String content = null;
        while (lineReader.getLineNumber() < breakLineNumber - 3) {
            content = lineReader.readLine();
            if (content == null) {
                return;
            }
        }
        //$NON-NLS-1$
        int startIndex = content.indexOf("[") + 1;
        //$NON-NLS-1$
        int endIndex = content.indexOf(" main ] start");
        if (startIndex != -1 && endIndex != -1) {
            String nodeUniqueName = content.substring(startIndex, endIndex);
            List<? extends INode> breakpointNodes = CorePlugin.getContext().getBreakpointNodes(process);
            List<? extends INode> graphicalNodes = process.getGraphicalNodes();
            if (graphicalNodes == null) {
                return;
            }
            for (INode node : graphicalNodes) {
                if (node.getUniqueName().equals(nodeUniqueName) && removed && breakpointNodes.contains(node)) {
                    CorePlugin.getContext().removeBreakpoint(process, node);
                    if (node instanceof Node) {
                        final INode currentNode = node;
                        Display.getDefault().syncExec(new Runnable() {

                            @Override
                            public void run() {
                                ((Node) currentNode).removeStatus(Process.BREAKPOINT_STATUS);
                            }
                        });
                    }
                } else if (node.getUniqueName().equals(nodeUniqueName) && !removed && !breakpointNodes.contains(node)) {
                    CorePlugin.getContext().addBreakpoint(process, node);
                    if (node instanceof Node) {
                        final INode currentNode = node;
                        Display.getDefault().syncExec(new Runnable() {

                            @Override
                            public void run() {
                                ((Node) currentNode).addStatus(Process.BREAKPOINT_STATUS);
                            }
                        });
                    }
                }
            }
        }
    } catch (CoreException e) {
        RuntimeExceptionHandler.process(e);
    } catch (IOException e) {
        RuntimeExceptionHandler.process(e);
    }
}
Also used : INode(org.talend.core.model.process.INode) IFile(org.eclipse.core.resources.IFile) InputStreamReader(java.io.InputStreamReader) INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) IOException(java.io.IOException) IJavaBreakpoint(org.eclipse.jdt.debug.core.IJavaBreakpoint) IJavaLineBreakpoint(org.eclipse.jdt.debug.core.IJavaLineBreakpoint) LineNumberReader(java.io.LineNumberReader) CoreException(org.eclipse.core.runtime.CoreException)

Aggregations

IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 LineNumberReader (java.io.LineNumberReader)1 IFile (org.eclipse.core.resources.IFile)1 CoreException (org.eclipse.core.runtime.CoreException)1 IJavaBreakpoint (org.eclipse.jdt.debug.core.IJavaBreakpoint)1 IJavaLineBreakpoint (org.eclipse.jdt.debug.core.IJavaLineBreakpoint)1 INode (org.talend.core.model.process.INode)1 Node (org.talend.designer.core.ui.editor.nodes.Node)1