Skip to content

Commit 9d52740

Browse files
committed
Remove JavaFX from core
1 parent cff7fb9 commit 9d52740

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

core/src/main/java/edu/wpi/grip/core/serialization/Project.java

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
import java.io.Writer;
2323
import java.nio.charset.StandardCharsets;
2424
import java.util.Optional;
25-
import javafx.beans.property.SimpleBooleanProperty;
26-
import javafx.beans.value.ChangeListener;
2725
import javax.inject.Inject;
2826
import javax.inject.Singleton;
2927

@@ -39,7 +37,7 @@ public class Project {
3937
@Inject
4038
private PipelineRunner pipelineRunner;
4139
private Optional<File> file = Optional.empty();
42-
private final SimpleBooleanProperty saveIsDirty = new SimpleBooleanProperty(false);
40+
private boolean saveIsDirty = false;
4341

4442
@Inject
4543
public void initialize(StepConverter stepConverter,
@@ -113,7 +111,7 @@ void open(Reader reader) {
113111
this.pipeline.clear();
114112
this.xstream.fromXML(reader);
115113
pipelineRunner.startAsync();
116-
saveIsDirty.set(false);
114+
saveIsDirty = false;
117115
}
118116

119117
/**
@@ -129,27 +127,19 @@ public void save(File file) throws IOException {
129127

130128
public void save(Writer writer) {
131129
this.xstream.toXML(this.pipeline, writer);
132-
saveIsDirty.set(false);
130+
saveIsDirty = false;
133131
}
134132

135133
public boolean isSaveDirty() {
136-
return saveIsDirty.get();
137-
}
138-
139-
public void addDirtyListener(ChangeListener<Boolean> changeListener) {
140-
saveIsDirty.addListener(changeListener);
141-
}
142-
143-
public void removeDirtyListener(ChangeListener<Boolean> changeListener) {
144-
saveIsDirty.removeListener(changeListener);
134+
return saveIsDirty;
145135
}
146136

147137
@Subscribe
148138
public void onDirtiesSaveEvent(DirtiesSaveEvent dirtySaveEvent) {
149139
// Only update the flag the save isn't already dirty
150140
// We don't need to be redundantly checking if the event dirties the save
151-
if (!saveIsDirty.get() && dirtySaveEvent.doesDirtySave()) {
152-
saveIsDirty.set(true);
141+
if (!saveIsDirty && dirtySaveEvent.doesDirtySave()) {
142+
saveIsDirty = true;
153143
}
154144
}
155145
}

ui/src/main/java/edu/wpi/grip/ui/Main.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import edu.wpi.grip.core.GripCoreModule;
44
import edu.wpi.grip.core.GripFileModule;
55
import edu.wpi.grip.core.PipelineRunner;
6+
import edu.wpi.grip.core.events.DirtiesSaveEvent;
67
import edu.wpi.grip.core.events.UnexpectedThrowableEvent;
78
import edu.wpi.grip.core.http.GripServer;
89
import edu.wpi.grip.core.http.HttpPipelineSwitcher;
@@ -31,6 +32,7 @@
3132
import javafx.application.Application;
3233
import javafx.application.Platform;
3334
import javafx.application.Preloader;
35+
import javafx.beans.property.SimpleBooleanProperty;
3436
import javafx.fxml.FXMLLoader;
3537
import javafx.scene.Parent;
3638
import javafx.scene.Scene;
@@ -61,6 +63,7 @@ public class Main extends Application {
6163
@Inject private HttpPipelineSwitcher pipelineSwitcher;
6264
private Parent root;
6365
private boolean headless;
66+
private final SimpleBooleanProperty dirty = new SimpleBooleanProperty(false);
6467

6568
public static void main(String[] args) {
6669
launch(args);
@@ -124,7 +127,7 @@ public void start(Stage stage) throws IOException {
124127
cvOperations.addOperations();
125128
notifyPreloader(new Preloader.ProgressNotification(0.9));
126129

127-
project.addDirtyListener((observable, oldValue, newValue) -> {
130+
dirty.addListener((observable, oldValue, newValue) -> {
128131
if (newValue) {
129132
stage.setTitle(MAIN_TITLE + " | Edited");
130133
} else {
@@ -148,6 +151,13 @@ public void stop() {
148151
SafeShutdown.flagStopping();
149152
}
150153

154+
@Subscribe
155+
public void onDirtiesSaveEvent(DirtiesSaveEvent dirtySaveEvent) {
156+
if (dirty.get() != dirtySaveEvent.doesDirtySave()) {
157+
dirty.set(dirtySaveEvent.doesDirtySave());
158+
}
159+
}
160+
151161
@Subscribe
152162
@SuppressWarnings("PMD.AvoidCatchingThrowable")
153163
public final void onUnexpectedThrowableEvent(UnexpectedThrowableEvent event) {

0 commit comments

Comments
 (0)