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 16:55:29 UTC
[isis] branch master updated: ISIS-2340: fx: stubs for a FormPane
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 aa8cdfb ISIS-2340: fx: stubs for a FormPane
aa8cdfb is described below
commit aa8cdfb72a59ce66c38b37cc145d9df1c5c6d680
Author: Andi Huber <ah...@apache.org>
AuthorDate: Mon Jun 29 18:55:14 2020 +0200
ISIS-2340: fx: stubs for a FormPane
---
.../main/java/demoapp/javafx/DemoAppJavaFx.java | 3 +-
incubator/pom.xml | 1 +
.../javafx/ui/components/debug/DebugField.java | 10 ++-
.../javafx/ui/components/form/FormField.java | 32 ++++++++
.../viewer/javafx/ui/components/form/FormPane.java | 95 ++++++++++++++++++++++
.../components/{ => form}/field/CustomFieldFx.java | 2 +-
.../javafx/ui/components/object/ObjectViewFx.java | 4 +-
7 files changed, 139 insertions(+), 8 deletions(-)
diff --git a/examples/demo/javafx/src/main/java/demoapp/javafx/DemoAppJavaFx.java b/examples/demo/javafx/src/main/java/demoapp/javafx/DemoAppJavaFx.java
index 5eb49be..491689d 100644
--- a/examples/demo/javafx/src/main/java/demoapp/javafx/DemoAppJavaFx.java
+++ b/examples/demo/javafx/src/main/java/demoapp/javafx/DemoAppJavaFx.java
@@ -56,10 +56,11 @@ public class DemoAppJavaFx {
}
public static void main(String[] args) {
+
IsisPresets.logging(IsisInteractionFactoryDefault.class, "debug");
IsisPresets.logging(_Probe.class, "debug"); // enable debug entry logging
- IsisPresets.prototyping();
+ IsisPresets.prototyping(); // use prototyping mode as default, unless explicitly overridden (INCUBATING)
JavafxViewer.launch(DemoAppJavaFx.class, args);
}
diff --git a/incubator/pom.xml b/incubator/pom.xml
index 9ea8932..0b02534 100644
--- a/incubator/pom.xml
+++ b/incubator/pom.xml
@@ -113,6 +113,7 @@
<modules>
<module>mappings/microprofile</module>
<module>viewers/vaadin</module>
+ <module>viewers/javafx</module>
</modules>
</project>
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 bd935ee..7eda609 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
@@ -18,8 +18,9 @@
*/
package org.apache.isis.incubator.viewer.javafx.ui.components.debug;
+import org.apache.isis.core.commons.internal.base._Strings;
import org.apache.isis.incubator.viewer.javafx.model.util._fx;
-import org.apache.isis.incubator.viewer.javafx.ui.components.field.CustomFieldFx;
+import org.apache.isis.incubator.viewer.javafx.ui.components.form.field.CustomFieldFx;
import org.apache.isis.viewer.common.model.debug.DebugUiModel;
import lombok.val;
@@ -58,10 +59,11 @@ public class DebugField extends CustomFieldFx<DebugUiModel> {
model.getKeyValuePairs().forEach((k, v)->{
_fx.add(detailGrid, new Label(k));
val text = _fx.add(detailGrid, new TextArea(v));
-// val prefHeight = 16*(1+(int)_Strings.splitThenStream(v, "\n").count());
-// text.setPrefHeight(prefHeight);
+ val prefHeight = 16*(1+(int)_Strings.splitThenStream(v, "\n").count());
+ text.setPrefHeight(prefHeight);
+ text.setWrapText(true);
+ text.setEditable(false);
text.autosize();
- //text.disableProperty().set(true);
});
diff --git a/incubator/viewers/javafx/ui/src/main/java/org/apache/isis/incubator/viewer/javafx/ui/components/form/FormField.java b/incubator/viewers/javafx/ui/src/main/java/org/apache/isis/incubator/viewer/javafx/ui/components/form/FormField.java
new file mode 100644
index 0000000..1a61090
--- /dev/null
+++ b/incubator/viewers/javafx/ui/src/main/java/org/apache/isis/incubator/viewer/javafx/ui/components/form/FormField.java
@@ -0,0 +1,32 @@
+/*
+ * 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.form;
+
+import org.apache.isis.applib.annotation.LabelPosition;
+
+import javafx.scene.Node;
+
+public interface FormField {
+
+ LabelPosition getLabelPosition();
+
+ Node getUiLabel();
+ Node getUiField();
+
+}
diff --git a/incubator/viewers/javafx/ui/src/main/java/org/apache/isis/incubator/viewer/javafx/ui/components/form/FormPane.java b/incubator/viewers/javafx/ui/src/main/java/org/apache/isis/incubator/viewer/javafx/ui/components/form/FormPane.java
new file mode 100644
index 0000000..ecfb80f
--- /dev/null
+++ b/incubator/viewers/javafx/ui/src/main/java/org/apache/isis/incubator/viewer/javafx/ui/components/form/FormPane.java
@@ -0,0 +1,95 @@
+/*
+ * 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.form;
+
+import java.util.List;
+import java.util.Optional;
+
+import org.apache.isis.applib.annotation.LabelPosition;
+import org.apache.isis.applib.annotation.PropertyLayout;
+import org.apache.isis.core.commons.internal.collections._Lists;
+
+import lombok.NonNull;
+import lombok.val;
+
+import javafx.geometry.Insets;
+import javafx.geometry.Pos;
+import javafx.scene.Node;
+import javafx.scene.layout.GridPane;
+
+public class FormPane extends GridPane {
+
+ private final List<FormField> fields = _Lists.newArrayList();
+ private int rowCount = 0;
+
+ public FormPane() {
+ super();
+ val grid = grid();
+ grid.setAlignment(Pos.CENTER);
+ grid.setHgap(10);
+ grid.setVgap(10);
+ grid.setPadding(new Insets(25, 25, 25, 25));
+ }
+
+ @PropertyLayout()
+ public FormPane addField(FormField formField) {
+
+ fields.add(formField);
+
+ val labelPosition = Optional.ofNullable(formField.getLabelPosition())
+ .orElse(LabelPosition.DEFAULT);
+ switch(labelPosition) {
+ case NONE:
+ addRow(formField.getUiField());
+ break;
+ case TOP:
+ addRow(formField.getUiLabel());
+ addRow(formField.getUiField());
+ break;
+ case RIGHT:
+ addRow(formField.getUiField(), formField.getUiLabel());
+ break;
+ case LEFT:
+ case DEFAULT:
+ default:
+ addRow(formField.getUiLabel(), formField.getUiField());
+ break;
+ }
+ return this;
+ }
+
+ // -- HELPER
+
+ private GridPane grid() {
+ return this;
+ }
+
+ private void addRow(@NonNull Node spanningNode) {
+ grid().add(spanningNode, 0, rowCount, 2, 1);
+ ++rowCount;
+ }
+
+ private void addRow(@NonNull Node left, @NonNull Node right) {
+ grid().add(left, 0, rowCount);
+ grid().add(right, 1, rowCount);
+ ++rowCount;
+ }
+
+
+}
diff --git a/incubator/viewers/javafx/ui/src/main/java/org/apache/isis/incubator/viewer/javafx/ui/components/field/CustomFieldFx.java b/incubator/viewers/javafx/ui/src/main/java/org/apache/isis/incubator/viewer/javafx/ui/components/form/field/CustomFieldFx.java
similarity index 97%
rename from incubator/viewers/javafx/ui/src/main/java/org/apache/isis/incubator/viewer/javafx/ui/components/field/CustomFieldFx.java
rename to incubator/viewers/javafx/ui/src/main/java/org/apache/isis/incubator/viewer/javafx/ui/components/form/field/CustomFieldFx.java
index 6cfa30b..13b42e6 100644
--- a/incubator/viewers/javafx/ui/src/main/java/org/apache/isis/incubator/viewer/javafx/ui/components/field/CustomFieldFx.java
+++ b/incubator/viewers/javafx/ui/src/main/java/org/apache/isis/incubator/viewer/javafx/ui/components/form/field/CustomFieldFx.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.isis.incubator.viewer.javafx.ui.components.field;
+package org.apache.isis.incubator.viewer.javafx.ui.components.form.field;
import java.util.Objects;
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 21b847a..314efc5 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
@@ -141,10 +141,10 @@ public class ObjectViewFx extends VBox {
_fx.toolbarLayout(uiActionPanel);
uiActionPanel.prefWidthProperty().bind(
- container.widthProperty().multiply(0.95));
+ container.widthProperty().multiply(0.98));
uiActionPanel.maxWidthProperty().bind(
- container.widthProperty().multiply(0.95));
+ container.widthProperty().multiply(0.98));
_fx.backround(uiActionPanel, Color.FLORALWHITE);