You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2020/06/29 20:02:53 UTC
[isis] branch master updated: ISIS-2340: fx: adds TextFieldFactory
(in preparation of. a binding API)
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/master by this push:
new 34d6915 ISIS-2340: fx: adds TextFieldFactory (in preparation of. a binding API)
34d6915 is described below
commit 34d691574dec3fcc69362b6f29aa18f4343e48d0
Author: Andi Huber <ah...@apache.org>
AuthorDate: Mon Jun 29 22:02:42 2020 +0200
ISIS-2340: fx: adds TextFieldFactory (in preparation of. a binding API)
---
.../javafx/ui/IsisModuleIncViewerJavaFxUi.java | 2 +
.../ui/components/text/TextFieldFactory.java | 69 ++++++++++++++++++++++
2 files changed, 71 insertions(+)
diff --git a/incubator/viewers/javafx/ui/src/main/java/org/apache/isis/incubator/viewer/javafx/ui/IsisModuleIncViewerJavaFxUi.java b/incubator/viewers/javafx/ui/src/main/java/org/apache/isis/incubator/viewer/javafx/ui/IsisModuleIncViewerJavaFxUi.java
index 93034ee..c1d5d13 100644
--- a/incubator/viewers/javafx/ui/src/main/java/org/apache/isis/incubator/viewer/javafx/ui/IsisModuleIncViewerJavaFxUi.java
+++ b/incubator/viewers/javafx/ui/src/main/java/org/apache/isis/incubator/viewer/javafx/ui/IsisModuleIncViewerJavaFxUi.java
@@ -25,6 +25,7 @@ import org.apache.isis.incubator.viewer.javafx.model.events.IsisModuleIncViewerJ
import org.apache.isis.incubator.viewer.javafx.ui.components.UiComponentFactoryFx;
import org.apache.isis.incubator.viewer.javafx.ui.components.markup.MarkupFieldFactory;
import org.apache.isis.incubator.viewer.javafx.ui.components.other.FallbackFieldFactory;
+import org.apache.isis.incubator.viewer.javafx.ui.components.text.TextFieldFactory;
import org.apache.isis.incubator.viewer.javafx.ui.main.UiActionHandler;
import org.apache.isis.incubator.viewer.javafx.ui.main.UiBuilder;
import org.apache.isis.incubator.viewer.javafx.ui.main.UiController;
@@ -48,6 +49,7 @@ import org.apache.isis.viewer.common.model.IsisModuleViewerCommon;
UiController.class,
// component factories
+ TextFieldFactory.class,
MarkupFieldFactory.class,
FallbackFieldFactory.class,
diff --git a/incubator/viewers/javafx/ui/src/main/java/org/apache/isis/incubator/viewer/javafx/ui/components/text/TextFieldFactory.java b/incubator/viewers/javafx/ui/src/main/java/org/apache/isis/incubator/viewer/javafx/ui/components/text/TextFieldFactory.java
new file mode 100644
index 0000000..1a0b25a
--- /dev/null
+++ b/incubator/viewers/javafx/ui/src/main/java/org/apache/isis/incubator/viewer/javafx/ui/components/text/TextFieldFactory.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.isis.incubator.viewer.javafx.ui.components.text;
+
+import org.springframework.core.annotation.Order;
+
+import org.apache.isis.applib.annotation.LabelPosition;
+import org.apache.isis.applib.annotation.OrderPrecedence;
+import org.apache.isis.core.metamodel.facets.objectvalue.labelat.LabelAtFacet;
+import org.apache.isis.core.metamodel.facets.value.string.StringValueFacet;
+import org.apache.isis.incubator.viewer.javafx.ui.components.UiComponentHandlerFx;
+import org.apache.isis.incubator.viewer.javafx.ui.components.form.FormField;
+import org.apache.isis.incubator.viewer.javafx.ui.components.form.SimpleFormField;
+import org.apache.isis.viewer.common.model.binding.UiComponentFactory.Request;
+
+import lombok.val;
+
+import javafx.scene.control.Label;
+import javafx.scene.control.TextArea;
+
+@org.springframework.stereotype.Component
+@Order(OrderPrecedence.MIDPOINT)
+//@RequiredArgsConstructor(onConstructor_ = {@Inject})
+public class TextFieldFactory implements UiComponentHandlerFx {
+
+ @Override
+ public boolean isHandling(Request request) {
+ return request.hasFeatureFacet(StringValueFacet.class);
+ }
+
+ @Override
+ public FormField handle(Request request) {
+
+ val uiLabel = new Label(request.getFeatureLabel());
+
+ //TODO 1) move all the logic that is in the request to the underlying ManagedProperty
+ // 2) pass the ManagedProperty over with the request object
+ // 3) design for an API to bind a ManagedProperty to a FormField, also make sure this works
+ // with Vaadin's FormLayout/Field API
+ val textValue = request.getFeatureValue(String.class)
+ .orElse("");
+
+ val uiComponent = new TextArea(textValue);
+
+ val labelPosition = request.getFeatureFacet(LabelAtFacet.class)
+ .map(LabelAtFacet::label)
+ .orElse(LabelPosition.NOT_SPECIFIED);
+
+ return new SimpleFormField(labelPosition, uiLabel, uiComponent);
+ }
+
+
+}