Dealing with better status messages

This commit is contained in:
Manindra Moharana
2014-06-06 14:19:51 +05:30
parent a21ae3bc2c
commit 1c1c71bb3a
3 changed files with 82 additions and 10 deletions

View File

@@ -36,6 +36,8 @@ import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -48,6 +50,7 @@ import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
import javax.swing.border.EtchedBorder;
import javax.swing.table.TableModel;
import javax.swing.text.Document;
@@ -1377,6 +1380,63 @@ public class DebugEditor extends JavaEditor implements ActionListener {
statusNotice("Debugger halted.");
}
public static final int STATUS_EMPTY = 100, STATUS_COMPILER_ERR = 200,
STATUS_WARNING = 300, STATUS_INFO = 400, STATUS_ERR = 500;
public int statusMessageType = STATUS_EMPTY;
public String statusMessage;
public void statusMessage(final String what, int type){
// Don't re-display the old message again
if(what.equals(statusMessage) && type == statusMessageType) {
return;
}
statusMessage = what;
statusMessageType = type;
switch (type) {
case STATUS_COMPILER_ERR:
case STATUS_ERR:
super.statusError(what);
break;
case STATUS_INFO:
case STATUS_WARNING:
statusNotice(what);
break;
}
// log("SW 0");
// final Timer t = new Timer();
// t.schedule(new TimerTask() {
// @Override
// public void run() {
// log("SW 1");
// statusEmpty();
// log("SW 2");
// t.cancel();
// }
// }, 2000);
SwingWorker s = new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() throws Exception {
try {
log("SW 1");
Thread.sleep(2 * 1000);
log("SW 2");
} catch (InterruptedException e) {
e.printStackTrace();
}
statusEmpty();
return null;
}
};
s.execute();
}
public void statusEmpty(){
statusMessage = null;
statusMessageType = STATUS_EMPTY;
super.statusEmpty();
}
ErrorCheckerService errorCheckerService;
/**