Skip to content

Commit 60177d7

Browse files
committed
Better way to show updates during parsing
1 parent 4b59e51 commit 60177d7

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/main/java/programminglife/gui/controller/GuiController.java

+3
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ public void update(Observable o, Object arg) {
168168
Exception e = (Exception) arg;
169169
e.printStackTrace();
170170
Alerts.error(e.getMessage());
171+
} else if (arg instanceof String) {
172+
String msg = (String) arg;
173+
Platform.runLater(() -> ProgrammingLife.getStage().setTitle(msg));
171174
}
172175
} else if (o instanceof ProgressCounter) {
173176
progressBar.setVisible(true);

src/main/java/programminglife/parser/GraphParser.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,23 @@ public GraphParser(File graphFile) {
4343
@Override
4444
public void run() {
4545
try {
46+
this.setChanged();
47+
this.notifyObservers("Parsing " + this.graphFile.getPath());
4648
long startTime = System.nanoTime();
4749
if (!this.isCached) {
4850
Console.println("[%s] Parsing %s on separate Thread", Thread.currentThread().getName(), this.name);
49-
Platform.runLater(() -> ProgrammingLife.getStage().setTitle("Parsing " + this.graphFile.getPath()));
5051
parse();
5152
} else {
5253
Console.println("[%s] Loaded %s from cache", Thread.currentThread().getName(), this.name);
5354
}
5455

55-
Platform.runLater(() -> ProgrammingLife.getStage().setTitle("Loading genomes..."));
56-
5756
int secondsElapsed = (int) ((System.nanoTime() - startTime) / 1000000000.d);
5857
Console.println("[%s] Parsing took %d seconds", Thread.currentThread().getName(), secondsElapsed);
59-
this.progressCounter.finished();
58+
this.setChanged();
59+
this.notifyObservers(this.graph.getID());
6060
this.setChanged();
6161
this.notifyObservers(this.graph);
62+
this.progressCounter.finished();
6263
} catch (Exception e) {
6364
try {
6465
this.getGraph().rollback();

0 commit comments

Comments
 (0)