- statusBar = newStatusBar("Demo Main Window");
- statusBar.addShortcutKeypress(kbF1, cmHelp, "Help");
- statusBar.addShortcutKeypress(kbF2, cmShell, "Shell");
- statusBar.addShortcutKeypress(kbF3, cmOpen, "Open");
- statusBar.addShortcutKeypress(kbF10, cmExit, "Exit");
+ activate(first);
+
+ statusBar = newStatusBar(i18n.getString("statusBar"));
+ statusBar.addShortcutKeypress(kbF1, cmHelp,
+ i18n.getString("statusBarHelp"));
+ statusBar.addShortcutKeypress(kbF2, cmShell,
+ i18n.getString("statusBarShell"));
+ statusBar.addShortcutKeypress(kbF3, cmOpen,
+ i18n.getString("statusBarOpen"));
+ statusBar.addShortcutKeypress(kbF10, cmExit,
+ i18n.getString("statusBarExit"));
+ }
+
+ // ------------------------------------------------------------------------
+ // TWindow ----------------------------------------------------------------
+ // ------------------------------------------------------------------------
+
+ /**
+ * We need to override onClose so that the timer will no longer be called
+ * after we close the window. TTimers currently are completely unaware
+ * of the rest of the UI classes.
+ */
+ @Override
+ public void onClose() {
+ getApplication().removeTimer(timer);
+ }
+
+ /**
+ * Method that subclasses can override to handle posted command events.
+ *
+ * @param command command event
+ */
+ @Override
+ public void onCommand(final TCommandEvent command) {
+ if (command.equals(cmOpen)) {
+ try {
+ String filename = fileOpenBox(".");
+ if (filename != null) {
+ try {
+ new TEditorWindow(getApplication(),
+ new File(filename));
+ } catch (IOException e) {
+ messageBox(i18n.getString("errorTitle"),
+ MessageFormat.format(i18n.
+ getString("errorReadingFile"), e.getMessage()));
+ }
+ }
+ } catch (IOException e) {
+ messageBox(i18n.getString("errorTitle"),
+ MessageFormat.format(i18n.
+ getString("errorOpeningFile"), e.getMessage()));
+ }
+ return;
+ }
+
+ // Didn't handle it, let children get it instead
+ super.onCommand(command);