Skip to content

Commit

Permalink
DEV refs #31 : Moving of Strategy button, add (Treat|EstablishedEffec…
Browse files Browse the repository at this point in the history
…t)View
  • Loading branch information
Nathaël NOGUÈS committed Jul 26, 2016
1 parent 1197646 commit 360eec3
Show file tree
Hide file tree
Showing 23 changed files with 289 additions and 132 deletions.
2 changes: 1 addition & 1 deletion avek-gui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<configuration>
<appName>#AVEK</appName>
<vendor>AXONIC</vendor>
<mainClass>fr.axonic.avek.gui.view.MainFrame</mainClass>
<mainClass>fr.axonic.avek.gui.Main</mainClass>
<keyStoreAlias>AVEK</keyStoreAlias>
<keyStorePassword>AVEK.AXONIC.fr</keyStorePassword>
<allPermissions>true</allPermissions>
Expand Down
52 changes: 52 additions & 0 deletions avek-gui/src/main/java/fr/axonic/avek/gui/Main.java
Original file line number Diff line number Diff line change
@@ -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();
}
});
}

}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -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");
Expand All @@ -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<String, Set<AVar>> 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();
}

}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<UploadedFile> fileList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ...
Expand Down
4 changes: 2 additions & 2 deletions avek-gui/src/main/java/fr/axonic/avek/gui/util/Util.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<String> ls = Files.readAllLines(f.toPath());
for (String s : ls)
Expand Down
Original file line number Diff line number Diff line change
@@ -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<AEntity> list = Jsonifier.toAListofAListAndAVar(experimentParametersJson);

for (AEntity ae : list.getEntities())
paneParameters.addExpParameter(ae);
}
}

Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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
Expand All @@ -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<AEntity> list = Jsonifier.toAListofAListAndAVar(experimentParametersJson);

for (AEntity ae : list.getEntities())
Expand Down
Loading

0 comments on commit 360eec3

Please sign in to comment.