This is an automated email from the ASF dual-hosted git repository. danhaywood pushed a commit to branch ISIS-2222 in repository https://gitbox.apache.org/repos/asf/isis.git
commit b3dea47fa5196b23da03fb2df27e55bea774078a Author: danhaywood <[email protected]> AuthorDate: Sun Aug 9 15:31:10 2020 +0100 ISIS-2222: wip @Action#hidden 24/46 --- .../demoapp/dom/annotDomain/Action/ActionMenu.java | 9 +- .../ActionDomainEventVm-description.adoc | 4 +- .../demoapp/dom/annotDomain/Action/hidden/.gitkeep | 0 .../Action/hidden/ActionHiddenVm-description.adoc | 25 ++++ .../annotDomain/Action/hidden/ActionHiddenVm.java | 159 +++++++++++++++++++++ .../Action/hidden/ActionHiddenVm.layout.xml | 50 +++++++ ...onHiddenVm_mixinUpdateTextAndHiddenNowhere.java | 53 +++++++ ...iddenVm_mixinUpdateTextButHiddenEverywhere.java | 53 +++++++ ...ddenVm_mixinUpdateTextButHiddenObjectForms.java | 53 +++++++ ...ActionHiddenVm_mixinUpdateTextNoAnnotation.java | 53 +++++++ .../src/main/java/demoapp/dom/menubars.layout.xml | 1 + 11 files changed, 457 insertions(+), 3 deletions(-) diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/ActionMenu.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/ActionMenu.java index b3884aa..453d6e8 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/ActionMenu.java +++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/ActionMenu.java @@ -36,6 +36,7 @@ import demoapp.dom._infra.samples.NameSamples; import demoapp.dom.annotDomain.Action.associateWith.ActionAssociateWithVm; import demoapp.dom.annotDomain.Action.associateWith.child.ActionAssociateWithChildVm; import demoapp.dom.annotDomain.Action.domainEvent.ActionDomainEventVm; +import demoapp.dom.annotDomain.Action.hidden.ActionHiddenVm; import demoapp.dom.annotDomain.Action.typeOf.ActionTypeOfVm; import demoapp.dom.annotDomain.Action.typeOf.child.ActionTypeOfChildVm; import demoapp.dom.types.Samples; @@ -65,7 +66,13 @@ public class ActionMenu { @Action(semantics = SemanticsOf.SAFE) @ActionLayout(cssClassFa="fa-asterisk", describedAs = "Decouples interaction of actions") public ActionDomainEventVm domainEvent(){ - return new ActionDomainEventVm("change me"); + return new ActionDomainEventVm("value"); + } + + @Action(semantics = SemanticsOf.SAFE) + @ActionLayout(cssClassFa="fa-glasses", describedAs = "Visibility of actions") + public ActionHiddenVm hidden(){ + return new ActionHiddenVm("value"); } @Action(semantics = SemanticsOf.SAFE) diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/domainEvent/ActionDomainEventVm-description.adoc b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/domainEvent/ActionDomainEventVm-description.adoc index 380ac57..71bb7cd 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/domainEvent/ActionDomainEventVm-description.adoc +++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/domainEvent/ActionDomainEventVm-description.adoc @@ -22,7 +22,7 @@ The fallback domain event can be suppressed using the `isis.applib.annotation.ac The demo defines two actions that are annotated using `domainEvent` semantic: -* in the `ActionDomainEventVm` is a regular action, "updateText": +* in the `ActionHiddenVm` is a regular action, "updateText": + [source,java] ---- @@ -31,7 +31,7 @@ include::ActionDomainEventVm.java[tags=class] <.> the event class to emit; genericised by the target type <.> indicates that the framework should emit this type -* The `ActionDomainEventVm_mixinUpdateText` defines a mixin action, also annotated: +* The `ActionHiddenVm_mixinUpdateTextNoAnnotation` defines a mixin action, also annotated: + [source,java] ---- diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/hidden/.gitkeep b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/hidden/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/hidden/ActionHiddenVm-description.adoc b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/hidden/ActionHiddenVm-description.adoc new file mode 100644 index 0000000..7c93c9c --- /dev/null +++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/hidden/ActionHiddenVm-description.adoc @@ -0,0 +1,25 @@ +The `hidden` semantic specifies whether the action should be visible in the UI or not. + + +[source,java] +---- +include::ActionHiddenVm.java[tags=class] +---- + +Three actions: + +* `updateTextNoAnnotation` does not specify whether it is hidden or not. +The fallback is that actions are not hidden: ++ +[source,java] +---- +include::ActionHiddenVm.java[tags=action-no-annotation] +---- + +* `updateTextAndHiddenNowhere` action is explicitly annotated as not hidden: ++ +[source,java] +---- +include::ActionHiddenVm.java[tags=action-hidden-nowhere] +---- + diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/hidden/ActionHiddenVm.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/hidden/ActionHiddenVm.java new file mode 100644 index 0000000..4187d40 --- /dev/null +++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/hidden/ActionHiddenVm.java @@ -0,0 +1,159 @@ +/* + * 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 demoapp.dom.annotDomain.Action.hidden; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +import org.apache.isis.applib.annotation.Action; +import org.apache.isis.applib.annotation.ActionLayout; +import org.apache.isis.applib.annotation.DomainObject; +import org.apache.isis.applib.annotation.MemberOrder; +import org.apache.isis.applib.annotation.Nature; +import org.apache.isis.applib.annotation.Property; +import org.apache.isis.applib.annotation.SemanticsOf; +import org.apache.isis.applib.annotation.Where; +import org.apache.isis.applib.events.domain.ActionDomainEvent; + +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import demoapp.dom._infra.asciidocdesc.HasAsciiDocDescription; + +@XmlRootElement(name = "root") +@XmlType +@XmlAccessorType(XmlAccessType.FIELD) +@DomainObject( + nature=Nature.VIEW_MODEL, + objectType = "demo.ActionHiddenVm" +) +@NoArgsConstructor +//tag::class[] +public class ActionHiddenVm implements HasAsciiDocDescription { + // ... +//end::class[] + + public ActionHiddenVm(String value) { + this.text = value; + this.otherText = value; + } + + public String title() { + return "Action#hidden"; + } + + @Property() + @MemberOrder(name = "properties", sequence = "1") + @XmlElement(required = true) + @Getter @Setter + private String text; + + @Property() + @MemberOrder(name = "properties", sequence = "2") + @XmlElement(required = true) + @Getter @Setter + private String otherText; + +//tag::action-no-annotation[] + @Action( + semantics = SemanticsOf.IDEMPOTENT + , associateWith = "text" + , associateWithSequence = "1" + // no hidden attribute // <.> + ) + @ActionLayout( + describedAs = + "@Action()" + ) + public ActionHiddenVm updateTextNoAnnotation(final String text) { + setText(text); + return this; + } + public String default0UpdateTextNoAnnotation() { + return getText(); + } +//end::action-no-annotation[] + +//tag::action-hidden-nowhere[] + @Action( + semantics = SemanticsOf.IDEMPOTENT + , associateWith = "text" + , associateWithSequence = "2" + , hidden = Where.NOWHERE // <.> + ) + @ActionLayout( + describedAs = + "@Action(hidden = Where.OBJECT_FORMS)" + ) + public ActionHiddenVm updateTextAndHiddenNowhere(final String text) { + setText(text); + return this; + } + public String default0UpdateTextAndHiddenNowhere() { + return getText(); + } +//end::action-hidden-nowhere[] + +//tag::action-but-hidden-on-forms[] + @Action( + semantics = SemanticsOf.IDEMPOTENT + , associateWith = "text" + , associateWithSequence = "3" + , hidden = Where.OBJECT_FORMS // <.> + ) + @ActionLayout( + describedAs = + "@Action(hidden = Where.OBJECT_FORMS)" + ) + public ActionHiddenVm updateTextButHiddenOnForms(final String text) { + setText(text); + return this; + } + public String default0UpdateTextButHiddenOnForms() { + return getText(); + } +//end::action-but-hidden-on-forms[] + +//tag::action-but-hidden-everywhere[] + @Action( + semantics = SemanticsOf.IDEMPOTENT + , associateWith = "text" + , associateWithSequence = "4" + , hidden = Where.EVERYWHERE // <.> + ) + @ActionLayout( + describedAs = + "@Action(hidden = Where.OBJECT_FORMS)" + ) + public ActionHiddenVm updateTextButHiddenEverywhere(final String text) { + setText(text); + return this; + } + public String default0UpdateTextButHiddenEverywhere() { + return getText(); + } +//end::action-but-hidden-everywhere[] + +//tag::class[] +} +//end::class[] diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/hidden/ActionHiddenVm.layout.xml b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/hidden/ActionHiddenVm.layout.xml new file mode 100644 index 0000000..4b31324 --- /dev/null +++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/hidden/ActionHiddenVm.layout.xml @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<bs3:grid + xsi:schemaLocation="http://isis.apache.org/applib/layout/component http://isis.apache.org/applib/layout/component/component.xsd http://isis.apache.org/applib/layout/grid/bootstrap3 http://isis.apache.org/applib/layout/grid/bootstrap3/bootstrap3.xsd" + xmlns:bs3="http://isis.apache.org/applib/layout/grid/bootstrap3" + xmlns:cpt="http://isis.apache.org/applib/layout/component" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + + <bs3:row> + <bs3:col span="10" unreferencedActions="true"> + <cpt:domainObject /> + <cpt:action id="rebuildMetamodel"/> + </bs3:col> + <bs3:col span="2"> + <cpt:fieldSet name="" id="sources" /> + </bs3:col> + </bs3:row> + + <bs3:row> + <bs3:col span="6"> + <bs3:row> + <bs3:col span="12"> + <cpt:fieldSet name="Properties" id="properties"/> + <cpt:fieldSet name="Contributed" id="contributed"/> + <cpt:fieldSet name="Other" id="other" unreferencedProperties="true"/> + </bs3:col> + </bs3:row> + <bs3:row> + <bs3:col span="12"> + <cpt:collection id="events"/> + </bs3:col> + </bs3:row> + </bs3:col> + <bs3:col span="6"> + <cpt:fieldSet name="Description" id="description" > + <cpt:action id="clearHints" position="PANEL" /> + <cpt:action id="downloadLayoutXml" position="PANEL_DROPDOWN"/> + <cpt:action id="rebuildMetamodel" position="PANEL_DROPDOWN"/> + <cpt:action id="downloadMetamodelXml" position="PANEL_DROPDOWN"/> + <cpt:action id="inspectMetamodel" position="PANEL_DROPDOWN"/> + <cpt:action id="downloadJdoMetadata" position="PANEL_DROPDOWN"/> + <cpt:action id="openRestApi" position="PANEL_DROPDOWN" /> + <cpt:property id="description"/> + </cpt:fieldSet> + </bs3:col> + </bs3:row> + <bs3:row> + <bs3:col span="12" unreferencedCollections="true"/> + </bs3:row> + +</bs3:grid> diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/hidden/ActionHiddenVm_mixinUpdateTextAndHiddenNowhere.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/hidden/ActionHiddenVm_mixinUpdateTextAndHiddenNowhere.java new file mode 100644 index 0000000..34749ac --- /dev/null +++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/hidden/ActionHiddenVm_mixinUpdateTextAndHiddenNowhere.java @@ -0,0 +1,53 @@ +/* + * 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 demoapp.dom.annotDomain.Action.hidden; + +import org.apache.isis.applib.annotation.Action; +import org.apache.isis.applib.annotation.ActionLayout; +import org.apache.isis.applib.annotation.SemanticsOf; +import org.apache.isis.applib.annotation.Where; + +import lombok.RequiredArgsConstructor; + + +//tag::class[] +@Action( + semantics = SemanticsOf.SAFE + , associateWith = "otherText" + , associateWithSequence = "2" + , hidden = Where.NOWHERE // <.> +) +@ActionLayout( + describedAs = + "@Action(hidden = Where.NOWHERE)" +) +@RequiredArgsConstructor +public class ActionHiddenVm_mixinUpdateTextAndHiddenNowhere { + + private final ActionHiddenVm actionHiddenVm; + + public ActionHiddenVm act(final String text) { + actionHiddenVm.setOtherText(text); + return actionHiddenVm; + } + public String default0Act() { + return actionHiddenVm.getOtherText(); + } +} +//end::class[] diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/hidden/ActionHiddenVm_mixinUpdateTextButHiddenEverywhere.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/hidden/ActionHiddenVm_mixinUpdateTextButHiddenEverywhere.java new file mode 100644 index 0000000..0e0486e --- /dev/null +++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/hidden/ActionHiddenVm_mixinUpdateTextButHiddenEverywhere.java @@ -0,0 +1,53 @@ +/* + * 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 demoapp.dom.annotDomain.Action.hidden; + +import org.apache.isis.applib.annotation.Action; +import org.apache.isis.applib.annotation.ActionLayout; +import org.apache.isis.applib.annotation.SemanticsOf; +import org.apache.isis.applib.annotation.Where; + +import lombok.RequiredArgsConstructor; + + +//tag::class[] +@Action( + semantics = SemanticsOf.SAFE + , associateWith = "otherText" + , associateWithSequence = "4" + , hidden = Where.EVERYWHERE // <.> +) +@ActionLayout( + describedAs = + "@Action(hidden = Where.EVERYWHERE)" +) +@RequiredArgsConstructor +public class ActionHiddenVm_mixinUpdateTextButHiddenEverywhere { + + private final ActionHiddenVm actionHiddenVm; + + public ActionHiddenVm act(final String text) { + actionHiddenVm.setOtherText(text); + return actionHiddenVm; + } + public String default0Act() { + return actionHiddenVm.getOtherText(); + } +} +//end::class[] diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/hidden/ActionHiddenVm_mixinUpdateTextButHiddenObjectForms.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/hidden/ActionHiddenVm_mixinUpdateTextButHiddenObjectForms.java new file mode 100644 index 0000000..39458ad --- /dev/null +++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/hidden/ActionHiddenVm_mixinUpdateTextButHiddenObjectForms.java @@ -0,0 +1,53 @@ +/* + * 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 demoapp.dom.annotDomain.Action.hidden; + +import org.apache.isis.applib.annotation.Action; +import org.apache.isis.applib.annotation.ActionLayout; +import org.apache.isis.applib.annotation.SemanticsOf; +import org.apache.isis.applib.annotation.Where; + +import lombok.RequiredArgsConstructor; + + +//tag::class[] +@Action( + semantics = SemanticsOf.SAFE + , associateWith = "otherText" + , associateWithSequence = "3" + , hidden = Where.OBJECT_FORMS // <.> +) +@ActionLayout( + describedAs = + "@Action(hidden = Where.OBJECT_FORMS)" +) +@RequiredArgsConstructor +public class ActionHiddenVm_mixinUpdateTextButHiddenObjectForms { + + private final ActionHiddenVm actionHiddenVm; + + public ActionHiddenVm act(final String text) { + actionHiddenVm.setOtherText(text); + return actionHiddenVm; + } + public String default0Act() { + return actionHiddenVm.getOtherText(); + } +} +//end::class[] diff --git a/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/hidden/ActionHiddenVm_mixinUpdateTextNoAnnotation.java b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/hidden/ActionHiddenVm_mixinUpdateTextNoAnnotation.java new file mode 100644 index 0000000..1eabb01 --- /dev/null +++ b/examples/demo/domain/src/main/java/demoapp/dom/annotDomain/Action/hidden/ActionHiddenVm_mixinUpdateTextNoAnnotation.java @@ -0,0 +1,53 @@ +/* + * 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 demoapp.dom.annotDomain.Action.hidden; + +import org.apache.isis.applib.annotation.Action; +import org.apache.isis.applib.annotation.ActionLayout; +import org.apache.isis.applib.annotation.SemanticsOf; +import org.apache.isis.applib.events.domain.ActionDomainEvent; + +import lombok.RequiredArgsConstructor; + + +//tag::class[] +@Action( + semantics = SemanticsOf.SAFE + , associateWith = "otherText" + , associateWithSequence = "1" + // no hidden attribute // <.> +) +@ActionLayout( + describedAs = + "@Action()" +) +@RequiredArgsConstructor +public class ActionHiddenVm_mixinUpdateTextNoAnnotation { + + private final ActionHiddenVm actionHiddenVm; + + public ActionHiddenVm act(final String text) { + actionHiddenVm.setOtherText(text); + return actionHiddenVm; + } + public String default0Act() { + return actionHiddenVm.getOtherText(); + } +} +//end::class[] diff --git a/examples/demo/domain/src/main/java/demoapp/dom/menubars.layout.xml b/examples/demo/domain/src/main/java/demoapp/dom/menubars.layout.xml index d041e7f..db3a222 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/menubars.layout.xml +++ b/examples/demo/domain/src/main/java/demoapp/dom/menubars.layout.xml @@ -110,6 +110,7 @@ as a replacement for <mb3:named>@Action</mb3:named> <mb3:serviceAction objectType="demo.ActionMenu" id="associateWith"/> <mb3:serviceAction objectType="demo.ActionMenu" id="domainEvent"/> + <mb3:serviceAction objectType="demo.ActionMenu" id="hidden"/> <mb3:serviceAction objectType="demo.ActionMenu" id="typeOf"/> </mb3:section> <mb3:section>
