Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.

Button "filter" to display/pin filter in security analysis result viewer #99

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions gse-app/src/main/resources/css/gse.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 ;
}
Original file line number Diff line number Diff line change
@@ -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 <miora.ralambotiana at rte-france.com>
*/
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 <S, T> TableColumn<S, T> createColumn(String type) {
TableColumn<S, T> 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;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -34,9 +27,7 @@
/**
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
class PostContingencyResultPane extends BorderPane implements LimitViolationsResultPane {

private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle("lang.SecurityAnalysis");
class PostContingencyResultPane extends AbstractContingencyResultPane implements LimitViolationsResultPane {

class ResultRow {

Expand Down Expand Up @@ -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 <S, T> TableColumn<S, T> createColumn(String type) {
TableColumn<S, T> column = new TableColumn<>(RESOURCE_BUNDLE.getString(type));
column.setUserData(type);
return column;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <geoffroy.jamgotchian at rte-france.com>
*/
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<LimitViolation> violations = FXCollections.observableArrayList();

Expand Down Expand Up @@ -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 <S, T> TableColumn<S, T> createColumn(String type) {
TableColumn<S, T> column = new TableColumn<>(RESOURCE_BUNDLE.getString(type));
column.setUserData(type);
return column;
ToggleButton filterButton = createFilterButton(borderPane, filterPane);
setRight(filterButton);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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�
Expand Down