Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Keimel2015-05-15 05:50:17 -0400
committerChristoph Keimel2015-05-15 05:50:37 -0400
commit2aee4911682f056f3779aad74d2b629489cc1674 (patch)
tree895f45949a09fd31002b615c35c7fd2f6a0d377a
parent90f4565b73ffeaaa1a67dd1d8469efff23bfae74 (diff)
downloadorg.eclipse.efxclipse-2aee4911682f056f3779aad74d2b629489cc1674.tar.gz
org.eclipse.efxclipse-2aee4911682f056f3779aad74d2b629489cc1674.tar.xz
org.eclipse.efxclipse-2aee4911682f056f3779aad74d2b629489cc1674.zip
Bug 467386 - [sample] Add test adding new elements to
FilterableTreeItemSample and SortableTreeItemSample Change-Id: I1cf7d5db0843df4444053e54a9926a49b9e29b33 Signed-off-by: Christoph Keimel <c.keimel@emsw.de>
-rw-r--r--demos/org.eclipse.fx.ui.controls.sample/src/org/eclipse/fx/ui/controls/sample/FilterableTreeItemSample.java41
-rw-r--r--demos/org.eclipse.fx.ui.controls.sample/src/org/eclipse/fx/ui/controls/sample/SortableTreeItemSample.java40
2 files changed, 52 insertions, 29 deletions
diff --git a/demos/org.eclipse.fx.ui.controls.sample/src/org/eclipse/fx/ui/controls/sample/FilterableTreeItemSample.java b/demos/org.eclipse.fx.ui.controls.sample/src/org/eclipse/fx/ui/controls/sample/FilterableTreeItemSample.java
index 3b3e7068e..3da11b994 100644
--- a/demos/org.eclipse.fx.ui.controls.sample/src/org/eclipse/fx/ui/controls/sample/FilterableTreeItemSample.java
+++ b/demos/org.eclipse.fx.ui.controls.sample/src/org/eclipse/fx/ui/controls/sample/FilterableTreeItemSample.java
@@ -7,6 +7,7 @@ import javafx.collections.ObservableList;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
+import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.control.TitledPane;
import javafx.scene.control.TreeView;
@@ -26,6 +27,7 @@ public class FilterableTreeItemSample extends Application {
}
private TextField filterField;
+ private FilterableTreeItem<Actor> folder1;
@Override
public void start(Stage stage) throws Exception {
@@ -42,13 +44,14 @@ public class FilterableTreeItemSample extends Application {
private Parent createContents() {
VBox vbox = new VBox(6);
vbox.getChildren().add(createFilterPane());
+ vbox.getChildren().add(createAddItemPane());
Node demoPane = createDemoPane();
VBox.setVgrow(demoPane, Priority.ALWAYS);
vbox.getChildren().add(demoPane);
return new BorderPane(vbox);
}
- private Node createFilterPane() {
+ private Node createFilterPane() {
filterField = new TextField();
filterField.setPromptText("Enter filter text ...");
@@ -56,6 +59,26 @@ public class FilterableTreeItemSample extends Application {
pane.setCollapsible(false);
return pane;
}
+
+ private Node createAddItemPane() {
+ HBox box = new HBox(6);
+ TextField firstname = new TextField();
+ firstname.setPromptText("Enter first name ...");
+ TextField lastname = new TextField();
+ lastname.setPromptText("Enter last name ...");
+
+ Button addBtn = new Button("Add new actor to \"Folder 1\"");
+ addBtn.setOnAction(event -> {
+ FilterableTreeItem<Actor> treeItem = new FilterableTreeItem<>(new Actor(firstname.getText(), lastname.getText()));
+ folder1.getInternalChildren().add(treeItem);
+ });
+ addBtn.disableProperty().bind(Bindings.isEmpty(lastname.textProperty()));
+
+ box.getChildren().addAll(firstname, lastname, addBtn);
+ TitledPane pane = new TitledPane("Add new element", box);
+ pane.setCollapsible(false);
+ return pane;
+ }
private Node createDemoPane() {
HBox hbox = new HBox(6);
@@ -84,7 +107,7 @@ public class FilterableTreeItemSample extends Application {
private FilterableTreeItem<Actor> getTreeModel() {
FilterableTreeItem<Actor> root = new FilterableTreeItem<>(new Actor("Root"));
- FilterableTreeItem<Actor> folder1 = createFolder("Folder 1");
+ folder1 = createFolder("Folder 1");
folder1.setExpanded(true);
root.getInternalChildren().add(folder1);
root.getInternalChildren().add(createFolder("Folder 2"));
@@ -112,19 +135,7 @@ public class FilterableTreeItemSample extends Application {
new Actor("Denzel", "Washington"),
new Actor("Spencer", "Tracy"),
new Actor("Laurence", "Olivier"),
- new Actor("Jack", "Lemmon"),
- new Actor("Jeff", "Bridges"),
- new Actor("James", "Stewart"),
- new Actor("Sean", "Penn"),
- new Actor("Michael", "Caine"),
- new Actor("Morgan", "Freeman"),
- new Actor("Robert", "Duvall"),
- new Actor("Gene", "Hackman"),
- new Actor("Clint", "Eastwood"),
- new Actor("Gregory", "Peck"),
- new Actor("Robin", "Williams"),
- new Actor("Ben", "Kingsley"),
- new Actor("Philip", "Seymour Hoffman"));
+ new Actor("Jack", "Lemmon"));
return actorList;
}
diff --git a/demos/org.eclipse.fx.ui.controls.sample/src/org/eclipse/fx/ui/controls/sample/SortableTreeItemSample.java b/demos/org.eclipse.fx.ui.controls.sample/src/org/eclipse/fx/ui/controls/sample/SortableTreeItemSample.java
index 6a7c484a2..8ca3ce40a 100644
--- a/demos/org.eclipse.fx.ui.controls.sample/src/org/eclipse/fx/ui/controls/sample/SortableTreeItemSample.java
+++ b/demos/org.eclipse.fx.ui.controls.sample/src/org/eclipse/fx/ui/controls/sample/SortableTreeItemSample.java
@@ -7,7 +7,9 @@ import javafx.collections.ObservableList;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
+import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
+import javafx.scene.control.TextField;
import javafx.scene.control.TitledPane;
import javafx.scene.control.ToggleButton;
import javafx.scene.control.ToggleGroup;
@@ -29,6 +31,7 @@ public class SortableTreeItemSample extends Application {
private ToggleGroup sortGroup;
private CheckBox cbReverse;
+ private SortableTreeItem<Actor> folder1;
@Override
public void start(Stage stage) throws Exception {
@@ -45,6 +48,7 @@ public class SortableTreeItemSample extends Application {
private Parent createContents() {
VBox vbox = new VBox(6);
vbox.getChildren().add(createInputPane());
+ vbox.getChildren().add(createAddItemPane());
Node demoPane = createDemoPane();
VBox.setVgrow(demoPane, Priority.ALWAYS);
vbox.getChildren().add(demoPane);
@@ -81,6 +85,26 @@ public class SortableTreeItemSample extends Application {
result.setCollapsible(false);
return result;
}
+
+ private Node createAddItemPane() {
+ HBox box = new HBox(6);
+ TextField firstname = new TextField();
+ firstname.setPromptText("Enter first name ...");
+ TextField lastname = new TextField();
+ lastname.setPromptText("Enter last name ...");
+
+ Button addBtn = new Button("Add new actor to \"Folder 1\"");
+ addBtn.setOnAction(event -> {
+ SortableTreeItem<Actor> treeItem = new SortableTreeItem<>(new Actor(firstname.getText(), lastname.getText()));
+ folder1.getInternalChildren().add(treeItem);
+ });
+ addBtn.disableProperty().bind(Bindings.isEmpty(lastname.textProperty()));
+
+ box.getChildren().addAll(firstname, lastname, addBtn);
+ TitledPane pane = new TitledPane("Add new element", box);
+ pane.setCollapsible(false);
+ return pane;
+ }
private Node createDemoPane() {
HBox hbox = new HBox(6);
@@ -127,7 +151,7 @@ public class SortableTreeItemSample extends Application {
private SortableTreeItem<Actor> getTreeModel() {
SortableTreeItem<Actor> root = new SortableTreeItem<>(new Actor("Root"));
- SortableTreeItem<Actor> folder1 = createFolder("Folder 1");
+ folder1 = createFolder("Folder 1");
folder1.setExpanded(true);
root.getInternalChildren().add(folder1);
root.getInternalChildren().add(createFolder("Folder 2"));
@@ -155,19 +179,7 @@ public class SortableTreeItemSample extends Application {
new Actor("Denzel", "Washington"),
new Actor("Spencer", "Tracy"),
new Actor("Laurence", "Olivier"),
- new Actor("Jack", "Lemmon"),
- new Actor("Jeff", "Bridges"),
- new Actor("James", "Stewart"),
- new Actor("Sean", "Penn"),
- new Actor("Michael", "Caine"),
- new Actor("Morgan", "Freeman"),
- new Actor("Robert", "Duvall"),
- new Actor("Gene", "Hackman"),
- new Actor("Clint", "Eastwood"),
- new Actor("Gregory", "Peck"),
- new Actor("Robin", "Williams"),
- new Actor("Ben", "Kingsley"),
- new Actor("Philip", "Seymour Hoffman"));
+ new Actor("Jack", "Lemmon"));
return actorList;
}

Back to the top