Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Schindl2016-05-05 10:54:57 -0400
committerTom Schindl2016-05-05 10:54:57 -0400
commit344c95abb9657a5eb3816744a50fad6fa2150d97 (patch)
treeb52091671473308f0b438e1c441f9cb12f938b0d
parent86480427aa1ae11da03f405e6b40306bf18eaaa8 (diff)
downloadorg.eclipse.efxclipse-344c95abb9657a5eb3816744a50fad6fa2150d97.tar.gz
org.eclipse.efxclipse-344c95abb9657a5eb3816744a50fad6fa2150d97.tar.xz
org.eclipse.efxclipse-344c95abb9657a5eb3816744a50fad6fa2150d97.zip
Bug 493084 - Rework status decoration system
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/META-INF/MANIFEST.MF2
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/OSGI-INF/services/org.eclipse.fx.ui.controls.form.GraphicDecorator.xml7
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/OSGI-INF/services/org.eclipse.fx.ui.controls.form.SimpleStatusDecorator.xml7
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/DecoratedNode.java11
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/DecoratedNodeBuilder.java63
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/GraphicDecorator.java139
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/NodeDecorator.java26
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/SimpleDecoratedNode.java41
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/SimpleStatusDecorator.java24
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/StatusDecorator.java11
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/StatusNode.java2
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/graphic-status-decorator.css20
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/icons/dialog-error-8.pngbin0 -> 355 bytes
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/icons/dialog-error-8@2x.pngbin0 -> 716 bytes
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/icons/dialog-error.svgzbin4050 -> 4410 bytes
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/icons/dialog-info-8.pngbin0 -> 393 bytes
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/icons/dialog-info-8@2x.pngbin0 -> 781 bytes
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/icons/dialog-information.svgzbin14132 -> 16202 bytes
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/icons/dialog-warning-8.pngbin0 -> 322 bytes
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/icons/dialog-warning-8@2x.pngbin0 -> 585 bytes
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/icons/dialog-warning.svgzbin4982 -> 5425 bytes
-rw-r--r--demos/org.eclipse.fx.ui.controls.sample/src/org/eclipse/fx/ui/controls/sample/ValidationVMSample.java18
-rw-r--r--demos/org.eclipse.fx.ui.controls.sample/src/org/eclipse/fx/ui/controls/sample/ValidationVMSample2.java85
23 files changed, 340 insertions, 116 deletions
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/META-INF/MANIFEST.MF b/bundles/runtime/org.eclipse.fx.ui.controls/META-INF/MANIFEST.MF
index 936799a54..398617eee 100644
--- a/bundles/runtime/org.eclipse.fx.ui.controls/META-INF/MANIFEST.MF
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/META-INF/MANIFEST.MF
@@ -29,7 +29,7 @@ Export-Package: org.eclipse.fx.ui.controls;version="2.4.0",
Bundle-ActivationPolicy: lazy
Service-Component: OSGI-INF/services/org.eclipse.fx.ui.controls.styledtext.UnderlineStrategyFactory.xml,
OSGI-INF/services/org.eclipse.fx.ui.controls.image.fontawesome.FontAwesomeIconFontProvider.xml,
- OSGI-INF/services/org.eclipse.fx.ui.controls.form.SimpleStatusDecorator.xml
+ OSGI-INF/services/org.eclipse.fx.ui.controls.form.GraphicDecorator.xml
Bundle-Vendor: Eclipse.org
Import-Package: com.google.common.collect;version="15.0.0",
org.eclipse.fx.core;version="2.4.0",
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/OSGI-INF/services/org.eclipse.fx.ui.controls.form.GraphicDecorator.xml b/bundles/runtime/org.eclipse.fx.ui.controls/OSGI-INF/services/org.eclipse.fx.ui.controls.form.GraphicDecorator.xml
new file mode 100644
index 000000000..605f0a430
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/OSGI-INF/services/org.eclipse.fx.ui.controls.form.GraphicDecorator.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.fx.ui.controls.form.GraphicDecorator">
+ <service>
+ <provide interface="org.eclipse.fx.ui.controls.form.NodeDecorator"/>
+ </service>
+ <implementation class="org.eclipse.fx.ui.controls.form.GraphicDecorator"/>
+</scr:component> \ No newline at end of file
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/OSGI-INF/services/org.eclipse.fx.ui.controls.form.SimpleStatusDecorator.xml b/bundles/runtime/org.eclipse.fx.ui.controls/OSGI-INF/services/org.eclipse.fx.ui.controls.form.SimpleStatusDecorator.xml
deleted file mode 100644
index 45870b4a5..000000000
--- a/bundles/runtime/org.eclipse.fx.ui.controls/OSGI-INF/services/org.eclipse.fx.ui.controls.form.SimpleStatusDecorator.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.fx.ui.controls.form.SimpleStatusDecorator">
- <service>
- <provide interface="org.eclipse.fx.ui.controls.form.StatusDecorator"/>
- </service>
- <implementation class="org.eclipse.fx.ui.controls.form.SimpleStatusDecorator"/>
-</scr:component> \ No newline at end of file
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/DecoratedNode.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/DecoratedNode.java
new file mode 100644
index 000000000..8d5da1ce2
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/DecoratedNode.java
@@ -0,0 +1,11 @@
+package org.eclipse.fx.ui.controls.form;
+
+import org.eclipse.fx.core.Status;
+
+import javafx.beans.property.ObjectProperty;
+
+public interface DecoratedNode {
+ public ObjectProperty<Status> statusProperty();
+ public void setStatus(Status status);
+ public Status getStatus();
+}
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/DecoratedNodeBuilder.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/DecoratedNodeBuilder.java
deleted file mode 100644
index 267663019..000000000
--- a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/DecoratedNodeBuilder.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package org.eclipse.fx.ui.controls.form;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.function.BiConsumer;
-import java.util.function.Consumer;
-
-import org.eclipse.fx.core.Util;
-import org.eclipse.fx.core.property.ValidationStatusPropertyOwner;
-
-import javafx.scene.Node;
-
-public final class DecoratedNodeBuilder {
- private final StatusDecorator decorator;
- private final ValidationStatusPropertyOwner statusPropertyOwner;
- private List<MutatorDef> nodeMutatorList;
- private final Node decoratedNode;
-
- static class MutatorDef {
- final Object data;
- final BiConsumer<Node,Object> mutator;
-
- public MutatorDef(Object data, BiConsumer<Node,?> mutator) {
- this.data = data;
- this.mutator = (BiConsumer<Node, Object>) mutator;
- }
-
- }
- DecoratedNodeBuilder(Node decoratedNode, StatusDecorator decorator, ValidationStatusPropertyOwner statusPropertyOwner) {
- this.decorator = decorator;
- this.decoratedNode = decoratedNode;
- this.statusPropertyOwner = statusPropertyOwner;
- }
-
- public static DecoratedNodeBuilder create(Node decoratedNode, ValidationStatusPropertyOwner statusPropertyOwner) {
- return create(decoratedNode,Util.getService(DecoratedNodeBuilder.class, StatusDecorator.class).orElse(new SimpleStatusDecorator()),statusPropertyOwner);
- }
-
- public static DecoratedNodeBuilder create(Node decoratedNode, StatusDecorator decorator, ValidationStatusPropertyOwner statusPropertyOwner) {
- return new DecoratedNodeBuilder(decoratedNode,decorator, statusPropertyOwner);
- }
-
- public DecoratedNodeBuilder decoratedNodeMutator(Consumer<Node> mutator) {
- decoratedNodeMutator(null, (n,o) -> mutator.accept(n));
- return this;
- }
-
- public <O> DecoratedNodeBuilder decoratedNodeMutator(O data, BiConsumer<Node, O> mutator) {
- if( this.nodeMutatorList == null ) {
- this.nodeMutatorList = new ArrayList<>();
- }
- this.nodeMutatorList.add( new MutatorDef(data, mutator) );
- return this;
- }
-
- public Node build() {
- Node node = this.decorator.decorate(this.statusPropertyOwner.statusProperty(), this.decoratedNode);
- if( this.nodeMutatorList != null ) {
- this.nodeMutatorList.forEach( m -> m.mutator.accept(node, m.data));
- }
- return node;
- }
-}
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/GraphicDecorator.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/GraphicDecorator.java
new file mode 100644
index 000000000..346c76cf3
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/GraphicDecorator.java
@@ -0,0 +1,139 @@
+package org.eclipse.fx.ui.controls.form;
+
+import org.eclipse.fx.core.Status;
+import org.eclipse.fx.core.Status.State;
+import org.osgi.service.component.annotations.Component;
+
+import javafx.beans.binding.Bindings;
+import javafx.beans.property.ObjectProperty;
+import javafx.beans.property.SimpleObjectProperty;
+import javafx.css.PseudoClass;
+import javafx.scene.Node;
+import javafx.scene.control.ContentDisplay;
+import javafx.scene.control.Control;
+import javafx.scene.control.Label;
+import javafx.scene.control.SkinBase;
+
+@Component
+public class GraphicDecorator implements NodeDecorator {
+ static final String BASE_STYLESHEET = GraphicDecorator.class.getResource("graphic-status-decorator.css").toExternalForm(); //$NON-NLS-1$
+
+ public enum Location {
+ TOP_LEFT,
+ TOP_RIGHT,
+ BOTTOM_LEFT,
+ BOTTOM_RIGHT
+ }
+
+// public interface LocationProvider extends Predicate<Control> {
+// public Location getLocation(Control node);
+// }
+
+ private Location location;
+
+ public GraphicDecorator() {
+ this(Location.TOP_LEFT);
+ }
+
+ public GraphicDecorator(Location location) {
+ this.location = location;
+ }
+
+ @Override
+ public DecoratedNode decorate(Node node) {
+ if( node instanceof Control ) {
+ return new GraphicDecoratedControl((Control) node, this.location);
+ }
+ throw new IllegalArgumentException("Unable to decorate '"+node+"'"); //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ static class GraphicDecoratedControl implements DecoratedNode {
+ private final Label icon;
+ private final ObjectProperty<Status> statusProperty = new SimpleObjectProperty<Status>(this, "status", Status.ok()); //$NON-NLS-1$
+
+ private static PseudoClass error = PseudoClass.getPseudoClass("error");
+ private static PseudoClass warning = PseudoClass.getPseudoClass("warning");
+ private static PseudoClass ok = PseudoClass.getPseudoClass("ok");
+ private static PseudoClass cancel = PseudoClass.getPseudoClass("cancel");
+
+ public GraphicDecoratedControl(Control c, Location location) {
+ this.icon = new Label() {
+ @Override
+ public String getUserAgentStylesheet() {
+ return BASE_STYLESHEET;
+ }
+ };
+ this.icon.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
+ this.icon.getStyleClass().add("status-decorator-icon"); //$NON-NLS-1$
+ this.icon.setManaged(false);
+
+ if( c.getSkin() != null ) {
+ ((SkinBase<?>)c.getSkin()).getChildren().add(this.icon);
+ }
+
+ c.skinProperty().addListener( ( ob, ol, ne ) -> {
+ if( ol != null ) {
+ ((SkinBase<?>)ol).getChildren().remove(this.icon);
+ }
+
+ if( ne != null ) {
+ ((SkinBase<?>)ne).getChildren().add(this.icon);
+ }
+ });
+
+ if( location == Location.TOP_LEFT ) {
+ this.icon.translateXProperty().bind(this.icon.widthProperty().divide(-2));
+ this.icon.translateYProperty().bind(this.icon.heightProperty().divide(-2));
+ } else if( location == Location.TOP_RIGHT ) {
+ this.icon.translateXProperty().bind(Bindings.createDoubleBinding(() -> {
+ return Double.valueOf(c.getWidth() - this.icon.widthProperty().get() / 2);
+ },this.icon.widthProperty(), c.widthProperty()));
+ this.icon.translateYProperty().bind(this.icon.heightProperty().divide(-2));
+ } else if( location == Location.BOTTOM_LEFT ) {
+ this.icon.translateXProperty().bind(this.icon.widthProperty().divide(-2));
+ this.icon.translateYProperty().bind(Bindings.createDoubleBinding(() -> {
+ return Double.valueOf(c.getHeight() - this.icon.heightProperty().get() / 2);
+ }, this.icon.heightProperty(), c.heightProperty()));
+ } else if( location == Location.BOTTOM_RIGHT ) {
+ this.icon.translateXProperty().bind(Bindings.createDoubleBinding(() -> {
+ return Double.valueOf(c.getWidth() - this.icon.widthProperty().get() / 2);
+ },this.icon.widthProperty(), c.widthProperty()));
+ this.icon.translateYProperty().bind(Bindings.createDoubleBinding(() -> {
+ return Double.valueOf(c.getHeight() - this.icon.heightProperty().get() / 2);
+ }, this.icon.heightProperty(), c.heightProperty()));
+ }
+
+ updatePseudoState(this.icon, this.statusProperty.getValue());
+ this.statusProperty.addListener( (o, ol, ne) -> {
+ updatePseudoState(this.icon, ne);
+ });
+
+ this.icon.translateXProperty().addListener( o -> {
+ System.err.println(this.icon.translateXProperty().get());
+ });
+ }
+
+ private static void updatePseudoState(Node statusIcon, Status status) {
+ statusIcon.pseudoClassStateChanged(error, status.getState() == State.ERROR);
+ statusIcon.pseudoClassStateChanged(warning, status.getState() == State.WARNING);
+ statusIcon.pseudoClassStateChanged(ok, status.getState() == State.OK);
+ statusIcon.pseudoClassStateChanged(cancel, status.getState() == State.CANCEL);
+ statusIcon.autosize();
+ }
+
+ @Override
+ public ObjectProperty<Status> statusProperty() {
+ return this.statusProperty;
+ }
+
+ @Override
+ public void setStatus(Status status) {
+ statusProperty().set(status);
+ }
+
+ @Override
+ public Status getStatus() {
+ return statusProperty().get();
+ }
+ }
+}
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/NodeDecorator.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/NodeDecorator.java
new file mode 100644
index 000000000..55d5aff32
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/NodeDecorator.java
@@ -0,0 +1,26 @@
+package org.eclipse.fx.ui.controls.form;
+
+import org.eclipse.fx.core.Util;
+import org.eclipse.fx.core.property.ValidationStatusPropertyOwner;
+
+import javafx.scene.Node;
+
+public interface NodeDecorator {
+ public DecoratedNode decorate(Node node);
+
+ public static DecoratedNode apply(NodeDecorator decorator, Node control) {
+ return decorator.decorate(control);
+ }
+
+ public static DecoratedNode apply(Node control) {
+ return Util.getService(NodeDecorator.class).orElseGet(() -> new GraphicDecorator()).decorate(control);
+ }
+
+ public static void apply(Node control, ValidationStatusPropertyOwner statusOwner) {
+ apply(control).statusProperty().bind(statusOwner.statusProperty());
+ }
+
+ public static void apply(NodeDecorator decorator, Node control, ValidationStatusPropertyOwner statusOwner) {
+ apply(decorator, control).statusProperty().bind(statusOwner.statusProperty());
+ }
+}
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/SimpleDecoratedNode.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/SimpleDecoratedNode.java
new file mode 100644
index 000000000..05a190ceb
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/SimpleDecoratedNode.java
@@ -0,0 +1,41 @@
+package org.eclipse.fx.ui.controls.form;
+
+import org.eclipse.fx.core.Status;
+import org.eclipse.fx.core.property.ValidationStatusPropertyOwner;
+
+import javafx.beans.property.ObjectProperty;
+import javafx.beans.property.SimpleObjectProperty;
+import javafx.scene.Node;
+import javafx.scene.layout.HBox;
+import javafx.scene.layout.Priority;
+
+public class SimpleDecoratedNode extends HBox implements DecoratedNode {
+ private ObjectProperty<Status> statusProperty = new SimpleObjectProperty<Status>(this, "status", Status.ok()); //$NON-NLS-1$
+
+ public SimpleDecoratedNode(Node node) {
+ HBox.setHgrow(node, Priority.ALWAYS);
+ getStyleClass().add("status-decoration-container"); //$NON-NLS-1$
+ getChildren().addAll(new StatusNode(this.statusProperty),node);
+ }
+
+ @Override
+ public ObjectProperty<Status> statusProperty() {
+ return this.statusProperty;
+ }
+
+ @Override
+ public void setStatus(Status status) {
+ statusProperty().set(status);
+ }
+
+ @Override
+ public Status getStatus() {
+ return statusProperty().get();
+ }
+
+ public static SimpleDecoratedNode create(Node node, ValidationStatusPropertyOwner validationStatusOwner) {
+ SimpleDecoratedNode c = new SimpleDecoratedNode(node);
+ c.statusProperty().bind(validationStatusOwner.statusProperty());
+ return c;
+ }
+}
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/SimpleStatusDecorator.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/SimpleStatusDecorator.java
deleted file mode 100644
index 644d198b5..000000000
--- a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/SimpleStatusDecorator.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package org.eclipse.fx.ui.controls.form;
-
-import org.eclipse.fx.core.Status;
-import org.osgi.service.component.annotations.Component;
-
-import javafx.beans.property.ReadOnlyProperty;
-import javafx.scene.Node;
-import javafx.scene.layout.HBox;
-import javafx.scene.layout.Priority;
-
-@Component
-public class SimpleStatusDecorator implements StatusDecorator {
-
- @Override
- public Node decorate(ReadOnlyProperty<Status> statusProperty, Node node) {
- HBox box = new HBox();
- box.getStyleClass().add("status-decoration-container"); //$NON-NLS-1$
-
- HBox.setHgrow(node, Priority.ALWAYS);
- box.getChildren().addAll(new StatusNode(statusProperty),node);
-
- return box;
- }
-}
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/StatusDecorator.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/StatusDecorator.java
deleted file mode 100644
index 9664aea52..000000000
--- a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/StatusDecorator.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.eclipse.fx.ui.controls.form;
-
-import org.eclipse.fx.core.Status;
-
-import javafx.beans.property.Property;
-import javafx.beans.property.ReadOnlyProperty;
-import javafx.scene.Node;
-
-public interface StatusDecorator {
- public Node decorate(ReadOnlyProperty<Status> statusProperty, Node node);
-}
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/StatusNode.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/StatusNode.java
index 60d70cbb8..5d1a5b4e2 100644
--- a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/StatusNode.java
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/StatusNode.java
@@ -15,7 +15,7 @@ public class StatusNode extends Region {
private static PseudoClass ok = PseudoClass.getPseudoClass("ok");
private static PseudoClass cancel = PseudoClass.getPseudoClass("cancel");
- static final String BASE_STYLESHEET = SimpleStatusDecorator.class.getResource("status-icon.css").toExternalForm(); //$NON-NLS-1$
+ static final String BASE_STYLESHEET = SimpleDecoratedNode.class.getResource("status-icon.css").toExternalForm(); //$NON-NLS-1$
public StatusNode(ReadOnlyProperty<Status> statusProperty) {
Label statusIcon = new Label();
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/graphic-status-decorator.css b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/graphic-status-decorator.css
new file mode 100644
index 000000000..451379263
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/graphic-status-decorator.css
@@ -0,0 +1,20 @@
+.status-decorator-icon {
+ -fx-pref-width: 8;
+ -fx-pref-height: 8;
+}
+
+.status-decorator-icon:error {
+ -fx-graphic: url("icons/dialog-error-8.png");
+}
+
+.status-decorator-icon:warning {
+ -fx-graphic: url("icons/dialog-warning-8.png");
+}
+
+.status-decorator-icon:cancel {
+
+}
+
+.status-decorator-icon:ok {
+ visibility: false;
+} \ No newline at end of file
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/icons/dialog-error-8.png b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/icons/dialog-error-8.png
new file mode 100644
index 000000000..86ebc3a8b
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/icons/dialog-error-8.png
Binary files differ
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/icons/dialog-error-8@2x.png b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/icons/dialog-error-8@2x.png
new file mode 100644
index 000000000..bbba2d78c
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/icons/dialog-error-8@2x.png
Binary files differ
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/icons/dialog-error.svgz b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/icons/dialog-error.svgz
index 545a1ace6..730f2d557 100644
--- a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/icons/dialog-error.svgz
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/icons/dialog-error.svgz
Binary files differ
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/icons/dialog-info-8.png b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/icons/dialog-info-8.png
new file mode 100644
index 000000000..7f3343bcf
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/icons/dialog-info-8.png
Binary files differ
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/icons/dialog-info-8@2x.png b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/icons/dialog-info-8@2x.png
new file mode 100644
index 000000000..a3f8ee5b0
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/icons/dialog-info-8@2x.png
Binary files differ
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/icons/dialog-information.svgz b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/icons/dialog-information.svgz
index d73e7ac5d..05537e604 100644
--- a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/icons/dialog-information.svgz
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/icons/dialog-information.svgz
Binary files differ
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/icons/dialog-warning-8.png b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/icons/dialog-warning-8.png
new file mode 100644
index 000000000..349ac5a6b
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/icons/dialog-warning-8.png
Binary files differ
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/icons/dialog-warning-8@2x.png b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/icons/dialog-warning-8@2x.png
new file mode 100644
index 000000000..622ceefa9
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/icons/dialog-warning-8@2x.png
Binary files differ
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/icons/dialog-warning.svgz b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/icons/dialog-warning.svgz
index 660e0f4db..d93369ad2 100644
--- a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/icons/dialog-warning.svgz
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/form/icons/dialog-warning.svgz
Binary files differ
diff --git a/demos/org.eclipse.fx.ui.controls.sample/src/org/eclipse/fx/ui/controls/sample/ValidationVMSample.java b/demos/org.eclipse.fx.ui.controls.sample/src/org/eclipse/fx/ui/controls/sample/ValidationVMSample.java
index a755cf359..2f393bf1a 100644
--- a/demos/org.eclipse.fx.ui.controls.sample/src/org/eclipse/fx/ui/controls/sample/ValidationVMSample.java
+++ b/demos/org.eclipse.fx.ui.controls.sample/src/org/eclipse/fx/ui/controls/sample/ValidationVMSample.java
@@ -5,7 +5,7 @@ import org.eclipse.fx.core.Status.State;
import org.eclipse.fx.core.property.StatusAggregator;
import org.eclipse.fx.core.property.ValidatedSimpleStringProperty;
import org.eclipse.fx.core.property.ValidatedStringProperty;
-import org.eclipse.fx.ui.controls.form.DecoratedNodeBuilder;
+import org.eclipse.fx.ui.controls.form.SimpleDecoratedNode;
import org.eclipse.fx.ui.controls.form.StatusNode;
import org.eclipse.fx.ui.panes.GridData;
import org.eclipse.fx.ui.panes.GridData.Alignment;
@@ -62,10 +62,10 @@ public class ValidationVMSample extends Application {
TextField field = new TextField();
field.textProperty().bindBidirectional(vm.firstname.bindProperty());
- p.getChildren().add(DecoratedNodeBuilder
- .create(field, vm.firstname)
- .decoratedNodeMutator(new GridData(GridData.FILL_HORIZONTAL), GridLayoutPane::setConstraint)
- .build());
+ SimpleDecoratedNode d = SimpleDecoratedNode.create(field, vm.firstname);
+ GridLayoutPane.setConstraint(d, new GridData(GridData.FILL_HORIZONTAL));
+
+ p.getChildren().add(d);
}
{
@@ -75,10 +75,10 @@ public class ValidationVMSample extends Application {
TextField field = new TextField();
field.textProperty().bindBidirectional(vm.lastname.bindProperty());
- p.getChildren().add(DecoratedNodeBuilder
- .create(field, vm.lastname)
- .decoratedNodeMutator(new GridData(GridData.FILL_HORIZONTAL), GridLayoutPane::setConstraint)
- .build());
+ SimpleDecoratedNode d = SimpleDecoratedNode.create(field, vm.lastname);
+ GridLayoutPane.setConstraint(d, new GridData(GridData.FILL_HORIZONTAL));
+
+ p.getChildren().add(d);
}
primaryStage.setScene(new Scene(p,800,600));
diff --git a/demos/org.eclipse.fx.ui.controls.sample/src/org/eclipse/fx/ui/controls/sample/ValidationVMSample2.java b/demos/org.eclipse.fx.ui.controls.sample/src/org/eclipse/fx/ui/controls/sample/ValidationVMSample2.java
new file mode 100644
index 000000000..f47a5aae8
--- /dev/null
+++ b/demos/org.eclipse.fx.ui.controls.sample/src/org/eclipse/fx/ui/controls/sample/ValidationVMSample2.java
@@ -0,0 +1,85 @@
+package org.eclipse.fx.ui.controls.sample;
+
+import org.eclipse.fx.core.Status;
+import org.eclipse.fx.core.Status.State;
+import org.eclipse.fx.core.property.StatusAggregator;
+import org.eclipse.fx.core.property.ValidatedSimpleStringProperty;
+import org.eclipse.fx.core.property.ValidatedStringProperty;
+import org.eclipse.fx.ui.controls.form.NodeDecorator;
+import org.eclipse.fx.ui.controls.form.StatusNode;
+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.scene.Scene;
+import javafx.scene.control.Label;
+import javafx.scene.control.TextField;
+import javafx.stage.Stage;
+
+public class ValidationVMSample2 extends Application {
+
+ static class VM {
+ private final ValidatedStringProperty firstname;
+ private final ValidatedStringProperty lastname;
+ private final StatusAggregator aggregator;
+
+ public VM(String firstname, String lastname) {
+ this.firstname = new ValidatedSimpleStringProperty(new SimpleStringProperty(this, "firstname",firstname));
+ this.firstname.registerValidator(s -> s.isEmpty() ? Status.status(State.ERROR, -1, "Vorname muß befüllt sein", null) : Status.ok());
+
+ this.lastname = new ValidatedSimpleStringProperty(new SimpleStringProperty(this, "lastname", lastname));
+ this.lastname.registerValidator(s -> s.isEmpty() ? Status.status(State.ERROR, -1, "Nachname muß befüllt sein", null) : Status.ok());
+
+ this.aggregator = new StatusAggregator(this.firstname,this.lastname);
+ }
+ }
+
+ public static void main(String[] args) {
+ launch(args);
+ }
+
+ @Override
+ public void start(Stage primaryStage) throws Exception {
+ GridLayoutPane p = new GridLayoutPane();
+ p.setNumColumns(2);
+
+ VM vm = new VM("Tom", "Schindl");
+
+ Label title = new Label("My Form");
+ title.setGraphic(new StatusNode(vm.aggregator.statusProperty()));
+ 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);
+
+
+ {
+ Label l = new Label("Vorname");
+ p.getChildren().add(l);
+
+ TextField field = new TextField();
+ field.textProperty().bindBidirectional(vm.firstname.bindProperty());
+ GridLayoutPane.setConstraint(field, new GridData(GridData.FILL_HORIZONTAL));
+
+ NodeDecorator.apply(field, vm.firstname);
+ p.getChildren().add(field);
+ }
+
+ {
+ Label l = new Label("Nachname");
+ p.getChildren().add(l);
+
+ TextField field = new TextField();
+ field.textProperty().bindBidirectional(vm.lastname.bindProperty());
+ GridLayoutPane.setConstraint(field, new GridData(GridData.FILL_HORIZONTAL));
+
+ NodeDecorator.apply(field, vm.lastname);
+ p.getChildren().add(field);
+ }
+
+ primaryStage.setScene(new Scene(p,800,600));
+ primaryStage.show();
+ }
+}

Back to the top