import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
// ------------------------------------------------------------------------
// Public constants -------------------------------------------------------
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// Public constants -------------------------------------------------------
// ------------------------------------------------------------------------
- messageBox("About", "Jexer Version " +
- this.getClass().getPackage().getImplementationVersion(),
+ messageBox(i18n.getString("aboutDialogTitle"),
+ MessageFormat.format(i18n.getString("aboutDialogText"),
+ this.getClass().getPackage().getImplementationVersion()),
if (debugThreads) {
System.err.printf("%d %s drawAll() enter\n",
System.currentTimeMillis(), Thread.currentThread());
if (debugThreads) {
System.err.printf("%d %s drawAll() enter\n",
System.currentTimeMillis(), Thread.currentThread());
menuColor = theme.getColor("tmenu.highlighted");
menuMnemonicColor = theme.getColor("tmenu.mnemonic.highlighted");
topLevel = menu;
menuColor = theme.getColor("tmenu.highlighted");
menuMnemonicColor = theme.getColor("tmenu.mnemonic.highlighted");
topLevel = menu;
- TWidget activeWidget = null;
- if (sorted.size() > 0) {
- activeWidget = sorted.get(sorted.size() - 1).getActiveChild();
- if (activeWidget.isCursorVisible()) {
- if ((activeWidget.getCursorAbsoluteY() < desktopBottom)
- && (activeWidget.getCursorAbsoluteY() > desktopTop)
- ) {
- getScreen().putCursor(true,
- activeWidget.getCursorAbsoluteX(),
- activeWidget.getCursorAbsoluteY());
- cursor = true;
- } else {
- getScreen().putCursor(false,
- activeWidget.getCursorAbsoluteX(),
- activeWidget.getCursorAbsoluteY());
- cursor = false;
+ if (!menuIsActive) {
+ TWidget activeWidget = null;
+ if (sorted.size() > 0) {
+ activeWidget = sorted.get(sorted.size() - 1).getActiveChild();
+ if (activeWidget.isCursorVisible()) {
+ if ((activeWidget.getCursorAbsoluteY() < desktopBottom)
+ && (activeWidget.getCursorAbsoluteY() > desktopTop)
+ ) {
+ getScreen().putCursor(true,
+ activeWidget.getCursorAbsoluteX(),
+ activeWidget.getCursorAbsoluteY());
+ cursor = true;
+ } else {
+ getScreen().putCursor(false,
+ activeWidget.getCursorAbsoluteX(),
+ activeWidget.getCursorAbsoluteY());
+ cursor = false;
+ }
desktop.setDimensions(0, 0, resize.getWidth(),
resize.getHeight() - 1);
}
desktop.setDimensions(0, 0, resize.getWidth(),
resize.getHeight() - 1);
}
+
+ // Unset activeWindow now before unfocus, so that a window
+ // lifecycle change inside onUnfocus() doesn't call
+ // switchWindow() and lead to a stack overflow.
+ TWindow oldActiveWindow = activeWindow;
+ activeWindow = null;
+ oldActiveWindow.onUnfocus();
// They selected the menu, go activate it
for (TMenu menu: menus) {
// They selected the menu, go activate it
for (TMenu menu: menus) {
fileMenu.addDefaultItem(TMenu.MID_OPEN_FILE);
fileMenu.addSeparator();
fileMenu.addDefaultItem(TMenu.MID_SHELL);
fileMenu.addDefaultItem(TMenu.MID_EXIT);
fileMenu.addDefaultItem(TMenu.MID_OPEN_FILE);
fileMenu.addSeparator();
fileMenu.addDefaultItem(TMenu.MID_SHELL);
fileMenu.addDefaultItem(TMenu.MID_EXIT);
- TStatusBar statusBar = fileMenu.newStatusBar("File-management " +
- "commands (Open, Save, Print, etc.)");
- statusBar.addShortcutKeypress(kbF1, cmHelp, "Help");
+ TStatusBar statusBar = fileMenu.newStatusBar(i18n.
+ getString("fileMenuStatus"));
+ statusBar.addShortcutKeypress(kbF1, cmHelp, i18n.getString("Help"));
editMenu.addDefaultItem(TMenu.MID_CUT);
editMenu.addDefaultItem(TMenu.MID_COPY);
editMenu.addDefaultItem(TMenu.MID_PASTE);
editMenu.addDefaultItem(TMenu.MID_CLEAR);
editMenu.addDefaultItem(TMenu.MID_CUT);
editMenu.addDefaultItem(TMenu.MID_COPY);
editMenu.addDefaultItem(TMenu.MID_PASTE);
editMenu.addDefaultItem(TMenu.MID_CLEAR);
- TStatusBar statusBar = editMenu.newStatusBar("Editor operations, " +
- "undo, and Clipboard access");
- statusBar.addShortcutKeypress(kbF1, cmHelp, "Help");
+ TStatusBar statusBar = editMenu.newStatusBar(i18n.
+ getString("editMenuStatus"));
+ statusBar.addShortcutKeypress(kbF1, cmHelp, i18n.getString("Help"));
windowMenu.addDefaultItem(TMenu.MID_TILE);
windowMenu.addDefaultItem(TMenu.MID_CASCADE);
windowMenu.addDefaultItem(TMenu.MID_CLOSE_ALL);
windowMenu.addDefaultItem(TMenu.MID_TILE);
windowMenu.addDefaultItem(TMenu.MID_CASCADE);
windowMenu.addDefaultItem(TMenu.MID_CLOSE_ALL);
windowMenu.addDefaultItem(TMenu.MID_WINDOW_NEXT);
windowMenu.addDefaultItem(TMenu.MID_WINDOW_PREVIOUS);
windowMenu.addDefaultItem(TMenu.MID_WINDOW_CLOSE);
windowMenu.addDefaultItem(TMenu.MID_WINDOW_NEXT);
windowMenu.addDefaultItem(TMenu.MID_WINDOW_PREVIOUS);
windowMenu.addDefaultItem(TMenu.MID_WINDOW_CLOSE);
- TStatusBar statusBar = windowMenu.newStatusBar("Open, arrange, and " +
- "list windows");
- statusBar.addShortcutKeypress(kbF1, cmHelp, "Help");
+ TStatusBar statusBar = windowMenu.newStatusBar(i18n.
+ getString("windowMenuStatus"));
+ statusBar.addShortcutKeypress(kbF1, cmHelp, i18n.getString("Help"));
helpMenu.addDefaultItem(TMenu.MID_HELP_CONTENTS);
helpMenu.addDefaultItem(TMenu.MID_HELP_INDEX);
helpMenu.addDefaultItem(TMenu.MID_HELP_SEARCH);
helpMenu.addDefaultItem(TMenu.MID_HELP_CONTENTS);
helpMenu.addDefaultItem(TMenu.MID_HELP_INDEX);
helpMenu.addDefaultItem(TMenu.MID_HELP_SEARCH);
- TStatusBar statusBar = helpMenu.newStatusBar("Access online help");
- statusBar.addShortcutKeypress(kbF1, cmHelp, "Help");
+ TStatusBar statusBar = helpMenu.newStatusBar(i18n.
+ getString("helpMenuStatus"));
+ statusBar.addShortcutKeypress(kbF1, cmHelp, i18n.getString("Help"));
protected boolean onCommand(final TCommandEvent command) {
// Default: handle cmExit
if (command.equals(cmExit)) {
protected boolean onCommand(final TCommandEvent command) {
// Default: handle cmExit
if (command.equals(cmExit)) {
- if (messageBox("Confirmation", "Exit application?",
+ if (messageBox(i18n.getString("exitDialogTitle"),
+ i18n.getString("exitDialogText"),
- if (messageBox("Confirmation", "Exit application?",
+ if (messageBox(i18n.getString("exitDialogTitle"),
+ i18n.getString("exitDialogText"),
TWindow window = new TWindow(this, title, 0, 0, width, height);
return window;
}
TWindow window = new TWindow(this, title, 0, 0, width, height);
return window;
}
/**
* Convenience function to create a new window and make it active.
* Window will be located at (0, 0).
/**
* Convenience function to create a new window and make it active.
* Window will be located at (0, 0).
+ /**
+ * Convenience function to open a file in an editor window and make it
+ * active.
+ *
+ * @param file the file to open
+ * @throws IOException if a java.io operation throws
+ */
+ public final TEditorWindow addEditor(final File file) throws IOException {
+
+ TEditorWindow editor = new TEditorWindow(this, file);
+ return editor;
+ }
+