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/26 13:47:52 UTC
[isis] branch master updated: ISIS-2340: fx: adds a first
ComponentFactory (Markup)
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 4b94aae ISIS-2340: fx: adds a first ComponentFactory (Markup)
4b94aae is described below
commit 4b94aaef43136d5c8229c8084c6e324305532908
Author: Andi Huber <ah...@apache.org>
AuthorDate: Fri Jun 26 15:47:35 2020 +0200
ISIS-2340: fx: adds a first ComponentFactory (Markup)
---
.../javafx/ui/IsisModuleIncViewerJavaFxUi.java | 2 +
.../javafx/ui/components/debug/DebugField.java | 1 -
.../ui/components/markup/MarkupFieldFactory.java | 59 ++++++++++++++++++++++
.../javafx/ui/components/object/ObjectViewFx.java | 1 -
.../ui/components/other/FallbackFieldFactory.java | 3 +-
.../common/model/binding/UiComponentFactory.java | 6 +++
6 files changed, 68 insertions(+), 4 deletions(-)
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 607d6a5..93034ee 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
@@ -23,6 +23,7 @@ import org.springframework.context.annotation.Import;
import org.apache.isis.incubator.viewer.javafx.model.events.IsisModuleIncViewerJavaFxModel;
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.main.UiActionHandler;
import org.apache.isis.incubator.viewer.javafx.ui.main.UiBuilder;
@@ -47,6 +48,7 @@ import org.apache.isis.viewer.common.model.IsisModuleViewerCommon;
UiController.class,
// component factories
+ MarkupFieldFactory.class,
FallbackFieldFactory.class,
// @Service's
diff --git a/incubator/viewers/javafx/ui/src/main/java/org/apache/isis/incubator/viewer/javafx/ui/components/debug/DebugField.java b/incubator/viewers/javafx/ui/src/main/java/org/apache/isis/incubator/viewer/javafx/ui/components/debug/DebugField.java
index 192d771..1711bfd 100644
--- a/incubator/viewers/javafx/ui/src/main/java/org/apache/isis/incubator/viewer/javafx/ui/components/debug/DebugField.java
+++ b/incubator/viewers/javafx/ui/src/main/java/org/apache/isis/incubator/viewer/javafx/ui/components/debug/DebugField.java
@@ -55,7 +55,6 @@ public class DebugField extends CustomFieldFx<DebugUiModel> {
@Override
protected void setPresentationValue(DebugUiModel model) {
this.model = model;
-
detailPane.setText(model.getSummaryText());
val rowIndex = new LongAdder();
diff --git a/incubator/viewers/javafx/ui/src/main/java/org/apache/isis/incubator/viewer/javafx/ui/components/markup/MarkupFieldFactory.java b/incubator/viewers/javafx/ui/src/main/java/org/apache/isis/incubator/viewer/javafx/ui/components/markup/MarkupFieldFactory.java
new file mode 100644
index 0000000..4103acc
--- /dev/null
+++ b/incubator/viewers/javafx/ui/src/main/java/org/apache/isis/incubator/viewer/javafx/ui/components/markup/MarkupFieldFactory.java
@@ -0,0 +1,59 @@
+/*
+ * 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.markup;
+
+import org.springframework.core.annotation.Order;
+
+import org.apache.isis.applib.annotation.OrderPrecedence;
+import org.apache.isis.applib.value.Markup;
+import org.apache.isis.incubator.viewer.javafx.ui.components.UiComponentHandlerFx;
+import org.apache.isis.viewer.common.model.binding.UiComponentFactory.Request;
+
+import lombok.val;
+
+import javafx.scene.Node;
+import javafx.scene.control.TextArea;
+
+@org.springframework.stereotype.Component
+@Order(OrderPrecedence.MIDPOINT)
+public class MarkupFieldFactory implements UiComponentHandlerFx {
+
+ @Override
+ public boolean isHandling(Request request) {
+ return request.isFeatureTypeInstanceOf(Markup.class);
+ }
+
+ @Override
+ public Node handle(Request request) {
+
+ val markupHtml = request.getFeatureValue(Markup.class)
+ .map(Markup::asString)
+ .orElse("");
+
+//XXX Unfortunately we have no simple means of auto-fitting a WebView
+// val uiComponent = new WebView();
+// uiComponent.getEngine().loadContent(markupHtml, "text/html");
+
+ val uiComponent = new TextArea(markupHtml);
+ uiComponent.setPrefHeight(40);
+ return uiComponent;
+ }
+
+
+}
diff --git a/incubator/viewers/javafx/ui/src/main/java/org/apache/isis/incubator/viewer/javafx/ui/components/object/ObjectViewFx.java b/incubator/viewers/javafx/ui/src/main/java/org/apache/isis/incubator/viewer/javafx/ui/components/object/ObjectViewFx.java
index f8abc86..f778197 100644
--- a/incubator/viewers/javafx/ui/src/main/java/org/apache/isis/incubator/viewer/javafx/ui/components/object/ObjectViewFx.java
+++ b/incubator/viewers/javafx/ui/src/main/java/org/apache/isis/incubator/viewer/javafx/ui/components/object/ObjectViewFx.java
@@ -49,7 +49,6 @@ import lombok.NonNull;
import lombok.val;
import lombok.extern.log4j.Log4j2;
-import javafx.geometry.Insets;
import javafx.scene.control.TabPane;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
diff --git a/incubator/viewers/javafx/ui/src/main/java/org/apache/isis/incubator/viewer/javafx/ui/components/other/FallbackFieldFactory.java b/incubator/viewers/javafx/ui/src/main/java/org/apache/isis/incubator/viewer/javafx/ui/components/other/FallbackFieldFactory.java
index 0118b18..18f5376 100644
--- a/incubator/viewers/javafx/ui/src/main/java/org/apache/isis/incubator/viewer/javafx/ui/components/other/FallbackFieldFactory.java
+++ b/incubator/viewers/javafx/ui/src/main/java/org/apache/isis/incubator/viewer/javafx/ui/components/other/FallbackFieldFactory.java
@@ -54,8 +54,7 @@ public class FallbackFieldFactory implements UiComponentHandlerFx {
public Node handle(Request request) {
val spec = request.getObjectFeature().getSpecification();
-
- val debugUiModel = DebugUiModel.of("type not handled")
+ val debugUiModel = DebugUiModel.of(spec.getCorrespondingClass().getSimpleName() + " type not handled")
.withProperty("ObjectFeature.specification.fullIdentifier", spec.getFullIdentifier())
.withProperty("ObjectFeature.identifier", request.getObjectFeature().getIdentifier().toString());
diff --git a/viewers/common/src/main/java/org/apache/isis/viewer/common/model/binding/UiComponentFactory.java b/viewers/common/src/main/java/org/apache/isis/viewer/common/model/binding/UiComponentFactory.java
index b2c84b6..ea741b2 100644
--- a/viewers/common/src/main/java/org/apache/isis/viewer/common/model/binding/UiComponentFactory.java
+++ b/viewers/common/src/main/java/org/apache/isis/viewer/common/model/binding/UiComponentFactory.java
@@ -82,6 +82,12 @@ public interface UiComponentFactory<T> {
: false;
}
+ public boolean isFeatureTypeInstanceOf(@Nullable Class<?> type) {
+ return type!=null
+ ? type.isAssignableFrom(getFeatureType())
+ : false;
+ }
+
/**
* @param facetType
* @return Whether there exists a facet for this feature, that is of the