From e52280bc218946b0798d0077cf852c2b82fe5898 Mon Sep 17 00:00:00 2001 From: SeekDaSky Date: Tue, 12 Dec 2017 14:39:34 +0100 Subject: [PATCH] =?UTF-8?q?Impl=C3=A9mentation=20de=20la=20recherche=20par?= =?UTF-8?q?=20cat=C3=A9gorie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Classes/Category.java | 1 + controller/Article.java | 6 +++++- controller/RootLayout.java | 24 +++++++++++++++++++++++- fxml/model.fxml | 27 +++++++++++++++------------ 4 files changed, 44 insertions(+), 14 deletions(-) diff --git a/Classes/Category.java b/Classes/Category.java index f910b19..6020364 100644 --- a/Classes/Category.java +++ b/Classes/Category.java @@ -22,4 +22,5 @@ public enum Category { public String getLabel(){ return this.label; } public String getColor(){ return this.color; } + } diff --git a/controller/Article.java b/controller/Article.java index 6e76cf1..eb5cb8e 100644 --- a/controller/Article.java +++ b/controller/Article.java @@ -124,7 +124,11 @@ public class Article{ ImageView g_image = (ImageView) p_parent.getChildren().get(0); /* (2) Update title */ - g_image.setImage(new Image(p_uri)); + try { + g_image.setImage(new Image(p_uri)); + }catch(Exception e) { + g_image.setImage(new Image("http://lorempicsum.com/futurama/255/200/2")); + } } diff --git a/controller/RootLayout.java b/controller/RootLayout.java index fd59cd1..6d2f51c 100644 --- a/controller/RootLayout.java +++ b/controller/RootLayout.java @@ -1,5 +1,6 @@ package controller; +import java.awt.Color; import java.io.IOException; import java.util.ArrayList; @@ -25,6 +26,7 @@ import javafx.scene.input.KeyCode; import javafx.scene.input.KeyEvent; import javafx.scene.input.MouseEvent; import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.Background; import javafx.scene.layout.FlowPane; import javafx.scene.layout.VBox; import javafx.scene.text.Text; @@ -49,7 +51,7 @@ public class RootLayout extends Application implements EventObserver { /* (1) store primary stage + title it */ this.root_stage = primary_stage; - this.root_stage.setTitle("Inifiny Mail Client"); + this.root_stage.setTitle("Language learner pro plus 2000"); /* (2) Load the root layout*/ this.loadRootLayout(); @@ -92,6 +94,8 @@ public class RootLayout extends Application implements EventObserver { /* (4) #header_icon*/ new HeaderIconStyleSheet( this.root_scene.lookup("#header_icon") ); + this.handleMainLayoutChange("magazines"); + } public void loadRootLayout(){ @@ -201,6 +205,9 @@ public class RootLayout extends Application implements EventObserver { System.out.println(DictionaryModel.getInstance().getTranslations().size()+" Traductions ont été trouvés"); System.out.println(DictionaryModel.getInstance().getUsages().size()+" Exemples ont été trouvés"); break; + + case "changeMagCategory": + NewsListModel.getInstance().setCategory(Category.valueOf(e.getObjectId().toLowerCase())); } } @@ -223,6 +230,21 @@ public class RootLayout extends Application implements EventObserver { break; case "magazines" : + VBox subMenuContainer = (VBox) this.root_layout.lookup("#submenu"); + + for(Node n : subMenuContainer.getChildren()) { + FlowPane p = (FlowPane) n; + p.setOnMousePressed(new EventHandler() { + @Override + public void handle(MouseEvent event) { + //horreur...malheur + p.setStyle("-fx-background-color: #DDDDDD"); + RootLayout.this.root_layout.lookup("#"+NewsListModel.getInstance().getCategory().getLabel()).setStyle("fx-background-color: #F3F3F3"); + RootLayout.this.handleEvent(new Classes.Event(p.getChildren().get(0).getId(), "changeMagCategory")); + } + }); + } + NewsListModel.getInstance().addObserver("MainClass", this); NewsListModel.getInstance().setCategory(Category.gaming); NewsListModel.getInstance().setSortType(SortTypes.relevancy); diff --git a/fxml/model.fxml b/fxml/model.fxml index 65f54ee..df7b83d 100644 --- a/fxml/model.fxml +++ b/fxml/model.fxml @@ -118,7 +118,7 @@ - + @@ -134,7 +134,7 @@ - + @@ -150,7 +150,7 @@ - + @@ -166,7 +166,7 @@ - + @@ -182,7 +182,7 @@ - + @@ -198,7 +198,7 @@ - + @@ -214,7 +214,7 @@ - + @@ -230,7 +230,7 @@ - + @@ -246,7 +246,7 @@ - + @@ -262,7 +262,7 @@ - + @@ -279,7 +279,7 @@ - + @@ -294,7 +294,7 @@ - + @@ -374,6 +374,9 @@ + + +