Skip to content

Commit

Permalink
DEV refs #9 : Showing levels of subParameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathaël NOGUÈS committed Jul 13, 2016
1 parent f07e902 commit 407d31f
Show file tree
Hide file tree
Showing 10 changed files with 224 additions and 257 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.control.Button;
import javafx.scene.control.ScrollPane;

import java.io.File;
import java.io.IOException;
Expand All @@ -32,10 +33,12 @@ public class MainController {
private static Parent root;

@FXML private Button btnStrategy;
@FXML private ParametersPane paneExpParameters;
@FXML private ScrollPane paneParameters;
@FXML private ExpSubject expSubject;
@FXML private JellyBeansSelector jellyBeansSelector;

private ParametersPane paneExpParameters;

private String getFileContent(String path) throws IOException, URISyntaxException {
String res = "";
File f = new File(getClass().getClassLoader()
Expand All @@ -49,6 +52,10 @@ private String getFileContent(String path) throws IOException, URISyntaxExceptio

@FXML
protected void initialize() throws Exception {
paneExpParameters = new ParametersPane();
paneParameters.setContent(paneExpParameters);


// TODO MOCK ONLY ↓↓↓ ////////////////////////////////////////////////
String monitoredSystemJson = getFileContent("files/subjectFile.json");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,94 +3,83 @@
import fr.axonic.avek.model.base.engine.AVar;
import fr.axonic.avek.model.base.engine.FormatType;
import javafx.event.ActionEvent;
import javafx.scene.Node;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Control;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;

import java.util.HashSet;
import java.util.Set;
import java.util.function.Consumer;

/**
* Created by Nathaël N on 04/07/16.
*/
class ExpParameter implements IExpParameter {

// GUI Component
private CheckBox markedUtil;
private Label paramName;
private LevelMark levelMark;
private Label paramTitle;
private Label paramValue;
private TextField minEquivRange;
private TextField maxEquivRange;

public ExpParameter(AVar paramValue) {
ExpParameter(AVar paramValue, int level) {
// Init elements
markedUtil = new CheckBox();
markedUtil.setSelected(true);
markedUtil.setOnAction(this::onClickMarkedUtil);
GridPane.setColumnIndex(markedUtil, 0);

this.paramName = new Label(paramValue.getLabel());
this.paramValue = new Label(" : "+paramValue.getValue().toString());
if(paramValue.getFormat().getType() == FormatType.NUMBER) {
minEquivRange = new TextField(paramValue.getValue().toString());
maxEquivRange = new TextField(paramValue.getValue().toString());
}
levelMark = new LevelMark(level);
GridPane.setColumnIndex(levelMark, 1);

// Dispose on line
GridPane.setColumnIndex(markedUtil, 0);
GridPane.setColumnIndex(this.paramName, 1);
GridPane.setColumnIndex(this.paramValue, 2);
if(minEquivRange != null)
GridPane.setColumnIndex(minEquivRange, 3);
if(maxEquivRange != null)
GridPane.setColumnIndex(maxEquivRange, 4);
this.paramTitle = new Label(paramValue.getLabel());
GridPane.setColumnIndex(this.paramTitle, 2);

// Linking action listeners
markedUtil.setOnAction(this::onClickMarkedUtil);
}

public void setParamName(String paramName) {
this.paramName.setText(paramName);
}
this.paramValue = new Label(" : "+paramValue.getValue().toString());
GridPane.setColumnIndex(this.paramValue, 3);

public void setParamValue(String paramValue) {
this.paramValue.setText(paramValue);
}
if(paramValue.getFormat().getType() == FormatType.NUMBER) {
minEquivRange = new TextField(paramValue.getValue().toString());
minEquivRange.setMaxWidth(70);
GridPane.setColumnIndex(minEquivRange, 4);

public boolean isMakedUtil() {
return !markedUtil.isIndeterminate() && markedUtil.isSelected();
maxEquivRange = new TextField(paramValue.getValue().toString());
maxEquivRange.setMaxWidth(70);
GridPane.setColumnIndex(maxEquivRange, 5);
}
}

private void onClickMarkedUtil(ActionEvent event) {
boolean b = markedUtil.isSelected();

paramName.setDisable(!b);
paramTitle.setDisable(!b);
paramValue.setDisable(!b);
if(minEquivRange != null)
minEquivRange.setDisable(!b);
if(maxEquivRange != null)
maxEquivRange.setDisable(!b);
}

@Override
public Set<Control> getElements() {
Set<Control> elts = new HashSet<>();
elts.add(paramName);
elts.add(paramValue);
Set<Node> getElements() {
Set<Node> elts = new HashSet<>();

elts.add(markedUtil);
elts.add(paramTitle);
elts.add(levelMark);
elts.add(paramValue);
if(minEquivRange != null)
elts.add(minEquivRange);

if(maxEquivRange != null)
elts.add(maxEquivRange);

elts.add(markedUtil);

return elts;
}

@Override
public String getName() {
return paramName.getText();
return paramTitle.getText();
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
package fr.axonic.avek.gui.view.parameters;

import javafx.scene.control.Control;

import java.util.Set;
import java.util.function.Consumer;

/**
* Created by Nathaël N on 04/07/16.
* Created by Nathaël N on 13/07/16.
*/
public interface IExpParameter {
Set<Control> getElements();
String getName();
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package fr.axonic.avek.gui.view.parameters;

import javafx.scene.control.Label;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.Priority;
import javafx.scene.text.Text;

/**
* Created by Nathaël N on 13/07/16.
*/
public class LevelMark extends HBox {
private final String TRANSPARENT = "-fx-background-color: #fff0";
private final String BLUE = "-fx-background-color: #2f25";
private final String ARROW = "-fx-background-color: #2fa5";

public LevelMark(int level) {
this(level, false);
}
public LevelMark(int level, boolean withArrow) {
for(int i=0; i<level; i++) {
this.getChildren().add(new OneLevelMark(TRANSPARENT));
this.getChildren().add(new OneLevelMark(BLUE));
this.getChildren().add(new OneLevelMark(TRANSPARENT));
}
if(withArrow) {
this.getChildren().add(new OneLevelMark(TRANSPARENT));
this.getChildren().add(new OneLevelMark(ARROW));
this.getChildren().add(new OneLevelMark(TRANSPARENT));
}

GridPane.setVgrow(this, Priority.ALWAYS);
}

private class OneLevelMark extends Pane {
OneLevelMark(String c, int s) {
this.setStyle(c);
this.setMinWidth(s);
this.setPrefWidth(s);
this.setMaxWidth(s);
}
OneLevelMark(String c) {
this(c, 7);
}
}
}

This file was deleted.

Loading

0 comments on commit 407d31f

Please sign in to comment.