1 package net.argius.stew.ui.window;
3 import static java.awt.event.ActionEvent.ACTION_PERFORMED;
4 import static javax.swing.JOptionPane.*;
5 import static javax.swing.JSplitPane.VERTICAL_SPLIT;
6 import static javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER;
7 import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS;
8 import static net.argius.stew.ui.window.AnyActionKey.*;
11 import java.awt.event.*;
14 import java.lang.Thread.UncaughtExceptionHandler;
17 import java.util.Map.Entry;
18 import java.util.List;
19 import java.util.Timer;
20 import java.util.concurrent.*;
23 import javax.swing.event.*;
24 import javax.swing.table.*;
25 import javax.swing.text.*;
27 import net.argius.stew.*;
28 import net.argius.stew.ui.*;
31 * The Launcher implementation for GUI(Swing).
33 public final class WindowLauncher implements
37 UncaughtExceptionHandler {
39 private static final Logger log = Logger.getLogger(WindowLauncher.class);
40 private static final ResourceManager res = ResourceManager.getInstance(WindowLauncher.class);
41 private static final List<WindowLauncher> instances = Collections.synchronizedList(new ArrayList<WindowLauncher>());
43 private final WindowOutputProcessor op;
44 private final Menu menu;
45 private final JPanel panel1;
46 private final JSplitPane split1;
47 private final JSplitPane split2;
48 private final ResultSetTable resultSetTable;
49 private final ConsoleTextArea textArea;
50 private final DatabaseInfoTree infoTree;
51 private final TextSearchPanel textSearchPanel;
52 private final JLabel statusBar;
53 private final List<String> historyList;
54 private final ExecutorService executorService;
56 private Environment env;
57 private Map<JComponent, TextSearch> textSearchMap;
58 private int historyIndex;
59 private JComponent focused;
64 final JSplitPane split1 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
65 final DatabaseInfoTree infoTree = new DatabaseInfoTree(this);
66 final ResultSetTable resultSetTable = new ResultSetTable(this);
67 final JTableHeader resultSetTableHeader = resultSetTable.getTableHeader();
68 final ConsoleTextArea textArea = new ConsoleTextArea(this);
69 this.op = new WindowOutputProcessor(this, resultSetTable, textArea);
70 this.menu = new Menu(this);
71 this.panel1 = new JPanel(new BorderLayout());
73 this.split2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
74 this.resultSetTable = resultSetTable;
75 this.textArea = textArea;
76 this.infoTree = infoTree;
77 this.textSearchPanel = new TextSearchPanel(op);
78 this.statusBar = new JLabel(" ");
79 this.historyList = new LinkedList<String>();
80 this.historyIndex = 0;
81 this.executorService = Executors.newScheduledThreadPool(3,
82 DaemonThreadFactory.getInstance());
84 // OutputProcessor as frame
85 op.setTitle(res.get(".title"));
86 op.setIconImage(Utilities.getImageIcon("stew.png").getImage());
87 op.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
88 // splitpane (infotree and sub-splitpane)
89 split1.setResizeWeight(0.6f);
90 split1.setDividerSize(4);
91 // splitpane (table and textarea)
92 split2.setOrientation(VERTICAL_SPLIT);
93 split2.setDividerSize(6);
94 split2.setResizeWeight(0.6f);
96 textArea.setMargin(new Insets(4, 8, 4, 4));
97 textArea.setLineWrap(true);
98 textArea.setWrapStyleWord(false);
100 this.textSearchMap = new LinkedHashMap<JComponent, TextSearch>();
101 final TextSearchPanel textSearchPanel = this.textSearchPanel;
102 final Map<JComponent, TextSearch> textSearchMap = this.textSearchMap;
103 textSearchMap.put(infoTree, infoTree);
104 textSearchMap.put(resultSetTable, resultSetTable);
105 textSearchMap.put(resultSetTableHeader,
106 new ResultSetTable.TableHeaderTextSearch(resultSetTable,
107 resultSetTableHeader));
108 textSearchMap.put(textArea, textArea);
109 for (Entry<JComponent, TextSearch> entry : textSearchMap.entrySet()) {
110 final JComponent c = entry.getKey();
111 c.addFocusListener(new FocusAdapter() {
113 public void focusGained(FocusEvent e) {
115 textSearchPanel.setCurrentTarget(textSearchMap.get(c));
118 textSearchPanel.addTarget(entry.getValue());
121 statusBar.setForeground(Color.BLUE);
124 * split2 = ResultSetTable + TextArea
125 * +----------------------------+
127 * | +------------------------+ |
128 * | | scroll(resultSetTable) | |
129 * | +------------------------+ |
130 * | +------------------------+ |
131 * | | scroll(textArea) | |
132 * | +------------------------+ |
133 * +----------------------------+
134 * when DatabaseInfoTree is visible
135 * +-----------------------------------+
137 * | +-------------------------------+ |
139 * | | +------------+ +------------+ | |
140 * | | | scroll | | split2 | | |
141 * | | | (infoTree) | | | | |
142 * | | +------------+ +------------+ | |
143 * | +-------------------------------+ |
144 * | | textSearchPanel | |
145 * | +-------------------------------+ |
146 * +-----------------------------------+
148 * +-----------------------------------+
149 * when DatabaseInfoTree is not visible
150 * +-----------------------------------+
152 * | +-------------------------------+ |
154 * | +-------------------------------+ |
155 * | | textSearchPanel | |
156 * | +-------------------------------+ |
157 * +-----------------------------------+
159 * +-----------------------------------+
161 split2.setTopComponent(new JScrollPane(resultSetTable));
162 split2.setBottomComponent(new JScrollPane(textArea, VERTICAL_SCROLLBAR_ALWAYS, HORIZONTAL_SCROLLBAR_NEVER));
163 op.add(panel1, BorderLayout.CENTER);
164 op.add(statusBar, BorderLayout.PAGE_END);
165 op.setJMenuBar(menu);
166 // [Restores Configs]
167 op.addPropertyChangeListener(menu);
168 infoTree.addPropertyChangeListener(menu);
169 resultSetTable.addPropertyChangeListener(menu);
170 statusBar.addPropertyChangeListener(menu);
172 op.removePropertyChangeListener(menu);
173 infoTree.removePropertyChangeListener(menu);
174 resultSetTable.removePropertyChangeListener(menu);
175 // XXX cannot restore config of status-bar at following code
176 // statusBar.removePropertyChangeListener(menu);
178 ContextMenu.create(infoTree, infoTree);
179 ContextMenu.create(resultSetTable);
180 ContextMenu.create(resultSetTable.getRowHeader(), resultSetTable, "ResultSetTable");
181 ContextMenu.create(resultSetTableHeader, resultSetTable, "ResultSetTableColumnHeader");
182 ContextMenu.createForText(textArea);
186 public void launch(Environment env) {
188 op.setEnvironment(env);
190 op.output(new Prompt(env));
191 textArea.requestFocus();
196 Thread.setDefaultUncaughtExceptionHandler(this);
201 public void uncaughtException(Thread t, Throwable e) {
202 log.fatal(e, "%s", t);
203 op.showErrorDialog(e);
207 public void anyActionPerformed(AnyActionEvent ev) {
208 log.atEnter("anyActionPerformed", ev);
211 resultSetTable.editingCanceled(new ChangeEvent(ev.getSource()));
212 final Object source = ev.getSource();
213 if (ev.isAnyOf(newWindow)) {
215 } else if (ev.isAnyOf(closeWindow)) {
217 } else if (ev.isAnyOf(quit)) {
219 } else if (ev.isAnyOf(showInfoTree)) {
220 setInfoTreePaneVisibility(((JCheckBoxMenuItem)source).isSelected());
223 } else if (ev.isAnyOf(cut, copy, paste, selectAll)) {
224 if (focused != null) {
226 if (ev.isAnyOf(cut)) {
227 if (focused instanceof JTextComponent) {
228 cmd = "cut-to-clipboard";
232 } else if (ev.isAnyOf(copy)) {
233 if (focused instanceof JTextComponent) {
234 cmd = "copy-to-clipboard";
236 cmd = ev.getActionCommand();
238 } else if (ev.isAnyOf(paste)) {
239 if (focused instanceof JTextComponent) {
240 cmd = "paste-from-clipboard";
241 } else if (focused instanceof DatabaseInfoTree) {
244 cmd = ev.getActionCommand();
246 } else if (ev.isAnyOf(selectAll)) {
247 if (focused instanceof JTextComponent) {
250 cmd = ev.getActionCommand();
255 if (cmd.length() == 0) {
256 log.debug("no action: %s, cmd=%s",
258 ev.getActionCommand());
260 final Action action = focused.getActionMap().get(cmd);
261 log.debug("convert to plain Action Event: orig=%s", ev);
262 action.actionPerformed(new ActionEvent(focused, ACTION_PERFORMED, cmd));
265 } else if (ev.isAnyOf(find)) {
266 textSearchPanel.setCurrentTarget(textSearchMap.get(focused));
267 textSearchPanel.setVisible(true);
268 } else if (ev.isAnyOf(toggleFocus)) {
269 if (textArea.isFocusOwner()) {
270 resultSetTable.requestFocus();
272 textArea.requestFocus();
274 } else if (ev.isAnyOf(clearMessage)) {
277 } else if (ev.isAnyOf(showStatusBar)) {
278 statusBar.setVisible(((JCheckBoxMenuItem)source).isSelected());
279 } else if (ev.isAnyOf(showColumnNumber)) {
280 resultSetTable.anyActionPerformed(ev);
281 } else if (ev.isAnyOf(refresh)) {
283 } else if (ev.isAnyOf(autoAdjustModeNone,
284 autoAdjustModeHeader,
286 autoAdjustModeHeaderAndValue)) {
287 resultSetTable.setAutoAdjustMode(ev.getActionCommand());
288 } else if (ev.isAnyOf(widenColumnWidth, narrowColumnWidth, adjustColumnWidth)) {
289 resultSetTable.anyActionPerformed(ev);
290 } else if (ev.isAnyOf(executeCommand, execute)) {
291 executeCommand(textArea.getEditableText());
292 } else if (ev.isAnyOf(breakCommand)) {
293 env.getOutputProcessor().close();
294 env.setOutputProcessor(new WindowOutputProcessor.Bypass(op));
295 op.output(res.get("i.cancelled"));
297 } else if (ev.isAnyOf(lastHistory)) {
299 } else if (ev.isAnyOf(nextHistory)) {
301 } else if (ev.isAnyOf(sendRollback)) {
302 if (confirmCommitable()
303 && showConfirmDialog(op, res.get("i.confirm-rollback"), null, OK_CANCEL_OPTION) == OK_OPTION) {
304 executeCommand("rollback");
306 } else if (ev.isAnyOf(sendCommit)) {
307 if (confirmCommitable()
308 && showConfirmDialog(op, res.get("i.confirm-commit"), null, OK_CANCEL_OPTION) == OK_OPTION) {
309 executeCommand("commit");
311 } else if (ev.isAnyOf(connect)) {
312 env.updateConnectorMap();
313 if (env.getConnectorMap().isEmpty()) {
314 showMessageDialog(op, res.get("w.no-connector"));
317 Object[] a = ConnectorEntry.toList(env.getConnectorMap().values()).toArray();
318 final String m = res.get("i.choose-connection");
319 Object value = showInputDialog(op, m, null, PLAIN_MESSAGE, null, a, a[0]);
321 ConnectorEntry c = (ConnectorEntry)value;
322 executeCommand("connect " + c.getId());
324 } else if (ev.isAnyOf(disconnect)) {
325 executeCommand("disconnect");
326 } else if (ev.isAnyOf(postProcessModeNone,
327 postProcessModeFocus,
328 postProcessModeShake,
329 postProcessModeBlink)) {
330 op.setPostProcessMode(ev.getActionCommand());
331 } else if (ev.isAnyOf(inputEcryptionKey)) {
333 } else if (ev.isAnyOf(editConnectors)) {
335 } else if (ev.isAnyOf(sortResult)) {
336 resultSetTable.doSort(resultSetTable.getSelectedColumn());
337 } else if (ev.isAnyOf(importFile, exportFile, showAbout)) {
338 op.anyActionPerformed(ev);
339 } else if (ev.isAnyOf(showHelp)) {
341 } else if (ev.isAnyOf(ResultSetTable.ActionKey.findColumnName)) {
342 resultSetTable.getTableHeader().requestFocus();
343 textSearchPanel.setVisible(true);
344 } else if (ev.isAnyOf(ResultSetTable.ActionKey.jumpToColumn)) {
345 resultSetTable.anyActionPerformed(ev);
346 } else if (ev.isAnyOf(ConsoleTextArea.ActionKey.insertText)) {
347 textArea.anyActionPerformed(ev);
349 log.warn("not expected: Event=%s", ev);
351 } catch (Exception ex) {
352 op.showErrorDialog(ex);
354 log.atExit("dispatch");
358 * Controls visibility of DatabaseInfoTree pane.
361 void setInfoTreePaneVisibility(boolean show) {
364 split1.setTopComponent(new JScrollPane(infoTree));
365 split1.setBottomComponent(split2);
367 panel1.add(split1, BorderLayout.CENTER);
368 panel1.add(textSearchPanel, BorderLayout.PAGE_END);
369 infoTree.setEnabled(true);
372 infoTree.refreshRoot(env);
373 } catch (SQLException ex) {
375 op.showErrorDialog(ex);
380 infoTree.setEnabled(false);
382 panel1.add(split2, BorderLayout.CENTER);
383 panel1.add(textSearchPanel, BorderLayout.PAGE_END);
385 SwingUtilities.updateComponentTreeUI(op);
388 private void loadConfiguration() {
389 Configuration cnf = Configuration.load();
390 op.setSize(cnf.getSize());
391 op.setLocation(cnf.getLocation());
392 split2.setDividerLocation(cnf.getDividerLocation());
393 statusBar.setVisible(cnf.isShowStatusBar());
394 resultSetTable.setShowColumnNumber(cnf.isShowTableColumnNumber());
395 split1.setDividerLocation(cnf.getDividerLocation0());
396 op.setAlwaysOnTop(cnf.isAlwaysOnTop());
397 resultSetTable.setAutoAdjustMode(cnf.getAutoAdjustMode());
398 op.setPostProcessMode(cnf.getPostProcessMode());
399 setInfoTreePaneVisibility(cnf.isShowInfoTree());
400 changeFont("monospaced", Font.PLAIN, 1.0d);
403 private void saveConfiguration() {
404 Configuration cnf = Configuration.load();
405 if ((op.getExtendedState() & Frame.MAXIMIZED_BOTH) == 0) {
406 // only not maximized
407 cnf.setSize(op.getSize());
408 cnf.setLocation(op.getLocation());
409 cnf.setDividerLocation(split2.getDividerLocation());
410 cnf.setDividerLocation0(split1.getDividerLocation());
412 cnf.setShowStatusBar(statusBar.isVisible());
413 cnf.setShowTableColumnNumber(resultSetTable.isShowColumnNumber());
414 cnf.setShowInfoTree(infoTree.isEnabled());
415 cnf.setAlwaysOnTop(op.isAlwaysOnTop());
416 cnf.setAutoAdjustMode(resultSetTable.getAutoAdjustMode());
417 cnf.setPostProcessMode(op.getPostProcessMode());
422 * Configuration (Bean) for saving and loading.
424 @SuppressWarnings("all")
425 public static final class Configuration {
427 private static final Logger log = Logger.getLogger(Configuration.class);
429 private Dimension size;
430 private Point location;
431 private int dividerLocation;
432 private int dividerLocation0;
433 private boolean showStatusBar;
434 private boolean showTableColumnNumber;
435 private boolean showInfoTree;
436 private boolean alwaysOnTop;
437 private String autoAdjustMode;
438 private String postProcessMode;
440 public Configuration() {
441 this.size = new Dimension(640, 480);
442 this.location = new Point(200, 200);
443 this.dividerLocation = -1;
444 this.dividerLocation0 = -1;
445 this.showStatusBar = false;
446 this.showTableColumnNumber = false;
447 this.showInfoTree = false;
448 this.alwaysOnTop = false;
449 this.autoAdjustMode = AnyActionKey.autoAdjustMode.toString();
450 this.postProcessMode = AnyActionKey.postProcessMode.toString();
454 final File file = getFile();
455 log.debug("save Configuration to: [%s]", file.getAbsolutePath());
457 XMLEncoder encoder = new XMLEncoder(new FileOutputStream(file));
459 encoder.writeObject(this);
463 } catch (Exception ex) {
468 static Configuration load() {
469 final File file = getFile();
470 log.debug("load Configuration from: [%s]", file.getAbsolutePath());
473 XMLDecoder decoder = new XMLDecoder(new FileInputStream(file));
475 return (Configuration)decoder.readObject();
479 } catch (Exception ex) {
483 return new Configuration();
486 private static File getFile() {
487 return Bootstrap.getSystemFile(Configuration.class.getName() + ".xml");
490 public Dimension getSize() {
494 public void setSize(Dimension size) {
498 public Point getLocation() {
502 public void setLocation(Point location) {
503 this.location = location;
506 public int getDividerLocation() {
507 return dividerLocation;
510 public void setDividerLocation(int dividerLocation) {
511 this.dividerLocation = dividerLocation;
514 public int getDividerLocation0() {
515 return dividerLocation0;
518 public void setDividerLocation0(int dividerLocation0) {
519 this.dividerLocation0 = dividerLocation0;
522 public boolean isShowStatusBar() {
523 return showStatusBar;
526 public void setShowStatusBar(boolean showStatusBar) {
527 this.showStatusBar = showStatusBar;
530 public boolean isShowTableColumnNumber() {
531 return showTableColumnNumber;
534 public void setShowTableColumnNumber(boolean showTableColumnNumber) {
535 this.showTableColumnNumber = showTableColumnNumber;
538 public boolean isShowInfoTree() {
542 public void setShowInfoTree(boolean showInfoTree) {
543 this.showInfoTree = showInfoTree;
546 public boolean isAlwaysOnTop() {
550 public void setAlwaysOnTop(boolean alwaysOnTop) {
551 this.alwaysOnTop = alwaysOnTop;
554 public String getAutoAdjustMode() {
555 return autoAdjustMode;
558 public void setAutoAdjustMode(String autoAdjustMode) {
559 this.autoAdjustMode = autoAdjustMode;
562 public String getPostProcessMode() {
563 return postProcessMode;
566 public void setPostProcessMode(String postProcessMode) {
567 this.postProcessMode = postProcessMode;
572 private void changeFont(String family, int style, double sizeRate) {
573 FontControlLookAndFeel.change(family, style, sizeRate);
574 SwingUtilities.updateComponentTreeUI(op);
575 Font newfont = textArea.getFont();
576 if (newfont != null) {
577 statusBar.setFont(newfont.deriveFont(newfont.getSize() * 0.8f));
581 void handleError(Throwable th) {
583 op.showErrorDialog(th);
586 static void invoke() {
587 invoke(new WindowLauncher());
590 static void invoke(WindowLauncher instance) {
591 final Environment env = new Environment();
592 env.setOutputProcessor(new WindowOutputProcessor.Bypass(instance.op));
593 instance.launch(env);
597 * Starts to exit application.
600 for (WindowLauncher instance : new ArrayList<WindowLauncher>(instances)) {
603 } catch (Exception ex) {
604 log.warn(ex, "error occurred when closing all instances");
610 * Closes this window.
613 instances.remove(this);
617 executorService.shutdown();
624 * Confirms whether pressed YES or not at dialog.
626 * @return true if pressed YES
628 private boolean confirmYes(String message) {
629 return showConfirmDialog(op, message, "", YES_NO_OPTION) == YES_OPTION;
632 private boolean confirmCommitable() {
633 if (env.getCurrentConnection() == null) {
634 showMessageDialog(op, res.get("w.not-connect"), null, OK_OPTION);
637 if (env.getCurrentConnector().isReadOnly()) {
638 showMessageDialog(op, res.get("w.connector-readonly"), null, OK_OPTION);
644 private void retrieveHistory(int value) {
645 if (historyList.isEmpty()) {
648 historyIndex += value;
649 if (historyIndex >= historyList.size()) {
651 } else if (historyIndex < 0) {
652 historyIndex = historyList.size() - 1;
654 textArea.replace(historyList.get(historyIndex));
655 final int endPosition = textArea.getEndPosition();
656 textArea.setSelectionStart(endPosition);
657 textArea.moveCaretPosition(endPosition);
658 textArea.requestFocus();
662 * Requests to close this window.
664 void requestClose() {
665 if (instances.size() == 1) {
667 } else if (env.getCurrentConnection() == null || confirmYes(res.get("i.confirm-close"))) {
673 * Requests to exit this application.
676 if (confirmYes(res.get("i.confirm-quit"))) {
681 private void refreshResult() {
682 if (resultSetTable.getModel() instanceof ResultSetTableModel) {
683 ResultSetTableModel m = resultSetTable.getResultSetTableModel();
684 if (m.isSameConnection(env.getCurrentConnection())) {
685 final String s = m.getCommandString();
686 if (s != null && s.length() > 0) {
693 private void editEncryptionKey() {
694 JPasswordField password = new JPasswordField(20);
695 Object[] a = {res.get("i.input-encryption-key"), password};
696 if (showConfirmDialog(op, a, null, OK_CANCEL_OPTION) == OK_OPTION) {
697 CipherPassword.setSecretKey(String.valueOf(password.getPassword()));
701 private void editConnectorMap() {
702 env.updateConnectorMap();
703 if (env.getCurrentConnector() != null) {
704 showMessageDialog(op, res.get("i.reconnect-after-edited-current-connector"));
706 ConnectorMapEditDialog dialog = new ConnectorMapEditDialog(op, env);
708 dialog.setModal(true);
709 dialog.setLocationRelativeTo(op);
710 dialog.setVisible(true);
711 env.updateConnectorMap();
714 private static void showHelp() {
715 final File localeFile = new File("MANUAL_" + Locale.getDefault().getLanguage() + ".html");
716 final File htmlFile = (localeFile.exists()) ? localeFile : new File("MANUAL.html");
717 boolean wasOpened = false;
718 if (Desktop.isDesktopSupported()) {
719 Desktop desktop = Desktop.getDesktop();
720 if (desktop.isSupported(Desktop.Action.OPEN)) {
721 if (htmlFile.exists()) {
723 desktop.open(htmlFile);
725 } catch (IOException ex) {
726 throw new RuntimeException(ex);
732 final String msg = String.format("%s%nfile=%s",
733 res.get("e.cannot-open-help-automatically", htmlFile),
734 htmlFile.getAbsolutePath());
735 WindowOutputProcessor.showInformationMessageDialog(getRootFrame(), msg, "");
740 * Executes a command.
741 * @param commandString
743 void executeCommand(String commandString) {
744 assert commandString != null;
745 if (!commandString.equals(textArea.getEditableText())) {
746 textArea.replace(commandString);
749 if (commandString.trim().length() == 0) {
752 final String cmd = commandString;
753 final Environment env = this.env;
754 final DatabaseInfoTree infoTree = this.infoTree;
755 final JLabel statusBar = this.statusBar;
756 final OutputProcessor opref = env.getOutputProcessor();
759 executorService.execute(new Runnable() {
762 Connection conn = env.getCurrentConnection();
763 long time = System.currentTimeMillis();
764 if (!Command.invoke(env, cmd)) {
767 if (infoTree.isEnabled()) {
769 if (env.getCurrentConnection() != conn) {
771 if (env.getCurrentConnection() != null) {
772 infoTree.refreshRoot(env);
775 } catch (Throwable th) {
779 if (env.getOutputProcessor() == opref) {
780 time = System.currentTimeMillis() - time;
781 statusBar.setText(res.get("i.statusbar-message", time / 1000f, cmd));
782 AnyAction invoker = new AnyAction(this);
783 invoker.doLater("callDoPostProcess");
786 @SuppressWarnings("unused")
787 void callDoPostProcess() {
788 WindowLauncher.this.doPostProcess();
791 } catch (Exception ex) {
792 throw new RuntimeException(ex);
794 historyIndex = historyList.size();
796 if (historyList.contains(commandString)) {
797 historyList.remove(commandString);
799 historyList.add(commandString);
801 historyIndex = historyList.size();
804 void doPreProcess() {
805 ((Menu)op.getJMenuBar()).setEnabledStates(true);
806 resultSetTable.setEnabled(false);
807 textArea.setEnabled(false);
811 void doPostProcess() {
812 ((Menu)op.getJMenuBar()).setEnabledStates(false);
813 resultSetTable.setEnabled(true);
814 textArea.setEnabled(true);
815 op.output(new Prompt(env));
819 static void wakeup() {
820 for (WindowLauncher instance : new ArrayList<WindowLauncher>(instances)) {
822 SwingUtilities.updateComponentTreeUI(instance.op);
823 } catch (Exception ex) {
830 private static final class WakeupTimerTask extends TimerTask {
831 private final AnyAction aa = new AnyAction(this);
834 aa.doLater("callWakeup");
836 @SuppressWarnings("unused")
846 public static void main(String... args) {
847 final int residentCycle = Bootstrap.getPropertyAsInt("net.argius.stew.ui.window.resident",
849 if (residentCycle > 0) {
850 final long msec = residentCycle * 60000L;
851 Timer timer = new Timer(true);
852 timer.scheduleAtFixedRate(new WakeupTimerTask(), msec, msec);
854 EventQueue.invokeLater(new WindowLauncher());