diff --git a/gse-app/src/main/resources/css/gse.css b/gse-app/src/main/resources/css/gse.css index e89e52da..e5b0f2b2 100644 --- a/gse-app/src/main/resources/css/gse.css +++ b/gse-app/src/main/resources/css/gse.css @@ -105,6 +105,16 @@ -fx-background-color: derive(-fx-mark-color, -30%); } +.filter-button { + -fx-background-color: transparent; + -fx-faint-focus-color: transparent; + -fx-background-color: transparent; +} + +.filter-button:selected { + -fx-background-color: #A3A3A4; +} + .tab-text-unsaved { -fx-text-base-color: #0000cd ; } diff --git a/gse-security-analysis/src/main/java/com/powsybl/gse/security/AbstractContingencyResultPane.java b/gse-security-analysis/src/main/java/com/powsybl/gse/security/AbstractContingencyResultPane.java new file mode 100644 index 00000000..87fecf77 --- /dev/null +++ b/gse-security-analysis/src/main/java/com/powsybl/gse/security/AbstractContingencyResultPane.java @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2018, RTE (http://www.rte-france.com) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package com.powsybl.gse.security; + +import javafx.scene.Group; +import javafx.scene.control.Label; +import javafx.scene.control.ScrollPane; +import javafx.scene.control.TableColumn; +import javafx.scene.control.ToggleButton; +import javafx.scene.layout.BorderPane; + +import java.util.ResourceBundle; + +/** + * @author Miora Ralambotiana + */ +abstract class AbstractContingencyResultPane extends BorderPane { + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle("lang.SecurityAnalysis"); + + private static void onMouseClickedOnFilter(BorderPane borderPane, LimitViolationsFilterPane filterPane) { + if (borderPane.getRight() != null) { + borderPane.setRight(null); + } else { + borderPane.setRight(new ScrollPane(filterPane)); + } + } + + static TableColumn createColumn(String type) { + TableColumn column = new TableColumn<>(RESOURCE_BUNDLE.getString(type)); + column.setUserData(type); + return column; + } + + static ToggleButton createFilterButton(BorderPane borderPane, LimitViolationsFilterPane filterPane) { + ToggleButton filterButton = new ToggleButton(); + Label label = new Label(RESOURCE_BUNDLE.getString("Filters")); + label.setRotate(90); + filterButton.setGraphic(new Group(label)); + filterButton.getStyleClass().add("filter-button"); + filterButton.setOnMouseClicked(event -> onMouseClickedOnFilter(borderPane, filterPane)); + return filterButton; + } + +} diff --git a/gse-security-analysis/src/main/java/com/powsybl/gse/security/PostContingencyResultPane.java b/gse-security-analysis/src/main/java/com/powsybl/gse/security/PostContingencyResultPane.java index e410a063..5bddcc33 100644 --- a/gse-security-analysis/src/main/java/com/powsybl/gse/security/PostContingencyResultPane.java +++ b/gse-security-analysis/src/main/java/com/powsybl/gse/security/PostContingencyResultPane.java @@ -13,19 +13,12 @@ import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.collections.transformation.FilteredList; -import javafx.geometry.Side; -import javafx.scene.control.ScrollPane; -import javafx.scene.control.SelectionMode; -import javafx.scene.control.TableColumn; -import javafx.scene.control.TableColumnBase; -import javafx.scene.control.TableView; +import javafx.scene.control.*; import javafx.scene.layout.BorderPane; -import org.controlsfx.control.HiddenSidesPane; import java.util.ArrayList; import java.util.List; import java.util.Objects; -import java.util.ResourceBundle; import java.util.function.Predicate; import java.util.prefs.Preferences; import java.util.stream.Collectors; @@ -34,9 +27,7 @@ /** * @author Geoffroy Jamgotchian */ -class PostContingencyResultPane extends BorderPane implements LimitViolationsResultPane { - - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle("lang.SecurityAnalysis"); +class PostContingencyResultPane extends AbstractContingencyResultPane implements LimitViolationsResultPane { class ResultRow { @@ -154,21 +145,15 @@ LimitViolation getViolation() { TableUtils.installCopyPasteHandler(tableView, true); filterPane = new LimitViolationsFilterPane(this); - HiddenSidesPane hiddenSidesPane = new HiddenSidesPane(); - hiddenSidesPane.setContent(tableView); - hiddenSidesPane.setRight(new ScrollPane(filterPane)); - // to prevent filter pane from disappear when clicking on a control - filterPane.setOnMouseEntered(e -> hiddenSidesPane.setPinnedSide(Side.LEFT)); - filterPane.setOnMouseExited(e -> hiddenSidesPane.setPinnedSide(null)); + BorderPane borderPane = new BorderPane(); + borderPane.setCenter(tableView); - setCenter(hiddenSidesPane); - } + setCenter(borderPane); + + ToggleButton filterButton = createFilterButton(borderPane, filterPane); + setRight(filterButton); - private static TableColumn createColumn(String type) { - TableColumn column = new TableColumn<>(RESOURCE_BUNDLE.getString(type)); - column.setUserData(type); - return column; } @Override diff --git a/gse-security-analysis/src/main/java/com/powsybl/gse/security/PreContingencyResultPane.java b/gse-security-analysis/src/main/java/com/powsybl/gse/security/PreContingencyResultPane.java index de72c4ac..8f2e4d58 100644 --- a/gse-security-analysis/src/main/java/com/powsybl/gse/security/PreContingencyResultPane.java +++ b/gse-security-analysis/src/main/java/com/powsybl/gse/security/PreContingencyResultPane.java @@ -13,26 +13,17 @@ import javafx.collections.ObservableList; import javafx.collections.transformation.FilteredList; import javafx.collections.transformation.SortedList; -import javafx.geometry.Side; -import javafx.scene.control.ScrollPane; -import javafx.scene.control.SelectionMode; -import javafx.scene.control.TableColumn; -import javafx.scene.control.TableColumnBase; -import javafx.scene.control.TableView; +import javafx.scene.control.*; import javafx.scene.layout.BorderPane; -import org.controlsfx.control.HiddenSidesPane; import java.util.Objects; -import java.util.ResourceBundle; import java.util.function.Predicate; import java.util.prefs.Preferences; /** * @author Geoffroy Jamgotchian */ -class PreContingencyResultPane extends BorderPane implements LimitViolationsResultPane { - - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle("lang.SecurityAnalysis"); +class PreContingencyResultPane extends AbstractContingencyResultPane implements LimitViolationsResultPane { private final ObservableList violations = FXCollections.observableArrayList(); @@ -92,21 +83,14 @@ class PreContingencyResultPane extends BorderPane implements LimitViolationsResu TableUtils.installCopyPasteHandler(tableView, true); filterPane = new LimitViolationsFilterPane(this); - HiddenSidesPane hiddenSidesPane = new HiddenSidesPane(); - hiddenSidesPane.setContent(tableView); - hiddenSidesPane.setRight(new ScrollPane(filterPane)); - // to prevent filter pane from disappear when clicking on a control - filterPane.setOnMouseEntered(e -> hiddenSidesPane.setPinnedSide(Side.LEFT)); - filterPane.setOnMouseExited(e -> hiddenSidesPane.setPinnedSide(null)); + BorderPane borderPane = new BorderPane(); + borderPane.setCenter(tableView); - setCenter(hiddenSidesPane); - } + setCenter(borderPane); - private static TableColumn createColumn(String type) { - TableColumn column = new TableColumn<>(RESOURCE_BUNDLE.getString(type)); - column.setUserData(type); - return column; + ToggleButton filterButton = createFilterButton(borderPane, filterPane); + setRight(filterButton); } @Override diff --git a/gse-security-analysis/src/main/resources/lang/SecurityAnalysis.properties b/gse-security-analysis/src/main/resources/lang/SecurityAnalysis.properties index 80720773..2d81b2ff 100644 --- a/gse-security-analysis/src/main/resources/lang/SecurityAnalysis.properties +++ b/gse-security-analysis/src/main/resources/lang/SecurityAnalysis.properties @@ -7,6 +7,7 @@ CreateSecurityAnalysis=Create security analysis DeselectAll=Deselect all EditSecurityAnalysis=Edit security analysis Equipment=Equipment +Filters=Filters Limit=Limit Load=Load (%) MandatoryName=Name is mandatory diff --git a/gse-security-analysis/src/main/resources/lang/SecurityAnalysis_fr.properties b/gse-security-analysis/src/main/resources/lang/SecurityAnalysis_fr.properties index d203f3b4..f51bc084 100644 --- a/gse-security-analysis/src/main/resources/lang/SecurityAnalysis_fr.properties +++ b/gse-security-analysis/src/main/resources/lang/SecurityAnalysis_fr.properties @@ -7,6 +7,7 @@ CreateSecurityAnalysis=Cr DeselectAll=Desélectionner tout EditSecurityAnalysis=Editer analyse de sécurité Equipment=Equipement +Filters=Filtres Limit=Limite Load=Charge (%) MandatoryName=Créer une analyse de sécurité