Skip to content

Commit bcea46a

Browse files
committed
Put property binding in FXML instead of in the controller
1 parent 370f099 commit bcea46a

2 files changed

Lines changed: 33 additions & 27 deletions

File tree

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

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,12 @@
4141
*/
4242
public class DeployController {
4343

44-
// Default deploy information for FRC. This can be overridden by the use for applications outside of FRC or not
44+
// Default deploy information for FRC. This can be overridden by the user for applications outside of FRC or not
4545
// using the roboRIO (ie: coprocessors)
4646
public final static String DEFAULT_USER = "lvuser";
47-
private final static String DEFAULT_JAVA_HOME = "/usr/local/frc/JRE/";
48-
private final static String DEFAULT_DIR = "/home/" + DEFAULT_USER;
47+
public final static String DEFAULT_JAVA_HOME = "/usr/local/frc/JRE/";
48+
public final static String DEFAULT_DIR = "/home/" + DEFAULT_USER;
49+
4950
private final static String GRIP_JAR = "grip.jar";
5051
private final static String PROJECT_FILE = "project.grip";
5152

@@ -70,16 +71,6 @@ public class DeployController {
7071
@FXML
7172
public void initialize() {
7273
address.setText(pipeline.getProjectSettings().computeDeployAddress());
73-
user.setText(DEFAULT_USER);
74-
javaHome.setText(DEFAULT_JAVA_HOME);
75-
deployDir.setText(DEFAULT_DIR);
76-
77-
// While deploying, change the UI appropriately. This includes disabling controls and enabling the progress bar.
78-
address.disableProperty().bind(deploying);
79-
user.disableProperty().bind(deploying);
80-
password.disableProperty().bind(deploying);
81-
javaHome.disableProperty().bind(deploying);
82-
deployDir.disableProperty().bind(deploying);
8374
deployButton.disableProperty().bind(deploying);
8475
progress.disableProperty().bind(deploying.not());
8576
deploying.addListener((o, b, d) -> progress.setProgress(d ? ProgressIndicator.INDETERMINATE_PROGRESS : 0));
@@ -92,10 +83,6 @@ public void updateSettings(ProjectSettingsChangedEvent event) {
9283

9384
@FXML
9485
public void onDeploy() {
95-
if (deploying.get()) {
96-
throw new IllegalStateException("There's already a deploy in progress");
97-
}
98-
9986
deploying.setValue(true);
10087
console.clear();
10188

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

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<?language javascript ?>
44

55
<?import edu.wpi.grip.ui.util.DPIUtility?>
6+
<?import edu.wpi.grip.ui.DeployController?>
67
<?import javafx.scene.control.*?>
78
<?import javafx.scene.image.Image?>
89
<?import javafx.scene.image.ImageView?>
@@ -15,20 +16,38 @@
1516
<ColumnConstraints hgrow="ALWAYS"/>
1617
</columnConstraints>
1718

18-
<Label disable="${address.disabled}" text="Address" GridPane.columnIndex="0" GridPane.rowIndex="0"/>
19-
<TextField fx:id="address" promptText="Address" GridPane.columnIndex="1" GridPane.rowIndex="0"/>
19+
<Label disable="${deployButton.disabled}" text="Address" GridPane.columnIndex="0" GridPane.rowIndex="0"/>
20+
<TextField disable="${deployButton.disabled}" fx:id="address" promptText="Address" GridPane.columnIndex="1"
21+
GridPane.rowIndex="0"/>
2022

21-
<Label disable="${user.disabled}" text="User" GridPane.columnIndex="0" GridPane.rowIndex="1"/>
22-
<TextField fx:id="user" promptText="User" GridPane.columnIndex="1" GridPane.rowIndex="1"/>
23+
<Label disable="${deployButton.disabled}" text="User" GridPane.columnIndex="0" GridPane.rowIndex="1"/>
24+
<TextField disable="${deployButton.disabled}" fx:id="user" promptText="User" GridPane.columnIndex="1"
25+
GridPane.rowIndex="1">
26+
<text>
27+
<DeployController fx:constant="DEFAULT_USER"/>
28+
</text>
29+
</TextField>
2330

24-
<Label disable="${password.disabled}" text="Password" GridPane.columnIndex="0" GridPane.rowIndex="2"/>
25-
<PasswordField fx:id="password" promptText="Password" GridPane.columnIndex="1" GridPane.rowIndex="2"/>
31+
<Label disable="${deployButton.disabled}" text="Password" GridPane.columnIndex="0" GridPane.rowIndex="2"/>
32+
<PasswordField disable="${deployButton.disabled}" fx:id="password" promptText="Password"
33+
GridPane.columnIndex="1" GridPane.rowIndex="2"/>
2634

27-
<Label disable="${javaHome.disabled}" text="Java Home" GridPane.columnIndex="0" GridPane.rowIndex="3"/>
28-
<TextField fx:id="javaHome" promptText="Java Home" GridPane.columnIndex="1" GridPane.rowIndex="3"/>
35+
<Label disable="${deployButton.disabled}" text="Java Home" GridPane.columnIndex="0" GridPane.rowIndex="3"/>
36+
<TextField disable="${deployButton.disabled}" fx:id="javaHome" promptText="Java Home"
37+
GridPane.columnIndex="1" GridPane.rowIndex="3">
38+
<text>
39+
<DeployController fx:constant="DEFAULT_JAVA_HOME"/>
40+
</text>
41+
</TextField>
2942

30-
<Label disable="${deployDir.disabled}" text="Deploy Directory" GridPane.columnIndex="0" GridPane.rowIndex="4"/>
31-
<TextField fx:id="deployDir" promptText="Deploy Directory" GridPane.columnIndex="1" GridPane.rowIndex="4"/>
43+
<Label disable="${deployButton.disabled}" text="Deploy Directory" GridPane.columnIndex="0"
44+
GridPane.rowIndex="4"/>
45+
<TextField disable="${deployButton.disabled}" fx:id="deployDir" promptText="Deploy Directory"
46+
GridPane.columnIndex="1" GridPane.rowIndex="4">
47+
<text>
48+
<DeployController fx:constant="DEFAULT_DIR"/>
49+
</text>
50+
</TextField>
3251
</GridPane>
3352

3453
<ButtonBar>

0 commit comments

Comments
 (0)