mirror of
https://github.com/klmp200/PQT_Gestionnaire_vente_stock.git
synced 2024-12-22 15:31:08 +00:00
Module Client : utilisation des pseudo classes pour les variations de style css des cellules de tableview et de listview
This commit is contained in:
parent
312a5ce293
commit
41c59d31fe
@ -13,6 +13,7 @@ import javafx.beans.property.SimpleDoubleProperty;
|
||||
import javafx.beans.property.SimpleIntegerProperty;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.css.PseudoClass;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.input.KeyCode;
|
||||
@ -68,10 +69,24 @@ class StockScreenView implements IFXComponent {
|
||||
HBox.setHgrow(separator, Priority.ALWAYS);
|
||||
mainPaneContent.setTop(mainPaneTopContent);
|
||||
|
||||
PseudoClass outOfStockPseudoClass = PseudoClass.getPseudoClass("stock-out");
|
||||
PseudoClass lowStockPseudoClass = PseudoClass.getPseudoClass("stock-low");
|
||||
PseudoClass highStockPseudoClass = PseudoClass.getPseudoClass("stock-high");
|
||||
stockTableView = new TableView<>();
|
||||
stockTableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
|
||||
stockTableView.setRowFactory(tableView->{
|
||||
TableRow<Product> row = new TableRow<>();
|
||||
row.itemProperty().addListener((obs, oldVal, newVal)->{
|
||||
if(newVal!=null){
|
||||
row.pseudoClassStateChanged(outOfStockPseudoClass, newVal.getAmountRemaining()<=0);
|
||||
row.pseudoClassStateChanged(lowStockPseudoClass, newVal.getAmountRemaining()>0 && newVal.getAmountRemaining()<30);
|
||||
row.pseudoClassStateChanged(highStockPseudoClass, newVal.getAmountRemaining()>=30);
|
||||
}else{
|
||||
row.pseudoClassStateChanged(outOfStockPseudoClass, false);
|
||||
row.pseudoClassStateChanged(lowStockPseudoClass, false);
|
||||
row.pseudoClassStateChanged(highStockPseudoClass, false);
|
||||
}
|
||||
});
|
||||
row.setOnMouseClicked(event -> {
|
||||
if (event.getButton().equals(MouseButton.PRIMARY) && event.getClickCount() == 2)
|
||||
ctrl.getProductActivationListener().onProductActivated(row.getItem());
|
||||
|
@ -1,18 +1,25 @@
|
||||
package com.pqt.client.gui.ressources.components.generics.javafx_override;
|
||||
|
||||
import javafx.css.PseudoClass;
|
||||
import javafx.scene.control.ListCell;
|
||||
|
||||
public class HighlightListCell<T> extends ListCell<T> {
|
||||
|
||||
private PseudoClass highlightPC;
|
||||
private boolean highlighted;
|
||||
|
||||
public HighlightListCell() {
|
||||
super();
|
||||
highlighted = false;
|
||||
highlightPC = PseudoClass.getPseudoClass("highlighted");
|
||||
}
|
||||
|
||||
public void setHighLight(boolean highLight){
|
||||
if(highLight){
|
||||
if(!getStyleClass().contains("list-cell-highlighted"))
|
||||
getStyleClass().add("list-cell-highlighted");
|
||||
}
|
||||
else
|
||||
getStyleClass().remove("list-cell-highlighted");
|
||||
highlighted = highLight;
|
||||
this.pseudoClassStateChanged(highlightPC, highLight);
|
||||
}
|
||||
|
||||
public boolean isHightlighted(){
|
||||
return getStyleClass().contains("list-cell-highlighted");
|
||||
return highlighted;
|
||||
}
|
||||
}
|
||||
|
@ -51,6 +51,7 @@
|
||||
.list-view {
|
||||
-fx-base: #1d1d1d;
|
||||
-fx-control-inner-background: #1d1d1d;
|
||||
-fx-control-inner-background-alt: #333333;
|
||||
-fx-background-color: #1d1d1d;
|
||||
-fx-table-cell-border-color: transparent;
|
||||
-fx-table-header-border-color: transparent;
|
||||
@ -71,8 +72,10 @@
|
||||
.list-view:focused .list-cell:filled:focused:selected {
|
||||
-fx-background-color: -fx-focus-color;
|
||||
}
|
||||
.list-cell-highlighted{
|
||||
-fx-background-color: #4d4d4d;
|
||||
.list-cell:highlighted{
|
||||
-fx-text-fill: #cc7a00;
|
||||
-fx-border-width: 1px;
|
||||
-fx-border-color: white;
|
||||
}
|
||||
|
||||
.table-view {
|
||||
@ -108,6 +111,26 @@
|
||||
-fx-opacity: 1;
|
||||
}
|
||||
|
||||
.table-view .table-row-cell {
|
||||
-fx-control-inner-background: #1d1d1d;
|
||||
-fx-control-inner-background-alt: #333333;
|
||||
}
|
||||
|
||||
.table-view .table-row-cell:stock-out {
|
||||
-fx-control-inner-background: #4d0000;
|
||||
-fx-control-inner-background-alt: #4d0000;
|
||||
}
|
||||
|
||||
.table-view .table-row-cell:stock-low {
|
||||
-fx-control-inner-background: #4d2e00;
|
||||
-fx-control-inner-background-alt: #4d2e00;
|
||||
}
|
||||
|
||||
.table-view .table-row-cell:stock-high {
|
||||
-fx-control-inner-background: #1a3300;
|
||||
-fx-control-inner-background-alt: #1a3300;
|
||||
}
|
||||
|
||||
.table-view:focused .table-row-cell:filled:focused:selected {
|
||||
-fx-background-color: -fx-focus-color;
|
||||
}
|
||||
@ -247,7 +270,7 @@
|
||||
.validator .button{
|
||||
-fx-pref-width: 150;
|
||||
-fx-pref-height: 50;
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
-fx-background-color: #2e2e2e;
|
||||
|
Loading…
Reference in New Issue
Block a user