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 2016/03/03 20:47:06 UTC
[13/50] [abbrv] isis git commit: ISIS-993: guard against invisible
actions corresponding to null links.
ISIS-993: guard against invisible actions corresponding to null links.
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/bbd593bc
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/bbd593bc
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/bbd593bc
Branch: refs/heads/master
Commit: bbd593bc10ab486aad16cc7eff6dd3b2e06a0222
Parents: 959d424
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Thu Feb 11 10:08:59 2016 +0000
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Thu Feb 11 10:08:59 2016 +0000
----------------------------------------------------------------------
.../entityactions/EntityActionUtil.java | 24 ++++++++++++++------
1 file changed, 17 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/bbd593bc/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/entityactions/EntityActionUtil.java
----------------------------------------------------------------------
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/entityactions/EntityActionUtil.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/entityactions/EntityActionUtil.java
index de6e2ca..efa53f6 100644
--- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/entityactions/EntityActionUtil.java
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actionmenu/entityactions/EntityActionUtil.java
@@ -22,6 +22,8 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import com.google.common.base.Function;
+import com.google.common.base.Predicates;
+import com.google.common.collect.FluentIterable;
import com.google.common.collect.Lists;
import org.apache.wicket.Session;
import org.apache.isis.applib.annotation.Where;
@@ -107,6 +109,11 @@ public final class EntityActionUtil {
* Converts an {@link org.apache.isis.viewer.wicket.model.models.EntityModel} and a (subset of its) {@link org.apache.isis.core.metamodel.spec.feature.ObjectAction}s into a
* list of {@link org.apache.isis.viewer.wicket.model.links.LinkAndLabel}s intended to be apassed
* to the {@link AdditionalLinksPanel}.
+ *
+ * <p>
+ * The length of the list returned may smaller than the inbound actions; any null links
+ * (for invisible actions) will be discarded.
+ * </p>
*/
public static List<LinkAndLabel> asLinkAndLabelsForAdditionalLinksPanel(
final EntityModel entityModel,
@@ -116,13 +123,16 @@ public final class EntityActionUtil {
final ActionLinkFactory linkFactory = new EntityActionLinkFactory(entityModel);
final ObjectAdapterMemento adapterMemento = entityModel.getObjectAdapterMemento();
- return Lists.transform(actions, new Function<ObjectAction, LinkAndLabel>() {
-
- @Override
- public LinkAndLabel apply(ObjectAction objectAction) {
- return linkFactory.newLink(linkId, adapterMemento, objectAction);
- }
- });
+ return FluentIterable.from(actions)
+ .transform(new Function<ObjectAction, LinkAndLabel>() {
+
+ @Override
+ public LinkAndLabel apply(ObjectAction objectAction) {
+ return linkFactory.newLink(linkId, adapterMemento, objectAction);
+ }
+ })
+ .filter(Predicates.<LinkAndLabel>notNull())
+ .toList();
}
private static List<ObjectAction> addActions(