diff --git a/avek-gui/pom.xml b/avek-gui/pom.xml index 02925df..5f07141 100644 --- a/avek-gui/pom.xml +++ b/avek-gui/pom.xml @@ -30,7 +30,7 @@ #AVEK AXONIC - fr.axonic.avek.gui.view.MainFrame + fr.axonic.avek.gui.Main AVEK AVEK.AXONIC.fr true diff --git a/avek-gui/src/main/java/fr/axonic/avek/gui/Main.java b/avek-gui/src/main/java/fr/axonic/avek/gui/Main.java new file mode 100644 index 0000000..fcbae4e --- /dev/null +++ b/avek-gui/src/main/java/fr/axonic/avek/gui/Main.java @@ -0,0 +1,52 @@ +package fr.axonic.avek.gui; + +import fr.axonic.avek.gui.util.ConcurrentTaskManager; +import fr.axonic.avek.gui.util.Util; +import fr.axonic.avek.gui.view.GeneralizedView; +import fr.axonic.avek.gui.view.MainFrame; +import javafx.application.Application; +import javafx.scene.Scene; +import javafx.stage.Stage; +import org.apache.log4j.Logger; + +import java.io.IOException; + +public class Main extends Application { + private final static Logger logger = Logger.getLogger(Main.class); + + public static void main(String[] args) { + launch(args); + } + + @Override + public void start(Stage primaryStage) throws IOException { + ConcurrentTaskManager ctm = new ConcurrentTaskManager(); + + logger.debug("Loading MainFrame..."); + + primaryStage.setTitle("#AVEK analyzer"); + + MainFrame mainFrame = new MainFrame(); + Scene s = new Scene(mainFrame, 800, 600); + primaryStage.setScene(s); + + primaryStage.show(); + logger.debug("MainFrame created."); + + + ctm.runLaterOnThread(() -> { + try { + GeneralizedView generalizedView = new GeneralizedView(); + Thread.sleep(2000); + ctm.runLaterOnPlatform(() -> mainFrame.setView(generalizedView)); + Thread.sleep(2000); + ctm.runLaterOnPlatform(() -> generalizedView.setMonitoredSystem(Util.getFileContent("files/subjectFile.json"))); + Thread.sleep(2000); + ctm.runLaterOnPlatform(() -> generalizedView.setExperimentParameters(Util.getFileContent("files/parametersFile.json"))); + } catch (Exception e) { + e.printStackTrace(); + } + }); + } + +} \ No newline at end of file diff --git a/avek-gui/src/main/java/fr/axonic/avek/gui/components/subjects/Subject.java b/avek-gui/src/main/java/fr/axonic/avek/gui/components/MonitoredSystemPane.java similarity index 62% rename from avek-gui/src/main/java/fr/axonic/avek/gui/components/subjects/Subject.java rename to avek-gui/src/main/java/fr/axonic/avek/gui/components/MonitoredSystemPane.java index 5cc0c9f..cd1c065 100644 --- a/avek-gui/src/main/java/fr/axonic/avek/gui/components/subjects/Subject.java +++ b/avek-gui/src/main/java/fr/axonic/avek/gui/components/MonitoredSystemPane.java @@ -1,6 +1,5 @@ -package fr.axonic.avek.gui.components.subjects; +package fr.axonic.avek.gui.components; -import fr.axonic.avek.gui.util.ConcurrentTaskManager; import fr.axonic.avek.model.MonitoredSystem; import fr.axonic.avek.model.base.engine.AVar; import javafx.event.ActionEvent; @@ -19,11 +18,11 @@ /** * Created by Nathaël N on 04/07/16. */ -public class Subject extends BorderPane { - private final static Logger logger = Logger.getLogger(Subject.class); - private static final URL FXML - = Subject.class.getClassLoader().getResource("fxml/components/Subject.fxml"); - private static final String CSS = "css/subjects/subjects.css"; +public class MonitoredSystemPane extends BorderPane { + private final static Logger logger = Logger.getLogger(MonitoredSystemPane.class); + private static final URL FXML = MonitoredSystemPane.class.getClassLoader() + .getResource("fxml/components/MonitoredSystem.fxml"); + private static final String CSS = "css/MonitoredSystem.css"; @FXML private Label title; @@ -33,17 +32,17 @@ public class Subject extends BorderPane { private Button btnHistory; // should be public - public Subject() { + public MonitoredSystemPane() { FXMLLoader fxmlLoader = new FXMLLoader(FXML); fxmlLoader.setRoot(this); fxmlLoader.setController(this); - logger.info("Loading Subject... (fxml)"); + logger.info("Loading MonitoredSystemPane... (fxml)"); try { fxmlLoader.load(); - logger.debug("Subject loaded."); + logger.debug("MonitoredSystemPane loaded."); } catch (IOException e) { - logger.fatal("Impossible to load FXML for Subject", e); + logger.fatal("Impossible to load FXML for MonitoredSystemPane", e); } logger.debug("Adding subject.css"); @@ -56,24 +55,19 @@ private void onClicShowHistory(ActionEvent event) { } public void setMonitoredSystem(MonitoredSystem ms) { - ConcurrentTaskManager ctm = new ConcurrentTaskManager(); - logger.debug("Setting monitored system"); - ctm.runLaterOnPlatform(acrdnExpSubject.getPanes()::clear); + acrdnExpSubject.getPanes().clear(); Map> map = ms.getMap(); for (String category : map.keySet()) { ScrollPane sp = new ScrollPane(); VBox vb = new VBox(); - ctm.runLaterOnPlatform(() -> acrdnExpSubject.getPanes().add(new TitledPane(category, sp))); + acrdnExpSubject.getPanes().add(new TitledPane(category, sp)); sp.setContent(vb); for (AVar av : map.get(category)) vb.getChildren().add(new Label(av.getLabel() + " : " + av.getValue().toString())); } - - ctm.waitForTasks(); } - } diff --git a/avek-gui/src/main/java/fr/axonic/avek/gui/components/filelist/FileListView.java b/avek-gui/src/main/java/fr/axonic/avek/gui/components/filelist/FileListView.java index c833c86..521236a 100644 --- a/avek-gui/src/main/java/fr/axonic/avek/gui/components/filelist/FileListView.java +++ b/avek-gui/src/main/java/fr/axonic/avek/gui/components/filelist/FileListView.java @@ -1,6 +1,5 @@ package fr.axonic.avek.gui.components.filelist; -import fr.axonic.avek.gui.components.parameters.ParametersPane; import fr.axonic.avek.gui.model.structure.UploadedFile; import fr.axonic.avek.gui.util.ConcurrentTaskManager; import javafx.fxml.FXML; @@ -29,7 +28,7 @@ public class FileListView extends StackPane { private final static Logger logger = Logger.getLogger(FileListView.class); private static final URL FXML - = ParametersPane.class.getClassLoader().getResource("fxml/components/FileListView.fxml"); + = FileListView.class.getClassLoader().getResource("fxml/components/FileListView.fxml"); @FXML private ListView fileList; diff --git a/avek-gui/src/main/java/fr/axonic/avek/gui/components/parameters/GeneralizedParametersPane.java b/avek-gui/src/main/java/fr/axonic/avek/gui/components/parameters/GeneralizedParametersPane.java index 51f56eb..c9f826d 100644 --- a/avek-gui/src/main/java/fr/axonic/avek/gui/components/parameters/GeneralizedParametersPane.java +++ b/avek-gui/src/main/java/fr/axonic/avek/gui/components/parameters/GeneralizedParametersPane.java @@ -2,7 +2,6 @@ package fr.axonic.avek.gui.components.parameters; import fr.axonic.avek.gui.components.filelist.FileListView; -import fr.axonic.avek.gui.components.parameters.list.ParametersGroup; import fr.axonic.avek.gui.components.parameters.list.ParametersRoot; import fr.axonic.avek.model.base.engine.AEntity; import javafx.fxml.FXML; diff --git a/avek-gui/src/main/java/fr/axonic/avek/gui/components/parameters/list/ParametersCategory.java b/avek-gui/src/main/java/fr/axonic/avek/gui/components/parameters/list/ParametersCategory.java index da867f7..156a584 100644 --- a/avek-gui/src/main/java/fr/axonic/avek/gui/components/parameters/list/ParametersCategory.java +++ b/avek-gui/src/main/java/fr/axonic/avek/gui/components/parameters/list/ParametersCategory.java @@ -10,7 +10,7 @@ */ public class ParametersCategory extends ParametersGroup { private static final Logger logger = Logger.getLogger(ParametersCategory.class); - private static final String CSS = "css/parameters/parameters.css"; + private static final String CSS = "css/Parameters.css"; private final CategoryTitle simpleParam; @@ -25,7 +25,7 @@ public class ParametersCategory extends ParametersGroup { this.setVgap(2); - logger.info("Adding parameters.css"); + logger.info("Adding Parameters.css"); this.getStylesheets().add(CSS); } diff --git a/avek-gui/src/main/java/fr/axonic/avek/gui/components/parameters/list/ParametersGroup.java b/avek-gui/src/main/java/fr/axonic/avek/gui/components/parameters/list/ParametersGroup.java index af03cad..d1b4303 100644 --- a/avek-gui/src/main/java/fr/axonic/avek/gui/components/parameters/list/ParametersGroup.java +++ b/avek-gui/src/main/java/fr/axonic/avek/gui/components/parameters/list/ParametersGroup.java @@ -31,7 +31,7 @@ public abstract class ParametersGroup extends GridPane implements IExpParameter /* [ checkbox ][ Levelmark ][ Title & ... ] - [] ↓ MainFrame ParametersGrid's title + [] ↓ Main ParametersGrid's title [] |↓ ParametersGrid's title [] || A subelement : value ... [] || A subelement : value ... diff --git a/avek-gui/src/main/java/fr/axonic/avek/gui/util/Util.java b/avek-gui/src/main/java/fr/axonic/avek/gui/util/Util.java index 37da86a..396f4f9 100644 --- a/avek-gui/src/main/java/fr/axonic/avek/gui/util/Util.java +++ b/avek-gui/src/main/java/fr/axonic/avek/gui/util/Util.java @@ -1,6 +1,6 @@ package fr.axonic.avek.gui.util; -import fr.axonic.avek.gui.view.MainFrame; +import fr.axonic.avek.gui.Main; import java.io.File; import java.io.IOException; @@ -16,7 +16,7 @@ public abstract class Util { public static String getFileContent(String path) { String res = ""; try { - File f = new File(MainFrame.class.getClassLoader() + File f = new File(Main.class.getClassLoader() .getResource(path).toURI()); List ls = Files.readAllLines(f.toPath()); for (String s : ls) diff --git a/avek-gui/src/main/java/fr/axonic/avek/gui/view/EstablishEffectView.java b/avek-gui/src/main/java/fr/axonic/avek/gui/view/EstablishEffectView.java new file mode 100644 index 0000000..da511da --- /dev/null +++ b/avek-gui/src/main/java/fr/axonic/avek/gui/view/EstablishEffectView.java @@ -0,0 +1,68 @@ +package fr.axonic.avek.gui.view; + +import fr.axonic.avek.gui.components.MonitoredSystemPane; +import fr.axonic.avek.gui.components.parameters.ParametersPane; +import fr.axonic.avek.gui.components.results.JellyBeansSelector; +import fr.axonic.avek.gui.model.json.Jsonifier; +import fr.axonic.avek.model.MonitoredSystem; +import fr.axonic.avek.model.base.engine.AEntity; +import fr.axonic.avek.model.base.engine.AList; +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.scene.control.Button; +import org.apache.log4j.Logger; + +import java.io.IOException; +import java.net.URL; + +public class EstablishEffectView extends AbstractView { + private final static Logger logger = Logger.getLogger(EstablishEffectView.class); + private final static URL FXML + = EstablishEffectView.class.getClassLoader().getResource("fxml/views/GeneralizedView.fxml"); + + @FXML + private Button btnStrategy; + @FXML + private ParametersPane paneParameters; + @FXML + private MonitoredSystemPane monitoredSystemPane; + @FXML + private JellyBeansSelector jellyBeansSelector; + + // Should be public + public EstablishEffectView() { + FXMLLoader fxmlLoader = new FXMLLoader(FXML); + fxmlLoader.setController(this); + fxmlLoader.setRoot(this); + + logger.info("Loading EstablishEffectView... (fxml)"); + try { + fxmlLoader.load(); + logger.debug("EstablishEffectView loaded."); + } catch (IOException e) { + logger.fatal("Impossible to load FXML for EstablishEffectView", e); + } + } + + @FXML + void onClicStrategyButton(ActionEvent event) { + btnStrategy.setDisable(true); + } + + /** Fill experiment monitoredSystemPane informations + * + * @param monitoredSystemJson the MonitoredSystem as a Json String + */ + void setMonitoredSystem(String monitoredSystemJson) { + monitoredSystemPane.setMonitoredSystem(MonitoredSystem.fromJson(monitoredSystemJson)); + } + + void setExperimentParameters(String experimentParametersJson) { + AList list = Jsonifier.toAListofAListAndAVar(experimentParametersJson); + + for (AEntity ae : list.getEntities()) + paneParameters.addExpParameter(ae); + } +} + diff --git a/avek-gui/src/main/java/fr/axonic/avek/gui/view/GeneralizedView.java b/avek-gui/src/main/java/fr/axonic/avek/gui/view/GeneralizedView.java index 3513cdc..bf6c7e8 100644 --- a/avek-gui/src/main/java/fr/axonic/avek/gui/view/GeneralizedView.java +++ b/avek-gui/src/main/java/fr/axonic/avek/gui/view/GeneralizedView.java @@ -1,9 +1,8 @@ package fr.axonic.avek.gui.view; +import fr.axonic.avek.gui.components.MonitoredSystemPane; import fr.axonic.avek.gui.components.parameters.GeneralizedParametersPane; -import fr.axonic.avek.gui.components.parameters.ParametersPane; import fr.axonic.avek.gui.components.results.JellyBeansSelector; -import fr.axonic.avek.gui.components.subjects.Subject; import fr.axonic.avek.gui.model.json.Jsonifier; import fr.axonic.avek.model.MonitoredSystem; import fr.axonic.avek.model.base.engine.AEntity; @@ -27,7 +26,8 @@ public class GeneralizedView extends AbstractView { @FXML private GeneralizedParametersPane paneParameters; @FXML - private Subject subject; + private MonitoredSystemPane monitoredSystemPane; + @FXML private JellyBeansSelector jellyBeansSelector; // Should be public @@ -50,15 +50,18 @@ void onClicStrategyButton(ActionEvent event) { btnStrategy.setDisable(true); } - /** Fill experiment subject informations + /** Fill experiment monitoredSystemPane informations * * @param monitoredSystemJson the MonitoredSystem as a Json String */ - void setMonitoredSystem(String monitoredSystemJson) { - subject.setMonitoredSystem(MonitoredSystem.fromJson(monitoredSystemJson)); + public void setMonitoredSystem(String monitoredSystemJson) { + MonitoredSystem ms = MonitoredSystem.fromJson(monitoredSystemJson); + + monitoredSystemPane.setMonitoredSystem(ms); } - void setExperimentParameters(String experimentParametersJson) { + + public void setExperimentParameters(String experimentParametersJson) { AList list = Jsonifier.toAListofAListAndAVar(experimentParametersJson); for (AEntity ae : list.getEntities()) diff --git a/avek-gui/src/main/java/fr/axonic/avek/gui/view/MainFrame.java b/avek-gui/src/main/java/fr/axonic/avek/gui/view/MainFrame.java index fdbb065..7714300 100644 --- a/avek-gui/src/main/java/fr/axonic/avek/gui/view/MainFrame.java +++ b/avek-gui/src/main/java/fr/axonic/avek/gui/view/MainFrame.java @@ -1,65 +1,55 @@ package fr.axonic.avek.gui.view; -import fr.axonic.avek.gui.util.ConcurrentTaskManager; -import fr.axonic.avek.gui.util.Util; -import javafx.application.Application; -import javafx.scene.Scene; +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.scene.control.Button; import javafx.scene.layout.BorderPane; -import javafx.stage.Stage; import org.apache.log4j.Logger; import java.io.IOException; +import java.net.URL; -public class MainFrame extends Application { +/** + * Created by Nathaël N on 26/07/16. + */ +public class MainFrame extends BorderPane { private final static Logger logger = Logger.getLogger(MainFrame.class); + private final static URL FXML = MainFrame.class.getClassLoader() + .getResource("fxml/views/MainFrame.fxml"); - private final BorderPane frame; - - public MainFrame() { - frame = new BorderPane(); - } - - public void setView(AbstractView view) { - frame.getChildren().clear(); - frame.setCenter(view); - } - + @FXML + private Button btnStrategy; - // // // // // Application MAIN // // // // // + private AbstractView view; - public static void main(String[] args) { - launch(args); + public MainFrame() { + FXMLLoader fxmlLoader = new FXMLLoader(FXML); + fxmlLoader.setController(this); + fxmlLoader.setRoot(this); + + logger.info("Loading MainFrame... (fxml)"); + try { + fxmlLoader.load(); + logger.debug("MainFrame loaded."); + } catch (IOException e) { + logger.fatal("Impossible to load FXML for MainFrame", e); + } + + // TODO Temporary solution + setView(new GeneralizedView()); } - @Override - public void start(Stage primaryStage) throws IOException { - ConcurrentTaskManager ctm = new ConcurrentTaskManager(); - - logger.debug("Loading Frame..."); - - primaryStage.setTitle("#AVEK analyzer"); - GeneralizedView generalizedView = new GeneralizedView(); + @FXML + private void onClicStrategyButton(ActionEvent event) { - Scene s = new Scene(frame, 800, 600); - primaryStage.setScene(s); - - primaryStage.show(); - logger.debug("Frame created."); + } - ctm.runLaterOnThread(() -> { - try { - Thread.sleep(2000); - ctm.runLaterOnPlatform(() -> setView(generalizedView)); - Thread.sleep(2000); - ctm.runLaterOnPlatform(() -> generalizedView.setMonitoredSystem(Util.getFileContent("files/subjectFile.json"))); - Thread.sleep(2000); - ctm.runLaterOnPlatform(() -> generalizedView.setExperimentParameters(Util.getFileContent("files/parametersFile.json"))); - } catch (Exception e) { - e.printStackTrace(); - } - }); + public void setView(AbstractView view) { + setCenter(view); // remove abstract view currently loaded + this.view = view; } -} \ No newline at end of file +} diff --git a/avek-gui/src/main/java/fr/axonic/avek/gui/view/TreatView.java b/avek-gui/src/main/java/fr/axonic/avek/gui/view/TreatView.java new file mode 100644 index 0000000..e6dc620 --- /dev/null +++ b/avek-gui/src/main/java/fr/axonic/avek/gui/view/TreatView.java @@ -0,0 +1,65 @@ +package fr.axonic.avek.gui.view; + +import fr.axonic.avek.gui.components.MonitoredSystemPane; +import fr.axonic.avek.gui.components.parameters.ParametersPane; +import fr.axonic.avek.gui.model.json.Jsonifier; +import fr.axonic.avek.model.MonitoredSystem; +import fr.axonic.avek.model.base.engine.AEntity; +import fr.axonic.avek.model.base.engine.AList; +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.scene.control.Button; +import org.apache.log4j.Logger; + +import java.io.IOException; +import java.net.URL; + +public class TreatView extends AbstractView { + private final static Logger logger = Logger.getLogger(TreatView.class); + private final static URL FXML + = TreatView.class.getClassLoader().getResource("fxml/views/GeneralizedView.fxml"); + + @FXML + private Button btnStrategy; + @FXML + private ParametersPane paneParameters; + @FXML + private MonitoredSystemPane monitoredSystemPane; + + // Should be public + public TreatView() { + FXMLLoader fxmlLoader = new FXMLLoader(FXML); + fxmlLoader.setController(this); + fxmlLoader.setRoot(this); + + logger.info("Loading TreatView... (fxml)"); + try { + fxmlLoader.load(); + logger.debug("TreatView loaded."); + } catch (IOException e) { + logger.fatal("Impossible to load FXML for TreatView", e); + } + } + + @FXML + void onClicStrategyButton(ActionEvent event) { + btnStrategy.setDisable(true); + } + + /** Fill experiment monitoredSystemPane informations + * + * @param monitoredSystemJson the MonitoredSystem as a Json String + */ + void setMonitoredSystem(String monitoredSystemJson) { + monitoredSystemPane.setMonitoredSystem(MonitoredSystem.fromJson(monitoredSystemJson)); + } + + void setExperimentParameters(String experimentParametersJson) { + AList list = Jsonifier.toAListofAListAndAVar(experimentParametersJson); + + for (AEntity ae : list.getEntities()) + paneParameters.addExpParameter(ae); + } +} + diff --git a/avek-gui/src/main/resources/css/subjects/subjects.css b/avek-gui/src/main/resources/css/MonitoredSystem.css similarity index 100% rename from avek-gui/src/main/resources/css/subjects/subjects.css rename to avek-gui/src/main/resources/css/MonitoredSystem.css diff --git a/avek-gui/src/main/resources/css/parameters/parameters.css b/avek-gui/src/main/resources/css/Parameters.css similarity index 100% rename from avek-gui/src/main/resources/css/parameters/parameters.css rename to avek-gui/src/main/resources/css/Parameters.css diff --git a/avek-gui/src/main/resources/fxml/components/Subject.fxml b/avek-gui/src/main/resources/fxml/components/MonitoredSystem.fxml similarity index 100% rename from avek-gui/src/main/resources/fxml/components/Subject.fxml rename to avek-gui/src/main/resources/fxml/components/MonitoredSystem.fxml diff --git a/avek-gui/src/main/resources/fxml/views/EtablishEffectView.fxml b/avek-gui/src/main/resources/fxml/views/EtablishEffectView.fxml index 40b400c..3d565be 100644 --- a/avek-gui/src/main/resources/fxml/views/EtablishEffectView.fxml +++ b/avek-gui/src/main/resources/fxml/views/EtablishEffectView.fxml @@ -1,25 +1,22 @@ + - - - - + + - +
+ + +
- -
diff --git a/avek-gui/src/main/resources/fxml/views/GeneralizedView.fxml b/avek-gui/src/main/resources/fxml/views/GeneralizedView.fxml index 0f66aa7..0f5f86a 100644 --- a/avek-gui/src/main/resources/fxml/views/GeneralizedView.fxml +++ b/avek-gui/src/main/resources/fxml/views/GeneralizedView.fxml @@ -1,24 +1,22 @@ - - - - + + + - +
+ + +
- -
diff --git a/avek-gui/src/main/resources/fxml/views/MainFrame.fxml b/avek-gui/src/main/resources/fxml/views/MainFrame.fxml index 5d5fc75..9b4caed 100644 --- a/avek-gui/src/main/resources/fxml/views/MainFrame.fxml +++ b/avek-gui/src/main/resources/fxml/views/MainFrame.fxml @@ -1,8 +1,14 @@ - - + + + +