From ee9a7195978ca9274260f513235ea59e4889905b Mon Sep 17 00:00:00 2001 From: berthaultval Date: Thu, 27 Feb 2020 16:17:35 +0100 Subject: [PATCH 1/4] Dark Mode Signed-off-by: berthaultval --- .../java/com/powsybl/gse/app/GseAppBar.java | 14 +++- .../java/com/powsybl/gse/app/GsePane.java | 9 ++- .../src/main/resources/css/gse-dark-theme.css | 70 +++++++++++++++++++ .../main/resources/lang/GseAppBar.properties | 1 + .../resources/lang/GseAppBar_fr.properties | 5 +- 5 files changed, 95 insertions(+), 4 deletions(-) create mode 100644 gse-app/src/main/resources/css/gse-dark-theme.css diff --git a/gse-app/src/main/java/com/powsybl/gse/app/GseAppBar.java b/gse-app/src/main/java/com/powsybl/gse/app/GseAppBar.java index ba843132..5804bcb1 100644 --- a/gse-app/src/main/java/com/powsybl/gse/app/GseAppBar.java +++ b/gse-app/src/main/java/com/powsybl/gse/app/GseAppBar.java @@ -14,11 +14,13 @@ import javafx.geometry.Pos; import javafx.scene.Node; import javafx.scene.control.Button; +import javafx.scene.control.Tooltip; import javafx.scene.layout.HBox; import javafx.scene.layout.Pane; import javafx.scene.layout.Priority; import javafx.scene.layout.Region; import javafx.scene.text.Text; +import org.controlsfx.control.ToggleSwitch; import java.util.ResourceBundle; @@ -35,6 +37,8 @@ public class GseAppBar extends HBox { private final Button helpButton; + private final ToggleSwitch styleSwitch; + private UserSessionPane userSessionPane; public GseAppBar(GseContext context, BrandingConfig brandingConfig) { @@ -49,6 +53,10 @@ public GseAppBar(GseContext context, BrandingConfig brandingConfig) { createButton.getStyleClass().add("gse-app-bar-text"); openButton = createButton(RESOURCE_BUNDLE.getString("Open"), null); openButton.getStyleClass().add("gse-app-bar-text"); + styleSwitch = new ToggleSwitch(); + Tooltip tooltipStyleSwitch = new Tooltip(RESOURCE_BUNDLE.getString("StyleModeDark")); + styleSwitch.setTooltip(tooltipStyleSwitch); + styleSwitch.getStyleClass().add("gse-app-bar-text"); Text questionGlyph = Glyph.createAwesomeFont('\uf059'); questionGlyph.getStyleClass().add("gse-app-bar-icon"); @@ -58,7 +66,7 @@ public GseAppBar(GseContext context, BrandingConfig brandingConfig) { Pane gluePanel = new Pane(); setHgrow(gluePanel, Priority.ALWAYS); - getChildren().addAll(logo, createButton, openButton, gluePanel); + getChildren().addAll(logo, createButton, openButton, gluePanel, styleSwitch); GseAuthenticator.find().ifPresent(authenticator -> { userSessionPane = new UserSessionPane(context, authenticator); getChildren().add(userSessionPane); @@ -80,6 +88,10 @@ public Button getOpenButton() { return openButton; } + public ToggleSwitch getToggleSwitch() { + return styleSwitch; + } + public Button getHelpButton() { return helpButton; } diff --git a/gse-app/src/main/java/com/powsybl/gse/app/GsePane.java b/gse-app/src/main/java/com/powsybl/gse/app/GsePane.java index 5d8ee7d9..04aafc2f 100644 --- a/gse-app/src/main/java/com/powsybl/gse/app/GsePane.java +++ b/gse-app/src/main/java/com/powsybl/gse/app/GsePane.java @@ -332,12 +332,19 @@ private GseAppBar createAppBar() { contextMenu.getItems().add(documentationMenuItem); }); - MenuItem aboutMenuItem = new MenuItem(RESOURCE_BUNDLE.getString("About") + "..."); + MenuItem aboutMenuItem = new MenuItem(RESOURCE_BUNDLE.getString("About")); aboutMenuItem.setOnAction(event -> showAbout()); MenuItem shortcutMenuItem = new MenuItem(RESOURCE_BUNDLE.getString("Shortcuts") + "..."); shortcutMenuItem.setOnAction(event -> showShortcuts()); contextMenu.getItems().addAll(aboutMenuItem, shortcutMenuItem); + appBar.getToggleSwitch().selectedProperty().addListener((observable, oldValue, newValue) -> { + if (newValue) { + this.getScene().getStylesheets().add("/css/gse-dark-theme.css"); + } else { + this.getScene().getStylesheets().remove("/css/gse-dark-theme.css"); + } + }); appBar.getHelpButton().setOnAction(event -> contextMenu.show(appBar.getHelpButton(), Side.BOTTOM, 0, 0)); return appBar; diff --git a/gse-app/src/main/resources/css/gse-dark-theme.css b/gse-app/src/main/resources/css/gse-dark-theme.css new file mode 100644 index 00000000..e5dfafe6 --- /dev/null +++ b/gse-app/src/main/resources/css/gse-dark-theme.css @@ -0,0 +1,70 @@ +.root { + -fx-accent: #1e74c6; + -fx-focus-color: -fx-accent; + -fx-base: #373e43; + -fx-control-inner-background: derive(-fx-base, 35%); + -fx-control-inner-background-alt: -fx-control-inner-background ; + -gse-app-bar-background-color: #3C3C3C; +} + +.label{ + -fx-text-fill: white; +} + +.text-field { + -fx-prompt-text-fill: white; +} + +.titulo{ + -fx-font-weight: bold; + -fx-font-size: 18px; +} + +.button{ + -fx-focus-traversable: false; +} + +.button:hover{ + -fx-text-fill: white; +} + +.separator *.line { + -fx-background-color: #3C3C3C; + -fx-border-style: solid; + -fx-border-width: 1px; +} + +.scroll-bar{ + -fx-background-color: derive(-fx-base,45%) +} + +.button:default { + -fx-base: -fx-accent ; +} + +.table-view{ + -fx-selection-bar-non-focused: derive(-fx-base, 50%); +} + +.table-view .column-header .label{ + -fx-alignment: CENTER_LEFT; + -fx-font-weight: none; +} + +.list-cell:even, +.list-cell:odd, +.table-row-cell:even, +.table-row-cell:odd{ + -fx-control-inner-background: derive(-fx-base, 15%); +} + +.list-cell:empty, +.table-row-cell:empty { + -fx-background-color: transparent; +} + +.list-cell, +.table-row-cell{ + -fx-border-color: transparent; + -fx-table-cell-border-color:transparent; +} diff --git a/gse-app/src/main/resources/lang/GseAppBar.properties b/gse-app/src/main/resources/lang/GseAppBar.properties index b9de88b0..df900894 100644 --- a/gse-app/src/main/resources/lang/GseAppBar.properties +++ b/gse-app/src/main/resources/lang/GseAppBar.properties @@ -1,3 +1,4 @@ Create=Create Open=Open SignOut=Sign out +StyleModeDark=Dark Mode \ No newline at end of file diff --git a/gse-app/src/main/resources/lang/GseAppBar_fr.properties b/gse-app/src/main/resources/lang/GseAppBar_fr.properties index c0269965..49a38960 100644 --- a/gse-app/src/main/resources/lang/GseAppBar_fr.properties +++ b/gse-app/src/main/resources/lang/GseAppBar_fr.properties @@ -1,3 +1,4 @@ -Create=Créer +Create=Cr\u00E9er Open=Ouvrir -SignOut=Déconnexion +SignOut=D\u00E9connexion +StyleModeDark=Mode Sombre From cd00096eb3dfe20d8b5d65f18902b3dfaeee7700 Mon Sep 17 00:00:00 2001 From: berthaultval Date: Thu, 27 Feb 2020 17:05:19 +0100 Subject: [PATCH 2/4] Checkstyle correction Signed-off-by: berthaultval --- gse-app/src/main/resources/lang/GseAppBar.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gse-app/src/main/resources/lang/GseAppBar.properties b/gse-app/src/main/resources/lang/GseAppBar.properties index df900894..c52fa4c9 100644 --- a/gse-app/src/main/resources/lang/GseAppBar.properties +++ b/gse-app/src/main/resources/lang/GseAppBar.properties @@ -1,4 +1,4 @@ Create=Create Open=Open SignOut=Sign out -StyleModeDark=Dark Mode \ No newline at end of file +StyleModeDark=Dark Mode From 8b8c7b6d316c07cc674a8417df55b4a6680d1daf Mon Sep 17 00:00:00 2001 From: berthaultval Date: Thu, 5 Mar 2020 14:50:42 +0100 Subject: [PATCH 3/4] add Preferences Pane Signed-off-by: berthaultval --- .../java/com/powsybl/gse/app/GseAppBar.java | 14 +--- .../java/com/powsybl/gse/app/GsePane.java | 22 +++--- .../main/resources/lang/GsePane.properties | 4 +- .../main/resources/lang/GsePane_fr.properties | 14 ++-- gse-spi/pom.xml | 4 + .../gse/spi/DefaultPreferencesPane.java | 73 +++++++++++++++++++ 6 files changed, 98 insertions(+), 33 deletions(-) create mode 100644 gse-spi/src/main/java/com/powsybl/gse/spi/DefaultPreferencesPane.java diff --git a/gse-app/src/main/java/com/powsybl/gse/app/GseAppBar.java b/gse-app/src/main/java/com/powsybl/gse/app/GseAppBar.java index d0c922ad..7939807b 100644 --- a/gse-app/src/main/java/com/powsybl/gse/app/GseAppBar.java +++ b/gse-app/src/main/java/com/powsybl/gse/app/GseAppBar.java @@ -16,13 +16,11 @@ import javafx.geometry.Pos; import javafx.scene.Node; import javafx.scene.control.Button; -import javafx.scene.control.Tooltip; import javafx.scene.layout.HBox; import javafx.scene.layout.Pane; import javafx.scene.layout.Priority; import javafx.scene.layout.Region; import javafx.scene.text.Text; -import org.controlsfx.control.ToggleSwitch; import java.util.List; import java.util.ResourceBundle; @@ -41,8 +39,6 @@ public class GseAppBar extends HBox { private final Button helpButton; - private final ToggleSwitch styleSwitch; - private UserSessionPane userSessionPane; public GseAppBar(GseContext context, BrandingConfig brandingConfig) { @@ -61,10 +57,6 @@ public GseAppBar(GseContext context, BrandingConfig brandingConfig, List