Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Schindl2016-03-31 09:01:24 -0400
committerTom Schindl2016-03-31 09:01:24 -0400
commit4ba1f95c03748b2666d2e5723d9c43ee01c4de21 (patch)
tree9dd141fa7fdfef12564f2d1b76a0c02a6d3a79cd
parent1a7c4f1a0444c65d6c467457899e6b07d7bc96c3 (diff)
downloadorg.eclipse.efxclipse-4ba1f95c03748b2666d2e5723d9c43ee01c4de21.tar.gz
org.eclipse.efxclipse-4ba1f95c03748b2666d2e5723d9c43ee01c4de21.tar.xz
org.eclipse.efxclipse-4ba1f95c03748b2666d2e5723d9c43ee01c4de21.zip
Bug 490787 - Add validation and decoration support
-rw-r--r--demos/org.eclipse.fx.ui.samples/.classpath7
-rw-r--r--demos/org.eclipse.fx.ui.samples/.gitignore1
-rw-r--r--demos/org.eclipse.fx.ui.samples/.project34
-rw-r--r--demos/org.eclipse.fx.ui.samples/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--demos/org.eclipse.fx.ui.samples/META-INF/MANIFEST.MF10
-rw-r--r--demos/org.eclipse.fx.ui.samples/build.properties4
-rw-r--r--demos/org.eclipse.fx.ui.samples/src/org/eclipse/fx/ui/samples/SampleApplication.java231
-rw-r--r--demos/org.eclipse.fx.ui.samples/src/org/eclipse/fx/ui/samples/sample.css3
8 files changed, 297 insertions, 0 deletions
diff --git a/demos/org.eclipse.fx.ui.samples/.classpath b/demos/org.eclipse.fx.ui.samples/.classpath
new file mode 100644
index 000000000..eca7bdba8
--- /dev/null
+++ b/demos/org.eclipse.fx.ui.samples/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/demos/org.eclipse.fx.ui.samples/.gitignore b/demos/org.eclipse.fx.ui.samples/.gitignore
new file mode 100644
index 000000000..ae3c17260
--- /dev/null
+++ b/demos/org.eclipse.fx.ui.samples/.gitignore
@@ -0,0 +1 @@
+/bin/
diff --git a/demos/org.eclipse.fx.ui.samples/.project b/demos/org.eclipse.fx.ui.samples/.project
new file mode 100644
index 000000000..0dd2a53bf
--- /dev/null
+++ b/demos/org.eclipse.fx.ui.samples/.project
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.fx.ui.samples</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
+ </natures>
+</projectDescription>
diff --git a/demos/org.eclipse.fx.ui.samples/.settings/org.eclipse.jdt.core.prefs b/demos/org.eclipse.fx.ui.samples/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..0c68a61dc
--- /dev/null
+++ b/demos/org.eclipse.fx.ui.samples/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/demos/org.eclipse.fx.ui.samples/META-INF/MANIFEST.MF b/demos/org.eclipse.fx.ui.samples/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..4d02f37ee
--- /dev/null
+++ b/demos/org.eclipse.fx.ui.samples/META-INF/MANIFEST.MF
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Samples
+Bundle-SymbolicName: org.eclipse.fx.ui.samples
+Bundle-Version: 1.0.0.qualifier
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Require-Bundle: org.eclipse.fx.core,
+ org.eclipse.fx.ui.dialogs;bundle-version="2.3.0",
+ org.eclipse.fx.ui.controls;bundle-version="2.3.0",
+ org.eclipse.fx.ui.panes
diff --git a/demos/org.eclipse.fx.ui.samples/build.properties b/demos/org.eclipse.fx.ui.samples/build.properties
new file mode 100644
index 000000000..34d2e4d2d
--- /dev/null
+++ b/demos/org.eclipse.fx.ui.samples/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/demos/org.eclipse.fx.ui.samples/src/org/eclipse/fx/ui/samples/SampleApplication.java b/demos/org.eclipse.fx.ui.samples/src/org/eclipse/fx/ui/samples/SampleApplication.java
new file mode 100644
index 000000000..2bc81387e
--- /dev/null
+++ b/demos/org.eclipse.fx.ui.samples/src/org/eclipse/fx/ui/samples/SampleApplication.java
@@ -0,0 +1,231 @@
+package org.eclipse.fx.ui.samples;
+
+import org.eclipse.fx.core.Status;
+import org.eclipse.fx.core.Status.State;
+import org.eclipse.fx.core.Subscription;
+import org.eclipse.fx.ui.controls.form.DefaultForm;
+import org.eclipse.fx.ui.controls.form.Form.BindingConfiguration;
+import org.eclipse.fx.ui.controls.form.StatusNode;
+import org.eclipse.fx.ui.controls.stage.FrameEvent;
+import org.eclipse.fx.ui.dialogs.TitleAreaDialog;
+import org.eclipse.fx.ui.panes.GridData;
+import org.eclipse.fx.ui.panes.GridData.Alignment;
+import org.eclipse.fx.ui.panes.GridLayoutPane;
+
+import javafx.application.Application;
+import javafx.beans.property.SimpleStringProperty;
+import javafx.beans.property.StringProperty;
+import javafx.scene.Node;
+import javafx.scene.Scene;
+import javafx.scene.control.Button;
+import javafx.scene.control.Label;
+import javafx.scene.control.Tab;
+import javafx.scene.control.TabPane;
+import javafx.scene.control.TextField;
+import javafx.scene.layout.HBox;
+import javafx.scene.layout.StackPane;
+import javafx.stage.Stage;
+import javafx.stage.Window;
+
+@SuppressWarnings("restriction")
+public class SampleApplication extends Application {
+ public static void main(String[] args) {
+ launch(args);
+ }
+
+ @Override
+ public void start(Stage primaryStage) throws Exception {
+ TabPane pane = new TabPane();
+ pane.getTabs().add(createHeavyWeightDialogs(primaryStage));
+ pane.getTabs().add(createLWWeightDialogs());
+ pane.getTabs().add(createValidation());
+ primaryStage.setScene(new Scene(pane, 800, 600));
+ primaryStage.show();
+ }
+
+ static class VM {
+ private StringProperty firstname = new SimpleStringProperty(this, "firstname");
+ private StringProperty lastname = new SimpleStringProperty(this, "lastname");
+
+ public VM(String firstname, String lastname) {
+ this.firstname.set(firstname);
+ this.lastname.set(lastname);
+ }
+ }
+
+ private Tab createValidation() {
+ Tab t = new Tab("Validation");
+
+ GridLayoutPane p = new GridLayoutPane();
+ p.setNumColumns(2);
+
+ DefaultForm form = new DefaultForm();
+ Label title = new Label("My Form");
+ title.setGraphic(new StatusNode(form.validationStatusProperty()));
+ title.setStyle("-fx-font-size: 2em; -fx-font-weight: bold;");
+
+ GridLayoutPane.setConstraint(title, new GridData(Alignment.FILL,Alignment.CENTER,true,false,2,1));
+ p.getChildren().add(title);
+
+ VM vm = new VM("Tom", "Schindl");
+
+ {
+ Label l = new Label("Vorname");
+ p.getChildren().add(l);
+
+ TextField field = new TextField();
+ p.getChildren().add(form.builder("firstname",field.textProperty(), vm.firstname, BindingConfiguration.VALIDATE_TO_OPPOSITE).decoratedNode(field)
+ .decoratedNodeMutator(new GridData(GridData.FILL_HORIZONTAL), GridLayoutPane::setConstraint)
+ .validator( s -> s.isEmpty() ? Status.status(State.ERROR, -1, "Vorname muß befüllt sein", null) : Status.ok())
+ .build()
+ .nodeWithStatus());
+ }
+
+ {
+ Label l = new Label("Nachname");
+ p.getChildren().add(l);
+
+ TextField field = new TextField();
+ p.getChildren().add(form.builder("lastname",field.textProperty(), vm.lastname, BindingConfiguration.VALIDATE_TO_OPPOSITE).decoratedNode(field)
+ .decoratedNodeMutator(new GridData(GridData.FILL_HORIZONTAL), GridLayoutPane::setConstraint)
+ .validator( s -> s.isEmpty() ? Status.status(State.ERROR, -1, "Nachname muß befüllt sein", null) : Status.ok())
+ .build()
+ .nodeWithStatus());
+ }
+
+ t.setContent(p);
+
+ return t;
+ }
+
+ private Tab createLWWeightDialogs() {
+ Tab t = new Tab("LW-weight Dialogs");
+
+ StackPane pane = new StackPane();
+ HBox container = new HBox();
+
+ {
+ Button b = new Button("LW Dialog");
+ b.setOnAction(e -> {
+ SampleLWTitleAreaDialog d = new SampleLWTitleAreaDialog();
+ d.addEventHandler(FrameEvent.CLOSED, ev -> {
+ pane.getChildren().remove(d);
+ });
+ pane.getChildren().add(d);
+ });
+ container.getChildren().add(b);
+ }
+
+ pane.getChildren().add(container);
+
+ t.setContent(pane);
+
+ return t;
+ }
+
+ private Tab createHeavyWeightDialogs(Stage s) {
+ Tab t = new Tab("Heavy-weight Dialogs");
+
+ HBox container = new HBox();
+
+ {
+ Button b = new Button("Show TitleArea Dialog");
+ b.setOnAction(e -> new SampleHeavyTitleAreaDialog(s).open());
+ container.getChildren().add(b);
+ }
+
+ t.setContent(container);
+
+ return t;
+ }
+
+
+ static class SampleLWTitleAreaDialog extends org.eclipse.fx.ui.controls.dialog.TitleAreaDialog {
+ private Subscription currentTempMessage;
+ public SampleLWTitleAreaDialog() {
+ super("Sample Dialog", "Sample Dialog", "This is a sample dialog");
+ setPrefSize(500, 300);
+ setClientArea(createClientArea());
+ addDefaultButtons();
+ }
+
+ private Node createClientArea() {
+ HBox box = new HBox();
+
+ {
+ Button b = new Button("Error");
+ b.setOnAction(e -> currentTempMessage = showTemporaryErrorMessage("This is an error message"));
+ box.getChildren().add(b);
+ }
+
+ {
+ Button b = new Button("Warning");
+ b.setOnAction(e -> currentTempMessage = showTemporaryWarningMessage("This is an warning message"));
+ box.getChildren().add(b);
+ }
+
+ {
+ Button b = new Button("Info");
+ b.setOnAction(e -> currentTempMessage = showTemporaryInfoMessage("This is an info message"));
+ box.getChildren().add(b);
+ }
+
+ {
+ Button b = new Button("Reset");
+ b.setOnAction(e -> {
+ if (currentTempMessage != null) {
+ currentTempMessage.dispose();
+ currentTempMessage = null;
+ }
+ });
+ box.getChildren().add(b);
+ }
+ return box;
+ }
+ }
+
+ static class SampleHeavyTitleAreaDialog extends TitleAreaDialog {
+ private Subscription currentTempMessage;
+
+ public SampleHeavyTitleAreaDialog(Window parent) {
+ super(parent, "Sample Dialog", "Sample Dialog", "This is a sample dialog", "sample-title-icon");
+ }
+
+ @Override
+ protected Node createDialogContent() {
+ HBox box = new HBox();
+
+ {
+ Button b = new Button("Error");
+ b.setOnAction(e -> currentTempMessage = showTemporaryErrorMessage("This is an error message"));
+ box.getChildren().add(b);
+ }
+
+ {
+ Button b = new Button("Warning");
+ b.setOnAction(e -> currentTempMessage = showTemporaryWarningMessage("This is an warning message"));
+ box.getChildren().add(b);
+ }
+
+ {
+ Button b = new Button("Info");
+ b.setOnAction(e -> currentTempMessage = showTemporaryInfoMessage("This is an info message"));
+ box.getChildren().add(b);
+ }
+
+ {
+ Button b = new Button("Reset");
+ b.setOnAction(e -> {
+ if (currentTempMessage != null) {
+ currentTempMessage.dispose();
+ currentTempMessage = null;
+ }
+ });
+ box.getChildren().add(b);
+ }
+
+ return box;
+ }
+
+ }
+}
diff --git a/demos/org.eclipse.fx.ui.samples/src/org/eclipse/fx/ui/samples/sample.css b/demos/org.eclipse.fx.ui.samples/src/org/eclipse/fx/ui/samples/sample.css
new file mode 100644
index 000000000..2c0350df4
--- /dev/null
+++ b/demos/org.eclipse.fx.ui.samples/src/org/eclipse/fx/ui/samples/sample.css
@@ -0,0 +1,3 @@
+.form-error {
+
+} \ No newline at end of file

Back to the top