mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 21:35:39 +00:00
Prepare to remove dependancy of core debugger implementation on GUI: introduction of GuiCallback interface that DebugGui implements.
This commit is contained in:
parent
5154be9d1e
commit
cd63019db8
@ -1915,7 +1915,7 @@ class LoadFile implements Runnable
|
||||
}
|
||||
}
|
||||
|
||||
class DebugGui extends JFrame
|
||||
class DebugGui extends JFrame implements GuiCallback
|
||||
{
|
||||
Main main;
|
||||
JDesktopPane desk;
|
||||
@ -2251,21 +2251,44 @@ class DebugGui extends JFrame
|
||||
}
|
||||
}
|
||||
|
||||
public void updateFileText(Main.SourceInfo sourceInfo)
|
||||
// Implementing GuiCallback
|
||||
|
||||
public void updateSourceText(final Main.SourceInfo sourceInfo)
|
||||
{
|
||||
String fileName = sourceInfo.url();
|
||||
FileWindow w = getFileWindow(fileName);
|
||||
if (w != null) {
|
||||
w.updateText(sourceInfo);
|
||||
w.show();
|
||||
} else if (!fileName.equals("<stdin>")) {
|
||||
createFileWindow(sourceInfo, -1);
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run()
|
||||
{
|
||||
String fileName = sourceInfo.url();
|
||||
FileWindow w = getFileWindow(fileName);
|
||||
if (w != null) {
|
||||
w.updateText(sourceInfo);
|
||||
w.show();
|
||||
} else if (!fileName.equals("<stdin>")) {
|
||||
createFileWindow(sourceInfo, -1);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void enterInterrupt(final Main.StackFrame lastFrame,
|
||||
final String threadTitle,
|
||||
final String alertMessage)
|
||||
{
|
||||
if (SwingUtilities.isEventDispatchThread()) {
|
||||
enterInterruptImpl(lastFrame, threadTitle, alertMessage);
|
||||
} else {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run()
|
||||
{
|
||||
enterInterruptImpl(lastFrame, threadTitle, alertMessage);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void enterInterrupt(Main.StackFrame lastFrame, String threadTitle,
|
||||
String alertMessage)
|
||||
void enterInterruptImpl(Main.StackFrame lastFrame, String threadTitle,
|
||||
String alertMessage)
|
||||
{
|
||||
statusBar.setText("Thread: " + threadTitle);
|
||||
|
||||
|
@ -0,0 +1,48 @@
|
||||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is GUI interface callback declaration for Rhino debugger
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* RUnit Software AS.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Igor Bukanov, igor@fastmail.fm
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
package org.mozilla.javascript.tools.debugger;
|
||||
|
||||
public interface GuiCallback
|
||||
{
|
||||
public void updateSourceText(Main.SourceInfo sourceInfo);
|
||||
|
||||
public void enterInterrupt(Main.StackFrame lastFrame,
|
||||
String threadTitle,
|
||||
String alertMessage);
|
||||
}
|
@ -57,8 +57,6 @@ import java.net.URL;
|
||||
|
||||
public class Main {
|
||||
|
||||
DebugGui debugGui;
|
||||
|
||||
static final int STEP_OVER = 0;
|
||||
static final int STEP_INTO = 1;
|
||||
static final int STEP_OUT = 2;
|
||||
@ -395,6 +393,8 @@ public class Main {
|
||||
}
|
||||
};
|
||||
|
||||
GuiCallback callback;
|
||||
DebugGui debugGui;
|
||||
|
||||
boolean breakFlag = false;
|
||||
|
||||
@ -583,12 +583,7 @@ public class Main {
|
||||
}
|
||||
}
|
||||
|
||||
swingInvokeLater(new Runnable() {
|
||||
public void run()
|
||||
{
|
||||
debugGui.updateFileText(sourceInfo);
|
||||
}
|
||||
});
|
||||
callback.updateSourceText(sourceInfo);
|
||||
}
|
||||
|
||||
FunctionSource functionSource(DebuggableScript fnOrScript)
|
||||
@ -801,13 +796,6 @@ public class Main {
|
||||
alertMessage = scriptException.toString();
|
||||
}
|
||||
|
||||
Runnable enterAction = new Runnable() {
|
||||
public void run()
|
||||
{
|
||||
debugGui.enterInterrupt(frame, threadTitle, alertMessage);
|
||||
}
|
||||
};
|
||||
|
||||
int returnValue = -1;
|
||||
if (!eventThreadFlag) {
|
||||
synchronized (monitor) {
|
||||
@ -815,7 +803,7 @@ public class Main {
|
||||
this.insideInterruptLoop = true;
|
||||
this.evalRequest = null;
|
||||
this.returnValue = -1;
|
||||
swingInvokeLater(enterAction);
|
||||
callback.enterInterrupt(frame, threadTitle, alertMessage);
|
||||
try {
|
||||
for (;;) {
|
||||
try {
|
||||
@ -846,7 +834,7 @@ public class Main {
|
||||
}
|
||||
} else {
|
||||
this.returnValue = -1;
|
||||
enterAction.run();
|
||||
callback.enterInterrupt(frame, threadTitle, alertMessage);
|
||||
while (this.returnValue == -1) {
|
||||
try {
|
||||
dispatchNextAwtEvent();
|
||||
@ -1095,6 +1083,7 @@ public class Main {
|
||||
public Main(String title)
|
||||
{
|
||||
debugGui = new DebugGui(this, title);
|
||||
callback = debugGui;
|
||||
}
|
||||
|
||||
public void doBreak() {
|
||||
|
Loading…
Reference in New Issue
Block a user