Skip to content

Commit e36272c

Browse files
committed
Do more property binding in FXML instead of the controller
Ideally we should do as little view stuff as possible in the controller class because of MVC or something.
1 parent daa79f0 commit e36272c

3 files changed

Lines changed: 11 additions & 8 deletions

File tree

core/src/main/java/edu/wpi/grip/core/settings/ProjectSettings.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public String getDeployJvmOptions() {
106106
}
107107

108108
public void setDeployJvmOptions(String deployJvmOptions) {
109-
this.deployJvmOptions = deployJvmOptions;
109+
if (deployJvmOptions != null) this.deployJvmOptions = deployJvmOptions;
110110
}
111111

112112
private String computeFRCAddress(int teamNumber) {

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import javafx.application.Platform;
1313
import javafx.beans.binding.Bindings;
1414
import javafx.beans.property.BooleanProperty;
15-
import javafx.beans.property.SimpleBooleanProperty;
1615
import javafx.fxml.FXML;
1716
import javafx.scene.control.*;
1817
import net.schmizz.sshj.SSHClient;
@@ -55,22 +54,19 @@ public class DeployController {
5554
@FXML private TextField deployDir;
5655
@FXML private ProgressIndicator progress;
5756
@FXML private Label command;
58-
@FXML private Button deployButton;
5957
@FXML private Label status;
6058
@FXML private TextArea console;
59+
@FXML private BooleanProperty deploying;
6160

6261
@Inject private EventBus eventBus;
6362
@Inject private Project project;
6463
@Inject private Pipeline pipeline;
65-
6664
@Inject private Logger logger;
67-
private final BooleanProperty deploying = new SimpleBooleanProperty(this, "deploying", false);
65+
6866
private Optional<Thread> deployThread = Optional.empty();
6967

7068
@FXML
7169
public void initialize() {
72-
deployButton.disableProperty().bind(deploying);
73-
progress.disableProperty().bind(deploying.not());
7470
deploying.addListener((o, b, d) -> progress.setProgress(d ? ProgressIndicator.INDETERMINATE_PROGRESS : 0));
7571
command.textProperty().bind(Bindings.concat(javaHome.textProperty(), "/bin/java ", jvmArgs.textProperty(),
7672
" -jar '", deployDir.textProperty(), "/", GRIP_JAR, "' '", deployDir.textProperty(), "/", PROJECT_FILE, "'"));

ui/src/main/resources/edu/wpi/grip/ui/Deploy.fxml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
<VBox styleClass="deploy-pane" maxWidth="Infinity" xmlns:fx="http://javafx.com/fxml/1"
1212
onKeyPressed="if (event.code == javafx.scene.input.KeyCode.ENTER) { controller.onDeploy() }"
1313
xmlns="http://javafx.com/javafx/null" fx:controller="edu.wpi.grip.ui.DeployController">
14+
<fx:define>
15+
<SimpleBooleanProperty fx:id="deploying"/>
16+
</fx:define>
17+
1418
<GridPane maxHeight="Infinity">
1519
<columnConstraints>
1620
<ColumnConstraints hgrow="NEVER" halignment="RIGHT"/>
@@ -59,6 +63,7 @@
5963
<buttons>
6064
<Button fx:id="deployButton" defaultButton="true" onMouseClicked="#onDeploy" text="Deploy"
6165
ButtonBar.buttonData="APPLY">
66+
<fx:script>deployButton.disableProperty().bind(deploying)</fx:script>
6267
<graphic>
6368
<ImageView styleClass="menu-graphic">
6469
<fitWidth>
@@ -78,7 +83,9 @@
7883
</ButtonBar>
7984

8085
<StackPane>
81-
<ProgressBar fx:id="progress" maxWidth="Infinity" progress="0"/>
86+
<ProgressBar fx:id="progress" maxWidth="Infinity" progress="0">
87+
<fx:script>progress.disableProperty().bind(deploying.not())</fx:script>
88+
</ProgressBar>
8289
<Label fx:id="status"/>
8390
</StackPane>
8491

0 commit comments

Comments
 (0)