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 infoTree.requestFocus();
271 } else if (infoTree.isFocusOwner()) {
272 resultSetTable.requestFocus();
274 textArea.requestFocus();
276 } else if (ev.isAnyOf(clearMessage)) {
279 } else if (ev.isAnyOf(showStatusBar)) {
280 statusBar.setVisible(((JCheckBoxMenuItem)source).isSelected());
281 } else if (ev.isAnyOf(showColumnNumber)) {
282 resultSetTable.anyActionPerformed(ev);
283 } else if (ev.isAnyOf(refresh)) {
285 } else if (ev.isAnyOf(autoAdjustModeNone,
286 autoAdjustModeHeader,
288 autoAdjustModeHeaderAndValue)) {
289 resultSetTable.setAutoAdjustMode(ev.getActionCommand());
290 } else if (ev.isAnyOf(widenColumnWidth, narrowColumnWidth, adjustColumnWidth)) {
291 resultSetTable.anyActionPerformed(ev);
292 } else if (ev.isAnyOf(executeCommand, execute)) {
293 executeCommand(textArea.getEditableText());
294 } else if (ev.isAnyOf(breakCommand)) {
295 env.getOutputProcessor().close();
296 env.setOutputProcessor(new WindowOutputProcessor.Bypass(op));
297 op.output(res.get("i.cancelled"));
299 } else if (ev.isAnyOf(lastHistory)) {
301 } else if (ev.isAnyOf(nextHistory)) {
303 } else if (ev.isAnyOf(sendRollback)) {
304 if (confirmCommitable()
305 && showConfirmDialog(op, res.get("i.confirm-rollback"), null, OK_CANCEL_OPTION) == OK_OPTION) {
306 executeCommand("rollback");
308 } else if (ev.isAnyOf(sendCommit)) {
309 if (confirmCommitable()
310 && showConfirmDialog(op, res.get("i.confirm-commit"), null, OK_CANCEL_OPTION) == OK_OPTION) {
311 executeCommand("commit");
313 } else if (ev.isAnyOf(connect)) {
314 env.updateConnectorMap();
315 if (env.getConnectorMap().isEmpty()) {
316 showMessageDialog(op, res.get("w.no-connector"));
319 Object[] a = ConnectorEntry.toList(env.getConnectorMap().values()).toArray();
320 final String m = res.get("i.choose-connection");
321 Object value = showInputDialog(op, m, null, PLAIN_MESSAGE, null, a, a[0]);
323 ConnectorEntry c = (ConnectorEntry)value;
324 executeCommand("connect " + c.getId());
326 } else if (ev.isAnyOf(disconnect)) {
327 executeCommand("disconnect");
328 } else if (ev.isAnyOf(postProcessModeNone,
329 postProcessModeFocus,
330 postProcessModeShake,
331 postProcessModeBlink)) {
332 op.setPostProcessMode(ev.getActionCommand());
333 } else if (ev.isAnyOf(inputEcryptionKey)) {
335 } else if (ev.isAnyOf(editConnectors)) {
337 } else if (ev.isAnyOf(sortResult)) {
338 resultSetTable.doSort(resultSetTable.getSelectedColumn());
339 } else if (ev.isAnyOf(importFile, exportFile, showAbout)) {
340 op.anyActionPerformed(ev);
341 } else if (ev.isAnyOf(showHelp)) {
343 } else if (ev.isAnyOf(ResultSetTable.ActionKey.findColumnName)) {
344 resultSetTable.getTableHeader().requestFocus();
345 textSearchPanel.setVisible(true);
346 } else if (ev.isAnyOf(ResultSetTable.ActionKey.jumpToColumn)) {
347 resultSetTable.anyActionPerformed(ev);
348 } else if (ev.isAnyOf(ConsoleTextArea.ActionKey.insertText)) {
349 textArea.anyActionPerformed(ev);
351 log.warn("not expected: Event=%s", ev);
353 } catch (Exception ex) {
354 op.showErrorDialog(ex);
356 log.atExit("dispatch");
360 * Controls visibility of DatabaseInfoTree pane.
363 void setInfoTreePaneVisibility(boolean show) {
366 split1.setTopComponent(new JScrollPane(infoTree));
367 split1.setBottomComponent(split2);
369 panel1.add(split1, BorderLayout.CENTER);
370 panel1.add(textSearchPanel, BorderLayout.PAGE_END);
371 infoTree.setEnabled(true);
374 infoTree.refreshRoot(env);
375 } catch (SQLException ex) {
377 op.showErrorDialog(ex);
382 infoTree.setEnabled(false);
384 panel1.add(split2, BorderLayout.CENTER);
385 panel1.add(textSearchPanel, BorderLayout.PAGE_END);
387 SwingUtilities.updateComponentTreeUI(op);
390 private void loadConfiguration() {
391 Configuration cnf = Configuration.load();
392 op.setSize(cnf.getSize());
393 op.setLocation(cnf.getLocation());
394 split2.setDividerLocation(cnf.getDividerLocation());
395 statusBar.setVisible(cnf.isShowStatusBar());
396 resultSetTable.setShowColumnNumber(cnf.isShowTableColumnNumber());
397 split1.setDividerLocation(cnf.getDividerLocation0());
398 op.setAlwaysOnTop(cnf.isAlwaysOnTop());
399 resultSetTable.setAutoAdjustMode(cnf.getAutoAdjustMode());
400 op.setPostProcessMode(cnf.getPostProcessMode());
401 setInfoTreePaneVisibility(cnf.isShowInfoTree());
402 changeFont("monospaced", Font.PLAIN, 1.0d);
405 private void saveConfiguration() {
406 Configuration cnf = Configuration.load();
407 if ((op.getExtendedState() & Frame.MAXIMIZED_BOTH) == 0) {
408 // only not maximized
409 cnf.setSize(op.getSize());
410 cnf.setLocation(op.getLocation());
411 cnf.setDividerLocation(split2.getDividerLocation());
412 cnf.setDividerLocation0(split1.getDividerLocation());
414 cnf.setShowStatusBar(statusBar.isVisible());
415 cnf.setShowTableColumnNumber(resultSetTable.isShowColumnNumber());
416 cnf.setShowInfoTree(infoTree.isEnabled());
417 cnf.setAlwaysOnTop(op.isAlwaysOnTop());
418 cnf.setAutoAdjustMode(resultSetTable.getAutoAdjustMode());
419 cnf.setPostProcessMode(op.getPostProcessMode());
424 * Configuration (Bean) for saving and loading.
426 @SuppressWarnings("all")
427 public static final class Configuration {
429 private static final Logger log = Logger.getLogger(Configuration.class);
431 private Dimension size;
432 private Point location;
433 private int dividerLocation;
434 private int dividerLocation0;
435 private boolean showStatusBar;
436 private boolean showTableColumnNumber;
437 private boolean showInfoTree;
438 private boolean alwaysOnTop;
439 private String autoAdjustMode;
440 private String postProcessMode;
442 public Configuration() {
443 this.size = new Dimension(640, 480);
444 this.location = new Point(200, 200);
445 this.dividerLocation = -1;
446 this.dividerLocation0 = -1;
447 this.showStatusBar = false;
448 this.showTableColumnNumber = false;
449 this.showInfoTree = false;
450 this.alwaysOnTop = false;
451 this.autoAdjustMode = AnyActionKey.autoAdjustMode.toString();
452 this.postProcessMode = AnyActionKey.postProcessMode.toString();
456 final File file = getFile();
457 log.debug("save Configuration to: [%s]", file.getAbsolutePath());
459 XMLEncoder encoder = new XMLEncoder(new FileOutputStream(file));
461 encoder.writeObject(this);
465 } catch (Exception ex) {
470 static Configuration load() {
471 final File file = getFile();
472 log.debug("load Configuration from: [%s]", file.getAbsolutePath());
475 XMLDecoder decoder = new XMLDecoder(new FileInputStream(file));
477 return (Configuration)decoder.readObject();
481 } catch (Exception ex) {
485 return new Configuration();
488 private static File getFile() {
489 return Bootstrap.getSystemFile(Configuration.class.getName() + ".xml");
492 public Dimension getSize() {
496 public void setSize(Dimension size) {
500 public Point getLocation() {
504 public void setLocation(Point location) {
505 this.location = location;
508 public int getDividerLocation() {
509 return dividerLocation;
512 public void setDividerLocation(int dividerLocation) {
513 this.dividerLocation = dividerLocation;
516 public int getDividerLocation0() {
517 return dividerLocation0;
520 public void setDividerLocation0(int dividerLocation0) {
521 this.dividerLocation0 = dividerLocation0;
524 public boolean isShowStatusBar() {
525 return showStatusBar;
528 public void setShowStatusBar(boolean showStatusBar) {
529 this.showStatusBar = showStatusBar;
532 public boolean isShowTableColumnNumber() {
533 return showTableColumnNumber;
536 public void setShowTableColumnNumber(boolean showTableColumnNumber) {
537 this.showTableColumnNumber = showTableColumnNumber;
540 public boolean isShowInfoTree() {
544 public void setShowInfoTree(boolean showInfoTree) {
545 this.showInfoTree = showInfoTree;
548 public boolean isAlwaysOnTop() {
552 public void setAlwaysOnTop(boolean alwaysOnTop) {
553 this.alwaysOnTop = alwaysOnTop;
556 public String getAutoAdjustMode() {
557 return autoAdjustMode;
560 public void setAutoAdjustMode(String autoAdjustMode) {
561 this.autoAdjustMode = autoAdjustMode;
564 public String getPostProcessMode() {
565 return postProcessMode;
568 public void setPostProcessMode(String postProcessMode) {
569 this.postProcessMode = postProcessMode;
574 private void changeFont(String family, int style, double sizeRate) {
575 FontControlLookAndFeel.change(family, style, sizeRate);
576 SwingUtilities.updateComponentTreeUI(op);
577 Font newfont = textArea.getFont();
578 if (newfont != null) {
579 statusBar.setFont(newfont.deriveFont(newfont.getSize() * 0.8f));
583 void handleError(Throwable th) {
585 op.showErrorDialog(th);
588 static void invoke() {
589 invoke(new WindowLauncher());
592 static void invoke(WindowLauncher instance) {
593 final Environment env = new Environment();
594 env.setOutputProcessor(new WindowOutputProcessor.Bypass(instance.op));
595 instance.launch(env);
599 * Starts to exit application.
602 for (WindowLauncher instance : new ArrayList<WindowLauncher>(instances)) {
605 } catch (Exception ex) {
606 log.warn(ex, "error occurred when closing all instances");
612 * Closes this window.
615 instances.remove(this);
619 executorService.shutdown();
626 * Confirms whether pressed YES or not at dialog.
628 * @return true if pressed YES
630 private boolean confirmYes(String message) {
631 return showConfirmDialog(op, message, "", YES_NO_OPTION) == YES_OPTION;
634 private boolean confirmCommitable() {
635 if (env.getCurrentConnection() == null) {
636 showMessageDialog(op, res.get("w.not-connect"), null, OK_OPTION);
639 if (env.getCurrentConnector().isReadOnly()) {
640 showMessageDialog(op, res.get("w.connector-readonly"), null, OK_OPTION);
646 private void retrieveHistory(int value) {
647 if (historyList.isEmpty()) {
650 historyIndex += value;
651 if (historyIndex >= historyList.size()) {
653 } else if (historyIndex < 0) {
654 historyIndex = historyList.size() - 1;
656 textArea.replace(historyList.get(historyIndex));
657 final int endPosition = textArea.getEndPosition();
658 textArea.setSelectionStart(endPosition);
659 textArea.moveCaretPosition(endPosition);
660 textArea.requestFocus();
664 * Requests to close this window.
666 void requestClose() {
667 if (instances.size() == 1) {
669 } else if (env.getCurrentConnection() == null || confirmYes(res.get("i.confirm-close"))) {
675 * Requests to exit this application.
678 if (confirmYes(res.get("i.confirm-quit"))) {
683 private void refreshResult() {
684 if (resultSetTable.getModel() instanceof ResultSetTableModel) {
685 ResultSetTableModel m = resultSetTable.getResultSetTableModel();
686 if (m.isSameConnection(env.getCurrentConnection())) {
687 final String s = m.getCommandString();
688 if (s != null && s.length() > 0) {
695 private void editEncryptionKey() {
696 JPasswordField password = new JPasswordField(20);
697 Object[] a = {res.get("i.input-encryption-key"), password};
698 if (showConfirmDialog(op, a, null, OK_CANCEL_OPTION) == OK_OPTION) {
699 CipherPassword.setSecretKey(String.valueOf(password.getPassword()));
703 private void editConnectorMap() {
704 env.updateConnectorMap();
705 if (env.getCurrentConnector() != null) {
706 showMessageDialog(op, res.get("i.reconnect-after-edited-current-connector"));
708 ConnectorMapEditDialog dialog = new ConnectorMapEditDialog(op, env);
710 dialog.setModal(true);
711 dialog.setLocationRelativeTo(op);
712 dialog.setVisible(true);
713 env.updateConnectorMap();
716 private static void showHelp() {
717 final File localeFile = new File("MANUAL_" + Locale.getDefault().getLanguage() + ".html");
718 final File htmlFile = (localeFile.exists()) ? localeFile : new File("MANUAL.html");
719 boolean wasOpened = false;
720 if (Desktop.isDesktopSupported()) {
721 Desktop desktop = Desktop.getDesktop();
722 if (desktop.isSupported(Desktop.Action.OPEN)) {
723 if (htmlFile.exists()) {
725 desktop.open(htmlFile);
727 } catch (IOException ex) {
728 throw new RuntimeException(ex);
734 final String msg = String.format("%s%nfile=%s",
735 res.get("e.cannot-open-help-automatically", htmlFile),
736 htmlFile.getAbsolutePath());
737 WindowOutputProcessor.showInformationMessageDialog(getRootFrame(), msg, "");
742 * Executes a command.
743 * @param commandString
745 void executeCommand(String commandString) {
746 assert commandString != null;
747 if (!commandString.equals(textArea.getEditableText())) {
748 textArea.replace(commandString);
751 if (commandString.trim().length() == 0) {
754 final String cmd = commandString;
755 final Environment env = this.env;
756 final DatabaseInfoTree infoTree = this.infoTree;
757 final JLabel statusBar = this.statusBar;
758 final OutputProcessor opref = env.getOutputProcessor();
761 executorService.execute(new Runnable() {
764 Connection conn = env.getCurrentConnection();
765 long time = System.currentTimeMillis();
766 if (!Command.invoke(env, cmd)) {
769 if (infoTree.isEnabled()) {
771 if (env.getCurrentConnection() != conn) {
773 if (env.getCurrentConnection() != null) {
774 infoTree.refreshRoot(env);
777 } catch (Throwable th) {
781 if (env.getOutputProcessor() == opref) {
782 time = System.currentTimeMillis() - time;
783 statusBar.setText(res.get("i.statusbar-message", time / 1000f, cmd));
784 AnyAction invoker = new AnyAction(this);
785 invoker.doLater("callDoPostProcess");
788 @SuppressWarnings("unused")
789 void callDoPostProcess() {
790 WindowLauncher.this.doPostProcess();
793 } catch (Exception ex) {
794 throw new RuntimeException(ex);
796 historyIndex = historyList.size();
798 if (historyList.contains(commandString)) {
799 historyList.remove(commandString);
801 historyList.add(commandString);
803 historyIndex = historyList.size();
806 void doPreProcess() {
807 ((Menu)op.getJMenuBar()).setEnabledStates(true);
808 resultSetTable.setEnabled(false);
809 textArea.setEnabled(false);
813 void doPostProcess() {
814 ((Menu)op.getJMenuBar()).setEnabledStates(false);
815 resultSetTable.setEnabled(true);
816 textArea.setEnabled(true);
817 op.output(new Prompt(env));
821 static void wakeup() {
822 for (WindowLauncher instance : new ArrayList<WindowLauncher>(instances)) {
824 SwingUtilities.updateComponentTreeUI(instance.op);
825 } catch (Exception ex) {
832 private static final class WakeupTimerTask extends TimerTask {
833 private final AnyAction aa = new AnyAction(this);
836 aa.doLater("callWakeup");
838 @SuppressWarnings("unused")
848 public static void main(String... args) {
849 final int residentCycle = Bootstrap.getPropertyAsInt("net.argius.stew.ui.window.resident",
851 if (residentCycle > 0) {
852 final long msec = residentCycle * 60000L;
853 Timer timer = new Timer(true);
854 timer.scheduleAtFixedRate(new WakeupTimerTask(), msec, msec);
856 EventQueue.invokeLater(new WindowLauncher());