exitAction is moved to DebugGui

This commit is contained in:
igor%mir2.org 2004-05-27 10:34:44 +00:00
Родитель cd63019db8
Коммит 7fe01ad6bc
2 изменённых файлов: 12 добавлений и 18 удалений

Просмотреть файл

@ -1918,6 +1918,7 @@ class LoadFile implements Runnable
class DebugGui extends JFrame implements GuiCallback class DebugGui extends JFrame implements GuiCallback
{ {
Main main; Main main;
Runnable exitAction;
JDesktopPane desk; JDesktopPane desk;
ContextWindow context; ContextWindow context;
Menubar menubar; Menubar menubar;
@ -2081,11 +2082,19 @@ class DebugGui extends JFrame implements GuiCallback
dlg.addChoosableFileFilter(filter); dlg.addChoosableFileFilter(filter);
addWindowListener(new WindowAdapter() { addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) { public void windowClosing(WindowEvent e) {
main.Exit(); exit();
} }
}); });
} }
void exit()
{
if (exitAction != null) {
SwingUtilities.invokeLater(exitAction);
}
main.setReturnValue(Main.EXIT);
}
FileWindow getFileWindow(String url) { FileWindow getFileWindow(String url) {
if (url == null || url.equals("<stdin>")) { if (url == null || url.equals("<stdin>")) {
return null; return null;
@ -2407,7 +2416,7 @@ class DebugGui extends JFrame implements GuiCallback
} else if (cmd.equals("Break")) { } else if (cmd.equals("Break")) {
main.doBreak(); main.doBreak();
} else if (cmd.equals("Exit")) { } else if (cmd.equals("Exit")) {
main.Exit(); exit();
} else if (cmd.equals("Open")) { } else if (cmd.equals("Open")) {
String fileName = chooseFile("Select a file to compile"); String fileName = chooseFile("Select a file to compile");
if (fileName != null) { if (fileName != null) {

Просмотреть файл

@ -399,7 +399,6 @@ public class Main {
boolean breakFlag = false; boolean breakFlag = false;
ScopeProvider scopeProvider; ScopeProvider scopeProvider;
Runnable exitAction;
int frameIndex = -1; int frameIndex = -1;
@ -731,11 +730,6 @@ public class Main {
} }
} }
static void swingInvokeLater(Runnable f)
{
SwingUtilities.invokeLater(f);
}
void contextSwitch (int frameIndex) { void contextSwitch (int frameIndex) {
this.frameIndex = frameIndex; this.frameIndex = frameIndex;
} }
@ -1043,15 +1037,6 @@ public class Main {
return resultString; return resultString;
} }
void Exit() {
// stop handling events
this.returnValue = EXIT;
// call the exit handler if any
if (exitAction != null) {
swingInvokeLater(exitAction);
}
}
private static java.awt.EventQueue awtEventQueue = null; private static java.awt.EventQueue awtEventQueue = null;
private static void dispatchNextAwtEvent() private static void dispatchNextAwtEvent()
@ -1149,7 +1134,7 @@ public class Main {
* selects "Exit..." or closes the Debugger main window * selects "Exit..." or closes the Debugger main window
*/ */
public void setExitAction(Runnable r) { public void setExitAction(Runnable r) {
exitAction = r; debugGui.exitAction = r;
} }
/** /**