2017-11-14 07:22:26 +00:00
|
|
|
package controller;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
2017-11-14 08:09:25 +00:00
|
|
|
import Interfaces.Event;
|
|
|
|
import Interfaces.EventObserver;
|
2017-11-14 07:22:26 +00:00
|
|
|
import javafx.application.Application;
|
|
|
|
import javafx.fxml.FXMLLoader;
|
|
|
|
import javafx.scene.Scene;
|
|
|
|
import javafx.scene.layout.AnchorPane;
|
|
|
|
import javafx.scene.layout.FlowPane;
|
|
|
|
import javafx.stage.Stage;
|
|
|
|
import model.HeaderMenuItem;
|
|
|
|
|
2017-11-14 08:09:25 +00:00
|
|
|
public class RootLayout extends Application implements EventObserver {
|
2017-11-14 07:22:26 +00:00
|
|
|
|
|
|
|
private Stage root_stage;
|
|
|
|
private Scene root_scene;
|
|
|
|
private AnchorPane root_layout;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void start(Stage primary_stage) {
|
|
|
|
|
|
|
|
/* (1) store primary stage + title it */
|
|
|
|
this.root_stage = primary_stage;
|
|
|
|
this.root_stage.setTitle("Inifiny Mail Client");
|
|
|
|
|
|
|
|
/* (2) Load the root layout*/
|
2017-11-14 08:09:25 +00:00
|
|
|
this.loadRootLayout();
|
2017-11-14 07:22:26 +00:00
|
|
|
|
|
|
|
/* (1) HEADER
|
|
|
|
-------------------------------------*/
|
|
|
|
/* (1) Create header menu */
|
2017-11-14 08:09:25 +00:00
|
|
|
HeaderMenu hm = new HeaderMenu((FlowPane) this.root_scene.lookup("#header_menu"));
|
2017-11-14 07:22:26 +00:00
|
|
|
|
2017-11-14 08:09:25 +00:00
|
|
|
hm.addItem( new HeaderMenuItem("notification", "/src/header-notif.png",this) );
|
|
|
|
hm.addItem( new HeaderMenuItem("mail", "/src/header-mail.png",this) );
|
|
|
|
hm.addItem( new HeaderMenuItem("search", "/src/header-search.png",this) );
|
|
|
|
hm.addItem( new HeaderMenuItem("menu", "/src/header-menu.png",this) );
|
2017-11-14 07:22:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void loadRootLayout(){
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
/* (1) Load the root_disp.fxml */
|
|
|
|
FXMLLoader loader = new FXMLLoader();
|
|
|
|
|
|
|
|
loader.setLocation(getClass().getResource("/fxml/model.fxml"));
|
|
|
|
|
|
|
|
/* (2) Load the layout into the scene */
|
|
|
|
this.root_layout = (AnchorPane) loader.load();
|
|
|
|
this.root_scene = new Scene(this.root_layout);
|
|
|
|
|
|
|
|
/* (3) Add the scene to the stage */
|
|
|
|
this.root_stage.setScene(this.root_scene);
|
|
|
|
|
|
|
|
/* (4) Show the stage */
|
|
|
|
this.root_stage.show();
|
|
|
|
|
|
|
|
}catch(IOException e){
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
launch(args);
|
|
|
|
}
|
2017-11-14 08:09:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void handleEvent(Event e) {
|
|
|
|
System.out.println("Object "+e.getObjectId()+" fired a "+e.getEventType()+" event");
|
|
|
|
|
|
|
|
}
|
2017-11-14 07:22:26 +00:00
|
|
|
}
|