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 12:59:32 UTC
[isis] branch master updated: ISIS-2340: fx: add missing actions
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 eb5ad6e ISIS-2340: fx: add missing actions
eb5ad6e is described below
commit eb5ad6ef2862b957dd8c15aae43deb345fa40322
Author: Andi Huber <ah...@apache.org>
AuthorDate: Fri Jun 26 14:59:14 2020 +0200
ISIS-2340: fx: add missing actions
---
.../main/java/demoapp/javafx/DemoAppJavaFx.java | 2 +
.../incubator/viewer/javafx/model/util/_fx.java | 25 ++++++++++
.../javafx/ui/components/object/ObjectViewFx.java | 53 ++++++++++++++------
.../javafx/ui/components/panel/TitledPanel.java | 57 ++++++++++++++++++++++
.../common/model/gridlayout/UiGridLayout.java | 4 +-
5 files changed, 124 insertions(+), 17 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 9865784..5eb49be 100644
--- a/examples/demo/javafx/src/main/java/demoapp/javafx/DemoAppJavaFx.java
+++ b/examples/demo/javafx/src/main/java/demoapp/javafx/DemoAppJavaFx.java
@@ -58,6 +58,8 @@ 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();
JavafxViewer.launch(DemoAppJavaFx.class, args);
}
diff --git a/incubator/viewers/javafx/model/src/main/java/org/apache/isis/incubator/viewer/javafx/model/util/_fx.java b/incubator/viewers/javafx/model/src/main/java/org/apache/isis/incubator/viewer/javafx/model/util/_fx.java
index 6f17b93..2ee7542 100644
--- a/incubator/viewers/javafx/model/src/main/java/org/apache/isis/incubator/viewer/javafx/model/util/_fx.java
+++ b/incubator/viewers/javafx/model/src/main/java/org/apache/isis/incubator/viewer/javafx/model/util/_fx.java
@@ -32,6 +32,7 @@ import javafx.scene.Node;
import javafx.scene.control.Accordion;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
+import javafx.scene.control.Labeled;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.control.TableColumn;
@@ -43,6 +44,8 @@ import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
+import javafx.scene.text.Font;
+import javafx.scene.text.FontWeight;
@UtilityClass
public final class _fx {
@@ -55,6 +58,11 @@ public final class _fx {
}
// -- COMPONENT FACTORIES
+
+ public static <T extends Node> T add(Pane container, T component) {
+ container.getChildren().add(component);
+ return component;
+ }
public static Label newLabel(Pane container, String label) {
val component = new Label(label);
@@ -163,5 +171,22 @@ public final class _fx {
return component;
}
+ public static void toolbarLayout(HBox component) {
+ component.setPadding(new Insets(15, 12, 15, 12));
+ component.setSpacing(10);
+ }
+
+ public static void h1(Labeled component) {
+ component.setFont(Font.font("Verdana", FontWeight.BOLD, 20));
+ }
+
+ public static void h2(Labeled component) {
+ component.setFont(Font.font("Verdana", FontWeight.BOLD, 18));
+ }
+
+ public static void h3(Labeled component) {
+ component.setFont(Font.font("Verdana", FontWeight.NORMAL, 17));
+ }
+
}
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 f8f93b7..f8abc86 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
@@ -40,6 +40,7 @@ import org.apache.isis.incubator.viewer.javafx.model.context.UiContext;
import org.apache.isis.incubator.viewer.javafx.model.util._fx;
import org.apache.isis.incubator.viewer.javafx.ui.components.UiComponentFactoryFx;
import org.apache.isis.incubator.viewer.javafx.ui.components.collections.TableViewFx;
+import org.apache.isis.incubator.viewer.javafx.ui.components.panel.TitledPanel;
import org.apache.isis.viewer.common.model.binding.UiComponentFactory;
import org.apache.isis.viewer.common.model.binding.interaction.ObjectBinding;
import org.apache.isis.viewer.common.model.gridlayout.UiGridLayout;
@@ -84,12 +85,15 @@ public class ObjectViewFx extends VBox {
@Override
protected void onObjectTitle(Pane container, DomainObjectLayoutData domainObjectData) {
- _fx.newLabel(container, objectInteractor.getTitle());
+ _fx.h1(_fx.newLabel(container, objectInteractor.getTitle()));
}
@Override
protected Pane newRow(Pane container, BS3Row bs3Row) {
val uiRow = _fx.newHBox(container);
+
+ uiRow.setSpacing(4);
+
//uiRow.setWidthFull();
//uiRow.setWrapMode(FlexLayout.WrapMode.WRAP); // allow line breaking
return uiRow;
@@ -100,7 +104,9 @@ public class ObjectViewFx extends VBox {
val uiCol = _fx.newVBox(container);
- uiCol.setOpaqueInsets(new Insets(10, 10, 10, 10));
+ uiCol.setSpacing(4);
+
+ //uiCol.setOpaqueInsets(new Insets(10, 10, 10, 10));
// final int span = bs3col.getSpan();
@@ -115,6 +121,7 @@ public class ObjectViewFx extends VBox {
@Override
protected Pane newActionPanel(Pane container) {
val uiActionPanel = _fx.newHBox(container);
+ _fx.toolbarLayout(uiActionPanel);
//uiActionPanel.setWrapMode(FlexLayout.WrapMode.WRAP); // allow line breaking
//uiActionPanel.setAlignItems(Alignment.BASELINE);
@@ -138,11 +145,15 @@ public class ObjectViewFx extends VBox {
@Override
protected Pane newFieldSet(Pane container, FieldSet fieldSetData) {
- _fx.newLabel(container, fieldSetData.getName())
- .setStyle("isis-field-set-label"); // corresponds to H2 (html)
+ val titledPanel = _fx.add(container, new TitledPanel(fieldSetData.getName()));
- val uiFieldSet = _fx.newGrid(container);
- return uiFieldSet;
+ // handle associated actions
+ for(val actionData : fieldSetData.getActions()) {
+ onAction(titledPanel.getUiActionBar(), actionData);
+ }
+
+ val uiFieldSet = _fx.newGrid(titledPanel);
+ return _fx.formLayout(uiFieldSet);
}
@@ -159,9 +170,9 @@ public class ObjectViewFx extends VBox {
.checkVisibility(Where.OBJECT_FORMS)
.get()
.ifPresent(managedAction -> {
- _fx.newButton(
+ val uiButton = _fx.newButton(
container,
- actionData.getNamed(),
+ managedAction.getName(),
event->actionEventHandler.accept(managedAction));
});
}
@@ -175,9 +186,16 @@ public class ObjectViewFx extends VBox {
.checkVisibility(Where.OBJECT_FORMS)
.get()
.ifPresent(managedProperty -> {
- val uiProperty = uiComponentFactory
- .componentFor(UiComponentFactory.Request.of(Where.OBJECT_FORMS, managedProperty));
- container.getChildren().add(uiProperty);
+
+ val uiProperty = _fx.add(container,
+ uiComponentFactory.componentFor(
+ UiComponentFactory.Request.of(Where.OBJECT_FORMS, managedProperty)));
+
+ // handle associated actions
+ for(val actionData : propertyData.getActions()) {
+ onAction(container, actionData);
+ }
+
});
}
@@ -191,11 +209,16 @@ public class ObjectViewFx extends VBox {
.get()
.ifPresent(managedCollection -> {
- _fx.newLabel(container, managedCollection.getName())
- .setStyle("isis-collection-label"); // corresponds to H3 (html)
+ val titledPanel = _fx.add(container, new TitledPanel(managedCollection.getName()));
- val uiCollection = TableViewFx.forManagedCollection(uiContext, managedCollection);
- container.getChildren().add(uiCollection);
+ // handle associated actions
+ for(val actionData : collectionData.getActions()) {
+ onAction(titledPanel.getUiActionBar(), actionData);
+ }
+
+ _fx.add(titledPanel,
+ TableViewFx.forManagedCollection(uiContext, managedCollection));
+
});
}
diff --git a/incubator/viewers/javafx/ui/src/main/java/org/apache/isis/incubator/viewer/javafx/ui/components/panel/TitledPanel.java b/incubator/viewers/javafx/ui/src/main/java/org/apache/isis/incubator/viewer/javafx/ui/components/panel/TitledPanel.java
new file mode 100644
index 0000000..5872073
--- /dev/null
+++ b/incubator/viewers/javafx/ui/src/main/java/org/apache/isis/incubator/viewer/javafx/ui/components/panel/TitledPanel.java
@@ -0,0 +1,57 @@
+/*
+ * 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.panel;
+
+import org.apache.isis.incubator.viewer.javafx.model.util._fx;
+
+import lombok.Getter;
+
+import javafx.scene.control.Label;
+import javafx.scene.layout.Border;
+import javafx.scene.layout.BorderStroke;
+import javafx.scene.layout.BorderStrokeStyle;
+import javafx.scene.layout.BorderWidths;
+import javafx.scene.layout.CornerRadii;
+import javafx.scene.layout.HBox;
+import javafx.scene.layout.VBox;
+import javafx.scene.paint.Color;
+
+@Getter
+public class TitledPanel extends VBox {
+
+ private final Label uiLabel = new Label();
+ private final HBox uiActionBar = new HBox();
+
+ public TitledPanel(String label) {
+ super();
+ _fx.add(this, uiActionBar);
+ _fx.add(uiActionBar, uiLabel);
+ uiLabel.setText(label);
+ _fx.h3(uiLabel);
+ _fx.toolbarLayout(uiActionBar);
+
+ setBorder(new Border(new BorderStroke(
+ Color.ORANGE,
+ BorderStrokeStyle.DASHED,
+ new CornerRadii(3),
+ new BorderWidths(1))));
+
+ }
+
+}
diff --git a/viewers/common/src/main/java/org/apache/isis/viewer/common/model/gridlayout/UiGridLayout.java b/viewers/common/src/main/java/org/apache/isis/viewer/common/model/gridlayout/UiGridLayout.java
index 0ca3f96..b3536e7 100644
--- a/viewers/common/src/main/java/org/apache/isis/viewer/common/model/gridlayout/UiGridLayout.java
+++ b/viewers/common/src/main/java/org/apache/isis/viewer/common/model/gridlayout/UiGridLayout.java
@@ -134,7 +134,7 @@ public class UiGridLayout {
}
for(val collectionData : bS3Col.getCollections()) {
- visitor.onCollection(uiCol, collectionData);
+ visitor.onCollection(uiCol, collectionData);
}
}
@@ -156,7 +156,7 @@ public class UiGridLayout {
private <C, T> void visitFieldSet(FieldSet cptFieldSet, C container, Visitor<C, T> visitor) {
val uiFieldSet = visitor.newFieldSet(container, cptFieldSet);
for(val propertyData: cptFieldSet.getProperties()) {
- visitor.onProperty(uiFieldSet, propertyData);
+ visitor.onProperty(uiFieldSet, propertyData);
}
}