Skip to content

Commit 2771bb8

Browse files
authored
Use material design theme (#941)
1 parent 40cdbc1 commit 2771bb8

16 files changed

+1157
-46
lines changed

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

+8-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,11 @@ public void start(Stage stage) throws IOException {
145145

146146
stage.setTitle(MAIN_TITLE);
147147
stage.getIcons().add(new Image("/edu/wpi/grip/ui/icons/grip.png"));
148-
stage.setScene(new Scene(root));
148+
Scene scene = new Scene(root);
149+
root.getStylesheets().clear();
150+
scene.getStylesheets().clear();
151+
root.getStylesheets().setAll("/edu/wpi/grip/ui/GRIP.css");
152+
stage.setScene(scene);
149153
notifyPreloader(new Preloader.ProgressNotification(1.0));
150154
notifyPreloader(new Preloader.StateChangeNotification(
151155
Preloader.StateChangeNotification.Type.BEFORE_START));
@@ -167,6 +171,8 @@ public void start(Stage stage) throws IOException {
167171
} catch (GripServerException e) {
168172
logger.log(Level.SEVERE, "The HTTP server could not be started", e);
169173
Alert alert = new Alert(Alert.AlertType.CONFIRMATION, "", ButtonType.YES, ButtonType.NO);
174+
alert.initOwner(root.getScene().getWindow());
175+
alert.getDialogPane().getStylesheets().setAll(root.getStylesheets());
170176
alert.setTitle("The HTTP server could not be started");
171177
alert.setHeaderText("The HTTP server could not be started");
172178
alert.setContentText(
@@ -203,6 +209,7 @@ public final void onUnexpectedThrowableEvent(UnexpectedThrowableEvent event) {
203209
// Don't create more than one exception dialog at the same time
204210
final ExceptionAlert exceptionAlert = new ExceptionAlert(root, throwable,
205211
message, isFatal, getHostServices());
212+
exceptionAlert.initOwner(root.getScene().getWindow());
206213
exceptionAlert.setInitialFocus();
207214
exceptionAlert.showAndWait();
208215
} catch (Throwable e) {

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

+18-3
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ private boolean showConfirmationDialogAndWait() {
141141
dialog.setTitle("Save Project?");
142142
dialog.setHeaderText("Save the current project first?");
143143
dialog.getDialogPane().getButtonTypes().setAll(save, dontSave, cancel);
144+
dialog.initOwner(root.getScene().getWindow());
144145

145146
if (!dialog.showAndWait().isPresent()) { // NOPMD
146147
return false;
@@ -186,7 +187,11 @@ public void openProject() {
186187
new ExtensionFilter("GRIP File", "*.grip"),
187188
new ExtensionFilter("All Files", "*", "*.*"));
188189

189-
project.getFile().ifPresent(file -> fileChooser.setInitialDirectory(file.getParentFile()));
190+
if (project.getFile().isPresent()) {
191+
fileChooser.setInitialDirectory(project.getFile().get().getParentFile());
192+
} else {
193+
fileChooser.setInitialDirectory(new File(System.getProperty("user.home") + "/GRIP"));
194+
}
190195

191196
final File file = fileChooser.showOpenDialog(root.getScene().getWindow());
192197
if (file != null) {
@@ -250,6 +255,7 @@ protected void showProjectSettingsEditor() {
250255

251256
ProjectSettingsEditor projectSettingsEditor
252257
= new ProjectSettingsEditor(root, projectSettings, appSettings);
258+
projectSettingsEditor.initOwner(root.getScene().getWindow());
253259
projectSettingsEditor.showAndWait().ifPresent(buttonType -> {
254260
if (buttonType == ButtonType.OK) {
255261
eventBus.post(new ProjectSettingsChangedEvent(projectSettings));
@@ -262,8 +268,11 @@ protected void showProjectSettingsEditor() {
262268
protected void showProjectAboutDialog() throws IOException {
263269
if (aboutDialogStage == null) {
264270
aboutDialogStage = new Stage();
265-
aboutDialogStage.setScene(new Scene(aboutPane));
266-
aboutDialogStage.initStyle(StageStyle.UTILITY);
271+
Scene scene = new Scene(aboutPane);
272+
scene.getStylesheets().setAll(root.getStylesheets());
273+
aboutDialogStage.setScene(scene);
274+
aboutDialogStage.initStyle(StageStyle.UNDECORATED);
275+
aboutDialogStage.initOwner(root.getScene().getWindow());
267276
aboutDialogStage.focusedProperty().addListener((observable, oldvalue, newvalue) -> {
268277
if (oldvalue) {
269278
aboutDialogStage.hide();
@@ -323,6 +332,8 @@ protected void generate() {
323332
return;
324333
}
325334
Dialog<CodeGenerationSettings> optionsDialog = new CodeGenerationSettingsDialog(codegenPane);
335+
optionsDialog.getDialogPane().getStylesheets().setAll(root.getStylesheets());
336+
optionsDialog.initOwner(root.getScene().getWindow());
326337
optionsDialog.showAndWait().ifPresent(settings -> {
327338
eventBus.post(new CodeGenerationSettingsChangedEvent(settings));
328339
Exporter exporter = new Exporter(pipeline.getSteps(), settings);
@@ -361,6 +372,7 @@ protected void deploy() {
361372
Dialog<ButtonType> dialog = new Dialog<>();
362373
dialog.setTitle("Deploy");
363374
dialog.setHeaderText("Deploy");
375+
dialog.initOwner(root.getScene().getWindow());
364376
dialog.setGraphic(graphic);
365377
dialog.getDialogPane().getButtonTypes().setAll(ButtonType.CLOSE);
366378
dialog.getDialogPane().styleProperty().bind(root.styleProperty());
@@ -381,6 +393,8 @@ public void onWarningEvent(WarningEvent e) {
381393

382394
private void showWarningAlert(WarningEvent e) {
383395
Alert alert = new WarningAlert(e.getHeader(), e.getBody(), root.getScene().getWindow());
396+
alert.getDialogPane().getStylesheets().setAll(root.getStylesheets());
397+
alert.initOwner(root.getScene().getWindow());
384398
alert.showAndWait();
385399
}
386400

@@ -405,6 +419,7 @@ private void showAnalysis() {
405419
if (analysisStage == null) {
406420
analysisStage = new Stage();
407421
analysisStage.setScene(new Scene(analysisPane));
422+
analysisPane.getStylesheets().setAll(root.getStylesheets());
408423
analysisStage.initOwner(root.getScene().getWindow());
409424
analysisStage.setTitle("Pipeline Analysis");
410425
analysisStage.getIcons().add(new Image("/edu/wpi/grip/ui/icons/grip.png"));

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

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.controlsfx.property.BeanPropertyUtils;
99

1010
import javafx.collections.ObservableList;
11+
import javafx.geometry.Insets;
1112
import javafx.scene.Parent;
1213
import javafx.scene.control.ButtonType;
1314
import javafx.scene.control.Dialog;
@@ -43,6 +44,7 @@ public ProjectSettingsEditor(Parent root,
4344
new CustomPropertySheet(BeanPropertyUtils.getProperties(appSettings))
4445
);
4546
content.setSpacing(5.0);
47+
content.setPadding(Insets.EMPTY);
4648

4749
DialogPane pane = getDialogPane();
4850
pane.getButtonTypes().setAll(ButtonType.OK, ButtonType.CANCEL);

ui/src/main/java/edu/wpi/grip/ui/analysis/AnalysisController.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,20 @@
4242
import javafx.scene.control.TextArea;
4343
import javafx.scene.control.TextField;
4444
import javafx.scene.layout.HBox;
45+
import javafx.scene.layout.Pane;
4546
import javafx.util.Callback;
4647

4748
import javax.annotation.Nullable;
4849

4950
/**
5051
* Controller for the analysis view.
5152
*/
53+
@SuppressWarnings("PMD.TooManyFields")
5254
public class AnalysisController {
5355

56+
@FXML
57+
private Pane root;
58+
5459
// Table
5560
@FXML
5661
private TableView<StepStatisticsEntry> table;
@@ -191,6 +196,8 @@ private void exportCsv() {
191196
// Show benchmarking results
192197
Platform.runLater(() -> {
193198
Alert a = new Alert(Alert.AlertType.INFORMATION);
199+
a.initOwner(root.getScene().getWindow());
200+
a.getDialogPane().getStylesheets().setAll(root.getStylesheets());
194201
a.setHeaderText("Benchmarking results");
195202
TextArea resultArea = new TextArea(csvReport);
196203
a.getDialogPane().setContent(resultArea);
@@ -204,7 +211,6 @@ private void exportCsv() {
204211
*
205212
* @param m the map to stream
206213
* @param <E> the type of the values in the map
207-
*
208214
* @return a stream of the entries in the map, sorted by their key's index.
209215
*/
210216
private <E> Stream<Map.Entry<Step, E>> sortedStream(Map<Step, E> m) {

ui/src/main/java/edu/wpi/grip/ui/pipeline/AddSourceButton.java

+4
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ public class AddSourceButton extends MenuButton {
8484
super("Add Source");
8585
this.eventBus = eventBus;
8686

87+
getStyleClass().add("add-source-button");
88+
8789
addMenuItem("Image(s)",
8890
getClass().getResource("/edu/wpi/grip/ui/icons/add-image.png"), mouseEvent -> {
8991
// Show a file picker so the user can open one or more images from disk
@@ -392,6 +394,8 @@ private class SourceDialog extends Dialog<ButtonType> {
392394
private SourceDialog(final Parent root, Node customField) {
393395
super();
394396

397+
initOwner(root.getScene().getWindow());
398+
395399
setOnShowing(event -> activeDialog = Optional.of(this));
396400
setOnHidden(event -> activeDialog = Optional.empty());
397401

ui/src/main/java/edu/wpi/grip/ui/util/DPIUtility.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class DPIUtility {
1717
public static final double SMALL_ICON_SIZE = 16.0 * (isManualHiDPI() ? HIDPI_SCALE : 1.0);
1818
public static final double LARGE_ICON_SIZE = 48.0 * (isManualHiDPI() ? HIDPI_SCALE : 1.0);
1919
public static final double STROKE_WIDTH = 2.0 * (isManualHiDPI() ? HIDPI_SCALE : 1.0);
20-
public static final double SETTINGS_DIALOG_SIZE = 400.0 * (isManualHiDPI() ? HIDPI_SCALE : 1.0);
20+
public static final double SETTINGS_DIALOG_SIZE = 425.0 * (isManualHiDPI() ? HIDPI_SCALE : 1.0);
2121

2222
private static boolean isManualHiDPI() {
2323
// We need to do manual size adjustments for HiDPI on Linux. JavaFX automatically does this

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

+1-10
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<?import javafx.scene.layout.StackPane?>
1111
<?import javafx.scene.layout.VBox?>
1212
<?import javafx.scene.text.Font?>
13-
<VBox fx:id="root" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="330.0" prefWidth="600.0" styleClass="about-window" stylesheets="@GRIP.css" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="edu.wpi.grip.ui.AboutDialogController">
13+
<VBox fx:id="root" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="330.0" prefWidth="600.0" styleClass="about-window" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="edu.wpi.grip.ui.AboutDialogController">
1414
<children>
1515
<Pane VBox.vgrow="ALWAYS" />
1616
<HBox>
@@ -43,9 +43,6 @@
4343
<HBox.margin>
4444
<Insets left="-3.0" />
4545
</HBox.margin>
46-
<padding>
47-
<Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
48-
</padding>
4946
</StackPane>
5047
</children>
5148
</HBox>
@@ -59,9 +56,6 @@
5956
<HBox.margin>
6057
<Insets left="-3.0" />
6158
</HBox.margin>
62-
<padding>
63-
<Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
64-
</padding>
6559
</StackPane>
6660
</children>
6761
</HBox>
@@ -86,7 +80,4 @@
8680
</padding>
8781
</HBox>
8882
</children>
89-
<stylesheets>
90-
<URL value="@GRIP.css" />
91-
</stylesheets>
9283
</VBox>

0 commit comments

Comments
 (0)