diff -r 766e8327016d php.dbgp/src/org/netbeans/modules/php/dbgp/actions/RunToCursorActionProvider.java --- a/php.dbgp/src/org/netbeans/modules/php/dbgp/actions/RunToCursorActionProvider.java Fri Jun 06 19:28:24 2008 +0200 +++ b/php.dbgp/src/org/netbeans/modules/php/dbgp/actions/RunToCursorActionProvider.java Wed Jun 11 17:35:01 2008 +0200 @@ -29,6 +29,7 @@ import org.netbeans.modules.php.dbgp.pac import org.netbeans.modules.php.dbgp.packets.BrkpntSetCommand; import org.netbeans.modules.php.dbgp.packets.RunCommand; import org.netbeans.spi.debugger.ContextProvider; +import org.netbeans.spi.debugger.ui.EditorContextDispatcher; import org.openide.text.Line; @@ -60,7 +61,7 @@ public class RunToCursorActionProvider e Line line = Utils.getCurrentLine(); BrkpntSetCommand command = BrkpntCommandBuilder.buildLineBreakpoint( id, session.getTransactionId(), - Utils.getCurrentFileObject( Utils.getCurrentNode()), + EditorContextDispatcher.getDefault().getCurrentFile(), line.getLineNumber() ); command.setTemporary( true ); session.sendCommandLater(command); diff -r 766e8327016d php.dbgp/src/org/netbeans/modules/php/dbgp/annotations/ToolTipAnnotation.java --- a/php.dbgp/src/org/netbeans/modules/php/dbgp/annotations/ToolTipAnnotation.java Fri Jun 06 19:28:24 2008 +0200 +++ b/php.dbgp/src/org/netbeans/modules/php/dbgp/annotations/ToolTipAnnotation.java Wed Jun 11 17:35:01 2008 +0200 @@ -58,6 +58,7 @@ import org.netbeans.modules.php.dbgp.bre import org.netbeans.modules.php.dbgp.breakpoints.Utils; import org.netbeans.modules.php.dbgp.packets.EvalCommand; import org.netbeans.modules.php.dbgp.packets.Property; +import org.netbeans.spi.debugger.ui.EditorContextDispatcher; import org.openide.cookies.EditorCookie; import org.openide.filesystems.FileObject; import org.openide.loaders.DataObject; @@ -174,11 +175,11 @@ public class ToolTipAnnotation extends A StyledDocument document = editorCookie.getDocument(); final int offset = NbDocument.findLineOffset(document, part.getLine().getLineNumber()) + part.getColumn(); - String selectedText = getSelectedText( editorCookie, offset); + JEditorPane ep = EditorContextDispatcher.getDefault().getCurrentEditor(); + String selectedText = getSelectedText( ep, offset); if ( selectedText != null ){ sendEvalCommand( selectedText ); } else { - JEditorPane ep = Utils.getEditorPane( editorCookie ); final String identifier = getIdentifier(document, ep, offset); if (identifier != null && isDollarMark(identifier.charAt(0))) { Runnable runnable = new Runnable(){ @@ -284,8 +285,7 @@ public class ToolTipAnnotation extends A session.sendCommandLater(command); } - private String getSelectedText( EditorCookie cookie , int offset ){ - JEditorPane pane = Utils.getEditorPane( cookie ); + private String getSelectedText( JEditorPane pane , int offset ){ if ((pane.getSelectionStart() <= offset) && (offset <= pane.getSelectionEnd())) { diff -r 766e8327016d php.dbgp/src/org/netbeans/modules/php/dbgp/breakpoints/BreakpointActionProvider.java --- a/php.dbgp/src/org/netbeans/modules/php/dbgp/breakpoints/BreakpointActionProvider.java Fri Jun 06 19:28:24 2008 +0200 +++ b/php.dbgp/src/org/netbeans/modules/php/dbgp/breakpoints/BreakpointActionProvider.java Wed Jun 11 17:35:01 2008 +0200 @@ -52,9 +52,9 @@ import org.netbeans.api.debugger.Breakpo import org.netbeans.api.debugger.Breakpoint; import org.netbeans.api.debugger.DebuggerManager; import org.netbeans.spi.debugger.ActionsProviderSupport; +import org.netbeans.spi.debugger.ui.EditorContextDispatcher; import org.openide.text.Line; import org.openide.util.WeakListeners; -import org.openide.windows.TopComponent; /** * @@ -66,8 +66,9 @@ public class BreakpointActionProvider ex public BreakpointActionProvider() { setEnabled(ActionsManager.ACTION_TOGGLE_BREAKPOINT, true); - TopComponent.getRegistry().addPropertyChangeListener( - WeakListeners.propertyChange(this, TopComponent.getRegistry())); + EditorContextDispatcher.getDefault().addPropertyChangeListener( + Utils.MIME_TYPE, + WeakListeners.propertyChange(this, EditorContextDispatcher.getDefault())); } public void doAction(Object action) { diff -r 766e8327016d php.dbgp/src/org/netbeans/modules/php/dbgp/breakpoints/Utils.java --- a/php.dbgp/src/org/netbeans/modules/php/dbgp/breakpoints/Utils.java Fri Jun 06 19:28:24 2008 +0200 +++ b/php.dbgp/src/org/netbeans/modules/php/dbgp/breakpoints/Utils.java Wed Jun 11 17:35:01 2008 +0200 @@ -43,7 +43,6 @@ import java.lang.reflect.InvocationTarge import java.lang.reflect.InvocationTargetException; import javax.swing.JEditorPane; -import javax.swing.SwingUtilities; import javax.swing.text.Caret; import javax.swing.text.StyledDocument; @@ -56,14 +55,13 @@ import org.netbeans.modules.php.dbgp.pac import org.netbeans.modules.php.dbgp.packets.BrkpntRemoveCommand; import org.netbeans.modules.php.dbgp.packets.BrkpntSetCommand; import org.netbeans.modules.php.dbgp.packets.BrkpntSetCommand.State; +import org.netbeans.spi.debugger.ui.EditorContextDispatcher; import org.openide.cookies.EditorCookie; import org.openide.cookies.LineCookie; import org.openide.filesystems.FileObject; import org.openide.loaders.DataObject; -import org.openide.nodes.Node; import org.openide.text.Line; import org.openide.text.NbDocument; -import org.openide.windows.TopComponent; /** @@ -72,7 +70,7 @@ import org.openide.windows.TopComponent; */ public class Utils { - private final static String MIME_TYPE = "text/x-php5"; //NOI18N + final static String MIME_TYPE = "text/x-php5"; //NOI18N public static LineFactory lineFactory = new LineFactory(); private Utils(){ @@ -80,24 +78,45 @@ public class Utils { } public static Line getCurrentLine() { - if ( !SwingUtilities.isEventDispatchThread() ){ - return getCurrentLineInAwt(); - } - - Node node = getCurrentNode(); - FileObject fileObject = getCurrentFileObject( node ); + FileObject fileObject = EditorContextDispatcher.getDefault().getCurrentFile(); if (!isPhpFile(fileObject)) { return null; } - LineCookie lineCookie = node.getCookie(LineCookie.class); - - if (lineCookie == null) { - return null; - } - - return getLine(lineCookie, node.getCookie(EditorCookie.class)); + EditorCookie editorCookie = EditorContextDispatcher.getDefault().getCurrentEditorCookie(); + + if (editorCookie == null) { + return null; + } + + JEditorPane editorPane = EditorContextDispatcher.getDefault().getCurrentEditor(); + + if (editorPane == null) { + return null; + } + + StyledDocument document = editorCookie.getDocument(); + if (document == null) { + return null; + } + + Caret caret = editorPane.getCaret(); + + if (caret == null) { + return null; + } + + int lineNumber = NbDocument.findLineNumber(document, caret.getDot()); + + try { + Line.Set lineSet = editorCookie.getLineSet(); + assert lineSet != null ; + + return lineSet.getCurrent(lineNumber); + } catch (IndexOutOfBoundsException ex) { + return null; + } } public static BrkpntSetCommand getCommand( DebugSession session, SessionId id, @@ -169,97 +188,6 @@ public class Utils { log( exception.getCause() ); } - private static Line getCurrentLineInAwt() { - final Line[] lines = new Line[1]; - try { - SwingUtilities.invokeAndWait( new Runnable(){ - public void run() { - Line line = getCurrentLine(); - lines[ 0 ] = line; - } - } - ); - } - catch (InterruptedException e) { - // awt thread should not be interrupted - assert false; - } - catch (InvocationTargetException e) { - log( e ); - } - return lines[0]; - } - - private static Line getLine( LineCookie lineCookie, - EditorCookie editorCookie ) - { - if (editorCookie == null) { - return null; - } - - JEditorPane editorPane = getEditorPane(editorCookie); - - if (editorPane == null) { - return null; - } - - StyledDocument document = editorCookie.getDocument(); - if (document == null) { - return null; - } - - Caret caret = editorPane.getCaret(); - - if (caret == null) { - return null; - } - - int lineNumber = NbDocument.findLineNumber(document, caret.getDot()); - - try { - Line.Set lineSet = lineCookie.getLineSet(); - assert lineSet != null ; - - return lineSet.getCurrent(lineNumber); - } catch (IndexOutOfBoundsException ex) { - return null; - } - } - - public static FileObject getCurrentFileObject( Node node ) { - if ( node == null ) { - return null; - } - FileObject fileObject = node.getLookup().lookup(FileObject.class); - - if (fileObject == null) { - DataObject dobj = node.getLookup().lookup(DataObject.class); - - if (dobj != null) { - fileObject = dobj.getPrimaryFile(); - } - } - return fileObject; - } - - public static Node getCurrentNode() { - Node[] nodes = TopComponent.getRegistry().getCurrentNodes(); - if (nodes == null || nodes.length != 1) { - return null; - } - return nodes [0]; - } - - - public static JEditorPane getEditorPane( final EditorCookie editorCookie ) { - assert SwingUtilities.isEventDispatchThread(); - JEditorPane[] panes = editorCookie.getOpenedPanes(); - if (panes == null || panes.length == 0) { - return null; - } - return panes[0]; - } - public static boolean isPhpFile(FileObject fileObject) { if (fileObject == null) { return false;