From c31fa88d6819753d6d2340aa19347554dd661f1f Mon Sep 17 00:00:00 2001 From: imuny <92868641+imuny0@users.noreply.github.com> Date: Tue, 7 Jun 2022 17:09:05 +0200 Subject: [PATCH 1/2] il y a un bug le hover reste sur les button deja selectionne --- .../java/fr/univ_amu/iut/fp/Controller.java | 119 ++++++++++-------- src/main/resources/META-INF/persistence.xml | 2 +- 2 files changed, 69 insertions(+), 52 deletions(-) diff --git a/src/main/java/fr/univ_amu/iut/fp/Controller.java b/src/main/java/fr/univ_amu/iut/fp/Controller.java index 45c1092..5e7034f 100644 --- a/src/main/java/fr/univ_amu/iut/fp/Controller.java +++ b/src/main/java/fr/univ_amu/iut/fp/Controller.java @@ -2,7 +2,6 @@ package fr.univ_amu.iut.fp; import fr.univ_amu.iut.Donnees; import fr.univ_amu.iut.dao.DAODiscipline; -import fr.univ_amu.iut.dao.DAORessource; import fr.univ_amu.iut.dao.DAOThematique; import fr.univ_amu.iut.dao.DAOUsage; import fr.univ_amu.iut.dao.factory.DAOFactory; @@ -10,7 +9,6 @@ import fr.univ_amu.iut.dao.factory.DAOFactoryProducer; import fr.univ_amu.iut.dao.factory.DAOType; import fr.univ_amu.iut.model.Discipline; import fr.univ_amu.iut.model.Thematique; -import fr.univ_amu.iut.screenController.ScreenController; import fr.univ_amu.iut.view.map.AcademiePath; import fr.univ_amu.iut.view.map.France; import fr.univ_amu.iut.view.map.FranceBuilder; @@ -29,6 +27,7 @@ import javafx.event.ActionEvent; import java.io.IOException; import java.net.URL; +import java.util.ArrayList; import java.util.List; import java.util.ResourceBundle; @@ -53,67 +52,87 @@ public class Controller implements Initializable { @FXML private Button recherche; + List listNomThematique = new ArrayList<>(); + // Style des boutons - Background btNormalBackground = new Background(new BackgroundFill(Color.rgb(255,110,64), new CornerRadii(30), Insets.EMPTY)); - Background btNormalHover = new Background(new BackgroundFill(Color.rgb(255,152,120), new CornerRadii(30), Insets.EMPTY)); - Background btNormalSelected = new Background(new BackgroundFill(Color.rgb(255,60,0), new CornerRadii(30), Insets.EMPTY)); + Background btNormalBackground = new Background(new BackgroundFill(Color.rgb(255, 110, 64), new CornerRadii(30), Insets.EMPTY)); + Background btNormalHover = new Background(new BackgroundFill(Color.rgb(255, 152, 120), new CornerRadii(30), Insets.EMPTY)); + Background btNormalSelected = new Background(new BackgroundFill(Color.rgb(255, 60, 0), new CornerRadii(30), Insets.EMPTY)); private void initFrance() { france = FranceBuilder.create() .backgroundColor(Color.web("#f5f0e1")) .fillColor(Color.web("#1e3d59")) .mousePressHandler(evt -> { - AcademiePath academiePath = (AcademiePath) evt.getSource(); - Donnees.setAcademieSelectionee(academiePath.getAcademie()); + AcademiePath academiePath = (AcademiePath) evt.getSource(); + Donnees.setAcademieSelectionee(academiePath.getAcademie()); }) .selectionEnabled(true) .build(); } - private Button initButton(Object obj,int x,int y){ + private Button initButton(Object obj, int x, int y) { String nom = ""; - + EventHandler actionHandler; EventHandler onPressHandler; - + onEnterHandler = evt -> { - Button bt = (Button) evt.getSource(); - bt.setBackground(btNormalHover); + Button bt = (Button) evt.getSource(); + bt.setBackground(btNormalHover); }; - - onExitHandler= evt -> { + + onExitHandler = evt -> { Button bt = (Button) evt.getSource(); bt.setBackground(btNormalBackground); }; + + if (obj instanceof Discipline) { + Discipline disciplineActuelle = (Discipline) obj; + nom = disciplineActuelle.getNom(); + actionHandler = event -> { + Donnees.setDisciplineSelectionee(disciplineActuelle); + }; + } else { + Thematique thematiqueActuelle = (Thematique) obj; + nom = thematiqueActuelle.getNom(); + actionHandler = event -> { + Donnees.setThematiqueSelectionee(thematiqueActuelle); + }; + } + + onPressHandler = event -> { Button bt = (Button) event.getSource(); - if(bt.getBackground().equals(btNormalSelected)){ + if (bt.getBackground().equals(btNormalSelected)) { bt.setBackground(btNormalHover); bt.setOnMouseEntered(onEnterHandler); - bt.setOnMouseExited(onExitHandler); - } - else{ + } else { + if (obj instanceof Discipline) { + for (int i = 0; i < discipline.getChildren().size(); ++i) { + Button btChild = (Button) discipline.getChildren().get(i); + btChild.setBackground(btNormalBackground); + + btChild.setOnMouseEntered(onEnterHandler); + } + } else { + for (int i = 0; i < thematique.getChildren().size(); ++i) { + Button btChild = (Button) thematique.getChildren().get(i); + btChild.setBackground(btNormalBackground); + btChild.setOnMouseEntered(null); + } + } bt.setBackground(btNormalSelected); bt.setOnMouseEntered(null); bt.setOnMouseExited(null); } }; - if ( obj instanceof Discipline ){ - Discipline disciplineActuelle = (Discipline) obj; - nom = disciplineActuelle.getNom(); - actionHandler = event -> {Donnees.setDisciplineSelectionee(disciplineActuelle);}; - } - else{ - Thematique thematiqueActuelle = (Thematique) obj; - nom = thematiqueActuelle.getNom(); - actionHandler = event -> {Donnees.setThematiqueSelectionee(thematiqueActuelle);}; - } - + Button bt = new Button(nom); bt.setMnemonicParsing(false); - bt.setMinSize(235,115); + bt.setMinSize(235, 115); bt.layoutXProperty().setValue(x); bt.layoutYProperty().setValue(y); bt.setId(nom); @@ -128,30 +147,28 @@ public class Controller implements Initializable { return bt; } - private Void placeButtonDiscipline(){ + private Void placeButtonDiscipline() { List disciplines = daoDiscipline.findAll(); - discipline.setMinHeight(disciplines.size()*65); - for (int i = 0;i thematiques = daoThematique.findAll(); - thematique.setMinHeight(thematiques.size()*65); - for (int i = 0;i d = daoDiscipline.findAll(); List t = daoThematique.findAll(); placeButtonThematique(); placeButtonDiscipline(); - EventHandler handler = event ->{ + EventHandler handler = event -> { //TODO Recherche en fonctions des objets selectionnés - Donnees.setUsagesObtenus(daoUsage.findByCriterias(Donnees.getThematiqueSelectionee(),Donnees.getDisciplineSelectionee(),Donnees.getAcademieSelectionee())); - + Donnees.setUsagesObtenus(daoUsage.findByCriterias(Donnees.getThematiqueSelectionee(), Donnees.getDisciplineSelectionee(), Donnees.getAcademieSelectionee())); + Stage resultats = new Stage(); try { resultats.setScene(new Scene(FXMLLoader.load(getClass().getResource("/fr/univ_amu/iut/fResultat/FResultat.fxml")))); @@ -187,7 +204,7 @@ public class Controller implements Initializable { } catch (IOException e) { e.printStackTrace(); } - + }; recherche.setOnAction(handler); } diff --git a/src/main/resources/META-INF/persistence.xml b/src/main/resources/META-INF/persistence.xml index 9d40b7c..73fb4a7 100644 --- a/src/main/resources/META-INF/persistence.xml +++ b/src/main/resources/META-INF/persistence.xml @@ -7,7 +7,7 @@ - + From c848fb31c15c8df7c89e841e6eaeb5992262e916 Mon Sep 17 00:00:00 2001 From: Thomas Rubini <74205383+ThomasRubini@users.noreply.github.com> Date: Tue, 7 Jun 2022 17:22:27 +0200 Subject: [PATCH 2/2] Fix pour les couleurs des boutons --- .../java/fr/univ_amu/iut/fp/Controller.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main/java/fr/univ_amu/iut/fp/Controller.java b/src/main/java/fr/univ_amu/iut/fp/Controller.java index 5e7034f..0f177b0 100644 --- a/src/main/java/fr/univ_amu/iut/fp/Controller.java +++ b/src/main/java/fr/univ_amu/iut/fp/Controller.java @@ -57,7 +57,7 @@ public class Controller implements Initializable { // Style des boutons Background btNormalBackground = new Background(new BackgroundFill(Color.rgb(255, 110, 64), new CornerRadii(30), Insets.EMPTY)); Background btNormalHover = new Background(new BackgroundFill(Color.rgb(255, 152, 120), new CornerRadii(30), Insets.EMPTY)); - Background btNormalSelected = new Background(new BackgroundFill(Color.rgb(255, 60, 0), new CornerRadii(30), Insets.EMPTY)); + Background btSelectedBackground = new Background(new BackgroundFill(Color.rgb(255, 60, 0), new CornerRadii(30), Insets.EMPTY)); private void initFrance() { france = FranceBuilder.create() @@ -105,27 +105,29 @@ public class Controller implements Initializable { onPressHandler = event -> { Button bt = (Button) event.getSource(); - if (bt.getBackground().equals(btNormalSelected)) { + if (bt.getBackground().equals(btSelectedBackground)) { bt.setBackground(btNormalHover); bt.setOnMouseEntered(onEnterHandler); + bt.setOnMouseExited(onExitHandler); } else { if (obj instanceof Discipline) { for (int i = 0; i < discipline.getChildren().size(); ++i) { - Button btChild = (Button) discipline.getChildren().get(i); - btChild.setBackground(btNormalBackground); - - btChild.setOnMouseEntered(onEnterHandler); + Button btLoop = (Button) discipline.getChildren().get(i); + btLoop.setBackground(btNormalBackground); + btLoop.setOnMouseEntered(onEnterHandler); + btLoop.setOnMouseExited(onExitHandler); } } else { for (int i = 0; i < thematique.getChildren().size(); ++i) { - Button btChild = (Button) thematique.getChildren().get(i); - btChild.setBackground(btNormalBackground); - btChild.setOnMouseEntered(null); + Button btLoop = (Button) thematique.getChildren().get(i); + btLoop.setBackground(btNormalBackground); + btLoop.setOnMouseEntered(onEnterHandler); + btLoop.setOnMouseExited(onExitHandler); } } - bt.setBackground(btNormalSelected); bt.setOnMouseEntered(null); bt.setOnMouseExited(null); + bt.setBackground(btSelectedBackground); } };