Skip to content

Commit

Permalink
[LayoutCreator] Fixes StatePane keyword bug. Adds experiment name fie…
Browse files Browse the repository at this point in the history
…ld to General Pane
  • Loading branch information
Pedro12909 committed May 25, 2018
1 parent 087a024 commit e1525a0
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ private void preparePanels() {

/**
* Prepares Tree View pane
*
* @return Group containing the TreeView
*/
private Group prepareTreeViewPane() {
Expand Down Expand Up @@ -203,22 +204,19 @@ private Group prepareTreeViewPane() {

TreeView<String> treeView = new TreeView<>(rootItem);
treeView.setEditable(false);
treeView.getSelectionModel().select(1);

treeView.getSelectionModel().selectedItemProperty()
.addListener(new ChangeListener<TreeItem<String>>() {
@Override
public void changed(ObservableValue<? extends TreeItem<String>> observableValue,
TreeItem<String> oldValue, TreeItem<String> newValue) {

Node oldNode = componentsMap.get(oldValue.getValue());

if (oldNode != null) {
middleLayout.getChildren().remove(oldNode);
if (oldValue != null) {
Node oldNode = componentsMap.get(oldValue.getValue());
middleLayout.getChildren().remove(oldNode);
}

Node newNode = componentsMap.get(newValue.getValue());
if(newNode != null) {
if (newNode != null) {
middleLayout.setCenter(newNode);
middleLayout.setMargin(newNode, new Insets(0, 30, 0, 10));
}
Expand All @@ -234,6 +232,7 @@ public void changed(ObservableValue<? extends TreeItem<String>> observableValue,

/**
* Creates the General Pane
*
* @return generalPane
*/
private Pane prepareGeneralPane() {
Expand All @@ -245,6 +244,7 @@ private Pane prepareGeneralPane() {

/**
* Create the State Panel Pane
*
* @return statePane
*/
private Pane prepareStatePane() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.Priority;
Expand All @@ -16,6 +19,11 @@
*/
public class GeneralPane extends Pane {

/**
* Experiment Name Text Field
*/
private final TextField experimentNameTextField = new TextField();

/**
* Full Screen CheckBox
*/
Expand All @@ -36,17 +44,31 @@ public class GeneralPane extends Pane {
*/
private final CheckBox resizableCheckBox = new CheckBox("Resizable");

/**
* Default Node Padding
*/
private static final Insets DEFAULT_PADDING =
new Insets(20);

/**
* Creates a Pane with specific components
*/
public GeneralPane() {
setComponents();
prepareComponents();
}

/**
* Sets GeneralPane Window Properties
* Prepares GeneralPane
*/
private void setComponents() {
private void prepareComponents() {
GridPane experimentNameBox = new GridPane();
experimentNameBox.setAlignment(Pos.CENTER_LEFT);
experimentNameBox.setHgap(30);
experimentNameBox.setPadding(DEFAULT_PADDING);
experimentNameBox.add(new Label("Experiment Name"), 0, 0);
experimentNameBox.add(experimentNameTextField, 1, 0);
experimentNameTextField.setPromptText("Experiment Name");

windowHeight.setPrefColumnCount(5);
windowHeight.setPromptText("Height");
windowWidth.setPrefColumnCount(5);
Expand All @@ -71,12 +93,12 @@ public void changed(ObservableValue<? extends Boolean> observableValue,

HBox windowSize = new HBox(fullScreenCheckBox, nodeSeparator, windowWidth, windowHeight);

windowSize.setPadding(new Insets(20));
windowSize.setPadding(DEFAULT_PADDING);
windowSize.setSpacing(10);

resizableCheckBox.setPadding(new Insets(20));
resizableCheckBox.setPadding(DEFAULT_PADDING);

VBox generalPaneLayout = new VBox(windowSize, resizableCheckBox);
VBox generalPaneLayout = new VBox(experimentNameBox, windowSize, resizableCheckBox);

getChildren().add(generalPaneLayout);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public StatePanelPane() {
private void preparePane() {
// Create and add first row to list
KeywordRow firstRow = new KeywordRow(xCounter, yCounter);

keywordRowList.add(firstRow);
yCounter++;
final VBox keyWordsPaneBox = new VBox(firstRow);
keyWordsPaneBox.setSpacing(5);

Expand All @@ -67,6 +67,12 @@ public void handle(ActionEvent actionEvent) {
KeywordRow lastRow = keywordRowList.get(keywordRowList.size() - 1);
keywordRowList.remove(lastRow);
keyWordsPaneBox.getChildren().remove(lastRow);
if (yCounter == 0) {
yCounter = 3;
xCounter--;
} else {
yCounter--;
}

if (keywordRowList.size() == 1) {
minusButton.setDisable(true);
Expand Down

0 comments on commit e1525a0

Please sign in to comment.