r12481 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r12480‎ | r12481 | r12482 >
Date:17:08, 7 January 2006
Author:vibber
Status:old
Tags:
Comment:
Poke at enable/disable of fields while the stuff runs
Modified paths:
  • /trunk/mwdumper/src/org/mediawiki/dumper/gui/DumperGui.java (modified) (history)
  • /trunk/mwdumper/src/org/mediawiki/dumper/gui/DumperWindow.java (modified) (history)

Diff [purge]

Index: trunk/mwdumper/src/org/mediawiki/dumper/gui/DumperGui.java
@@ -33,6 +33,7 @@
3434 final XmlDumpReader reader = new XmlDumpReader(stream, progress);
3535 new Thread() {
3636 public void run() {
 37+ running = true;
3738 gui.start();
3839 try {
3940 reader.readDump();
@@ -40,12 +41,8 @@
4142 } catch(IOException e) {
4243 gui.setProgress("FAILED: " + e.getMessage());
4344 }
44 - SwingUtilities.invokeLater(new Runnable() {
45 - public void run() {
46 - running = false;
47 - gui.stop();
48 - }
49 - });
 45+ running = false;
 46+ gui.stop();
5047 }
5148 }.start();
5249 }
Index: trunk/mwdumper/src/org/mediawiki/dumper/gui/DumperWindow.java
@@ -9,6 +9,7 @@
1010
1111 package org.mediawiki.dumper.gui;
1212
 13+import java.awt.Component;
1314 import java.io.File;
1415 import java.io.IOException;
1516 import javax.swing.JFileChooser;
@@ -32,14 +33,41 @@
3334 }
3435
3536 public void start() {
36 - // todo: set the button up to a stop mode. ;)
37 - startButton.setEnabled(false);
 37+ // disable the other fields...
 38+ setFieldsEnabled(false);
 39+
 40+ // todo: set the start button up to a stop mode instead of disabling it
3841 }
3942
4043 public void stop() {
41 - startButton.setEnabled(true);
 44+ setFieldsEnabled(true);
4245 }
4346
 47+ void setFieldsEnabled(boolean val) {
 48+ final boolean _val = val;
 49+ SwingUtilities.invokeLater(new Runnable() {
 50+ public void run() {
 51+ Component[] widgets = new Component[] {
 52+ fileText,
 53+ browseButton,
 54+
 55+ serverText,
 56+ portText,
 57+ userText,
 58+ passwordText,
 59+ connectButton,
 60+
 61+ schema14Radio,
 62+ schema15Radio,
 63+ prefixText,
 64+ startButton };
 65+ for (int i = 0; i < widgets.length; i++) {
 66+ widgets[i].setEnabled(_val);
 67+ }
 68+ }
 69+ });
 70+ }
 71+
4472 /**
4573 * Set the progress bar text asynchronously, eg from a background thread
4674 */

Status & tagging log