You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2017/10/25 16:48:09 UTC

[isis] branch master updated (19a47a8 -> bc5fdbe)

This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git.


    from 19a47a8  Merge branch 'ISIS-1752-menu-layout-resource'
     new d70337f  ISIS-1752: factors out MenuBarsService, refactors Wicket UI to use MenuBarsService.
     new 1360bc3  ISIS-1752: deletes unused methods in ServiceActionUtil (now within MenuBarsServiceDefault).
     new 0b7f445  ISIS-1572: adds outline docs for MenuBarsService
     new bc5fdbe  ISIS-1752: fixes unit test

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../_rgsvc_presentation-layer-spi_GridService.adoc |  35 +++-
 ...vc_presentation-layer-spi_MenuBarsService.adoc} |  40 ++--
 .../apache/isis/applib/layout/menus/MenuBars.java  |  16 ++
 .../isis/applib/services/menu/MenuBarsService.java |   9 +
 .../services/menu/MenuBarsServiceDefault.java}     |  86 +++-----
 .../runtime/services/menu/ServiceAndAction.java    |  27 +++
 .../resources/MenuBarsResourceServerside.java      | 218 +-------------------
 .../serviceactions/ServiceActionUtil.java          | 228 +++++++--------------
 .../serviceactions/ServiceActionsPanelFactory.java |  20 +-
 .../serviceactions/TertiaryActionsPanel.html       |  12 ++
 .../serviceactions/TertiaryMenuPanelFactory.java   |  20 +-
 11 files changed, 254 insertions(+), 457 deletions(-)
 copy adocs/documentation/src/main/asciidoc/guides/{rgant/_rgant-Action_typeOf.adoc => rgsvc/_rgsvc_presentation-layer-spi_MenuBarsService.adoc} (51%)
 create mode 100644 core/applib/src/main/java/org/apache/isis/applib/services/menu/MenuBarsService.java
 copy core/{viewer-restfulobjects-server/src/main/java/org/apache/isis/viewer/restfulobjects/server/resources/MenuBarsResourceServerside.java => runtime/src/main/java/org/apache/isis/core/runtime/services/menu/MenuBarsServiceDefault.java} (75%)
 create mode 100644 core/runtime/src/main/java/org/apache/isis/core/runtime/services/menu/ServiceAndAction.java

-- 
To stop receiving notification emails like this one, please contact
['"commits@isis.apache.org" <co...@isis.apache.org>'].

[isis] 01/04: ISIS-1752: factors out MenuBarsService, refactors Wicket UI to use MenuBarsService.

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git

commit d70337f97c1cfd347ea7515d58b736651d4ff74e
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Wed Oct 25 17:23:15 2017 +0100

    ISIS-1752: factors out MenuBarsService, refactors Wicket UI to use MenuBarsService.
---
 .../apache/isis/applib/layout/menus/MenuBars.java  |  17 ++
 .../isis/applib/services/menu/MenuBarsService.java |   9 +
 .../services/menu/MenuBarsServiceDefault.java}     |  86 +++-----
 .../runtime/services/menu/ServiceAndAction.java    |  27 +++
 .../resources/MenuBarsResourceServerside.java      | 218 +--------------------
 .../serviceactions/ServiceActionUtil.java          | 102 +++++++---
 .../serviceactions/ServiceActionsPanelFactory.java |  20 +-
 .../serviceactions/TertiaryMenuPanelFactory.java   |  20 +-
 8 files changed, 193 insertions(+), 306 deletions(-)

diff --git a/core/applib/src/main/java/org/apache/isis/applib/layout/menus/MenuBars.java b/core/applib/src/main/java/org/apache/isis/applib/layout/menus/MenuBars.java
index 591fc44..1fe0147 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/layout/menus/MenuBars.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/layout/menus/MenuBars.java
@@ -22,8 +22,11 @@ import java.io.Serializable;
 
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
 import javax.xml.bind.annotation.XmlType;
 
+import org.apache.isis.applib.annotation.DomainServiceLayout;
+
 /**
  * Describes the collection of domain services into menubars, broadly corresponding to the aggregation of information within {@link org.apache.isis.applib.annotation.DomainServiceLayout}.
  */
@@ -93,4 +96,18 @@ public class MenuBars implements Serializable {
     }
 
 
+
+    @XmlTransient
+    public MenuBar menuBarFor(final DomainServiceLayout.MenuBar menuBar) {
+        switch (menuBar) {
+        case PRIMARY:
+            return getPrimary();
+        case SECONDARY:
+            return getSecondary();
+        case TERTIARY:
+            return getTertiary();
+        }
+        return null;
+    }
+
 }
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/menu/MenuBarsService.java b/core/applib/src/main/java/org/apache/isis/applib/services/menu/MenuBarsService.java
new file mode 100644
index 0000000..5bd0e81
--- /dev/null
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/menu/MenuBarsService.java
@@ -0,0 +1,9 @@
+package org.apache.isis.applib.services.menu;
+
+import org.apache.isis.applib.annotation.Programmatic;
+import org.apache.isis.applib.layout.menus.MenuBars;
+
+public interface MenuBarsService {
+    @Programmatic
+    MenuBars menuBars();
+}
diff --git a/core/viewer-restfulobjects-server/src/main/java/org/apache/isis/viewer/restfulobjects/server/resources/MenuBarsResourceServerside.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/menu/MenuBarsServiceDefault.java
similarity index 75%
copy from core/viewer-restfulobjects-server/src/main/java/org/apache/isis/viewer/restfulobjects/server/resources/MenuBarsResourceServerside.java
copy to core/runtime/src/main/java/org/apache/isis/core/runtime/services/menu/MenuBarsServiceDefault.java
index f930875..684b365 100644
--- a/core/viewer-restfulobjects-server/src/main/java/org/apache/isis/viewer/restfulobjects/server/resources/MenuBarsResourceServerside.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/menu/MenuBarsServiceDefault.java
@@ -16,15 +16,13 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.apache.isis.viewer.restfulobjects.server.resources;
+package org.apache.isis.core.runtime.services.menu;
 
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
+import javax.inject.Inject;
 
 import com.google.common.base.Predicate;
 import com.google.common.base.Strings;
@@ -33,15 +31,17 @@ import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
 
+import org.apache.isis.applib.annotation.DomainService;
 import org.apache.isis.applib.annotation.DomainServiceLayout;
 import org.apache.isis.applib.annotation.NatureOfService;
-import org.apache.isis.applib.annotation.Where;
+import org.apache.isis.applib.annotation.Programmatic;
 import org.apache.isis.applib.filter.Filters;
 import org.apache.isis.applib.layout.menus.ActionLayoutData;
 import org.apache.isis.applib.layout.menus.Menu;
 import org.apache.isis.applib.layout.menus.MenuBar;
 import org.apache.isis.applib.layout.menus.MenuBars;
 import org.apache.isis.applib.layout.menus.MenuSection;
+import org.apache.isis.applib.services.menu.MenuBarsService;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.facets.actions.notinservicemenu.NotInServiceMenuFacet;
 import org.apache.isis.core.metamodel.facets.all.named.NamedFacet;
@@ -52,33 +52,31 @@ import org.apache.isis.core.metamodel.spec.ActionType;
 import org.apache.isis.core.metamodel.spec.ObjectSpecification;
 import org.apache.isis.core.metamodel.spec.feature.Contributed;
 import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
-import org.apache.isis.viewer.restfulobjects.applib.RepresentationType;
-import org.apache.isis.viewer.restfulobjects.applib.RestfulMediaType;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
-import org.apache.isis.viewer.restfulobjects.applib.menubars.MenuBarsResource;
-import org.apache.isis.viewer.restfulobjects.rendering.RestfulObjectsApplicationException;
-import org.apache.isis.viewer.restfulobjects.rendering.service.RepresentationService;
+import org.apache.isis.core.runtime.system.session.IsisSessionFactory;
 
-public class MenuBarsResourceServerside extends ResourceAbstract implements MenuBarsResource {
+@DomainService(nature = NatureOfService.DOMAIN)
+public class MenuBarsServiceDefault implements MenuBarsService {
 
-    @Override
-    @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_USER })
-    public Response menuBars() {
-        init(RepresentationType.MENUBARS, Where.ANYWHERE, RepresentationService.Intent.NOT_APPLICABLE);
+    MenuBars menuBars;
 
-        final Response.ResponseBuilder builder;
+    @Override @Programmatic
+    public MenuBars menuBars() {
 
-        MenuBars menuBars = new MenuBars();
+        if(menuBars == null) {
 
-        List<ObjectAdapter> serviceAdapters = getResourceContext().getServiceAdapters();
+            MenuBars menuBars = new MenuBars();
 
-        append(serviceAdapters, menuBars.getPrimary(), DomainServiceLayout.MenuBar.PRIMARY);
-        append(serviceAdapters, menuBars.getSecondary(), DomainServiceLayout.MenuBar.SECONDARY);
-        append(serviceAdapters, menuBars.getTertiary(), DomainServiceLayout.MenuBar.TERTIARY);
+            final List<ObjectAdapter> serviceAdapters =
+                    isisSessionFactory.getCurrentSession().getPersistenceSession().getServices();
 
-        builder = Response.status(Response.Status.OK).entity(menuBars).type(RepresentationType.MENUBARS.getXmlMediaType());
+            append(serviceAdapters, menuBars.getPrimary(), DomainServiceLayout.MenuBar.PRIMARY);
+            append(serviceAdapters, menuBars.getSecondary(), DomainServiceLayout.MenuBar.SECONDARY);
+            append(serviceAdapters, menuBars.getTertiary(), DomainServiceLayout.MenuBar.TERTIARY);
 
-        return builder.build();
+            this.menuBars = menuBars;
+        }
+
+        return menuBars;
     }
 
     private void append(
@@ -239,45 +237,9 @@ public class MenuBarsResourceServerside extends ResourceAbstract implements Menu
         };
     }
 
-    @Override
-    public Response deleteMenuBarsNotAllowed() {
-        throw RestfulObjectsApplicationException.createWithMessage(RestfulResponse.HttpStatusCode.METHOD_NOT_ALLOWED, "Deleting the menuBars resource is not allowed.");
-
-    }
-
-    @Override
-    public Response putMenuBarsNotAllowed() {
-        throw RestfulObjectsApplicationException.createWithMessage(RestfulResponse.HttpStatusCode.METHOD_NOT_ALLOWED, "Putting to the menuBars resource is not allowed.");
-
-    }
-
-    @Override
-    public Response postMenuBarsNotAllowed() {
-        throw RestfulObjectsApplicationException.createWithMessage(RestfulResponse.HttpStatusCode.METHOD_NOT_ALLOWED, "Posting to the menuBars resource is not allowed.");
-    }
+    @Inject
+    IsisSessionFactory isisSessionFactory;
 
 
 }
 
-class ServiceAndAction {
-    final String serviceName;
-    final ObjectAdapter serviceAdapter;
-    final ObjectAction objectAction;
-
-    public boolean separator;
-
-    ServiceAndAction(
-            final String serviceName,
-            final ObjectAdapter serviceAdapter,
-            final ObjectAction objectAction) {
-        this.serviceName = serviceName;
-        this.serviceAdapter = serviceAdapter;
-        this.objectAction = objectAction;
-    }
-
-    @Override
-    public String toString() {
-        return serviceName + " ~ " + objectAction.getIdentifier().toFullIdentityString();
-    }
-
-}
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/menu/ServiceAndAction.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/menu/ServiceAndAction.java
new file mode 100644
index 0000000..ca41c17
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/menu/ServiceAndAction.java
@@ -0,0 +1,27 @@
+package org.apache.isis.core.runtime.services.menu;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
+
+class ServiceAndAction {
+    final String serviceName;
+    final ObjectAdapter serviceAdapter;
+    final ObjectAction objectAction;
+
+    public boolean separator;
+
+    ServiceAndAction(
+            final String serviceName,
+            final ObjectAdapter serviceAdapter,
+            final ObjectAction objectAction) {
+        this.serviceName = serviceName;
+        this.serviceAdapter = serviceAdapter;
+        this.objectAction = objectAction;
+    }
+
+    @Override
+    public String toString() {
+        return serviceName + " ~ " + objectAction.getIdentifier().toFullIdentityString();
+    }
+
+}
diff --git a/core/viewer-restfulobjects-server/src/main/java/org/apache/isis/viewer/restfulobjects/server/resources/MenuBarsResourceServerside.java b/core/viewer-restfulobjects-server/src/main/java/org/apache/isis/viewer/restfulobjects/server/resources/MenuBarsResourceServerside.java
index f930875..23f224f 100644
--- a/core/viewer-restfulobjects-server/src/main/java/org/apache/isis/viewer/restfulobjects/server/resources/MenuBarsResourceServerside.java
+++ b/core/viewer-restfulobjects-server/src/main/java/org/apache/isis/viewer/restfulobjects/server/resources/MenuBarsResourceServerside.java
@@ -18,40 +18,13 @@
  */
 package org.apache.isis.viewer.restfulobjects.server.resources;
 
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 
-import com.google.common.base.Predicate;
-import com.google.common.base.Strings;
-import com.google.common.collect.FluentIterable;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-
-import org.apache.isis.applib.annotation.DomainServiceLayout;
-import org.apache.isis.applib.annotation.NatureOfService;
 import org.apache.isis.applib.annotation.Where;
-import org.apache.isis.applib.filter.Filters;
-import org.apache.isis.applib.layout.menus.ActionLayoutData;
-import org.apache.isis.applib.layout.menus.Menu;
-import org.apache.isis.applib.layout.menus.MenuBar;
 import org.apache.isis.applib.layout.menus.MenuBars;
-import org.apache.isis.applib.layout.menus.MenuSection;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facets.actions.notinservicemenu.NotInServiceMenuFacet;
-import org.apache.isis.core.metamodel.facets.all.named.NamedFacet;
-import org.apache.isis.core.metamodel.facets.members.order.MemberOrderFacet;
-import org.apache.isis.core.metamodel.facets.object.domainservice.DomainServiceFacet;
-import org.apache.isis.core.metamodel.facets.object.domainservicelayout.DomainServiceLayoutFacet;
-import org.apache.isis.core.metamodel.spec.ActionType;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.Contributed;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
+import org.apache.isis.applib.services.menu.MenuBarsService;
 import org.apache.isis.viewer.restfulobjects.applib.RepresentationType;
 import org.apache.isis.viewer.restfulobjects.applib.RestfulMediaType;
 import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
@@ -68,176 +41,16 @@ public class MenuBarsResourceServerside extends ResourceAbstract implements Menu
 
         final Response.ResponseBuilder builder;
 
-        MenuBars menuBars = new MenuBars();
-
-        List<ObjectAdapter> serviceAdapters = getResourceContext().getServiceAdapters();
+        final MenuBarsService menuBarsService =
+                getResourceContext().getServicesInjector().lookupService(MenuBarsService.class);
 
-        append(serviceAdapters, menuBars.getPrimary(), DomainServiceLayout.MenuBar.PRIMARY);
-        append(serviceAdapters, menuBars.getSecondary(), DomainServiceLayout.MenuBar.SECONDARY);
-        append(serviceAdapters, menuBars.getTertiary(), DomainServiceLayout.MenuBar.TERTIARY);
+        final MenuBars menuBars = menuBarsService.menuBars();
 
         builder = Response.status(Response.Status.OK).entity(menuBars).type(RepresentationType.MENUBARS.getXmlMediaType());
 
         return builder.build();
     }
 
-    private void append(
-            final List<ObjectAdapter> serviceAdapters,
-            final MenuBar menuBar,
-            final DomainServiceLayout.MenuBar menuBarPos) {
-
-        List<ServiceAndAction> serviceActions = Lists.newArrayList();
-
-        // cf ServiceActionsModel & ServiceActionUtil#buildMenu in Wicket viewer
-        for (final ObjectAdapter serviceAdapter : FluentIterable.from(serviceAdapters).filter(with(menuBarPos))) {
-            collateServiceActions(serviceAdapter, ActionType.USER, serviceActions);
-            collateServiceActions(serviceAdapter, ActionType.PROTOTYPE, serviceActions);
-        }
-
-        final Set<String> serviceNamesInOrder = serviceNamesInOrder(serviceAdapters, serviceActions);
-        final Map<String, List<ServiceAndAction>> serviceActionsByName = groupByServiceName(serviceActions);
-
-        // prune any service names that have no service actions
-        serviceNamesInOrder.retainAll(serviceActionsByName.keySet());
-
-        List<Menu> menus = buildMenuItems(serviceNamesInOrder, serviceActionsByName);
-        menuBar.getMenus().addAll(menus);
-    }
-
-    private static List<Menu> buildMenuItems(
-            final Set<String> serviceNamesInOrder,
-            final Map<String, List<ServiceAndAction>> serviceActionsByName) {
-
-        final List<Menu> menus = Lists.newArrayList();
-        for (String serviceName : serviceNamesInOrder) {
-
-            Menu menu = new Menu(serviceName);
-            menus.add(menu);
-
-            MenuSection menuSection = new MenuSection();
-            final List<ServiceAndAction> serviceActionsForName = serviceActionsByName.get(serviceName);
-            for (ServiceAndAction serviceAndAction : serviceActionsForName) {
-
-                if(serviceAndAction.separator && !menuSection.getActions().isEmpty()) {
-                    menu.getSections().add(menuSection);
-                    menuSection = new MenuSection();
-                }
-
-                ObjectAction objectAction = serviceAndAction.objectAction;
-                final String serviceOid = serviceAndAction.serviceAdapter.getOid().enString();
-                ActionLayoutData action = new ActionLayoutData(serviceOid, objectAction.getId());
-                action.setNamed(objectAction.getName());
-                menuSection.getActions().add(action);
-            }
-            if(!menuSection.getActions().isEmpty()) {
-                menu.getSections().add(menuSection);
-            }
-        }
-        return menus;
-    }
-
-
-    /**
-     * The unique service names, as they appear in order of the provided List of {@link ServiceAndAction}s.
-     *
-     * straight copy from Wicket UI
-     */
-    private static Set<String> serviceNamesInOrder(
-            final List<ObjectAdapter> serviceAdapters,
-            final List<ServiceAndAction> serviceActions) {
-        final Set<String> serviceNameOrder = Sets.newLinkedHashSet();
-
-        // first, order as defined in isis.properties
-        for (ObjectAdapter serviceAdapter : serviceAdapters) {
-            final ObjectSpecification serviceSpec = serviceAdapter.getSpecification();
-            String serviceName = serviceSpec.getFacet(NamedFacet.class).value();
-            serviceNameOrder.add(serviceName);
-        }
-        // then, any other services (eg due to misspellings, at the end)
-        for (ServiceAndAction serviceAction : serviceActions) {
-            if(!serviceNameOrder.contains(serviceAction.serviceName)) {
-                serviceNameOrder.add(serviceAction.serviceName);
-            }
-        }
-        return serviceNameOrder;
-    }
-
-    /**
-     * Group the provided {@link ServiceAndAction}s by their service name.
-     *
-     * straight copy from Wicket UI
-     */
-    private static Map<String, List<ServiceAndAction>> groupByServiceName(
-            final List<ServiceAndAction> serviceActions) {
-        final Map<String, List<ServiceAndAction>> serviceActionsByName = Maps.newTreeMap();
-
-        // map available services
-        ObjectAdapter lastServiceAdapter = null;
-
-        for (ServiceAndAction serviceAction : serviceActions) {
-            List<ServiceAndAction> serviceActionsForName = serviceActionsByName.get(serviceAction.serviceName);
-
-            final ObjectAdapter serviceAdapter = serviceAction.serviceAdapter;
-
-            if(serviceActionsForName == null) {
-                serviceActionsForName = Lists.newArrayList();
-                serviceActionsByName.put(serviceAction.serviceName, serviceActionsForName);
-            } else {
-                // capture whether this action is from a different service; if so, add a separator before it
-                serviceAction.separator = lastServiceAdapter != serviceAdapter;
-            }
-            serviceActionsForName.add(serviceAction);
-            lastServiceAdapter = serviceAdapter;
-        }
-
-        return serviceActionsByName;
-    }
-
-
-    private void collateServiceActions(
-            final ObjectAdapter serviceAdapter,
-            final ActionType actionType,
-            final List<ServiceAndAction> serviceActions) {
-        final ObjectSpecification serviceSpec = serviceAdapter.getSpecification();
-
-        // skip if annotated to not be included in repository menu using @DomainService
-        final DomainServiceFacet domainServiceFacet = serviceSpec.getFacet(DomainServiceFacet.class);
-        if (domainServiceFacet != null) {
-            final NatureOfService natureOfService = domainServiceFacet.getNatureOfService();
-            if (natureOfService == NatureOfService.VIEW_REST_ONLY ||
-                    natureOfService == NatureOfService.VIEW_CONTRIBUTIONS_ONLY ||
-                    natureOfService == NatureOfService.DOMAIN) {
-                return;
-            }
-        }
-
-        for (final ObjectAction objectAction : serviceSpec.getObjectActions(
-                actionType, Contributed.INCLUDED, Filters.<ObjectAction>any())) {
-
-            // skip if annotated to not be included in repository menu using legacy mechanism
-            if (objectAction.getFacet(NotInServiceMenuFacet.class) != null) {
-                continue;
-            }
-
-            final MemberOrderFacet memberOrderFacet = objectAction.getFacet(MemberOrderFacet.class);
-            String serviceName = memberOrderFacet != null? memberOrderFacet.name(): null;
-            if(Strings.isNullOrEmpty(serviceName)){
-                serviceName = serviceSpec.getFacet(NamedFacet.class).value();
-            }
-            serviceActions.add(new ServiceAndAction(serviceName, serviceAdapter, objectAction));
-        }
-    }
-
-    private static Predicate<ObjectAdapter> with(final DomainServiceLayout.MenuBar menuBar) {
-        return new Predicate<ObjectAdapter>() {
-            @Override
-            public boolean apply(ObjectAdapter input) {
-                final DomainServiceLayoutFacet facet =
-                        input.getSpecification().getFacet(DomainServiceLayoutFacet.class);
-                return facet != null && facet.getMenuBar() == menuBar;
-            }
-        };
-    }
 
     @Override
     public Response deleteMenuBarsNotAllowed() {
@@ -256,28 +69,5 @@ public class MenuBarsResourceServerside extends ResourceAbstract implements Menu
         throw RestfulObjectsApplicationException.createWithMessage(RestfulResponse.HttpStatusCode.METHOD_NOT_ALLOWED, "Posting to the menuBars resource is not allowed.");
     }
 
-
 }
 
-class ServiceAndAction {
-    final String serviceName;
-    final ObjectAdapter serviceAdapter;
-    final ObjectAction objectAction;
-
-    public boolean separator;
-
-    ServiceAndAction(
-            final String serviceName,
-            final ObjectAdapter serviceAdapter,
-            final ObjectAction objectAction) {
-        this.serviceName = serviceName;
-        this.serviceAdapter = serviceAdapter;
-        this.objectAction = objectAction;
-    }
-
-    @Override
-    public String toString() {
-        return serviceName + " ~ " + objectAction.getIdentifier().toFullIdentityString();
-    }
-
-}
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/serviceactions/ServiceActionUtil.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/serviceactions/ServiceActionUtil.java
index 3f01ece..19df562 100644
--- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/serviceactions/ServiceActionUtil.java
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/serviceactions/ServiceActionUtil.java
@@ -19,13 +19,36 @@
 
 package org.apache.isis.viewer.wicket.ui.components.actionmenu.serviceactions;
 
-import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import com.google.common.base.Function;
+import com.google.common.base.Strings;
+import com.google.common.collect.FluentIterable;
+import com.google.common.collect.ImmutableBiMap;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+
+import org.apache.wicket.AttributeModifier;
+import org.apache.wicket.Component;
+import org.apache.wicket.MarkupContainer;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.link.AbstractLink;
+import org.apache.wicket.markup.html.list.ListItem;
+import org.apache.wicket.markup.html.list.ListView;
+import org.apache.wicket.markup.html.panel.Fragment;
+import org.apache.wicket.model.Model;
+
 import org.apache.isis.applib.annotation.NatureOfService;
 import org.apache.isis.applib.filter.Filters;
+import org.apache.isis.applib.layout.menus.ActionLayoutData;
+import org.apache.isis.applib.layout.menus.Menu;
+import org.apache.isis.applib.layout.menus.MenuBar;
+import org.apache.isis.applib.layout.menus.MenuBars;
+import org.apache.isis.applib.layout.menus.MenuSection;
 import org.apache.isis.applib.services.i18n.TranslationService;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
@@ -44,20 +67,6 @@ import org.apache.isis.viewer.wicket.model.models.EntityModel;
 import org.apache.isis.viewer.wicket.model.models.ServiceActionsModel;
 import org.apache.isis.viewer.wicket.ui.components.actionmenu.CssClassFaBehavior;
 import org.apache.isis.viewer.wicket.ui.util.CssClassAppender;
-import org.apache.wicket.AttributeModifier;
-import org.apache.wicket.Component;
-import org.apache.wicket.MarkupContainer;
-import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.markup.html.link.AbstractLink;
-import org.apache.wicket.markup.html.list.ListItem;
-import org.apache.wicket.markup.html.list.ListView;
-import org.apache.wicket.markup.html.panel.Fragment;
-import org.apache.wicket.model.Model;
-
-import com.google.common.base.Strings;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
 
 import de.agilecoders.wicket.core.markup.html.bootstrap.components.TooltipBehavior;
 import de.agilecoders.wicket.core.markup.html.bootstrap.components.TooltipConfig;
@@ -194,23 +203,60 @@ public final class ServiceActionUtil {
         folderItem.add(subMenuItemsView);
     }
 
-    public static List<CssMenuItem> buildMenu(final ServiceActionsModel appActionsModel) {
+    public static List<CssMenuItem> buildMenu(
+            final MenuBars menuBars,
+            final ServiceActionsModel serviceActionsModel) {
 
-        final List<ObjectAdapter> serviceAdapters = appActionsModel.getObject();
+        final MenuBar menuBar = menuBars.menuBarFor(serviceActionsModel.getMenuBar());
 
-        final List<ServiceAndAction> serviceActions = Lists.newArrayList();
-        for (final ObjectAdapter serviceAdapter : serviceAdapters) {
-            collateServiceActions(serviceAdapter, ActionType.USER, serviceActions);
-            collateServiceActions(serviceAdapter, ActionType.PROTOTYPE, serviceActions);
-        }
-        
-        final Set<String> serviceNamesInOrder = serviceNamesInOrder(serviceAdapters, serviceActions);
-        final Map<String, List<ServiceAndAction>> serviceActionsByName = groupByServiceName(serviceActions);
+        final List<ObjectAdapter> serviceAdapters = serviceActionsModel.getObject();
+        final ImmutableMap<ObjectAdapter, String> oidByServiceAdapter = FluentIterable.from(serviceAdapters)
+                .toMap(new Function<ObjectAdapter, String>() {
+                    @Override
+                    public String apply(final ObjectAdapter objectAdapter) {
+                        return objectAdapter.getOid().enStringNoVersion();
+                    }
+                });
+        final ImmutableBiMap<String, ObjectAdapter> serviceAdapterByOid = ImmutableBiMap
+                .copyOf(oidByServiceAdapter).inverse();
+
+        final List<CssMenuItem> menuItems = Lists.newArrayList();
+        for (final Menu menu : menuBar.getMenus()) {
 
-        // prune any service names that have no service actions
-        serviceNamesInOrder.retainAll(serviceActionsByName.keySet());
+            final CssMenuItem serviceMenu = CssMenuItem.newMenuItem(menu.getNamed()).build();
 
-        return buildMenuItems(serviceNamesInOrder, serviceActionsByName);
+
+            for (final MenuSection menuSection : menu.getSections()) {
+
+                boolean firstSection = true;
+
+                for (final ActionLayoutData actionLayoutData : menuSection.getActions()) {
+                    final String oid = actionLayoutData.getOid();
+                    final ObjectAdapter serviceAdapter = serviceAdapterByOid.get(oid);
+                    final EntityModel entityModel = new EntityModel(serviceAdapter);
+                    final ObjectAction objectAction = serviceAdapter.getSpecification()
+                            .getObjectAction(actionLayoutData.getId());
+                    final ServiceAndAction serviceAndAction =
+                            new ServiceAndAction(actionLayoutData.getNamed(), entityModel, objectAction);
+
+                    if(firstSection) {
+                        serviceAndAction.separator = true;
+                        firstSection = false;
+                    }
+
+                    final CssMenuItem.Builder subMenuItemBuilder = serviceMenu.newSubMenuItem(serviceAndAction);
+                    if (subMenuItemBuilder == null) {
+                        // either service or this action is not visible
+                        continue;
+                    }
+                    subMenuItemBuilder.build();
+                }
+            }
+            if (serviceMenu.hasSubMenuItems()) {
+                menuItems.add(serviceMenu);
+            }
+        }
+        return menuItems;
     }
 
     /**
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/serviceactions/ServiceActionsPanelFactory.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/serviceactions/ServiceActionsPanelFactory.java
index 43c255f..aaf373f 100644
--- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/serviceactions/ServiceActionsPanelFactory.java
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/serviceactions/ServiceActionsPanelFactory.java
@@ -19,9 +19,16 @@
 
 package org.apache.isis.viewer.wicket.ui.components.actionmenu.serviceactions;
 
+import java.util.List;
+
 import org.apache.wicket.Component;
 import org.apache.wicket.model.IModel;
+
 import org.apache.isis.applib.annotation.DomainServiceLayout;
+import org.apache.isis.applib.layout.menus.MenuBars;
+import org.apache.isis.applib.services.menu.MenuBarsService;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.core.runtime.system.session.IsisSessionFactory;
 import org.apache.isis.viewer.wicket.model.models.ServiceActionsModel;
 import org.apache.isis.viewer.wicket.ui.ComponentFactory;
 import org.apache.isis.viewer.wicket.ui.ComponentFactoryAbstract;
@@ -55,7 +62,18 @@ public class ServiceActionsPanelFactory extends ComponentFactoryAbstract {
     @Override
     public Component createComponent(final String id, final IModel<?> model) {
         final ServiceActionsModel serviceActionsModel = (ServiceActionsModel) model;
-        return new ServiceActionsPanel(id, ServiceActionUtil.buildMenu(serviceActionsModel));
+
+        final MenuBarsService menuBarsService =
+                getIsisSessionFactory().getServicesInjector().lookupService(MenuBarsService.class);
+
+        final MenuBars menuBars = menuBarsService.menuBars();
+
+        final List<CssMenuItem> menuItems = ServiceActionUtil.buildMenu(menuBars, serviceActionsModel);
+
+        return new ServiceActionsPanel(id, menuItems);
     }
 
+    IsisSessionFactory getIsisSessionFactory() {
+        return IsisContext.getSessionFactory();
+    }
 }
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/serviceactions/TertiaryMenuPanelFactory.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/serviceactions/TertiaryMenuPanelFactory.java
index 5d28543..1498914 100644
--- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/serviceactions/TertiaryMenuPanelFactory.java
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/serviceactions/TertiaryMenuPanelFactory.java
@@ -19,9 +19,16 @@
 
 package org.apache.isis.viewer.wicket.ui.components.actionmenu.serviceactions;
 
+import java.util.List;
+
 import org.apache.wicket.Component;
 import org.apache.wicket.model.IModel;
+
 import org.apache.isis.applib.annotation.DomainServiceLayout;
+import org.apache.isis.applib.layout.menus.MenuBars;
+import org.apache.isis.applib.services.menu.MenuBarsService;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.core.runtime.system.session.IsisSessionFactory;
 import org.apache.isis.viewer.wicket.model.models.ServiceActionsModel;
 import org.apache.isis.viewer.wicket.ui.ComponentFactoryAbstract;
 import org.apache.isis.viewer.wicket.ui.ComponentType;
@@ -55,7 +62,18 @@ public class TertiaryMenuPanelFactory extends ComponentFactoryAbstract {
     @Override
     public Component createComponent(final String id, final IModel<?> model) {
         final ServiceActionsModel serviceActionsModel = (ServiceActionsModel) model;
-        return new TertiaryActionsPanel(id, ServiceActionUtil.buildMenu(serviceActionsModel));
+
+        final MenuBarsService menuBarsService =
+                getIsisSessionFactory().getServicesInjector().lookupService(MenuBarsService.class);
+
+        final MenuBars menuBars = menuBarsService.menuBars();
+
+        final List<CssMenuItem> menuItems = ServiceActionUtil.buildMenu(menuBars, serviceActionsModel);
+        return new TertiaryActionsPanel(id, menuItems);
+    }
+
+    IsisSessionFactory getIsisSessionFactory() {
+        return IsisContext.getSessionFactory();
     }
 
 }

-- 
To stop receiving notification emails like this one, please contact
"commits@isis.apache.org" <co...@isis.apache.org>.

[isis] 02/04: ISIS-1752: deletes unused methods in ServiceActionUtil (now within MenuBarsServiceDefault).

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 1360bc36c90f9c7368d0a261d26ce8498fe58f78
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Wed Oct 25 17:31:20 2017 +0100

    ISIS-1752: deletes unused methods in ServiceActionUtil (now within MenuBarsServiceDefault).
    
    Also tested whether can support nested items (ans: sort-of, though CSS is broken). ... hence new HTML for tertiary.
---
 .../serviceactions/ServiceActionUtil.java          | 150 ++-------------------
 .../serviceactions/TertiaryActionsPanel.html       |  12 ++
 2 files changed, 25 insertions(+), 137 deletions(-)

diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/serviceactions/ServiceActionUtil.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/serviceactions/ServiceActionUtil.java
index 19df562..ece262f 100644
--- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/serviceactions/ServiceActionUtil.java
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/serviceactions/ServiceActionUtil.java
@@ -20,8 +20,6 @@
 package org.apache.isis.viewer.wicket.ui.components.actionmenu.serviceactions;
 
 import java.util.List;
-import java.util.Map;
-import java.util.Set;
 
 import com.google.common.base.Function;
 import com.google.common.base.Strings;
@@ -29,8 +27,6 @@ import com.google.common.collect.FluentIterable;
 import com.google.common.collect.ImmutableBiMap;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
 
 import org.apache.wicket.AttributeModifier;
 import org.apache.wicket.Component;
@@ -42,8 +38,6 @@ import org.apache.wicket.markup.html.list.ListView;
 import org.apache.wicket.markup.html.panel.Fragment;
 import org.apache.wicket.model.Model;
 
-import org.apache.isis.applib.annotation.NatureOfService;
-import org.apache.isis.applib.filter.Filters;
 import org.apache.isis.applib.layout.menus.ActionLayoutData;
 import org.apache.isis.applib.layout.menus.Menu;
 import org.apache.isis.applib.layout.menus.MenuBar;
@@ -51,15 +45,7 @@ import org.apache.isis.applib.layout.menus.MenuBars;
 import org.apache.isis.applib.layout.menus.MenuSection;
 import org.apache.isis.applib.services.i18n.TranslationService;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
-import org.apache.isis.core.metamodel.facets.actions.notinservicemenu.NotInServiceMenuFacet;
-import org.apache.isis.core.metamodel.facets.all.named.NamedFacet;
-import org.apache.isis.core.metamodel.facets.members.order.MemberOrderFacet;
-import org.apache.isis.core.metamodel.facets.object.domainservice.DomainServiceFacet;
 import org.apache.isis.core.metamodel.services.ServicesInjector;
-import org.apache.isis.core.metamodel.spec.ActionType;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.Contributed;
 import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
 import org.apache.isis.core.runtime.system.IsisSystem;
 import org.apache.isis.core.runtime.system.session.IsisSessionFactoryBuilder;
@@ -77,7 +63,10 @@ public final class ServiceActionUtil {
 
     private ServiceActionUtil(){}
 
-    static void addLeafItem(final CssMenuItem menuItem, final ListItem<CssMenuItem> listItem, final MarkupContainer parent) {
+    static void addLeafItem(
+            final CssMenuItem menuItem,
+            final ListItem<CssMenuItem> listItem,
+            final MarkupContainer parent) {
         
     	Fragment leafItem;
         if (!menuItem.isSeparator()) {
@@ -179,7 +168,12 @@ public final class ServiceActionUtil {
         return itemsWithSeparators;
     }
 
-    static void addFolderItem(final CssMenuItem subMenuItem, final ListItem<CssMenuItem> listItem, final MarkupContainer parent, final SeparatorStrategy separatorStrategy) {
+    static void addFolderItem(
+            final CssMenuItem subMenuItem,
+            final ListItem<CssMenuItem> listItem,
+            final MarkupContainer parent,
+            final SeparatorStrategy separatorStrategy) {
+
         listItem.add(new CssClassAppender("dropdown-submenu"));
 
         Fragment folderItem = new Fragment("content", "folderItem", parent);
@@ -259,128 +253,10 @@ public final class ServiceActionUtil {
         return menuItems;
     }
 
-    /**
-     * Builds a hierarchy of {@link CssMenuItem}s, following the provided map of {@link ServiceAndAction}s (keyed by their service Name).
-     */
-    private static List<CssMenuItem> buildMenuItems(
-            final Set<String> serviceNamesInOrder,
-            final Map<String, List<ServiceAndAction>> serviceActionsByName) {
-
-        final List<CssMenuItem> menuItems = Lists.newArrayList();
-        for (String serviceName : serviceNamesInOrder) {
-            final CssMenuItem serviceMenuItem = CssMenuItem.newMenuItem(serviceName).build();
-            final List<ServiceAndAction> serviceActionsForName = serviceActionsByName.get(serviceName);
-            for (ServiceAndAction serviceAndAction : serviceActionsForName) {
-
-                final CssMenuItem.Builder subMenuItemBuilder = serviceMenuItem.newSubMenuItem(serviceAndAction);
-                if (subMenuItemBuilder == null) {
-                    // either service or this action is not visible
-                    continue;
-                }
-                subMenuItemBuilder.build();
-            }
-            if (serviceMenuItem.hasSubMenuItems()) {
-                menuItems.add(serviceMenuItem);
-            }
-        }
-        return menuItems;
-    }
-
-
-    // //////////////////////////////////////
-
-    /**
-     * Spin through all object actions of the service adapter, and add to the provided List of {@link ServiceAndAction}s.
-     */
-    private static void collateServiceActions(
-            final ObjectAdapter serviceAdapter,
-            final ActionType actionType,
-            final List<ServiceAndAction> serviceActions) {
-
-        final ObjectSpecification serviceSpec = serviceAdapter.getSpecification();
-
-        // skip if annotated to not be included in repository menu using @DomainService
-        final DomainServiceFacet domainServiceFacet = serviceSpec.getFacet(DomainServiceFacet.class);
-        if (domainServiceFacet != null) {
-            final NatureOfService natureOfService = domainServiceFacet.getNatureOfService();
-            if (natureOfService == NatureOfService.VIEW_REST_ONLY ||
-                    natureOfService == NatureOfService.VIEW_CONTRIBUTIONS_ONLY ||
-                    natureOfService == NatureOfService.DOMAIN) {
-                return;
-            }
-        }
-
-        for (final ObjectAction objectAction : serviceSpec.getObjectActions(
-                actionType, Contributed.INCLUDED, Filters.<ObjectAction>any())) {
-
-            // skip if annotated to not be included in repository menu using legacy mechanism
-            if (objectAction.getFacet(NotInServiceMenuFacet.class) != null) {
-                continue;
-            }
 
-            final MemberOrderFacet memberOrderFacet = objectAction.getFacet(MemberOrderFacet.class);
-            String serviceName = memberOrderFacet != null? memberOrderFacet.name(): null;
-            if(Strings.isNullOrEmpty(serviceName)){
-                serviceName = serviceSpec.getFacet(NamedFacet.class).value();
-            }
-            final EntityModel serviceModel = new EntityModel(serviceAdapter);
-            serviceActions.add(new ServiceAndAction(serviceName, serviceModel, objectAction));
-        }
-    }
-
-    /**
-     * The unique service names, as they appear in order of the provided List of {@link ServiceAndAction}s.
-     * @param serviceAdapters
-     */
-    private static Set<String> serviceNamesInOrder(
-            final List<ObjectAdapter> serviceAdapters, final List<ServiceAndAction> serviceActions) {
-        final Set<String> serviceNameOrder = Sets.newLinkedHashSet();
-
-        // first, order as defined in isis.properties
-        for (ObjectAdapter serviceAdapter : serviceAdapters) {
-            final ObjectSpecification serviceSpec = serviceAdapter.getSpecification();
-            String serviceName = serviceSpec.getFacet(NamedFacet.class).value();
-            serviceNameOrder.add(serviceName);
-        }
-        // then, any other services (eg due to misspellings, at the end)
-        for (ServiceAndAction serviceAction : serviceActions) {
-            if(!serviceNameOrder.contains(serviceAction.serviceName)) {
-                serviceNameOrder.add(serviceAction.serviceName);
-            }
-        }
-        return serviceNameOrder;
-    }
-
-    /**
-     * Group the provided {@link ServiceAndAction}s by their service name.
-     */
-    private static Map<String, List<ServiceAndAction>> groupByServiceName(final List<ServiceAndAction> serviceActions) {
-        final Map<String, List<ServiceAndAction>> serviceActionsByName = Maps.newTreeMap();
-
-        // map available services
-        ObjectAdapter lastServiceAdapter = null;
-
-        for (ServiceAndAction serviceAction : serviceActions) {
-            List<ServiceAndAction> serviceActionsForName = serviceActionsByName.get(serviceAction.serviceName);
-
-            final ObjectAdapter serviceAdapter =
-                    serviceAction.serviceEntityModel.load(AdapterManager.ConcurrencyChecking.NO_CHECK);
-
-            if(serviceActionsForName == null) {
-                serviceActionsForName = Lists.newArrayList();
-                serviceActionsByName.put(serviceAction.serviceName, serviceActionsForName);
-            } else {
-                // capture whether this action is from a different service; if so, add a separator before it
-                serviceAction.separator = lastServiceAdapter != serviceAdapter;
-            }
-            serviceActionsForName.add(serviceAction);
-            lastServiceAdapter = serviceAdapter;
-        }
-
-        return serviceActionsByName;
-    }
-    
-    private static void addConfirmationDialog(Component component, final ServicesInjector servicesInjector) {
+    private static void addConfirmationDialog(
+            final Component component,
+            final ServicesInjector servicesInjector) {
         
         final TranslationService translationService =
                 servicesInjector.lookupService(TranslationService.class);
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/serviceactions/TertiaryActionsPanel.html b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/serviceactions/TertiaryActionsPanel.html
index 8b45fed..6b1fa78 100644
--- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/serviceactions/TertiaryActionsPanel.html
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/serviceactions/TertiaryActionsPanel.html
@@ -43,6 +43,18 @@
                 </a>
             </wicket:fragment>
 
+            <wicket:fragment wicket:id="folderItem">
+                <a wicket:id="folderName" tabindex="-1"></a>
+                <ul class="dropdown-menu">
+                    <li wicket:id="subMenuItems">
+                        <wicket:container wicket:id="content"></wicket:container>
+                    </li>
+                </ul>
+            </wicket:fragment>
+
+            <wicket:fragment wicket:id="empty">
+            </wicket:fragment>
+
 
         </wicket:panel>
     </body>

-- 
To stop receiving notification emails like this one, please contact
"commits@isis.apache.org" <co...@isis.apache.org>.

[isis] 03/04: ISIS-1572: adds outline docs for MenuBarsService

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 0b7f44552d81ac7aa0172b1c6cad6d24778db518
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Wed Oct 25 17:41:41 2017 +0100

    ISIS-1572: adds outline docs for MenuBarsService
---
 .../_rgsvc_presentation-layer-spi_GridService.adoc | 35 ++++++++++++------
 ...svc_presentation-layer-spi_MenuBarsService.adoc | 41 ++++++++++++++++++++++
 2 files changed, 65 insertions(+), 11 deletions(-)

diff --git a/adocs/documentation/src/main/asciidoc/guides/rgsvc/_rgsvc_presentation-layer-spi_GridService.adoc b/adocs/documentation/src/main/asciidoc/guides/rgsvc/_rgsvc_presentation-layer-spi_GridService.adoc
index f5ceff8..f12e352 100644
--- a/adocs/documentation/src/main/asciidoc/guides/rgsvc/_rgsvc_presentation-layer-spi_GridService.adoc
+++ b/adocs/documentation/src/main/asciidoc/guides/rgsvc/_rgsvc_presentation-layer-spi_GridService.adoc
@@ -6,7 +6,8 @@
 
 
 
-The `GridService` provides the ability to load the XML layout (grid) for a domain class.   To do this it delegates:
+The `GridService` provides the ability to load the XML layout (grid) for a domain class.
+To do this it delegates:
 
 * to xref:../rgsvc/rgsvc.adoc#_rgsvc_presentation-layer-spi_GridLoaderService[`GridLoaderService`] to load a pre-existing layout for the domain class, if possible
 
@@ -14,7 +15,10 @@ The `GridService` provides the ability to load the XML layout (grid) for a domai
 Isis' internal metamodel, in other words to ensure that all of the domain objects' properties, collections and actions are associated with regions of the grid.
 
 Once a grid has been loaded for a domain class, this is cached internally by Apache Isis' internal meta model (in the
-`GridFacet` facet).  If running in prototype mode, any subsequent changes to the XML will be detected and the grid rebuilt.  This allows for dynamic reloading of layouts, providing a far faster feedback (eg if tweaking the UI while working with end-users).  Dynamic reloading is disabled in production mode.
+`GridFacet` facet).
+If running in prototype mode, any subsequent changes to the XML will be detected and the grid rebuilt.
+This allows for dynamic reloading of layouts, providing a far faster feedback (eg if tweaking the UI while working with end-users).
+Dynamic reloading is disabled in production mode.
 
 == SPI
 
@@ -33,16 +37,25 @@ public interface GridService {
     Grid minimal(Grid grid);                    // <8>
 }
 ----
-<1> whether dynamic reloading of layouts is enabled.  The default implementation enables reloading for prototyping, disables in production
+<1> whether dynamic reloading of layouts is enabled.
+The default implementation enables reloading for prototyping, disables in production
 <2> support metamodel invalidation/rebuilding of spec, eg as called by this xref:../rgcms/rgcms.adoc#__rgcms_classes_mixins_Object_rebuildMetamodel[Object mixin] action.
-<3> whether any persisted layout metadata (eg a `.layout.xml` file) exists for this domain class.  Just delegates to corresponding method in xref:../rgsvc/rgsvc.adoc#_rgsvc_presentation-layer-spi_GridLoaderService[`GridLoaderService`].
-<4> returns a new instance of a xref:../rgcms/rgcms.adoc#__rgcms_classes_layout_component[`Grid`] for the specified domain class, eg as loaded from a `layout.xml` file.  If none exists, will return null (and the calling xref:../rgsvc/rgsvc.adoc#_rgsvc_presentation-layer-spi_GridService[`GridService`] will use xref:../rgsvc/rgsvc.adoc#_rgsvc_presentation-layer-spi_GridSystemService[`GridSystemService`] to obtain a default grid for the domain class).
-<5> returns a default grid, eg two columns in ratio 4:8.  Used when no existing grid layout exists for a domain class.
-<6> validates and normalizes a grid, modifying the grid so that all of the domain object's members (properties, collections, actions) are bound to regions of the grid.  This is done using existing metadata, most notably that of the xref:../rgant/rgant.adoc#_rgant-MemberOrder[`@MemberOrder`] annotation.  Such a grid, if persisted as the layout XML file for the domain class, allows the `@MemberOrder` annotation to be removed from the source code of the domain class (but other annotations m [...]
-<7> Takes a normalized grid and enriches it with additional metadata (taken from Apache Isis' internal metadata) that can be represented in the layout XML.  Such a grid, if persisted as the layout XML file for the domain class, allows all layout annotations (xref:../rgant/rgant.adoc#_rgant-ActionLayout[`@ActionLayout`], xref:../rgant/rgant.adoc#_rgant-PropertyLayout[`@PropertyLayout`] and xref:../rgant/rgant.adoc#_rgant-CollectionLayout[`@CollectionLayout`]) to be removed from the source [...]
-<8> Takes a normalized grid and strips out removes all members, leaving only the grid structure.  Such a grid, if persisted as the layout XML file for the domain class, requires that the xref:../rgant/rgant.adoc#_rgant-MemberOrder[`@MemberOrder`] annotation is retained in the source code of said class in order to bind members to the regions of the grid.
-
-The first four methods just delegate to the corresponding methods in xref:../rgsvc/rgsvc.adoc#_rgsvc_presentation-layer-spi_GridSystemService[`GridSystemService`], while the last four delegate to the  corresponding method in xref:../rgsvc/rgsvc.adoc#_rgsvc_presentation-layer-spi_GridSystemService[`GridSystemService`].  The service inspects the ``Grid``'s concrete class to determine which actual `GridSystemService` instance to delegate to.
+<3> whether any persisted layout metadata (eg a `.layout.xml` file) exists for this domain class.
+Just delegates to corresponding method in xref:../rgsvc/rgsvc.adoc#_rgsvc_presentation-layer-spi_GridLoaderService[`GridLoaderService`].
+<4> returns a new instance of a xref:../rgcms/rgcms.adoc#__rgcms_classes_layout_component[`Grid`] for the specified domain class, eg as loaded from a `layout.xml` file.
+If none exists, will return null (and the calling xref:../rgsvc/rgsvc.adoc#_rgsvc_presentation-layer-spi_GridService[`GridService`] will use xref:../rgsvc/rgsvc.adoc#_rgsvc_presentation-layer-spi_GridSystemService[`GridSystemService`] to obtain a default grid for the domain class).
+<5> returns a default grid, eg two columns in ratio 4:8.
+Used when no existing grid layout exists for a domain class.
+<6> validates and normalizes a grid, modifying the grid so that all of the domain object's members (properties, collections, actions) are bound to regions of the grid.
+This is done using existing metadata, most notably that of the xref:../rgant/rgant.adoc#_rgant-MemberOrder[`@MemberOrder`] annotation.
+Such a grid, if persisted as the layout XML file for the domain class, allows the `@MemberOrder` annotation to be removed from the source code of the domain class (but other annotations must be retained).
+<7> Takes a normalized grid and enriches it with additional metadata (taken from Apache Isis' internal metadata) that can be represented in the layout XML.
+Such a grid, if persisted as the layout XML file for the domain class, allows all layout annotations (xref:../rgant/rgant.adoc#_rgant-ActionLayout[`@ActionLayout`], xref:../rgant/rgant.adoc#_rgant-PropertyLayout[`@PropertyLayout`] and xref:../rgant/rgant.adoc#_rgant-CollectionLayout[`@CollectionLayout`]) to be removed from the source code of the domain class.
+<8> Takes a normalized grid and strips out removes all members, leaving only the grid structure.
+Such a grid, if persisted as the layout XML file for the domain class, requires that the xref:../rgant/rgant.adoc#_rgant-MemberOrder[`@MemberOrder`] annotation is retained in the source code of said class in order to bind members to the regions of the grid.
+
+The first four methods just delegate to the corresponding methods in xref:../rgsvc/rgsvc.adoc#_rgsvc_presentation-layer-spi_GridSystemService[`GridSystemService`], while the last four delegate to the  corresponding method in xref:../rgsvc/rgsvc.adoc#_rgsvc_presentation-layer-spi_GridSystemService[`GridSystemService`].
+The service inspects the ``Grid``'s concrete class to determine which actual `GridSystemService` instance to delegate to.
 
 
 == Implementation
diff --git a/adocs/documentation/src/main/asciidoc/guides/rgsvc/_rgsvc_presentation-layer-spi_MenuBarsService.adoc b/adocs/documentation/src/main/asciidoc/guides/rgsvc/_rgsvc_presentation-layer-spi_MenuBarsService.adoc
new file mode 100644
index 0000000..1cb1047
--- /dev/null
+++ b/adocs/documentation/src/main/asciidoc/guides/rgsvc/_rgsvc_presentation-layer-spi_MenuBarsService.adoc
@@ -0,0 +1,41 @@
+[[_rgsvc_presentation-layer-spi_MenuBarsService]]
+= `MenuBarsService` (`1.16.0-SNAPSHOT`)
+:Notice: 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 ag [...]
+:_basedir: ../../
+:_imagesdir: images/
+
+
+
+The `MenuBarsService` is responsible for returning an XML representation of the domain service actions.
+This is used by the Wicket viewer to build up the menu, and is also served as the "menuBars" resource by the xref:../ugvro/ugvro.adoc#[Restful Objects] viewer.
+
+
+[NOTE]
+====
+TODO: need to flesh this out...
+====
+
+
+== SPI
+
+The SPI defined by this service is:
+
+[source,java]
+----
+public interface MenuBarsService {
+    MenuBars menuBars();                    // <1>
+}
+----
+<1> An instance of `MenuBars`.
+
+[NOTE]
+====
+TODO: need to document `MenuBars` in the rgcms.adoc guide.
+====
+
+
+== Implementation
+
+The framework provides a default implementation of this service, namely `o.a.i.core.runtime.services.menu.MenuBarsServiceDefault`.
+
+

-- 
To stop receiving notification emails like this one, please contact
"commits@isis.apache.org" <co...@isis.apache.org>.

[isis] 04/04: ISIS-1752: fixes unit test

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git

commit bc5fdbe8de369c6e8c45d38992000f242812be4e
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Wed Oct 25 17:47:58 2017 +0100

    ISIS-1752: fixes unit test
---
 .../src/main/java/org/apache/isis/applib/layout/menus/MenuBars.java      | 1 -
 1 file changed, 1 deletion(-)

diff --git a/core/applib/src/main/java/org/apache/isis/applib/layout/menus/MenuBars.java b/core/applib/src/main/java/org/apache/isis/applib/layout/menus/MenuBars.java
index 1fe0147..1d3946e 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/layout/menus/MenuBars.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/layout/menus/MenuBars.java
@@ -97,7 +97,6 @@ public class MenuBars implements Serializable {
 
 
 
-    @XmlTransient
     public MenuBar menuBarFor(final DomainServiceLayout.MenuBar menuBar) {
         switch (menuBar) {
         case PRIMARY:

-- 
To stop receiving notification emails like this one, please contact
"commits@isis.apache.org" <co...@isis.apache.org>.