Skip to content

Commit

Permalink
Use material design theme (#941)
Browse files Browse the repository at this point in the history
  • Loading branch information
SamCarlberg authored Aug 17, 2020
1 parent 40cdbc1 commit 2771bb8
Show file tree
Hide file tree
Showing 16 changed files with 1,157 additions and 46 deletions.
9 changes: 8 additions & 1 deletion ui/src/main/java/edu/wpi/grip/ui/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,11 @@ public void start(Stage stage) throws IOException {

stage.setTitle(MAIN_TITLE);
stage.getIcons().add(new Image("/edu/wpi/grip/ui/icons/grip.png"));
stage.setScene(new Scene(root));
Scene scene = new Scene(root);
root.getStylesheets().clear();
scene.getStylesheets().clear();
root.getStylesheets().setAll("/edu/wpi/grip/ui/GRIP.css");
stage.setScene(scene);
notifyPreloader(new Preloader.ProgressNotification(1.0));
notifyPreloader(new Preloader.StateChangeNotification(
Preloader.StateChangeNotification.Type.BEFORE_START));
Expand All @@ -167,6 +171,8 @@ public void start(Stage stage) throws IOException {
} catch (GripServerException e) {
logger.log(Level.SEVERE, "The HTTP server could not be started", e);
Alert alert = new Alert(Alert.AlertType.CONFIRMATION, "", ButtonType.YES, ButtonType.NO);
alert.initOwner(root.getScene().getWindow());
alert.getDialogPane().getStylesheets().setAll(root.getStylesheets());
alert.setTitle("The HTTP server could not be started");
alert.setHeaderText("The HTTP server could not be started");
alert.setContentText(
Expand Down Expand Up @@ -203,6 +209,7 @@ public final void onUnexpectedThrowableEvent(UnexpectedThrowableEvent event) {
// Don't create more than one exception dialog at the same time
final ExceptionAlert exceptionAlert = new ExceptionAlert(root, throwable,
message, isFatal, getHostServices());
exceptionAlert.initOwner(root.getScene().getWindow());
exceptionAlert.setInitialFocus();
exceptionAlert.showAndWait();
} catch (Throwable e) {
Expand Down
21 changes: 18 additions & 3 deletions ui/src/main/java/edu/wpi/grip/ui/MainWindowController.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ private boolean showConfirmationDialogAndWait() {
dialog.setTitle("Save Project?");
dialog.setHeaderText("Save the current project first?");
dialog.getDialogPane().getButtonTypes().setAll(save, dontSave, cancel);
dialog.initOwner(root.getScene().getWindow());

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

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

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

ProjectSettingsEditor projectSettingsEditor
= new ProjectSettingsEditor(root, projectSettings, appSettings);
projectSettingsEditor.initOwner(root.getScene().getWindow());
projectSettingsEditor.showAndWait().ifPresent(buttonType -> {
if (buttonType == ButtonType.OK) {
eventBus.post(new ProjectSettingsChangedEvent(projectSettings));
Expand All @@ -262,8 +268,11 @@ protected void showProjectSettingsEditor() {
protected void showProjectAboutDialog() throws IOException {
if (aboutDialogStage == null) {
aboutDialogStage = new Stage();
aboutDialogStage.setScene(new Scene(aboutPane));
aboutDialogStage.initStyle(StageStyle.UTILITY);
Scene scene = new Scene(aboutPane);
scene.getStylesheets().setAll(root.getStylesheets());
aboutDialogStage.setScene(scene);
aboutDialogStage.initStyle(StageStyle.UNDECORATED);
aboutDialogStage.initOwner(root.getScene().getWindow());
aboutDialogStage.focusedProperty().addListener((observable, oldvalue, newvalue) -> {
if (oldvalue) {
aboutDialogStage.hide();
Expand Down Expand Up @@ -323,6 +332,8 @@ protected void generate() {
return;
}
Dialog<CodeGenerationSettings> optionsDialog = new CodeGenerationSettingsDialog(codegenPane);
optionsDialog.getDialogPane().getStylesheets().setAll(root.getStylesheets());
optionsDialog.initOwner(root.getScene().getWindow());
optionsDialog.showAndWait().ifPresent(settings -> {
eventBus.post(new CodeGenerationSettingsChangedEvent(settings));
Exporter exporter = new Exporter(pipeline.getSteps(), settings);
Expand Down Expand Up @@ -361,6 +372,7 @@ protected void deploy() {
Dialog<ButtonType> dialog = new Dialog<>();
dialog.setTitle("Deploy");
dialog.setHeaderText("Deploy");
dialog.initOwner(root.getScene().getWindow());
dialog.setGraphic(graphic);
dialog.getDialogPane().getButtonTypes().setAll(ButtonType.CLOSE);
dialog.getDialogPane().styleProperty().bind(root.styleProperty());
Expand All @@ -381,6 +393,8 @@ public void onWarningEvent(WarningEvent e) {

private void showWarningAlert(WarningEvent e) {
Alert alert = new WarningAlert(e.getHeader(), e.getBody(), root.getScene().getWindow());
alert.getDialogPane().getStylesheets().setAll(root.getStylesheets());
alert.initOwner(root.getScene().getWindow());
alert.showAndWait();
}

Expand All @@ -405,6 +419,7 @@ private void showAnalysis() {
if (analysisStage == null) {
analysisStage = new Stage();
analysisStage.setScene(new Scene(analysisPane));
analysisPane.getStylesheets().setAll(root.getStylesheets());
analysisStage.initOwner(root.getScene().getWindow());
analysisStage.setTitle("Pipeline Analysis");
analysisStage.getIcons().add(new Image("/edu/wpi/grip/ui/icons/grip.png"));
Expand Down
2 changes: 2 additions & 0 deletions ui/src/main/java/edu/wpi/grip/ui/ProjectSettingsEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.controlsfx.property.BeanPropertyUtils;

import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.scene.Parent;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Dialog;
Expand Down Expand Up @@ -43,6 +44,7 @@ public ProjectSettingsEditor(Parent root,
new CustomPropertySheet(BeanPropertyUtils.getProperties(appSettings))
);
content.setSpacing(5.0);
content.setPadding(Insets.EMPTY);

DialogPane pane = getDialogPane();
pane.getButtonTypes().setAll(ButtonType.OK, ButtonType.CANCEL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,20 @@
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.util.Callback;

import javax.annotation.Nullable;

/**
* Controller for the analysis view.
*/
@SuppressWarnings("PMD.TooManyFields")
public class AnalysisController {

@FXML
private Pane root;

// Table
@FXML
private TableView<StepStatisticsEntry> table;
Expand Down Expand Up @@ -191,6 +196,8 @@ private void exportCsv() {
// Show benchmarking results
Platform.runLater(() -> {
Alert a = new Alert(Alert.AlertType.INFORMATION);
a.initOwner(root.getScene().getWindow());
a.getDialogPane().getStylesheets().setAll(root.getStylesheets());
a.setHeaderText("Benchmarking results");
TextArea resultArea = new TextArea(csvReport);
a.getDialogPane().setContent(resultArea);
Expand All @@ -204,7 +211,6 @@ private void exportCsv() {
*
* @param m the map to stream
* @param <E> the type of the values in the map
*
* @return a stream of the entries in the map, sorted by their key's index.
*/
private <E> Stream<Map.Entry<Step, E>> sortedStream(Map<Step, E> m) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ public class AddSourceButton extends MenuButton {
super("Add Source");
this.eventBus = eventBus;

getStyleClass().add("add-source-button");

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

initOwner(root.getScene().getWindow());

setOnShowing(event -> activeDialog = Optional.of(this));
setOnHidden(event -> activeDialog = Optional.empty());

Expand Down
2 changes: 1 addition & 1 deletion ui/src/main/java/edu/wpi/grip/ui/util/DPIUtility.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class DPIUtility {
public static final double SMALL_ICON_SIZE = 16.0 * (isManualHiDPI() ? HIDPI_SCALE : 1.0);
public static final double LARGE_ICON_SIZE = 48.0 * (isManualHiDPI() ? HIDPI_SCALE : 1.0);
public static final double STROKE_WIDTH = 2.0 * (isManualHiDPI() ? HIDPI_SCALE : 1.0);
public static final double SETTINGS_DIALOG_SIZE = 400.0 * (isManualHiDPI() ? HIDPI_SCALE : 1.0);
public static final double SETTINGS_DIALOG_SIZE = 425.0 * (isManualHiDPI() ? HIDPI_SCALE : 1.0);

private static boolean isManualHiDPI() {
// We need to do manual size adjustments for HiDPI on Linux. JavaFX automatically does this
Expand Down
11 changes: 1 addition & 10 deletions ui/src/main/resources/edu/wpi/grip/ui/AboutDialog.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>
<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">
<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">
<children>
<Pane VBox.vgrow="ALWAYS" />
<HBox>
Expand Down Expand Up @@ -43,9 +43,6 @@
<HBox.margin>
<Insets left="-3.0" />
</HBox.margin>
<padding>
<Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
</padding>
</StackPane>
</children>
</HBox>
Expand All @@ -59,9 +56,6 @@
<HBox.margin>
<Insets left="-3.0" />
</HBox.margin>
<padding>
<Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
</padding>
</StackPane>
</children>
</HBox>
Expand All @@ -86,7 +80,4 @@
</padding>
</HBox>
</children>
<stylesheets>
<URL value="@GRIP.css" />
</stylesheets>
</VBox>
Loading

0 comments on commit 2771bb8

Please sign in to comment.