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 2014/11/10 11:23:08 UTC
[01/23] isis git commit: ISIS-537 Write the 'type' HTML attribute
even for invisible buttons with placeholder
Repository: isis
Updated Branches:
refs/heads/ISIS-939 ee4fe8b8f -> 5022f8563
ISIS-537 Write the 'type' HTML attribute even for invisible buttons with placeholder
https://trello.com/c/JwALpbYI/113-bootlint-error-always-set-a-type-on-buttons
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/bbdf17bb
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/bbdf17bb
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/bbdf17bb
Branch: refs/heads/ISIS-939
Commit: bbdf17bb84b7146e09e3c86ee5d67af95f3bf818
Parents: ee4fe8b
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Fri Nov 7 12:20:22 2014 +0200
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Fri Nov 7 12:20:22 2014 +0200
----------------------------------------------------------------------
.../entity/properties/EntityPropertiesForm.java | 37 ++++++++++++++++++++
1 file changed, 37 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/bbdf17bb/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/properties/EntityPropertiesForm.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/properties/EntityPropertiesForm.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/properties/EntityPropertiesForm.java
index cbfe092..6dc5cd6 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/properties/EntityPropertiesForm.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/properties/EntityPropertiesForm.java
@@ -40,6 +40,8 @@ import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.markup.repeater.RepeatingView;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.ResourceModel;
+import org.apache.wicket.request.Response;
+import org.apache.wicket.util.string.Strings;
import org.apache.wicket.util.visit.IVisit;
import org.apache.wicket.util.visit.IVisitor;
import org.apache.isis.applib.annotation.MemberGroupLayout.ColumnSpans;
@@ -278,6 +280,41 @@ public class EntityPropertiesForm extends FormAbstract<ObjectAdapter> {
super.onError(target, form);
toEditMode(target);
}
+
+ /**
+ * Render the 'type' attribute even for invisible buttons to avoid
+ * <a href="https://github.com/twbs/bootlint/wiki/W007">Bootlint W007</a>
+ *
+ * @param tag The component tag to render
+ * @param response The response to write to
+ */
+ // TODO mgrigorov Move this to Wicket Bootstrap project
+ @Override
+ protected void renderPlaceholderTag(ComponentTag tag, Response response) {
+ String ns = Strings.isEmpty(tag.getNamespace()) ? null : tag.getNamespace() + ':';
+
+ response.write("<");
+ if (ns != null)
+ {
+ response.write(ns);
+ }
+ response.write(tag.getName());
+ response.write(" id=\"");
+ response.write(getAjaxRegionMarkupId());
+
+ String type = tag.getAttribute("type");
+ if (!Strings.isEmpty(type)) {
+ response.write("\" type=\""+type);
+ }
+
+ response.write("\" style=\"display:none\"></");
+ if (ns != null)
+ {
+ response.write(ns);
+ }
+ response.write(tag.getName());
+ response.write(">");
+ }
}
public class AjaxButtonForValidate extends AjaxButtonWithOnError implements IFormSubmitterWithPreValidateHook {
[20/23] isis git commit: ISIS-942: Allow auditing in transactions of
entities being created/deleted.
Posted by da...@apache.org.
ISIS-942: Allow auditing in transactions of entities being created/deleted.
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/3b397385
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/3b397385
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/3b397385
Branch: refs/heads/ISIS-939
Commit: 3b397385b9315231f403f294b3a1aba73bf4ce42
Parents: b1a0f1d
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Fri Nov 7 17:13:51 2014 +0000
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Mon Nov 10 10:21:48 2014 +0000
----------------------------------------------------------------------
.../system/transaction/IsisTransaction.java | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/3b397385/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java
index b2536ba..c5171e9 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java
@@ -106,6 +106,19 @@ public class IsisTransaction implements TransactionScopedComponent {
}
};
+ private static class Placeholder {
+ private static Placeholder NEW = new Placeholder("[NEW]");
+ private static Placeholder DELETED = new Placeholder("[DELETED]");
+ private final String str;
+ public Placeholder(String str) {
+ this.str = str;
+ }
+ @Override
+ public String toString() {
+ return str;
+ }
+ }
+
public static enum State {
/**
* Started, still in progress.
@@ -1195,6 +1208,9 @@ public class IsisTransaction implements TransactionScopedComponent {
}
public boolean differ() {
+ if(getPre() == Placeholder.NEW || getPost() == Placeholder.DELETED) {
+ return true;
+ }
return !Objects.equal(getPre(), getPost());
}
}
@@ -1226,7 +1242,7 @@ public class IsisTransaction implements TransactionScopedComponent {
if(property.isNotPersisted()) {
continue;
}
- PreAndPostValues papv = PreAndPostValues.pre("[NEW]");
+ PreAndPostValues papv = PreAndPostValues.pre(Placeholder.NEW);
changedObjectProperties.put(aap, papv);
}
}
@@ -1309,7 +1325,7 @@ public class IsisTransaction implements TransactionScopedComponent {
if(adapter.isDestroyed()) {
// don't touch the object!!!
// JDO, for example, will complain otherwise...
- papv.setPost("[DELETED]");
+ papv.setPost(Placeholder.DELETED);
} else {
papv.setPost(aap.getPropertyValue());
}
[12/23] isis git commit: ISIS-537: updating comments only.
Posted by da...@apache.org.
ISIS-537: updating comments only.
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/bb087872
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/bb087872
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/bb087872
Branch: refs/heads/ISIS-939
Commit: bb0878725fb92199caada73e12511480ede613ba
Parents: 4912641
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Sun Nov 9 12:20:40 2014 +0000
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Mon Nov 10 10:21:39 2014 +0000
----------------------------------------------------------------------
.../selector/links/EntityLinksSelectorPanelFactory.java | 5 -----
.../isis/viewer/wicket/ui/panels/PanelAbstract.java | 10 +++++-----
2 files changed, 5 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/bb087872/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/selector/links/EntityLinksSelectorPanelFactory.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/selector/links/EntityLinksSelectorPanelFactory.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/selector/links/EntityLinksSelectorPanelFactory.java
index 32a4c23..30b2ce3 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/selector/links/EntityLinksSelectorPanelFactory.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/selector/links/EntityLinksSelectorPanelFactory.java
@@ -29,12 +29,7 @@ import org.apache.isis.viewer.wicket.ui.components.entity.EntityComponentFactory
/**
* {@link ComponentFactory} for {@link EntityLinksSelectorPanel}.
- *
- * <p>
- * Either this selector, or {@link EntityDropDownSelectorPanelFactory} should be registered;
- * but not both.
*/
-// TODO mgrigorov: EntityDropDownSelectorPanelFactory doesn't seem to exist anymore. Update the javadoc
public class EntityLinksSelectorPanelFactory extends EntityComponentFactoryAbstract {
private static final long serialVersionUID = 1L;
http://git-wip-us.apache.org/repos/asf/isis/blob/bb087872/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/PanelAbstract.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/PanelAbstract.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/PanelAbstract.java
index daa7029..f873e00 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/PanelAbstract.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/PanelAbstract.java
@@ -109,22 +109,22 @@ public abstract class PanelAbstract<T extends IModel<?>> extends Panel implement
/**
* Renders the corresponding CSS for this panel.
- *
+ *
* <p>
- * For most subclasses of {@link PanelAbstract} - specifically those that have their own {@link ComponentFactory},
+ * For most subclasses of {@link PanelAbstract} - specifically those that have their own {@link ComponentFactory},
* it is additionally the responsibility (via {@link ComponentFactory#getCssResourceReference()}) of the factory
* to declare the {@link CssResourceReference}(s) to be included. These are then all bundled up into
* a single unit, as part of the application bootstrapping (<tt>IsisWicketApplication#init</tt>).
- *
+ *
* <p>
* This is done because some browsers (we're looking at you, IE!) have a limit of only 31 CSS files.
- *
+ *
* <p>
* For subclasses that do not have a {@link ComponentFactory}, their CSS will simply be referenced standalone.
*/
@Override
public void renderHead(final IHeaderResponse response) {
- // TODO: mgrigorov remove this stuff once happy no longer needed at all.
+ // TODO: mgrigorov remove this stuff once happy no longer needed at all, plus any CSS of panels that used to rely on this.
// PanelUtil.renderHead(response, this.getClass());
}
[09/23] isis git commit: ISIS-537: moved impl of
LinksSelectorPanelAbstract (.java) to subclasses.
Posted by da...@apache.org.
ISIS-537: moved impl of LinksSelectorPanelAbstract (.java) to subclasses.
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/b1677ca8
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/b1677ca8
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/b1677ca8
Branch: refs/heads/ISIS-939
Commit: b1677ca880b7a27a831ecf84e387952aca12a241
Parents: 3b80b5e
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Sun Nov 9 11:57:48 2014 +0000
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Mon Nov 10 10:21:35 2014 +0000
----------------------------------------------------------------------
.../CollectionContentsLinksSelectorPanel.java | 408 ++++++++++++++++---
.../links/EntityLinksSelectorPanel.java | 352 +++++++++++++++-
.../links/LinksSelectorPanelAbstract.java | 40 +-
3 files changed, 724 insertions(+), 76 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/b1677ca8/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java
index 81f7ece..096903c 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java
@@ -19,26 +19,52 @@
package org.apache.isis.viewer.wicket.ui.components.collectioncontents.selector.links;
-import java.util.List;
+import de.agilecoders.wicket.core.markup.html.bootstrap.button.Buttons;
+import java.util.ArrayList;
+import java.util.List;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;
-
+import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
+import org.apache.wicket.MarkupContainer;
import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.markup.html.AjaxLink;
+import org.apache.wicket.event.Broadcast;
+import org.apache.wicket.markup.ComponentTag;
+import org.apache.wicket.markup.head.IHeaderResponse;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+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.model.IModel;
-
+import org.apache.wicket.model.Model;
import org.apache.isis.applib.annotation.Render.Type;
+import org.apache.isis.core.commons.lang.StringExtensions;
import org.apache.isis.core.metamodel.facets.members.render.RenderFacet;
import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
+import org.apache.isis.viewer.wicket.model.hints.IsisUiHintEvent;
import org.apache.isis.viewer.wicket.model.hints.UiHintContainer;
+import org.apache.isis.viewer.wicket.model.hints.UiHintPathSignificant;
+import org.apache.isis.viewer.wicket.model.links.LinkAndLabel;
+import org.apache.isis.viewer.wicket.model.links.LinksProvider;
import org.apache.isis.viewer.wicket.model.models.EntityCollectionModel;
+import org.apache.isis.viewer.wicket.ui.CollectionContentsAsFactory;
import org.apache.isis.viewer.wicket.ui.ComponentFactory;
import org.apache.isis.viewer.wicket.ui.ComponentType;
+import org.apache.isis.viewer.wicket.ui.components.additionallinks.AdditionalLinksPanel;
import org.apache.isis.viewer.wicket.ui.components.collection.CollectionCountProvider;
import org.apache.isis.viewer.wicket.ui.components.collection.CollectionPanel;
import org.apache.isis.viewer.wicket.ui.components.collectioncontents.ajaxtable.CollectionContentsAsAjaxTablePanelFactory;
import org.apache.isis.viewer.wicket.ui.components.collectioncontents.unresolved.CollectionContentsAsUnresolvedPanelFactory;
+import org.apache.isis.viewer.wicket.ui.panels.PanelAbstract;
+import org.apache.isis.viewer.wicket.ui.panels.PanelUtil;
import org.apache.isis.viewer.wicket.ui.selector.links.LinksSelectorPanelAbstract;
+import org.apache.isis.viewer.wicket.ui.util.Components;
+import org.apache.isis.viewer.wicket.ui.util.CssClassAppender;
+import org.apache.isis.viewer.wicket.ui.util.CssClassRemover;
/**
* Provides a list of links for selecting other views that support
@@ -49,29 +75,317 @@ import org.apache.isis.viewer.wicket.ui.selector.links.LinksSelectorPanelAbstrac
* Most of the heavy lifting is factored out into the superclass,
* {@link LinksSelectorPanelAbstract}.
*/
-public class CollectionContentsLinksSelectorPanel extends LinksSelectorPanelAbstract<EntityCollectionModel> implements CollectionCountProvider {
+public class CollectionContentsLinksSelectorPanel
+ extends PanelAbstract<EntityCollectionModel> implements UiHintPathSignificant, CollectionCountProvider {
private static final long serialVersionUID = 1L;
+ private static final String INVISIBLE_CLASS = "link-selector-panel-invisible";
+ private static final int MAX_NUM_UNDERLYING_VIEWS = 10;
+
+ private static final String ID_ADDITIONAL_LINKS = "additionalLinks";
+
+ private static final String ID_VIEWS = "views";
+ private static final String ID_VIEW_LIST = "viewList";
+ private static final String ID_VIEW_LINK = "viewLink";
+ private static final String ID_VIEW_ITEM = "viewItem";
+ private static final String ID_VIEW_ITEM_TITLE = "viewItemTitle";
+ private static final String ID_VIEW_ITEM_ICON = "viewItemIcon";
+
+ private static final String UIHINT_VIEW = "view";
+ private static final String ID_VIEW_BUTTON_TITLE = "viewButtonTitle";
+ private static final String ID_VIEW_BUTTON_ICON = "viewButtonIcon";
+
+ private final ComponentType componentType;
+ private final String underlyingIdPrefix;
+
+ private ComponentFactory selectedComponentFactory;
+ protected Component selectedComponent;
+
+ /**
+ * May be <tt>null</tt>, depending upon the model implementation.
+ */
+ protected WebMarkupContainer additionalLinks;
+
public CollectionContentsLinksSelectorPanel(final String id, final EntityCollectionModel model, final ComponentFactory factory) {
- super(id, ComponentType.COLLECTION_CONTENTS.toString(), model, factory);
+ super(id, model);
+ this.underlyingIdPrefix = ComponentType.COLLECTION_CONTENTS.toString();
+ this.componentType = factory.getComponentType();
}
- /* (non-Javadoc)
- * @see org.apache.isis.viewer.wicket.ui.selector.links.LinksSelectorPanelAbstract#onInitialize()
+ /**
+ * Build UI only after added to parent.
*/
- @Override
public void onInitialize() {
super.onInitialize();
+ ComponentFactory componentFactory = getComponentFactoryRegistry().findComponentFactoryElseFailFast(getComponentType(), getModel());
+ addAdditionalLinks(getModel());
+ addUnderlyingViews(underlyingIdPrefix, getModel(), componentFactory);
applyCssVisibility(additionalLinks, selectedComponent instanceof CollectionCountProvider);
}
-
- @Override
- protected EntityCollectionModel dummyOf(EntityCollectionModel model) {
- return model.asDummy();
+
+
+ protected void addAdditionalLinks(final EntityCollectionModel model) {
+ if(!(model instanceof LinksProvider)) {
+ permanentlyHide(ID_ADDITIONAL_LINKS);
+ return;
+ }
+ LinksProvider linksProvider = (LinksProvider) model;
+ List<LinkAndLabel> links = linksProvider.getLinks();
+
+ addAdditionalLinks(this, links);
+ }
+
+ protected void addAdditionalLinks(MarkupContainer markupContainer, List<LinkAndLabel> links) {
+ if(links == null || links.isEmpty()) {
+ Components.permanentlyHide(markupContainer, ID_ADDITIONAL_LINKS);
+ return;
+ }
+ links = Lists.newArrayList(links); // copy, to serialize any lazy evaluation
+
+ additionalLinks = new AdditionalLinksPanel(ID_ADDITIONAL_LINKS, links);
+ markupContainer.addOrReplace(additionalLinks);
+ }
+
+ private void addUnderlyingViews(final String underlyingIdPrefix, final EntityCollectionModel model, final ComponentFactory factory) {
+ final List<ComponentFactory> componentFactories = findOtherComponentFactories(model, factory);
+
+ final int selected = honourViewHintElseDefault(componentFactories, model);
+
+ final CollectionContentsLinksSelectorPanel selectorPanel = this;
+
+ // create all, hide the one not selected
+ final Component[] underlyingViews = new Component[MAX_NUM_UNDERLYING_VIEWS];
+ int i = 0;
+ final EntityCollectionModel emptyModel = dummyOf(model);
+ for (ComponentFactory componentFactory : componentFactories) {
+ final String underlyingId = underlyingIdPrefix + "-" + i;
+
+ Component underlyingView = componentFactory.createComponent(underlyingId,i==selected? model: emptyModel);
+ underlyingViews[i++] = underlyingView;
+ selectorPanel.addOrReplace(underlyingView);
+ }
+
+ // hide any unused placeholders
+ while(i<MAX_NUM_UNDERLYING_VIEWS) {
+ String underlyingId = underlyingIdPrefix + "-" + i;
+ permanentlyHide(underlyingId);
+ i++;
+ }
+
+ // selector
+ if (componentFactories.size() <= 1) {
+ permanentlyHide(ID_VIEWS);
+ } else {
+ final Model<ComponentFactory> componentFactoryModel = new Model<>();
+
+ selectorPanel.selectedComponentFactory = componentFactories.get(selected);
+ componentFactoryModel.setObject(selectorPanel.selectedComponentFactory);
+
+ final WebMarkupContainer views = new WebMarkupContainer(ID_VIEWS);
+
+ final Label viewButtonTitle = new Label(ID_VIEW_BUTTON_TITLE, "Hidden");
+ views.addOrReplace(viewButtonTitle);
+
+ final Label viewButtonIcon = new Label(ID_VIEW_BUTTON_ICON, "");
+ views.addOrReplace(viewButtonIcon);
+
+ final WebMarkupContainer container = new WebMarkupContainer(ID_VIEW_LIST);
+
+ views.addOrReplace(container);
+ views.setOutputMarkupId(true);
+
+ this.setOutputMarkupId(true);
+
+ final ListView<ComponentFactory> listView = new ListView<ComponentFactory>(ID_VIEW_ITEM, componentFactories) {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void populateItem(ListItem<ComponentFactory> item) {
+
+ final int underlyingViewNum = item.getIndex();
+
+ final ComponentFactory componentFactory = item.getModelObject();
+ final AbstractLink link = new AjaxLink<Void>(ID_VIEW_LINK) {
+ private static final long serialVersionUID = 1L;
+ @Override
+ public void onClick(AjaxRequestTarget target) {
+ CollectionContentsLinksSelectorPanel linksSelectorPanel = CollectionContentsLinksSelectorPanel.this;
+ linksSelectorPanel.setViewHintAndBroadcast(underlyingViewNum, target);
+
+ final EntityCollectionModel dummyModel = dummyOf(model);
+ for(int i=0; i<MAX_NUM_UNDERLYING_VIEWS; i++) {
+ final Component component = underlyingViews[i];
+ if(component == null) {
+ continue;
+ }
+ final boolean isSelected = i == underlyingViewNum;
+ applyCssVisibility(component, isSelected);
+ component.setDefaultModel(isSelected? model: dummyModel);
+ }
+
+ selectorPanel.selectedComponentFactory = componentFactory;
+ selectorPanel.selectedComponent = underlyingViews[underlyingViewNum];
+ selectorPanel.onSelect(target);
+ target.add(selectorPanel, views);
+ }
+
+ @Override
+ protected void onComponentTag(ComponentTag tag) {
+ super.onComponentTag(tag);
+ Buttons.fixDisabledState(this, tag);
+ }
+ };
+
+ IModel<String> title = nameFor(componentFactory);
+ Label viewItemTitleLabel = new Label(ID_VIEW_ITEM_TITLE, title);
+ link.add(viewItemTitleLabel);
+
+ Label viewItemIcon = new Label(ID_VIEW_ITEM_ICON, "");
+ link.add(viewItemIcon);
+
+ boolean isEnabled = componentFactory != selectorPanel.selectedComponentFactory;
+ if (!isEnabled) {
+ viewButtonTitle.setDefaultModel(title);
+ IModel<String> cssClass = cssClassFor(componentFactory, viewButtonIcon);
+ viewButtonIcon.add(AttributeModifier.replace("class", "ViewLinkItem " + cssClass.getObject()));
+ link.setVisible(false);
+ } else {
+ IModel<String> cssClass = cssClassFor(componentFactory, viewItemIcon);
+ viewItemIcon.add(new CssClassAppender(cssClass));
+ }
+
+ item.add(link);
+ }
+
+ private IModel<String> cssClassFor(final ComponentFactory componentFactory, Label viewIcon) {
+ IModel<String> cssClass = null;
+ if (componentFactory instanceof CollectionContentsAsFactory) {
+ CollectionContentsAsFactory collectionContentsAsFactory = (CollectionContentsAsFactory) componentFactory;
+ cssClass = collectionContentsAsFactory.getCssClass();
+ viewIcon.setDefaultModelObject("");
+ viewIcon.setEscapeModelStrings(true);
+ }
+ if (cssClass == null) {
+ String name = componentFactory.getName();
+ cssClass = Model.of(StringExtensions.asLowerDashed(name));
+ // Small hack: if there is no specific CSS class then we assume that background-image is used
+ // the span.ViewItemLink should have some content to show it
+ // FIX: find a way to do this with CSS (width and height don't seems to help)
+ viewIcon.setDefaultModelObject("     ");
+ viewIcon.setEscapeModelStrings(false);
+ }
+ return cssClass;
+ }
+
+ private IModel<String> nameFor(final ComponentFactory componentFactory) {
+ IModel<String> name = null;
+ if (componentFactory instanceof CollectionContentsAsFactory) {
+ CollectionContentsAsFactory collectionContentsAsFactory = (CollectionContentsAsFactory) componentFactory;
+ name = collectionContentsAsFactory.getTitleLabel();
+ }
+ if (name == null) {
+ name = Model.of(componentFactory.getName());
+ }
+ return name;
+ }
+ };
+ container.add(listView);
+ addOrReplace(views);
+ }
+
+ for(i=0; i<MAX_NUM_UNDERLYING_VIEWS; i++) {
+ Component component = underlyingViews[i];
+ if(component != null) {
+ if(i != selected) {
+ component.add(new CssClassAppender(INVISIBLE_CLASS));
+ } else {
+ selectedComponent = component;
+ }
+ }
+ }
+ }
+
+
+
+ protected void setViewHintAndBroadcast(int viewNum, AjaxRequestTarget target) {
+ final UiHintContainer uiHintContainer = getUiHintContainer();
+ if(uiHintContainer == null) {
+ return;
+ }
+ uiHintContainer.setHint(CollectionContentsLinksSelectorPanel.this, UIHINT_VIEW, ""+viewNum);
+ send(getPage(), Broadcast.EXACT, new IsisUiHintEvent(uiHintContainer, target));
}
-
+ /**
+ * Iterates up the component hierarchy looking for a parent
+ * {@link org.apache.isis.viewer.wicket.ui.components.collection.CollectionPanel}, and if so adds to ajax target so that it'll
+ * be repainted.
+ *
+ * <p>
+ * Yeah, agreed, it's a little bit hacky doing it this way, because it bakes
+ * in knowledge that this component is created, somehow, by a parent {@link org.apache.isis.viewer.wicket.ui.components.collection.CollectionPanel}.
+ * Perhaps it could be refactored to use a more general purpose observer pattern?
+ *
+ * <p>
+ * In fact, I've since discovered that Wicket has an event bus, which is used by the
+ * {@link UiHintContainer hinting mechanism}. So this ought to be relatively easy to do.
+ */
+ protected void onSelect(AjaxRequestTarget target) {
+ Component component = this;
+ while(component != null) {
+ if(component instanceof CollectionPanel) {
+ CollectionPanel collectionPanel = (CollectionPanel) component;
+ boolean hasCount = collectionPanel.hasCount();
+ if(hasCount) {
+ collectionPanel.updateLabel(target);
+ }
+ if(additionalLinks != null) {
+ applyCssVisibility(additionalLinks, hasCount);
+ }
+ return;
+ }
+ component = component.getParent();
+ }
+ }
+
+
+ protected static void applyCssVisibility(final Component component, final boolean visible) {
+ if(component == null) {
+ return;
+ }
+ AttributeModifier modifier = visible ? new CssClassRemover(INVISIBLE_CLASS) : new CssClassAppender(INVISIBLE_CLASS);
+ component.add(modifier);
+ }
+
+ protected int honourViewHintElseDefault(final List<ComponentFactory> componentFactories, final IModel<?> model) {
+ // honour hints ...
+ final UiHintContainer hintContainer = getUiHintContainer();
+ if(hintContainer != null) {
+ String viewStr = hintContainer.getHint(this, UIHINT_VIEW);
+ if(viewStr != null) {
+ try {
+ int view = Integer.parseInt(viewStr);
+ if(view >= 0 && view < componentFactories.size()) {
+ return view;
+ }
+ } catch(NumberFormatException ex) {
+ // ignore
+ }
+ }
+ }
+
+ // ... else default
+ int initialFactory = determineInitialFactory(componentFactories, model);
+ if(hintContainer != null) {
+ hintContainer.setHint(this, UIHINT_VIEW, ""+initialFactory);
+ // don't broadcast (no AjaxRequestTarget, still configuring initial setup)
+ }
+ return initialFactory;
+ }
+
+
/**
* return the index of {@link CollectionContentsAsUnresolvedPanelFactory unresolved panel} if present and not eager loading;
* else the index of {@link CollectionContentsAsAjaxTablePanelFactory ajax table} if present,
@@ -92,11 +406,44 @@ public class CollectionContentsLinksSelectorPanel extends LinksSelectorPanelAbst
return 0;
}
- @Override
+ private List<ComponentFactory> findOtherComponentFactories(final EntityCollectionModel model, final ComponentFactory ignoreFactory) {
+ final List<ComponentFactory> componentFactories = getComponentFactoryRegistry().findComponentFactories(componentType, model);
+ ArrayList<ComponentFactory> otherFactories = Lists.newArrayList(Collections2.filter(componentFactories, new Predicate<ComponentFactory>() {
+ @Override
+ public boolean apply(final ComponentFactory input) {
+ return input != ignoreFactory;
+ }
+ }));
+ return ordered(otherFactories);
+ }
+
protected List<ComponentFactory> ordered(List<ComponentFactory> componentFactories) {
return orderAjaxTableToEnd(componentFactories);
}
+
+ @Override
+ public void renderHead(final IHeaderResponse response) {
+ super.renderHead(response);
+ PanelUtil.renderHead(response, LinksSelectorPanelAbstract.class);
+ }
+
+
+
+
+
+
+
+ /**
+ * Ask for a dummy (empty) {@link Model} to pass into those components that are rendered but will be
+ * made invisible using CSS styling.
+ */
+ protected EntityCollectionModel dummyOf(EntityCollectionModel model) {
+ return model.asDummy();
+ }
+
+
+
static List<ComponentFactory> orderAjaxTableToEnd(List<ComponentFactory> componentFactories) {
int ajaxTableIdx = findAjaxTable(componentFactories);
if(ajaxTableIdx>=0) {
@@ -134,38 +481,6 @@ public class CollectionContentsLinksSelectorPanel extends LinksSelectorPanelAbst
return renderFacet != null && renderFacet.value() == Type.EAGERLY;
}
- /**
- * Iterates up the component hierarchy looking for a parent
- * {@link CollectionPanel}, and if so adds to ajax target so that it'll
- * be repainted.
- *
- * <p>
- * Yeah, agreed, it's a little bit hacky doing it this way, because it bakes
- * in knowledge that this component is created, somehow, by a parent {@link CollectionPanel}.
- * Perhaps it could be refactored to use a more general purpose observer pattern?
- *
- * <p>
- * In fact, I've since discovered that Wicket has an event bus, which is used by the
- * {@link UiHintContainer hinting mechanism}. So this ought to be relatively easy to do.
- */
- protected void onSelect(AjaxRequestTarget target) {
- super.onSelect(target);
- Component component = this;
- while(component != null) {
- if(component instanceof CollectionPanel) {
- CollectionPanel collectionPanel = (CollectionPanel) component;
- boolean hasCount = collectionPanel.hasCount();
- if(hasCount) {
- collectionPanel.updateLabel(target);
- }
- if(additionalLinks != null) {
- applyCssVisibility(additionalLinks, hasCount);
- }
- return;
- }
- component = component.getParent();
- }
- }
@Override
public Integer getCount() {
@@ -177,5 +492,4 @@ public class CollectionContentsLinksSelectorPanel extends LinksSelectorPanelAbst
}
}
-
}
http://git-wip-us.apache.org/repos/asf/isis/blob/b1677ca8/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/selector/links/EntityLinksSelectorPanel.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/selector/links/EntityLinksSelectorPanel.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/selector/links/EntityLinksSelectorPanel.java
index 378f277..7cab8d8 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/selector/links/EntityLinksSelectorPanel.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/selector/links/EntityLinksSelectorPanel.java
@@ -19,15 +19,45 @@
package org.apache.isis.viewer.wicket.ui.components.entity.selector.links;
-import java.util.List;
+import de.agilecoders.wicket.core.markup.html.bootstrap.button.Buttons;
+import java.util.ArrayList;
+import java.util.List;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
+import com.google.common.collect.Lists;
+import org.apache.wicket.AttributeModifier;
+import org.apache.wicket.Component;
+import org.apache.wicket.MarkupContainer;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.markup.html.AjaxLink;
+import org.apache.wicket.event.Broadcast;
+import org.apache.wicket.markup.ComponentTag;
+import org.apache.wicket.markup.head.IHeaderResponse;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+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.model.IModel;
-
+import org.apache.wicket.model.Model;
+import org.apache.isis.core.commons.lang.StringExtensions;
+import org.apache.isis.viewer.wicket.model.hints.IsisUiHintEvent;
import org.apache.isis.viewer.wicket.model.hints.UiHintContainer;
+import org.apache.isis.viewer.wicket.model.hints.UiHintPathSignificant;
+import org.apache.isis.viewer.wicket.model.links.LinkAndLabel;
+import org.apache.isis.viewer.wicket.model.links.LinksProvider;
import org.apache.isis.viewer.wicket.model.models.EntityModel;
+import org.apache.isis.viewer.wicket.ui.CollectionContentsAsFactory;
import org.apache.isis.viewer.wicket.ui.ComponentFactory;
import org.apache.isis.viewer.wicket.ui.ComponentType;
+import org.apache.isis.viewer.wicket.ui.components.additionallinks.AdditionalLinksPanel;
+import org.apache.isis.viewer.wicket.ui.panels.PanelAbstract;
+import org.apache.isis.viewer.wicket.ui.panels.PanelUtil;
import org.apache.isis.viewer.wicket.ui.selector.links.LinksSelectorPanelAbstract;
+import org.apache.isis.viewer.wicket.ui.util.Components;
+import org.apache.isis.viewer.wicket.ui.util.CssClassAppender;
+import org.apache.isis.viewer.wicket.ui.util.CssClassRemover;
/**
* Provides a list of links for selecting other views that support
@@ -37,20 +67,47 @@ import org.apache.isis.viewer.wicket.ui.selector.links.LinksSelectorPanelAbstrac
* Most of the heavy lifting is factored out into the superclass,
* {@link LinksSelectorPanelAbstract}.
*/
-public class EntityLinksSelectorPanel extends LinksSelectorPanelAbstract<EntityModel> {
+public class EntityLinksSelectorPanel extends PanelAbstract<EntityModel> implements UiHintPathSignificant {
+
private static final long serialVersionUID = 1L;
+ private static final String INVISIBLE_CLASS = "link-selector-panel-invisible";
+ private static final int MAX_NUM_UNDERLYING_VIEWS = 10;
+
+ private static final String ID_ADDITIONAL_LINKS = "additionalLinks";
+ public static final String ID_ADDITIONAL_LINK = "additionalLink";
+
+ private static final String ID_VIEWS = "views";
+ private static final String ID_VIEW_LIST = "viewList";
+ private static final String ID_VIEW_LINK = "viewLink";
+ private static final String ID_VIEW_ITEM = "viewItem";
+ private static final String ID_VIEW_ITEM_TITLE = "viewItemTitle";
+ private static final String ID_VIEW_ITEM_ICON = "viewItemIcon";
+
+ private static final String UIHINT_VIEW = "view";
+ private static final String ID_VIEW_BUTTON_TITLE = "viewButtonTitle";
+ private static final String ID_VIEW_BUTTON_ICON = "viewButtonIcon";
+
+ private final ComponentType componentType;
+ private final String underlyingIdPrefix;
+
+ private ComponentFactory selectedComponentFactory;
+ protected Component selectedComponent;
+
+ /**
+ * May be <tt>null</tt>, depending upon the model implementation.
+ */
+ protected WebMarkupContainer additionalLinks;
+
+
public EntityLinksSelectorPanel(final String id, final EntityModel model, final ComponentFactory factory) {
- super(id, ComponentType.ENTITY.toString(), model, factory);
+ super(id, model);
+ this.underlyingIdPrefix = ComponentType.ENTITY.toString();
+ this.componentType = factory.getComponentType();
}
- @Override
- protected EntityModel dummyOf(EntityModel model) {
- return model;
- }
- @Override
protected int determineInitialFactory(List<ComponentFactory> componentFactories, IModel<?> model) {
return 0;
}
@@ -61,4 +118,281 @@ public class EntityLinksSelectorPanel extends LinksSelectorPanelAbstract<EntityM
return null;
}
+
+ /**
+ * Build UI only after added to parent.
+ */
+ public void onInitialize() {
+ super.onInitialize();
+ ComponentFactory componentFactory = getComponentFactoryRegistry().findComponentFactoryElseFailFast(getComponentType(), getModel());
+ addAdditionalLinks(getModel());
+ addUnderlyingViews(underlyingIdPrefix, getModel(), componentFactory);
+ }
+
+ protected void addAdditionalLinks(final EntityModel model) {
+ if(!(model instanceof LinksProvider)) {
+ permanentlyHide(ID_ADDITIONAL_LINKS);
+ return;
+ }
+ LinksProvider linksProvider = (LinksProvider) model;
+ List<LinkAndLabel> links = linksProvider.getLinks();
+
+ addAdditionalLinks(this, links);
+ }
+
+ protected void addAdditionalLinks(MarkupContainer markupContainer, List<LinkAndLabel> links) {
+ if(links == null || links.isEmpty()) {
+ Components.permanentlyHide(markupContainer, ID_ADDITIONAL_LINKS);
+ return;
+ }
+ links = Lists.newArrayList(links); // copy, to serialize any lazy evaluation
+
+ additionalLinks = new AdditionalLinksPanel(ID_ADDITIONAL_LINKS, links);
+ markupContainer.addOrReplace(additionalLinks);
+ }
+
+ private void addUnderlyingViews(final String underlyingIdPrefix, final EntityModel model, final ComponentFactory factory) {
+ final List<ComponentFactory> componentFactories = findOtherComponentFactories(model, factory);
+
+ final int selected = honourViewHintElseDefault(componentFactories, model);
+
+ final EntityLinksSelectorPanel selectorPanel = this;
+
+ // create all, hide the one not selected
+ final Component[] underlyingViews = new Component[MAX_NUM_UNDERLYING_VIEWS];
+ int i = 0;
+ final EntityModel emptyModel = dummyOf(model);
+ for (ComponentFactory componentFactory : componentFactories) {
+ final String underlyingId = underlyingIdPrefix + "-" + i;
+
+ Component underlyingView = componentFactory.createComponent(underlyingId,i==selected? model: emptyModel);
+ underlyingViews[i++] = underlyingView;
+ selectorPanel.addOrReplace(underlyingView);
+ }
+
+ // hide any unused placeholders
+ while(i<MAX_NUM_UNDERLYING_VIEWS) {
+ String underlyingId = underlyingIdPrefix + "-" + i;
+ permanentlyHide(underlyingId);
+ i++;
+ }
+
+ // selector
+ if (componentFactories.size() <= 1) {
+ permanentlyHide(ID_VIEWS);
+ } else {
+ final Model<ComponentFactory> componentFactoryModel = new Model<>();
+
+ selectorPanel.selectedComponentFactory = componentFactories.get(selected);
+ componentFactoryModel.setObject(selectorPanel.selectedComponentFactory);
+
+ final WebMarkupContainer views = new WebMarkupContainer(ID_VIEWS);
+
+ final Label viewButtonTitle = new Label(ID_VIEW_BUTTON_TITLE, "Hidden");
+ views.addOrReplace(viewButtonTitle);
+
+ final Label viewButtonIcon = new Label(ID_VIEW_BUTTON_ICON, "");
+ views.addOrReplace(viewButtonIcon);
+
+ final WebMarkupContainer container = new WebMarkupContainer(ID_VIEW_LIST);
+
+ views.addOrReplace(container);
+ views.setOutputMarkupId(true);
+
+ this.setOutputMarkupId(true);
+
+ final ListView<ComponentFactory> listView = new ListView<ComponentFactory>(ID_VIEW_ITEM, componentFactories) {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void populateItem(ListItem<ComponentFactory> item) {
+
+ final int underlyingViewNum = item.getIndex();
+
+ final ComponentFactory componentFactory = item.getModelObject();
+ final AbstractLink link = new AjaxLink<Void>(ID_VIEW_LINK) {
+ private static final long serialVersionUID = 1L;
+ @Override
+ public void onClick(AjaxRequestTarget target) {
+ EntityLinksSelectorPanel linksSelectorPanel = EntityLinksSelectorPanel.this;
+ linksSelectorPanel.setViewHintAndBroadcast(underlyingViewNum, target);
+
+ final EntityModel dummyModel = dummyOf(model);
+ for(int i=0; i<MAX_NUM_UNDERLYING_VIEWS; i++) {
+ final Component component = underlyingViews[i];
+ if(component == null) {
+ continue;
+ }
+ final boolean isSelected = i == underlyingViewNum;
+ applyCssVisibility(component, isSelected);
+ component.setDefaultModel(isSelected? model: dummyModel);
+ }
+
+ selectorPanel.selectedComponentFactory = componentFactory;
+ selectorPanel.selectedComponent = underlyingViews[underlyingViewNum];
+ selectorPanel.onSelect(target);
+ target.add(selectorPanel, views);
+ }
+
+ @Override
+ protected void onComponentTag(ComponentTag tag) {
+ super.onComponentTag(tag);
+ Buttons.fixDisabledState(this, tag);
+ }
+ };
+
+ IModel<String> title = nameFor(componentFactory);
+ Label viewItemTitleLabel = new Label(ID_VIEW_ITEM_TITLE, title);
+ link.add(viewItemTitleLabel);
+
+ Label viewItemIcon = new Label(ID_VIEW_ITEM_ICON, "");
+ link.add(viewItemIcon);
+
+ boolean isEnabled = componentFactory != selectorPanel.selectedComponentFactory;
+ if (!isEnabled) {
+ viewButtonTitle.setDefaultModel(title);
+ IModel<String> cssClass = cssClassFor(componentFactory, viewButtonIcon);
+ viewButtonIcon.add(AttributeModifier.replace("class", "ViewLinkItem " + cssClass.getObject()));
+ link.setVisible(false);
+ } else {
+ IModel<String> cssClass = cssClassFor(componentFactory, viewItemIcon);
+ viewItemIcon.add(new CssClassAppender(cssClass));
+ }
+
+ item.add(link);
+ }
+
+ private IModel<String> cssClassFor(final ComponentFactory componentFactory, Label viewIcon) {
+ IModel<String> cssClass = null;
+ if (componentFactory instanceof CollectionContentsAsFactory) {
+ CollectionContentsAsFactory collectionContentsAsFactory = (CollectionContentsAsFactory) componentFactory;
+ cssClass = collectionContentsAsFactory.getCssClass();
+ viewIcon.setDefaultModelObject("");
+ viewIcon.setEscapeModelStrings(true);
+ }
+ if (cssClass == null) {
+ String name = componentFactory.getName();
+ cssClass = Model.of(StringExtensions.asLowerDashed(name));
+ // Small hack: if there is no specific CSS class then we assume that background-image is used
+ // the span.ViewItemLink should have some content to show it
+ // FIX: find a way to do this with CSS (width and height don't seems to help)
+ viewIcon.setDefaultModelObject("     ");
+ viewIcon.setEscapeModelStrings(false);
+ }
+ return cssClass;
+ }
+
+ private IModel<String> nameFor(final ComponentFactory componentFactory) {
+ IModel<String> name = null;
+ if (componentFactory instanceof CollectionContentsAsFactory) {
+ CollectionContentsAsFactory collectionContentsAsFactory = (CollectionContentsAsFactory) componentFactory;
+ name = collectionContentsAsFactory.getTitleLabel();
+ }
+ if (name == null) {
+ name = Model.of(componentFactory.getName());
+ }
+ return name;
+ }
+ };
+ container.add(listView);
+ addOrReplace(views);
+ }
+
+ for(i=0; i<MAX_NUM_UNDERLYING_VIEWS; i++) {
+ Component component = underlyingViews[i];
+ if(component != null) {
+ if(i != selected) {
+ component.add(new CssClassAppender(INVISIBLE_CLASS));
+ } else {
+ selectedComponent = component;
+ }
+ }
+ }
+ }
+
+
+
+ protected void setViewHintAndBroadcast(int viewNum, AjaxRequestTarget target) {
+ final UiHintContainer uiHintContainer = getUiHintContainer();
+ if(uiHintContainer == null) {
+ return;
+ }
+ uiHintContainer.setHint(this, UIHINT_VIEW, ""+viewNum);
+ send(getPage(), Broadcast.EXACT, new IsisUiHintEvent(uiHintContainer, target));
+ }
+
+ /**
+ * Overrideable hook.
+ */
+ protected void onSelect(AjaxRequestTarget target) {
+ }
+
+ /**
+ * Ask for a dummy (empty) {@link Model} to pass into those components that are rendered but will be
+ * made invisible using CSS styling.
+ */
+ protected EntityModel dummyOf(EntityModel model) {
+ return model;
+ }
+
+ protected static void applyCssVisibility(final Component component, final boolean visible) {
+ if(component == null) {
+ return;
+ }
+ AttributeModifier modifier = visible ? new CssClassRemover(INVISIBLE_CLASS) : new CssClassAppender(INVISIBLE_CLASS);
+ component.add(modifier);
+ }
+
+ protected int honourViewHintElseDefault(final List<ComponentFactory> componentFactories, final IModel<?> model) {
+ // honour hints ...
+ final UiHintContainer hintContainer = getUiHintContainer();
+ if(hintContainer != null) {
+ String viewStr = hintContainer.getHint(this, UIHINT_VIEW);
+ if(viewStr != null) {
+ try {
+ int view = Integer.parseInt(viewStr);
+ if(view >= 0 && view < componentFactories.size()) {
+ return view;
+ }
+ } catch(NumberFormatException ex) {
+ // ignore
+ }
+ }
+ }
+
+ // ... else default
+ int initialFactory = determineInitialFactory(componentFactories, model);
+ if(hintContainer != null) {
+ hintContainer.setHint(this, UIHINT_VIEW, ""+initialFactory);
+ // don't broadcast (no AjaxRequestTarget, still configuring initial setup)
+ }
+ return initialFactory;
+ }
+
+
+ private List<ComponentFactory> findOtherComponentFactories(final EntityModel model, final ComponentFactory ignoreFactory) {
+ final List<ComponentFactory> componentFactories = getComponentFactoryRegistry().findComponentFactories(componentType, model);
+ ArrayList<ComponentFactory> otherFactories = Lists.newArrayList(Collections2.filter(componentFactories, new Predicate<ComponentFactory>() {
+ @Override
+ public boolean apply(final ComponentFactory input) {
+ return input != ignoreFactory;
+ }
+ }));
+ return ordered(otherFactories);
+ }
+
+ protected List<ComponentFactory> ordered(List<ComponentFactory> otherFactories) {
+ return otherFactories;
+ }
+
+
+ @Override
+ public void renderHead(final IHeaderResponse response) {
+ super.renderHead(response);
+ PanelUtil.renderHead(response, LinksSelectorPanelAbstract.class);
+ }
+
+
+
}
http://git-wip-us.apache.org/repos/asf/isis/blob/b1677ca8/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/selector/links/LinksSelectorPanelAbstract.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/selector/links/LinksSelectorPanelAbstract.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/selector/links/LinksSelectorPanelAbstract.java
index e494ce8..2b6b96f 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/selector/links/LinksSelectorPanelAbstract.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/selector/links/LinksSelectorPanelAbstract.java
@@ -73,20 +73,20 @@ public abstract class LinksSelectorPanelAbstract<T extends IModel<?>> extends Pa
private static final String ID_VIEW_ITEM = "viewItem";
private static final String ID_VIEW_ITEM_TITLE = "viewItemTitle";
private static final String ID_VIEW_ITEM_ICON = "viewItemIcon";
-
+
private static final String UIHINT_VIEW = "view";
private static final String ID_VIEW_BUTTON_TITLE = "viewButtonTitle";
private static final String ID_VIEW_BUTTON_ICON = "viewButtonIcon";
private final ComponentType componentType;
private final String underlyingIdPrefix;
-
+
private ComponentFactory selectedComponentFactory;
protected Component selectedComponent;
/**
* May be <tt>null</tt>, depending upon the model implementation.
- *
+ *
* @see #addAdditionalLinks(IModel)
*/
protected WebMarkupContainer additionalLinks;
@@ -97,7 +97,7 @@ public abstract class LinksSelectorPanelAbstract<T extends IModel<?>> extends Pa
this.underlyingIdPrefix = underlyingIdPrefix;
this.componentType = factory.getComponentType();
}
-
+
/**
* Build UI only after added to parent.
*/
@@ -115,7 +115,7 @@ public abstract class LinksSelectorPanelAbstract<T extends IModel<?>> extends Pa
}
LinksProvider linksProvider = (LinksProvider) model;
List<LinkAndLabel> links = linksProvider.getLinks();
-
+
addAdditionalLinks(this, links);
}
@@ -125,25 +125,25 @@ public abstract class LinksSelectorPanelAbstract<T extends IModel<?>> extends Pa
return;
}
links = Lists.newArrayList(links); // copy, to serialize any lazy evaluation
-
+
additionalLinks = new AdditionalLinksPanel(ID_ADDITIONAL_LINKS, links);
markupContainer.addOrReplace(additionalLinks);
}
-
+
private void addUnderlyingViews(final String underlyingIdPrefix, final T model, final ComponentFactory factory) {
final List<ComponentFactory> componentFactories = findOtherComponentFactories(model, factory);
final int selected = honourViewHintElseDefault(componentFactories, model);
final LinksSelectorPanelAbstract<T> selectorPanel = LinksSelectorPanelAbstract.this;
-
+
// create all, hide the one not selected
final Component[] underlyingViews = new Component[MAX_NUM_UNDERLYING_VIEWS];
int i = 0;
final T emptyModel = dummyOf(model);
for (ComponentFactory componentFactory : componentFactories) {
final String underlyingId = underlyingIdPrefix + "-" + i;
-
+
Component underlyingView = componentFactory.createComponent(underlyingId,i==selected? model: emptyModel);
underlyingViews[i++] = underlyingView;
selectorPanel.addOrReplace(underlyingView);
@@ -155,13 +155,13 @@ public abstract class LinksSelectorPanelAbstract<T extends IModel<?>> extends Pa
permanentlyHide(underlyingId);
i++;
}
-
+
// selector
if (componentFactories.size() <= 1) {
permanentlyHide(ID_VIEWS);
} else {
final Model<ComponentFactory> componentFactoryModel = new Model<>();
-
+
selectorPanel.selectedComponentFactory = componentFactories.get(selected);
componentFactoryModel.setObject(selectorPanel.selectedComponentFactory);
@@ -174,21 +174,21 @@ public abstract class LinksSelectorPanelAbstract<T extends IModel<?>> extends Pa
views.addOrReplace(viewButtonIcon);
final WebMarkupContainer container = new WebMarkupContainer(ID_VIEW_LIST);
-
+
views.addOrReplace(container);
views.setOutputMarkupId(true);
-
+
this.setOutputMarkupId(true);
-
+
final ListView<ComponentFactory> listView = new ListView<ComponentFactory>(ID_VIEW_ITEM, componentFactories) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(ListItem<ComponentFactory> item) {
-
+
final int underlyingViewNum = item.getIndex();
-
+
final ComponentFactory componentFactory = item.getModelObject();
final AbstractLink link = new AjaxLink<Void>(ID_VIEW_LINK) {
private static final long serialVersionUID = 1L;
@@ -196,7 +196,7 @@ public abstract class LinksSelectorPanelAbstract<T extends IModel<?>> extends Pa
public void onClick(AjaxRequestTarget target) {
LinksSelectorPanelAbstract<T> linksSelectorPanel = LinksSelectorPanelAbstract.this;
linksSelectorPanel.setViewHintAndBroadcast(underlyingViewNum, target);
-
+
final T dummyModel = dummyOf(model);
for(int i=0; i<MAX_NUM_UNDERLYING_VIEWS; i++) {
final Component component = underlyingViews[i];
@@ -207,7 +207,7 @@ public abstract class LinksSelectorPanelAbstract<T extends IModel<?>> extends Pa
applyCssVisibility(component, isSelected);
component.setDefaultModel(isSelected? model: dummyModel);
}
-
+
selectorPanel.selectedComponentFactory = componentFactory;
selectorPanel.selectedComponent = underlyingViews[underlyingViewNum];
selectorPanel.onSelect(target);
@@ -277,7 +277,7 @@ public abstract class LinksSelectorPanelAbstract<T extends IModel<?>> extends Pa
container.add(listView);
addOrReplace(views);
}
-
+
for(i=0; i<MAX_NUM_UNDERLYING_VIEWS; i++) {
Component component = underlyingViews[i];
if(component != null) {
@@ -365,7 +365,7 @@ public abstract class LinksSelectorPanelAbstract<T extends IModel<?>> extends Pa
return otherFactories;
}
-
+
@Override
public void renderHead(final IHeaderResponse response) {
super.renderHead(response);
[15/23] isis git commit: ISIS-537: refactoring out SelectorHelper
Posted by da...@apache.org.
ISIS-537: refactoring out SelectorHelper
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/457b3653
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/457b3653
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/457b3653
Branch: refs/heads/ISIS-939
Commit: 457b365355836c4ad47ff343e992c104b8984e83
Parents: 70af3c3
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Sun Nov 9 15:31:24 2014 +0000
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Mon Nov 10 10:21:42 2014 +0000
----------------------------------------------------------------------
.../viewer/wicket/model/models/EntityModel.java | 5 +-
.../CollectionContentsSelectorHelper.java | 96 ++++++++++++++++++++
...ectionContentsSelectorDropdownPanelTest.java | 67 ++++++++++++++
...ollectionContentsLinksSelectorPanelTest.java | 69 --------------
.../java/dom/todo/ToDoItemContributions.java | 3 +-
5 files changed, 165 insertions(+), 75 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/457b3653/component/viewer/wicket/model/src/main/java/org/apache/isis/viewer/wicket/model/models/EntityModel.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/model/src/main/java/org/apache/isis/viewer/wicket/model/models/EntityModel.java b/component/viewer/wicket/model/src/main/java/org/apache/isis/viewer/wicket/model/models/EntityModel.java
index 3955c31..6c66859 100644
--- a/component/viewer/wicket/model/src/main/java/org/apache/isis/viewer/wicket/model/models/EntityModel.java
+++ b/component/viewer/wicket/model/src/main/java/org/apache/isis/viewer/wicket/model/models/EntityModel.java
@@ -132,13 +132,11 @@ public class EntityModel extends BookmarkableModel<ObjectAdapter> implements UiH
private final Map<PropertyMemento, ScalarModel> propertyScalarModels = Maps.newHashMap();
private MemberGroupLayoutHint memberGroupLayoutHint;
-
/**
* Toggled by 'entityDetailsButton'.
*/
private boolean entityDetailsVisible;
-
/**
* {@link ConcurrencyException}, if any, that might have occurred previously
*/
@@ -479,8 +477,7 @@ public class EntityModel extends BookmarkableModel<ObjectAdapter> implements UiH
return null;
}
String hintKey = hintKey(component, key);
- String value = hints.get(hintKey);
- return value;
+ return hints.get(hintKey);
}
@Override
http://git-wip-us.apache.org/repos/asf/isis/blob/457b3653/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorHelper.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorHelper.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorHelper.java
new file mode 100644
index 0000000..6b796b5
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorHelper.java
@@ -0,0 +1,96 @@
+/*
+ * 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.viewer.wicket.ui.components.collectioncontents.selector.dropdown;
+
+import java.util.ArrayList;
+import java.util.List;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
+import com.google.common.collect.Lists;
+import org.apache.isis.viewer.wicket.model.models.EntityCollectionModel;
+import org.apache.isis.viewer.wicket.ui.ComponentFactory;
+import org.apache.isis.viewer.wicket.ui.ComponentType;
+import org.apache.isis.viewer.wicket.ui.app.registry.ComponentFactoryRegistry;
+import org.apache.isis.viewer.wicket.ui.components.collectioncontents.ajaxtable.CollectionContentsAsAjaxTablePanelFactory;
+import org.apache.isis.viewer.wicket.ui.components.collectioncontents.selector.links.CollectionContentsLinksSelectorPanelFactory;
+
+public class CollectionContentsSelectorHelper {
+
+ private static final long serialVersionUID = 1L;
+
+ private final ComponentType componentType;
+ private final ComponentFactoryRegistry componentFactoryRegistry;
+ private final EntityCollectionModel model;
+ private final ComponentFactory ignoreFactory;
+
+
+ public CollectionContentsSelectorHelper(
+ final ComponentType componentType,
+ final ComponentFactoryRegistry componentFactoryRegistry,
+ final EntityCollectionModel model,
+ final ComponentFactory ignoreFactory) {
+ this.componentType = componentType;
+ this.componentFactoryRegistry = componentFactoryRegistry;
+ this.model = model;
+ this.ignoreFactory = ignoreFactory;
+ }
+
+
+ public List<ComponentFactory> findOtherComponentFactories() {
+ final List<ComponentFactory> componentFactories = componentFactoryRegistry.findComponentFactories(componentType, model);
+ ArrayList<ComponentFactory> otherFactories = Lists.newArrayList(Collections2.filter(componentFactories, new Predicate<ComponentFactory>() {
+ @Override
+ public boolean apply(final ComponentFactory input) {
+ return input != ignoreFactory && input.getClass() != CollectionContentsLinksSelectorPanelFactory.class;
+ }
+ }));
+ return ordered(otherFactories);
+ }
+
+ private static List<ComponentFactory> ordered(List<ComponentFactory> componentFactories) {
+ return orderAjaxTableToEnd(componentFactories);
+ }
+
+
+
+ static List<ComponentFactory> orderAjaxTableToEnd(List<ComponentFactory> componentFactories) {
+ int ajaxTableIdx = findAjaxTable(componentFactories);
+ if(ajaxTableIdx>=0) {
+ List<ComponentFactory> orderedFactories = Lists.newArrayList(componentFactories);
+ ComponentFactory ajaxTableFactory = orderedFactories.remove(ajaxTableIdx);
+ orderedFactories.add(ajaxTableFactory);
+ return orderedFactories;
+ } else {
+ return componentFactories;
+ }
+ }
+
+ public static int findAjaxTable(List<ComponentFactory> componentFactories) {
+ for(int i=0; i<componentFactories.size(); i++) {
+ if(componentFactories.get(i) instanceof CollectionContentsAsAjaxTablePanelFactory) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/457b3653/component/viewer/wicket/ui/src/test/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorDropdownPanelTest.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/test/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorDropdownPanelTest.java b/component/viewer/wicket/ui/src/test/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorDropdownPanelTest.java
new file mode 100644
index 0000000..d116be4
--- /dev/null
+++ b/component/viewer/wicket/ui/src/test/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorDropdownPanelTest.java
@@ -0,0 +1,67 @@
+/*
+ * 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.viewer.wicket.ui.components.collectioncontents.selector.dropdown;
+
+import java.util.Arrays;
+import java.util.List;
+import org.jmock.auto.Mock;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2.Mode;
+import org.apache.isis.viewer.wicket.ui.ComponentFactory;
+import org.apache.isis.viewer.wicket.ui.components.collectioncontents.ajaxtable.CollectionContentsAsAjaxTablePanelFactory;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+public class CollectionContentsSelectorDropdownPanelTest {
+
+ @Rule
+ public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
+
+ @Mock
+ private ComponentFactory one;
+
+ @Mock
+ private ComponentFactory two;
+
+ private ComponentFactory ajaxTableComponentFactory;
+
+ @Before
+ public void setUp() throws Exception {
+ ajaxTableComponentFactory = new CollectionContentsAsAjaxTablePanelFactory();
+ }
+
+ @Test
+ public void testOrderAjaxTableToEnd() {
+
+ List<ComponentFactory> componentFactories =
+ Arrays.<ComponentFactory>asList(
+ one,
+ ajaxTableComponentFactory,
+ two);
+ List<ComponentFactory> orderAjaxTableToEnd = CollectionContentsSelectorDropdownPanel.orderAjaxTableToEnd(componentFactories);
+ assertThat(orderAjaxTableToEnd.get(0), is(one));
+ assertThat(orderAjaxTableToEnd.get(1), is(two));
+ assertThat(orderAjaxTableToEnd.get(2), is(ajaxTableComponentFactory));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/457b3653/component/viewer/wicket/ui/src/test/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanelTest.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/test/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanelTest.java b/component/viewer/wicket/ui/src/test/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanelTest.java
deleted file mode 100644
index 60e6351..0000000
--- a/component/viewer/wicket/ui/src/test/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanelTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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.viewer.wicket.ui.components.collectioncontents.selector.links;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.jmock.auto.Mock;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
-import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2.Mode;
-import org.apache.isis.viewer.wicket.ui.ComponentFactory;
-import org.apache.isis.viewer.wicket.ui.components.collectioncontents.ajaxtable.CollectionContentsAsAjaxTablePanelFactory;
-
-public class CollectionContentsLinksSelectorPanelTest {
-
- @Rule
- public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
-
- @Mock
- private ComponentFactory one;
-
- @Mock
- private ComponentFactory two;
-
- private ComponentFactory ajaxTableComponentFactory;
-
- @Before
- public void setUp() throws Exception {
- ajaxTableComponentFactory = new CollectionContentsAsAjaxTablePanelFactory();
- }
-
- @Test
- public void testOrderAjaxTableToEnd() {
-
- List<ComponentFactory> componentFactories =
- Arrays.<ComponentFactory>asList(
- one,
- ajaxTableComponentFactory,
- two);
- List<ComponentFactory> orderAjaxTableToEnd = CollectionContentsLinksSelectorPanel.orderAjaxTableToEnd(componentFactories);
- assertThat(orderAjaxTableToEnd.get(0), is(one));
- assertThat(orderAjaxTableToEnd.get(1), is(two));
- assertThat(orderAjaxTableToEnd.get(2), is(ajaxTableComponentFactory));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/457b3653/example/application/todoapp/dom/src/main/java/dom/todo/ToDoItemContributions.java
----------------------------------------------------------------------
diff --git a/example/application/todoapp/dom/src/main/java/dom/todo/ToDoItemContributions.java b/example/application/todoapp/dom/src/main/java/dom/todo/ToDoItemContributions.java
index 1b758f8..71d9142 100644
--- a/example/application/todoapp/dom/src/main/java/dom/todo/ToDoItemContributions.java
+++ b/example/application/todoapp/dom/src/main/java/dom/todo/ToDoItemContributions.java
@@ -159,10 +159,9 @@ public class ToDoItemContributions extends AbstractFactoryAndRepository {
@NotInServiceMenu
@ActionSemantics(Of.SAFE)
@NotContributed(As.ACTION)
- @Programmatic
public List<ToDoItem> similarTo(final ToDoItem toDoItem) {
final List<ToDoItem> similarToDoItems = allMatches(
- new QueryDefault<ToDoItem>(ToDoItem.class,
+ new QueryDefault<ToDoItem>(ToDoItem.class,
"findByOwnedByAndCategory",
"ownedBy", currentUserName(),
"category", toDoItem.getCategory()));
[04/23] isis git commit: ISIS-537 Use NotificationPanel instead of
FeedbackPanel
Posted by da...@apache.org.
ISIS-537 Use NotificationPanel instead of FeedbackPanel
https://trello.com/c/OB0ja10z/111-replace-all-usages-of-feedbackpanel-in-the-addons-with-notificationpanel-for-consistency-with-isis
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/8c0a5acd
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/8c0a5acd
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/8c0a5acd
Branch: refs/heads/ISIS-939
Commit: 8c0a5acda672b9f617a2542266c443f18704adb3
Parents: 8a2c825
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Fri Nov 7 13:29:14 2014 +0200
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Fri Nov 7 13:29:14 2014 +0200
----------------------------------------------------------------------
.../ui/components/entity/properties/EntityPropertiesForm.java | 3 +--
.../ui/components/widgets/formcomponent/FormFeedbackPanel.java | 5 ++---
2 files changed, 3 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/8c0a5acd/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/properties/EntityPropertiesForm.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/properties/EntityPropertiesForm.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/properties/EntityPropertiesForm.java
index 6dc5cd6..7fa2f99 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/properties/EntityPropertiesForm.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/properties/EntityPropertiesForm.java
@@ -36,7 +36,6 @@ import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Button;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.FormComponent;
-import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.markup.repeater.RepeatingView;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.ResourceModel;
@@ -107,7 +106,7 @@ public class EntityPropertiesForm extends FormAbstract<ObjectAdapter> {
private Button okButton;
private Button cancelButton;
- private FeedbackPanel feedback;
+ private NotificationPanel feedback;
private boolean renderedFirstField;
http://git-wip-us.apache.org/repos/asf/isis/blob/8c0a5acd/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/formcomponent/FormFeedbackPanel.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/formcomponent/FormFeedbackPanel.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/formcomponent/FormFeedbackPanel.java
index d673f24..d3ff54a 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/formcomponent/FormFeedbackPanel.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/formcomponent/FormFeedbackPanel.java
@@ -24,12 +24,11 @@ import de.agilecoders.wicket.core.markup.html.bootstrap.common.NotificationPanel
import org.apache.wicket.feedback.FeedbackMessage;
import org.apache.wicket.feedback.IFeedbackMessageFilter;
import org.apache.wicket.markup.html.form.FormComponent;
-import org.apache.wicket.markup.html.panel.FeedbackPanel;
/**
- * {@link FeedbackPanel} designed for forms; filters out any
+ * {@link NotificationPanel} designed for forms; filters out any
* {@link FeedbackMessage}s from {@link FormComponent}s (the idea being that
- * they will have their own {@link FeedbackPanel}s.
+ * they will have their own {@link NotificationPanel}s.
*/
public class FormFeedbackPanel extends NotificationPanel {
private static final long serialVersionUID = 1L;
[08/23] isis git commit: ISIS-537: moved markup and CSS for
LinksSelectorPanelAbstract into its subclasses
(CollectionContentsLinkSelectorPanel and EntityLinksSelectorPanel).
Posted by da...@apache.org.
ISIS-537: moved markup and CSS for LinksSelectorPanelAbstract into its subclasses (CollectionContentsLinkSelectorPanel and EntityLinksSelectorPanel).
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/3b80b5e3
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/3b80b5e3
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/3b80b5e3
Branch: refs/heads/ISIS-939
Commit: 3b80b5e374c0ebf617ad72fa0f1ac9f7efac4688
Parents: 27545b0
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Sun Nov 9 11:37:24 2014 +0000
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Mon Nov 10 10:21:34 2014 +0000
----------------------------------------------------------------------
.../CollectionContentsLinksSelectorPanel.css | 39 ++++++++++++++++++
.../CollectionContentsLinksSelectorPanel.html | 42 +++++++++++++++-----
.../selector/links/EntityLinksSelectorPanel.css | 37 +++++++++++++++++
.../links/EntityLinksSelectorPanel.html | 42 +++++++++++++++-----
.../links/LinksSelectorPanelAbstract.css | 37 -----------------
5 files changed, 138 insertions(+), 59 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/3b80b5e3/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.css
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.css b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.css
index 084d9ca..8c3902e 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.css
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.css
@@ -16,6 +16,45 @@
* specific language governing permissions and limitations
* under the License.
*/
+.linksSelectorPanel .viewLinks {
+ float:right;
+ display:block;
+}
+
+.linksSelectorPanel ul.dropdown-menu {
+ min-width: 0;
+}
+
+.linksSelectorPanel ul.dropdown-menu li.viewItem {
+ min-width: 0;
+}
+
+.linksSelectorPanel ul.viewList li.viewItem:first-child span {
+ border-radius:4px 0 0 4px;
+ -moz-border-radius:4px 0 0 4px;
+ -webkit-border-radius:4px 0 0 4px;
+}
+
+.linksSelectorPanel ul.viewList li.viewItem:last-child span {
+ border-radius:0 4px 4px 0;
+ -moz-border-radius:0 4px 4px 0;
+ -webkit-border-radius:0 4px 4px 0;
+}
+
+
+.linksSelectorPanel .link-selector-panel-invisible {
+ display:none;
+}
+
+.linksSelectorPanel .list-inline {
+ margin-left: 0;
+}
+
+.linksSelectorPanel .list-inline li {
+ padding-left: 0;
+}
+
+
.collectionContentsLinksSelectorPanel select {
margin-bottom: 1em;
}
http://git-wip-us.apache.org/repos/asf/isis/blob/3b80b5e3/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.html
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.html b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.html
index 22a440b..d35d523 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.html
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.html
@@ -7,9 +7,9 @@
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
@@ -17,12 +17,31 @@
specific language governing permissions and limitations
under the License.
-->
-<html xmlns="http://www.w3.org/1999/xhtml"
- xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd"
- xml:lang="en"
- lang="en">
- <body>
- <wicket:extend>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns:wicket="http://wicket.apache.org">
+<body>
+<wicket:panel>
+ <div class="linksSelectorPanel">
+ <div class="btn-group viewLinks" wicket:id="views">
+ <button type="button" class="btn btn-xs btn-info">
+ <span wicket:id="viewButtonIcon" class="ViewLinkItem"></span>
+ <span wicket:id="viewButtonTitle" class="ViewLinkItemTitle"></span>
+ </button>
+ <button type="button" class="btn btn-xs btn-info dropdown-toggle" data-toggle="dropdown">
+ <span class="caret"></span>
+ </button>
+ <ul wicket:id="viewList" class="dropdown-menu dropdown-menu-right" role="menu">
+ <li wicket:id="viewItem" class="viewItem">
+ <a href="#" wicket:id="viewLink">
+ <span wicket:id="viewItemIcon" class="ViewLinkItem"></span> <span wicket:id="viewItemTitle" class="ViewLinkItemTitle">[link title]</span>
+ </a>
+ </li>
+ </ul>
+ </div>
+
+ <span wicket:id="additionalLinks"></span>
+
+ <div class="views">
<div wicket:id="collectionContents-0" class="collectionContentsLinksSelectorPanel collectionContentsComponentType"></div>
<div wicket:id="collectionContents-1" class="collectionContentsLinksSelectorPanel collectionContentsComponentType"></div>
<div wicket:id="collectionContents-2" class="collectionContentsLinksSelectorPanel collectionContentsComponentType"></div>
@@ -33,7 +52,8 @@
<div wicket:id="collectionContents-7" class="collectionContentsLinksSelectorPanel collectionContentsComponentType"></div>
<div wicket:id="collectionContents-8" class="collectionContentsLinksSelectorPanel collectionContentsComponentType"></div>
<div wicket:id="collectionContents-9" class="collectionContentsLinksSelectorPanel collectionContentsComponentType"></div>
- </wicket:extend>
- </body>
+ </div>
+ </div>
+</wicket:panel>
+</body>
</html>
-
http://git-wip-us.apache.org/repos/asf/isis/blob/3b80b5e3/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/selector/links/EntityLinksSelectorPanel.css
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/selector/links/EntityLinksSelectorPanel.css b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/selector/links/EntityLinksSelectorPanel.css
index eaeea17..6f7be55 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/selector/links/EntityLinksSelectorPanel.css
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/selector/links/EntityLinksSelectorPanel.css
@@ -16,3 +16,40 @@
* specific language governing permissions and limitations
* under the License.
*/
+.linksSelectorPanel .viewLinks {
+ float:right;
+ display:block;
+}
+
+.linksSelectorPanel ul.dropdown-menu {
+ min-width: 0;
+}
+
+.linksSelectorPanel ul.dropdown-menu li.viewItem {
+ min-width: 0;
+}
+
+.linksSelectorPanel ul.viewList li.viewItem:first-child span {
+ border-radius:4px 0 0 4px;
+ -moz-border-radius:4px 0 0 4px;
+ -webkit-border-radius:4px 0 0 4px;
+}
+
+.linksSelectorPanel ul.viewList li.viewItem:last-child span {
+ border-radius:0 4px 4px 0;
+ -moz-border-radius:0 4px 4px 0;
+ -webkit-border-radius:0 4px 4px 0;
+}
+
+
+.linksSelectorPanel .link-selector-panel-invisible {
+ display:none;
+}
+
+.linksSelectorPanel .list-inline {
+ margin-left: 0;
+}
+
+.linksSelectorPanel .list-inline li {
+ padding-left: 0;
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/3b80b5e3/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/selector/links/EntityLinksSelectorPanel.html
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/selector/links/EntityLinksSelectorPanel.html b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/selector/links/EntityLinksSelectorPanel.html
index a1c9e5d..988f0a3 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/selector/links/EntityLinksSelectorPanel.html
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/selector/links/EntityLinksSelectorPanel.html
@@ -7,9 +7,9 @@
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
@@ -17,12 +17,31 @@
specific language governing permissions and limitations
under the License.
-->
-<html xmlns="http://www.w3.org/1999/xhtml"
- xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd"
- xml:lang="en"
- lang="en">
- <body>
- <wicket:extend>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns:wicket="http://wicket.apache.org">
+<body>
+<wicket:panel>
+ <div class="linksSelectorPanel">
+ <div class="btn-group viewLinks" wicket:id="views">
+ <button type="button" class="btn btn-xs btn-info">
+ <span wicket:id="viewButtonIcon" class="ViewLinkItem"></span>
+ <span wicket:id="viewButtonTitle" class="ViewLinkItemTitle"></span>
+ </button>
+ <button type="button" class="btn btn-xs btn-info dropdown-toggle" data-toggle="dropdown">
+ <span class="caret"></span>
+ </button>
+ <ul wicket:id="viewList" class="dropdown-menu dropdown-menu-right" role="menu">
+ <li wicket:id="viewItem" class="viewItem">
+ <a href="#" wicket:id="viewLink">
+ <span wicket:id="viewItemIcon" class="ViewLinkItem"></span> <span wicket:id="viewItemTitle" class="ViewLinkItemTitle">[link title]</span>
+ </a>
+ </li>
+ </ul>
+ </div>
+
+ <span wicket:id="additionalLinks"></span>
+
+ <div class="views">
<div wicket:id="entity-0" class="entityLinksSelectorPanel entityComponentType"></div>
<div wicket:id="entity-1" class="entityLinksSelectorPanel entityComponentType"></div>
<div wicket:id="entity-2" class="entityLinksSelectorPanel entityComponentType"></div>
@@ -33,7 +52,8 @@
<div wicket:id="entity-7" class="entityLinksSelectorPanel entityComponentType"></div>
<div wicket:id="entity-8" class="entityLinksSelectorPanel entityComponentType"></div>
<div wicket:id="entity-9" class="entityLinksSelectorPanel entityComponentType"></div>
- </wicket:extend>
- </body>
+ </div>
+ </div>
+</wicket:panel>
+</body>
</html>
-
http://git-wip-us.apache.org/repos/asf/isis/blob/3b80b5e3/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/selector/links/LinksSelectorPanelAbstract.css
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/selector/links/LinksSelectorPanelAbstract.css b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/selector/links/LinksSelectorPanelAbstract.css
index 335e510..9f1612a 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/selector/links/LinksSelectorPanelAbstract.css
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/selector/links/LinksSelectorPanelAbstract.css
@@ -17,40 +17,3 @@
* under the License.
*/
-.linksSelectorPanel .viewLinks {
- float:right;
- display:block;
-}
-
-.linksSelectorPanel ul.dropdown-menu {
- min-width: 0;
-}
-
-.linksSelectorPanel ul.dropdown-menu li.viewItem {
- min-width: 0;
-}
-
-.linksSelectorPanel ul.viewList li.viewItem:first-child span {
- border-radius:4px 0 0 4px;
- -moz-border-radius:4px 0 0 4px;
- -webkit-border-radius:4px 0 0 4px;
-}
-
-.linksSelectorPanel ul.viewList li.viewItem:last-child span {
- border-radius:0 4px 4px 0;
- -moz-border-radius:0 4px 4px 0;
- -webkit-border-radius:0 4px 4px 0;
-}
-
-
-.linksSelectorPanel .link-selector-panel-invisible {
- display:none;
-}
-
-.linksSelectorPanel .list-inline {
- margin-left: 0;
-}
-
-.linksSelectorPanel .list-inline li {
- padding-left: 0;
-}
[02/23] isis git commit: ISIS-537 Add 20px under the entity
(EntityPropertiesPanel) to make a clear distinction with the row for
entityCollectionsOverflow
Posted by da...@apache.org.
ISIS-537 Add 20px under the entity (EntityPropertiesPanel) to make a clear distinction with the row for entityCollectionsOverflow
https://trello.com/c/3LYn12tx/115-a-bit-more-space-underneath-the-ok-edit-cancel-buttons
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/d905d387
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/d905d387
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/d905d387
Branch: refs/heads/ISIS-939
Commit: d905d387a07eba8e1af3462b944fb3203a76a0d2
Parents: bbdf17b
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Fri Nov 7 13:13:06 2014 +0200
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Fri Nov 7 13:13:06 2014 +0200
----------------------------------------------------------------------
.../ui/components/entity/properties/EntityPropertiesPanel.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/d905d387/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/properties/EntityPropertiesPanel.html
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/properties/EntityPropertiesPanel.html b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/properties/EntityPropertiesPanel.html
index 18dfd1d..e5ff967 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/properties/EntityPropertiesPanel.html
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/properties/EntityPropertiesPanel.html
@@ -22,7 +22,7 @@
<wicket:panel>
<div class="entityPropertiesPanel entityPropertiesComponentType">
<form wicket:id="entityProperties" class="inputForm" role="form">
- <div class="row">
+ <div class="row" style="padding-bottom: 20px">
<div wicket:id="leftColumn">
<div class="inputFormTable properties">
<fieldset wicket:id="memberGroup" class="memberGroup myBlockContainer">
[14/23] isis git commit: ISIS-537: factored out
CollectionContentsSelectorDropdownPanel from
CollectionContentsLinksSelectorPanel.
Posted by da...@apache.org.
ISIS-537: factored out CollectionContentsSelectorDropdownPanel from CollectionContentsLinksSelectorPanel.
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/70af3c32
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/70af3c32
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/70af3c32
Branch: refs/heads/ISIS-939
Commit: 70af3c3238d90badefcb512cc733cf3e8ac3a294
Parents: 5918dd6
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Sun Nov 9 15:05:51 2014 +0000
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Mon Nov 10 10:21:41 2014 +0000
----------------------------------------------------------------------
...CollectionContentsSelectorDropdownPanel.html | 44 ++
...CollectionContentsSelectorDropdownPanel.java | 441 +++++++++++++++++++
...ionContentsSelectorSelectorDropdownPanel.css | 60 +++
.../CollectionContentsLinksSelectorPanel.html | 18 +-
.../CollectionContentsLinksSelectorPanel.java | 406 +++++++++--------
.../java/dom/todo/ToDoItemContributions.java | 1 +
6 files changed, 788 insertions(+), 182 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/70af3c32/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorDropdownPanel.html
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorDropdownPanel.html b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorDropdownPanel.html
new file mode 100644
index 0000000..ea2a4d8
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorDropdownPanel.html
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns:wicket="http://wicket.apache.org">
+<body>
+<wicket:panel>
+ <div class="linksSelectorPanel">
+ <div class="btn-group viewLinks" wicket:id="views">
+ <button type="button" class="btn btn-xs btn-info">
+ <span wicket:id="viewButtonIcon" class="ViewLinkItem"></span>
+ <span wicket:id="viewButtonTitle" class="ViewLinkItemTitle"></span>
+ </button>
+ <button type="button" class="btn btn-xs btn-info dropdown-toggle" data-toggle="dropdown">
+ <span class="caret"></span>
+ </button>
+ <ul wicket:id="viewList" class="dropdown-menu dropdown-menu-right" role="menu">
+ <li wicket:id="viewItem" class="viewItem">
+ <a href="#" wicket:id="viewLink">
+ <span wicket:id="viewItemIcon" class="ViewLinkItem"></span> <span wicket:id="viewItemTitle" class="ViewLinkItemTitle">[link title]</span>
+ </a>
+ </li>
+ </ul>
+ </div>
+ </div>
+</wicket:panel>
+</body>
+</html>
http://git-wip-us.apache.org/repos/asf/isis/blob/70af3c32/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorDropdownPanel.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorDropdownPanel.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorDropdownPanel.java
new file mode 100644
index 0000000..0903d2a
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorDropdownPanel.java
@@ -0,0 +1,441 @@
+/*
+ * 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.viewer.wicket.ui.components.collectioncontents.selector.dropdown;
+
+import de.agilecoders.wicket.core.markup.html.bootstrap.button.Buttons;
+
+import java.util.ArrayList;
+import java.util.List;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
+import com.google.common.collect.Lists;
+import org.apache.wicket.AttributeModifier;
+import org.apache.wicket.Component;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.markup.html.AjaxLink;
+import org.apache.wicket.event.Broadcast;
+import org.apache.wicket.markup.ComponentTag;
+import org.apache.wicket.markup.head.IHeaderResponse;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+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.model.IModel;
+import org.apache.wicket.model.Model;
+import org.apache.isis.applib.annotation.Render.Type;
+import org.apache.isis.core.commons.lang.StringExtensions;
+import org.apache.isis.core.metamodel.facets.members.render.RenderFacet;
+import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
+import org.apache.isis.viewer.wicket.model.hints.IsisUiHintEvent;
+import org.apache.isis.viewer.wicket.model.hints.UiHintContainer;
+import org.apache.isis.viewer.wicket.model.hints.UiHintPathSignificant;
+import org.apache.isis.viewer.wicket.model.models.EntityCollectionModel;
+import org.apache.isis.viewer.wicket.ui.CollectionContentsAsFactory;
+import org.apache.isis.viewer.wicket.ui.ComponentFactory;
+import org.apache.isis.viewer.wicket.ui.ComponentType;
+import org.apache.isis.viewer.wicket.ui.components.collectioncontents.ajaxtable.CollectionContentsAsAjaxTablePanelFactory;
+import org.apache.isis.viewer.wicket.ui.components.collectioncontents.selector.links.CollectionContentsLinksSelectorPanelFactory;
+import org.apache.isis.viewer.wicket.ui.components.collectioncontents.unresolved.CollectionContentsAsUnresolvedPanelFactory;
+import org.apache.isis.viewer.wicket.ui.panels.PanelAbstract;
+import org.apache.isis.viewer.wicket.ui.panels.PanelUtil;
+import org.apache.isis.viewer.wicket.ui.util.CssClassAppender;
+import org.apache.isis.viewer.wicket.ui.util.CssClassRemover;
+
+/**
+ * Provides a list of links for selecting other views that support
+ * {@link org.apache.isis.viewer.wicket.ui.ComponentType#COLLECTION_CONTENTS} with a backing
+ * {@link org.apache.isis.viewer.wicket.model.models.EntityCollectionModel}.
+ */
+public class CollectionContentsSelectorDropdownPanel
+ extends PanelAbstract<EntityCollectionModel> implements UiHintPathSignificant /*, CollectionCountProvider*/ {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final String INVISIBLE_CLASS = "link-selector-panel-invisible";
+// private static final int MAX_NUM_UNDERLYING_VIEWS = 10;
+
+ private static final String ID_VIEWS = "views";
+ private static final String ID_VIEW_LIST = "viewList";
+ private static final String ID_VIEW_LINK = "viewLink";
+ private static final String ID_VIEW_ITEM = "viewItem";
+ private static final String ID_VIEW_ITEM_TITLE = "viewItemTitle";
+ private static final String ID_VIEW_ITEM_ICON = "viewItemIcon";
+
+ private static final String UIHINT_VIEW = "view";
+ private static final String ID_VIEW_BUTTON_TITLE = "viewButtonTitle";
+ private static final String ID_VIEW_BUTTON_ICON = "viewButtonIcon";
+
+ private final ComponentType componentType;
+
+ private ComponentFactory selectedComponentFactory;
+// private Component selectedComponent;
+
+// /**
+// * May be <tt>null</tt>, depending upon the model implementation.
+// */
+// protected WebMarkupContainer additionalLinks;
+
+ public CollectionContentsSelectorDropdownPanel(final String id, final EntityCollectionModel model, final ComponentFactory factory) {
+ super(id, model);
+ this.componentType = factory.getComponentType();
+ }
+
+ /**
+ * Build UI only after added to parent.
+ */
+ public void onInitialize() {
+ super.onInitialize();
+ ComponentFactory componentFactory = getComponentFactoryRegistry().findComponentFactoryElseFailFast(getComponentType(), getModel());
+ addUnderlyingViews(getModel(), componentFactory);
+ }
+
+
+ private void addUnderlyingViews(final EntityCollectionModel model, final ComponentFactory factory) {
+ final List<ComponentFactory> componentFactories = findOtherComponentFactories(model, factory);
+
+ final int selected = honourViewHintElseDefault(componentFactories, model);
+
+ final CollectionContentsSelectorDropdownPanel selectorPanel = this;
+
+ // create all, hide the one not selected
+// final Component[] underlyingViews = new Component[MAX_NUM_UNDERLYING_VIEWS];
+// int i = 0;
+// final EntityCollectionModel emptyModel = model.asDummy();
+// for (ComponentFactory componentFactory : componentFactories) {
+// final String underlyingId = underlyingIdPrefix + "-" + i;
+//
+// Component underlyingView = componentFactory.createComponent(underlyingId,i==selected? model: emptyModel);
+// underlyingViews[i++] = underlyingView;
+// selectorPanel.addOrReplace(underlyingView);
+// }
+
+// // hide any unused placeholders
+// while(i<MAX_NUM_UNDERLYING_VIEWS) {
+// String underlyingId = underlyingIdPrefix + "-" + i;
+// permanentlyHide(underlyingId);
+// i++;
+// }
+
+ // selector
+ if (componentFactories.size() <= 1) {
+ permanentlyHide(ID_VIEWS);
+ } else {
+ final Model<ComponentFactory> componentFactoryModel = new Model<>();
+
+ selectorPanel.selectedComponentFactory = componentFactories.get(selected);
+ componentFactoryModel.setObject(selectorPanel.selectedComponentFactory);
+
+ final WebMarkupContainer views = new WebMarkupContainer(ID_VIEWS);
+
+ final Label viewButtonTitle = new Label(ID_VIEW_BUTTON_TITLE, "Hidden");
+ views.addOrReplace(viewButtonTitle);
+
+ final Label viewButtonIcon = new Label(ID_VIEW_BUTTON_ICON, "");
+ views.addOrReplace(viewButtonIcon);
+
+ final WebMarkupContainer container = new WebMarkupContainer(ID_VIEW_LIST);
+
+ views.addOrReplace(container);
+ views.setOutputMarkupId(true);
+
+ this.setOutputMarkupId(true);
+
+ final ListView<ComponentFactory> listView = new ListView<ComponentFactory>(ID_VIEW_ITEM, componentFactories) {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void populateItem(ListItem<ComponentFactory> item) {
+
+ final int underlyingViewNum = item.getIndex();
+
+ final ComponentFactory componentFactory = item.getModelObject();
+ final AbstractLink link = new AjaxLink<Void>(ID_VIEW_LINK) {
+ private static final long serialVersionUID = 1L;
+ @Override
+ public void onClick(AjaxRequestTarget target) {
+ CollectionContentsSelectorDropdownPanel linksSelectorPanel = CollectionContentsSelectorDropdownPanel.this;
+ linksSelectorPanel.setViewHintAndBroadcast(underlyingViewNum, target);
+
+// final EntityCollectionModel dummyModel = model.asDummy();
+// for(int i=0; i<MAX_NUM_UNDERLYING_VIEWS; i++) {
+// final Component component = underlyingViews[i];
+// if(component == null) {
+// continue;
+// }
+// final boolean isSelected = i == underlyingViewNum;
+// applyCssVisibility(component, isSelected);
+// component.setDefaultModel(isSelected? model: dummyModel);
+// }
+
+ selectorPanel.selectedComponentFactory = componentFactory;
+// selectorPanel.selectedComponent = underlyingViews[underlyingViewNum];
+// selectorPanel.onSelect(target);
+ target.add(selectorPanel, views);
+ }
+
+ @Override
+ protected void onComponentTag(ComponentTag tag) {
+ super.onComponentTag(tag);
+ Buttons.fixDisabledState(this, tag);
+ }
+ };
+
+ IModel<String> title = nameFor(componentFactory);
+ Label viewItemTitleLabel = new Label(ID_VIEW_ITEM_TITLE, title);
+ link.add(viewItemTitleLabel);
+
+ Label viewItemIcon = new Label(ID_VIEW_ITEM_ICON, "");
+ link.add(viewItemIcon);
+
+ boolean isEnabled = componentFactory != selectorPanel.selectedComponentFactory;
+ if (!isEnabled) {
+ viewButtonTitle.setDefaultModel(title);
+ IModel<String> cssClass = cssClassFor(componentFactory, viewButtonIcon);
+ viewButtonIcon.add(AttributeModifier.replace("class", "ViewLinkItem " + cssClass.getObject()));
+ link.setVisible(false);
+ } else {
+ IModel<String> cssClass = cssClassFor(componentFactory, viewItemIcon);
+ viewItemIcon.add(new CssClassAppender(cssClass));
+ }
+
+ item.add(link);
+ }
+
+ private IModel<String> cssClassFor(final ComponentFactory componentFactory, Label viewIcon) {
+ IModel<String> cssClass = null;
+ if (componentFactory instanceof CollectionContentsAsFactory) {
+ CollectionContentsAsFactory collectionContentsAsFactory = (CollectionContentsAsFactory) componentFactory;
+ cssClass = collectionContentsAsFactory.getCssClass();
+ viewIcon.setDefaultModelObject("");
+ viewIcon.setEscapeModelStrings(true);
+ }
+ if (cssClass == null) {
+ String name = componentFactory.getName();
+ cssClass = Model.of(StringExtensions.asLowerDashed(name));
+ // Small hack: if there is no specific CSS class then we assume that background-image is used
+ // the span.ViewItemLink should have some content to show it
+ // FIX: find a way to do this with CSS (width and height don't seems to help)
+ viewIcon.setDefaultModelObject("     ");
+ viewIcon.setEscapeModelStrings(false);
+ }
+ return cssClass;
+ }
+
+ private IModel<String> nameFor(final ComponentFactory componentFactory) {
+ IModel<String> name = null;
+ if (componentFactory instanceof CollectionContentsAsFactory) {
+ CollectionContentsAsFactory collectionContentsAsFactory = (CollectionContentsAsFactory) componentFactory;
+ name = collectionContentsAsFactory.getTitleLabel();
+ }
+ if (name == null) {
+ name = Model.of(componentFactory.getName());
+ }
+ return name;
+ }
+ };
+ container.add(listView);
+ addOrReplace(views);
+ }
+
+// for(i=0; i<MAX_NUM_UNDERLYING_VIEWS; i++) {
+// Component component = underlyingViews[i];
+// if(component != null) {
+// if(i != selected) {
+// component.add(new CssClassAppender(INVISIBLE_CLASS));
+// } else {
+// selectedComponent = component;
+// }
+// }
+// }
+ }
+
+
+
+ protected void setViewHintAndBroadcast(int viewNum, AjaxRequestTarget target) {
+ final UiHintContainer uiHintContainer = getUiHintContainer();
+ if(uiHintContainer == null) {
+ return;
+ }
+ uiHintContainer.setHint(CollectionContentsSelectorDropdownPanel.this, UIHINT_VIEW, ""+viewNum);
+ send(getPage(), Broadcast.EXACT, new IsisUiHintEvent(uiHintContainer, target));
+ }
+
+// /**
+// * Iterates up the component hierarchy looking for a parent
+// * {@link org.apache.isis.viewer.wicket.ui.components.collection.CollectionPanel}, and if so adds to ajax target so that it'll
+// * be repainted.
+// *
+// * <p>
+// * Yeah, agreed, it's a little bit hacky doing it this way, because it bakes
+// * in knowledge that this component is created, somehow, by a parent {@link org.apache.isis.viewer.wicket.ui.components.collection.CollectionPanel}.
+// * Perhaps it could be refactored to use a more general purpose observer pattern?
+// *
+// * <p>
+// * In fact, I've since discovered that Wicket has an event bus, which is used by the
+// * {@link org.apache.isis.viewer.wicket.model.hints.UiHintContainer hinting mechanism}. So this ought to be relatively easy to do.
+// */
+// public void onSelect(AjaxRequestTarget target) {
+// Component component = this;
+// while(component != null) {
+// if(component instanceof CollectionPanel) {
+// CollectionPanel collectionPanel = (CollectionPanel) component;
+// boolean hasCount = collectionPanel.hasCount();
+// if(hasCount) {
+// collectionPanel.updateLabel(target);
+// }
+//// if(additionalLinks != null) {
+//// applyCssVisibility(additionalLinks, hasCount);
+//// }
+// return;
+// }
+// component = component.getParent();
+// }
+// }
+
+
+ protected static void applyCssVisibility(final Component component, final boolean visible) {
+ if(component == null) {
+ return;
+ }
+ AttributeModifier modifier = visible ? new CssClassRemover(INVISIBLE_CLASS) : new CssClassAppender(INVISIBLE_CLASS);
+ component.add(modifier);
+ }
+
+ protected int honourViewHintElseDefault(final List<ComponentFactory> componentFactories, final IModel<?> model) {
+ // honour hints ...
+ final UiHintContainer hintContainer = getUiHintContainer();
+ if(hintContainer != null) {
+ String viewStr = hintContainer.getHint(this, UIHINT_VIEW);
+ if(viewStr != null) {
+ try {
+ int view = Integer.parseInt(viewStr);
+ if(view >= 0 && view < componentFactories.size()) {
+ return view;
+ }
+ } catch(NumberFormatException ex) {
+ // ignore
+ }
+ }
+ }
+
+ // ... else default
+ int initialFactory = determineInitialFactory(componentFactories, model);
+ if(hintContainer != null) {
+ hintContainer.setHint(this, UIHINT_VIEW, ""+initialFactory);
+ // don't broadcast (no AjaxRequestTarget, still configuring initial setup)
+ }
+ return initialFactory;
+ }
+
+
+ /**
+ * return the index of {@link org.apache.isis.viewer.wicket.ui.components.collectioncontents.unresolved.CollectionContentsAsUnresolvedPanelFactory unresolved panel} if present and not eager loading;
+ * else the index of {@link org.apache.isis.viewer.wicket.ui.components.collectioncontents.ajaxtable.CollectionContentsAsAjaxTablePanelFactory ajax table} if present,
+ * otherwise first factory.
+ */
+ protected int determineInitialFactory(final List<ComponentFactory> componentFactories, final IModel<?> model) {
+ if(!hasRenderEagerlyFacet(model)) {
+ for(int i=0; i<componentFactories.size(); i++) {
+ if(componentFactories.get(i) instanceof CollectionContentsAsUnresolvedPanelFactory) {
+ return i;
+ }
+ }
+ }
+ int ajaxTableIdx = findAjaxTable(componentFactories);
+ if(ajaxTableIdx>=0) {
+ return ajaxTableIdx;
+ }
+ return 0;
+ }
+
+ private List<ComponentFactory> findOtherComponentFactories(final EntityCollectionModel model, final ComponentFactory ignoreFactory) {
+ final List<ComponentFactory> componentFactories = getComponentFactoryRegistry().findComponentFactories(componentType, model);
+ ArrayList<ComponentFactory> otherFactories = Lists.newArrayList(Collections2.filter(componentFactories, new Predicate<ComponentFactory>() {
+ @Override
+ public boolean apply(final ComponentFactory input) {
+ return input != ignoreFactory && input.getClass() != CollectionContentsLinksSelectorPanelFactory.class;
+ }
+ }));
+ return ordered(otherFactories);
+ }
+
+ protected List<ComponentFactory> ordered(List<ComponentFactory> componentFactories) {
+ return orderAjaxTableToEnd(componentFactories);
+ }
+
+
+ @Override
+ public void renderHead(final IHeaderResponse response) {
+ super.renderHead(response);
+ PanelUtil.renderHead(response, CollectionContentsSelectorDropdownPanel.class);
+ }
+
+
+ static List<ComponentFactory> orderAjaxTableToEnd(List<ComponentFactory> componentFactories) {
+ int ajaxTableIdx = findAjaxTable(componentFactories);
+ if(ajaxTableIdx>=0) {
+ List<ComponentFactory> orderedFactories = Lists.newArrayList(componentFactories);
+ ComponentFactory ajaxTableFactory = orderedFactories.remove(ajaxTableIdx);
+ orderedFactories.add(ajaxTableFactory);
+ return orderedFactories;
+ } else {
+ return componentFactories;
+ }
+ }
+
+ private static int findAjaxTable(List<ComponentFactory> componentFactories) {
+ for(int i=0; i<componentFactories.size(); i++) {
+ if(componentFactories.get(i) instanceof CollectionContentsAsAjaxTablePanelFactory) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+
+ private static boolean hasRenderEagerlyFacet(IModel<?> model) {
+ if(!(model instanceof EntityCollectionModel)) {
+ return false;
+ }
+ final EntityCollectionModel entityCollectionModel = (EntityCollectionModel) model;
+ if(!entityCollectionModel.isParented()) {
+ return false;
+ }
+
+ final OneToManyAssociation collection =
+ entityCollectionModel.getCollectionMemento().getCollection();
+ RenderFacet renderFacet = collection.getFacet(RenderFacet.class);
+ return renderFacet != null && renderFacet.value() == Type.EAGERLY;
+ }
+
+
+// @Override
+// public Integer getCount() {
+// if(selectedComponent instanceof CollectionCountProvider) {
+// final CollectionCountProvider collectionCountProvider = (CollectionCountProvider) selectedComponent;
+// return collectionCountProvider.getCount();
+// } else {
+// return null;
+// }
+// }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/70af3c32/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorSelectorDropdownPanel.css
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorSelectorDropdownPanel.css b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorSelectorDropdownPanel.css
new file mode 100644
index 0000000..8c3902e
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorSelectorDropdownPanel.css
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ */
+.linksSelectorPanel .viewLinks {
+ float:right;
+ display:block;
+}
+
+.linksSelectorPanel ul.dropdown-menu {
+ min-width: 0;
+}
+
+.linksSelectorPanel ul.dropdown-menu li.viewItem {
+ min-width: 0;
+}
+
+.linksSelectorPanel ul.viewList li.viewItem:first-child span {
+ border-radius:4px 0 0 4px;
+ -moz-border-radius:4px 0 0 4px;
+ -webkit-border-radius:4px 0 0 4px;
+}
+
+.linksSelectorPanel ul.viewList li.viewItem:last-child span {
+ border-radius:0 4px 4px 0;
+ -moz-border-radius:0 4px 4px 0;
+ -webkit-border-radius:0 4px 4px 0;
+}
+
+
+.linksSelectorPanel .link-selector-panel-invisible {
+ display:none;
+}
+
+.linksSelectorPanel .list-inline {
+ margin-left: 0;
+}
+
+.linksSelectorPanel .list-inline li {
+ padding-left: 0;
+}
+
+
+.collectionContentsLinksSelectorPanel select {
+ margin-bottom: 1em;
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/70af3c32/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.html
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.html b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.html
index 1fbf7df..2903711 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.html
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.html
@@ -22,22 +22,26 @@
<body>
<wicket:panel>
<div class="linksSelectorPanel">
- <div class="btn-group viewLinks" wicket:id="views">
+ <span wicket:id="selectorDropdown"/>
+
+ <!--
+ <div class="btn-group viewLinks" xxwicket:id="views">
<button type="button" class="btn btn-xs btn-info">
- <span wicket:id="viewButtonIcon" class="ViewLinkItem"></span>
- <span wicket:id="viewButtonTitle" class="ViewLinkItemTitle"></span>
+ <span xxwicket:id="viewButtonIcon" class="ViewLinkItem"></span>
+ <span xxwicket:id="viewButtonTitle" class="ViewLinkItemTitle"></span>
</button>
<button type="button" class="btn btn-xs btn-info dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</button>
- <ul wicket:id="viewList" class="dropdown-menu dropdown-menu-right" role="menu">
- <li wicket:id="viewItem" class="viewItem">
- <a href="#" wicket:id="viewLink">
- <span wicket:id="viewItemIcon" class="ViewLinkItem"></span> <span wicket:id="viewItemTitle" class="ViewLinkItemTitle">[link title]</span>
+ <ul xxwicket:id="viewList" class="dropdown-menu dropdown-menu-right" role="menu">
+ <li xxwicket:id="viewItem" class="viewItem">
+ <a href="#" xxwicket:id="viewLink">
+ <span xxwicket:id="viewItemIcon" class="ViewLinkItem"></span> <span xxwicket:id="viewItemTitle" class="ViewLinkItemTitle">[link title]</span>
</a>
</li>
</ul>
</div>
+ -->
<div class="views">
<div wicket:id="collectionContents-0" class="collectionContentsLinksSelectorPanel collectionContentsComponentType"></div>
http://git-wip-us.apache.org/repos/asf/isis/blob/70af3c32/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java
index d0d987b..f29244f 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java
@@ -19,8 +19,6 @@
package org.apache.isis.viewer.wicket.ui.components.collectioncontents.selector.links;
-import de.agilecoders.wicket.core.markup.html.bootstrap.button.Buttons;
-
import java.util.ArrayList;
import java.util.List;
import com.google.common.base.Predicate;
@@ -29,31 +27,23 @@ import com.google.common.collect.Lists;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.ajax.markup.html.AjaxLink;
-import org.apache.wicket.event.Broadcast;
-import org.apache.wicket.markup.ComponentTag;
+import org.apache.wicket.event.IEvent;
import org.apache.wicket.markup.head.IHeaderResponse;
-import org.apache.wicket.markup.html.WebMarkupContainer;
-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.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.isis.applib.annotation.Render.Type;
-import org.apache.isis.core.commons.lang.StringExtensions;
import org.apache.isis.core.metamodel.facets.members.render.RenderFacet;
import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
+import org.apache.isis.viewer.wicket.model.hints.IsisEnvelopeEvent;
import org.apache.isis.viewer.wicket.model.hints.IsisUiHintEvent;
import org.apache.isis.viewer.wicket.model.hints.UiHintContainer;
import org.apache.isis.viewer.wicket.model.hints.UiHintPathSignificant;
import org.apache.isis.viewer.wicket.model.models.EntityCollectionModel;
-import org.apache.isis.viewer.wicket.ui.CollectionContentsAsFactory;
import org.apache.isis.viewer.wicket.ui.ComponentFactory;
import org.apache.isis.viewer.wicket.ui.ComponentType;
import org.apache.isis.viewer.wicket.ui.components.collection.CollectionCountProvider;
-import org.apache.isis.viewer.wicket.ui.components.collection.CollectionPanel;
import org.apache.isis.viewer.wicket.ui.components.collectioncontents.ajaxtable.CollectionContentsAsAjaxTablePanelFactory;
+import org.apache.isis.viewer.wicket.ui.components.collectioncontents.selector.dropdown.CollectionContentsSelectorDropdownPanel;
import org.apache.isis.viewer.wicket.ui.components.collectioncontents.unresolved.CollectionContentsAsUnresolvedPanelFactory;
import org.apache.isis.viewer.wicket.ui.panels.PanelAbstract;
import org.apache.isis.viewer.wicket.ui.panels.PanelUtil;
@@ -73,16 +63,20 @@ public class CollectionContentsLinksSelectorPanel
private static final String INVISIBLE_CLASS = "link-selector-panel-invisible";
private static final int MAX_NUM_UNDERLYING_VIEWS = 10;
- private static final String ID_VIEWS = "views";
- private static final String ID_VIEW_LIST = "viewList";
- private static final String ID_VIEW_LINK = "viewLink";
- private static final String ID_VIEW_ITEM = "viewItem";
- private static final String ID_VIEW_ITEM_TITLE = "viewItemTitle";
- private static final String ID_VIEW_ITEM_ICON = "viewItemIcon";
+ private static final String ID_SELECTOR_DROPDOWN = "selectorDropdown";
+
+// private static final String ID_VIEWS = "views";
+// private static final String ID_VIEW_LIST = "viewList";
+// private static final String ID_VIEW_LINK = "viewLink";
+// private static final String ID_VIEW_ITEM = "viewItem";
+// private static final String ID_VIEW_ITEM_TITLE = "viewItemTitle";
+// private static final String ID_VIEW_ITEM_ICON = "viewItemIcon";
private static final String UIHINT_VIEW = "view";
- private static final String ID_VIEW_BUTTON_TITLE = "viewButtonTitle";
- private static final String ID_VIEW_BUTTON_ICON = "viewButtonIcon";
+// private static final String ID_VIEW_BUTTON_TITLE = "viewButtonTitle";
+// private static final String ID_VIEW_BUTTON_ICON = "viewButtonIcon";
+
+ private final ComponentFactory componentFactory;
private final ComponentType componentType;
private final String underlyingIdPrefix;
@@ -90,13 +84,21 @@ public class CollectionContentsLinksSelectorPanel
private ComponentFactory selectedComponentFactory;
protected Component selectedComponent;
- /**
- * May be <tt>null</tt>, depending upon the model implementation.
- */
- protected WebMarkupContainer additionalLinks;
+// /**
+// * May be <tt>null</tt>, depending upon the model implementation.
+// */
+// protected WebMarkupContainer additionalLinks;
+
+ private Component[] underlyingViews;
+ private List<ComponentFactory> componentFactories;
+ private CollectionContentsSelectorDropdownPanel selectorDropdownPanel;
- public CollectionContentsLinksSelectorPanel(final String id, final EntityCollectionModel model, final ComponentFactory factory) {
+ public CollectionContentsLinksSelectorPanel(
+ final String id,
+ final EntityCollectionModel model,
+ final ComponentFactory factory) {
super(id, model);
+ componentFactory = factory;
this.underlyingIdPrefix = ComponentType.COLLECTION_CONTENTS.toString();
this.componentType = factory.getComponentType();
}
@@ -107,19 +109,20 @@ public class CollectionContentsLinksSelectorPanel
public void onInitialize() {
super.onInitialize();
ComponentFactory componentFactory = getComponentFactoryRegistry().findComponentFactoryElseFailFast(getComponentType(), getModel());
- addUnderlyingViews(underlyingIdPrefix, getModel(), componentFactory);
+ addUnderlyingViews(componentFactory);
}
- private void addUnderlyingViews(final String underlyingIdPrefix, final EntityCollectionModel model, final ComponentFactory factory) {
- final List<ComponentFactory> componentFactories = findOtherComponentFactories(model, factory);
+ private void addUnderlyingViews(final ComponentFactory factory) {
+ final EntityCollectionModel model = getModel();
+ componentFactories = findOtherComponentFactories(model, factory);
final int selected = honourViewHintElseDefault(componentFactories, model);
final CollectionContentsLinksSelectorPanel selectorPanel = this;
// create all, hide the one not selected
- final Component[] underlyingViews = new Component[MAX_NUM_UNDERLYING_VIEWS];
+ underlyingViews = new Component[MAX_NUM_UNDERLYING_VIEWS];
int i = 0;
final EntityCollectionModel emptyModel = model.asDummy();
for (ComponentFactory componentFactory : componentFactories) {
@@ -139,124 +142,130 @@ public class CollectionContentsLinksSelectorPanel
// selector
if (componentFactories.size() <= 1) {
- permanentlyHide(ID_VIEWS);
+ //permanentlyHide(ID_VIEWS);
+
+ permanentlyHide(ID_SELECTOR_DROPDOWN);
} else {
final Model<ComponentFactory> componentFactoryModel = new Model<>();
selectorPanel.selectedComponentFactory = componentFactories.get(selected);
componentFactoryModel.setObject(selectorPanel.selectedComponentFactory);
- final WebMarkupContainer views = new WebMarkupContainer(ID_VIEWS);
-
- final Label viewButtonTitle = new Label(ID_VIEW_BUTTON_TITLE, "Hidden");
- views.addOrReplace(viewButtonTitle);
-
- final Label viewButtonIcon = new Label(ID_VIEW_BUTTON_ICON, "");
- views.addOrReplace(viewButtonIcon);
-
- final WebMarkupContainer container = new WebMarkupContainer(ID_VIEW_LIST);
-
- views.addOrReplace(container);
- views.setOutputMarkupId(true);
+ selectorDropdownPanel = new CollectionContentsSelectorDropdownPanel(ID_SELECTOR_DROPDOWN, getModel(), componentFactory);
this.setOutputMarkupId(true);
- final ListView<ComponentFactory> listView = new ListView<ComponentFactory>(ID_VIEW_ITEM, componentFactories) {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- protected void populateItem(ListItem<ComponentFactory> item) {
-
- final int underlyingViewNum = item.getIndex();
-
- final ComponentFactory componentFactory = item.getModelObject();
- final AbstractLink link = new AjaxLink<Void>(ID_VIEW_LINK) {
- private static final long serialVersionUID = 1L;
- @Override
- public void onClick(AjaxRequestTarget target) {
- CollectionContentsLinksSelectorPanel linksSelectorPanel = CollectionContentsLinksSelectorPanel.this;
- linksSelectorPanel.setViewHintAndBroadcast(underlyingViewNum, target);
-
- final EntityCollectionModel dummyModel = model.asDummy();
- for(int i=0; i<MAX_NUM_UNDERLYING_VIEWS; i++) {
- final Component component = underlyingViews[i];
- if(component == null) {
- continue;
- }
- final boolean isSelected = i == underlyingViewNum;
- applyCssVisibility(component, isSelected);
- component.setDefaultModel(isSelected? model: dummyModel);
- }
-
- selectorPanel.selectedComponentFactory = componentFactory;
- selectorPanel.selectedComponent = underlyingViews[underlyingViewNum];
- selectorPanel.onSelect(target);
- target.add(selectorPanel, views);
- }
-
- @Override
- protected void onComponentTag(ComponentTag tag) {
- super.onComponentTag(tag);
- Buttons.fixDisabledState(this, tag);
- }
- };
-
- IModel<String> title = nameFor(componentFactory);
- Label viewItemTitleLabel = new Label(ID_VIEW_ITEM_TITLE, title);
- link.add(viewItemTitleLabel);
-
- Label viewItemIcon = new Label(ID_VIEW_ITEM_ICON, "");
- link.add(viewItemIcon);
-
- boolean isEnabled = componentFactory != selectorPanel.selectedComponentFactory;
- if (!isEnabled) {
- viewButtonTitle.setDefaultModel(title);
- IModel<String> cssClass = cssClassFor(componentFactory, viewButtonIcon);
- viewButtonIcon.add(AttributeModifier.replace("class", "ViewLinkItem " + cssClass.getObject()));
- link.setVisible(false);
- } else {
- IModel<String> cssClass = cssClassFor(componentFactory, viewItemIcon);
- viewItemIcon.add(new CssClassAppender(cssClass));
- }
-
- item.add(link);
- }
-
- private IModel<String> cssClassFor(final ComponentFactory componentFactory, Label viewIcon) {
- IModel<String> cssClass = null;
- if (componentFactory instanceof CollectionContentsAsFactory) {
- CollectionContentsAsFactory collectionContentsAsFactory = (CollectionContentsAsFactory) componentFactory;
- cssClass = collectionContentsAsFactory.getCssClass();
- viewIcon.setDefaultModelObject("");
- viewIcon.setEscapeModelStrings(true);
- }
- if (cssClass == null) {
- String name = componentFactory.getName();
- cssClass = Model.of(StringExtensions.asLowerDashed(name));
- // Small hack: if there is no specific CSS class then we assume that background-image is used
- // the span.ViewItemLink should have some content to show it
- // FIX: find a way to do this with CSS (width and height don't seems to help)
- viewIcon.setDefaultModelObject("     ");
- viewIcon.setEscapeModelStrings(false);
- }
- return cssClass;
- }
-
- private IModel<String> nameFor(final ComponentFactory componentFactory) {
- IModel<String> name = null;
- if (componentFactory instanceof CollectionContentsAsFactory) {
- CollectionContentsAsFactory collectionContentsAsFactory = (CollectionContentsAsFactory) componentFactory;
- name = collectionContentsAsFactory.getTitleLabel();
- }
- if (name == null) {
- name = Model.of(componentFactory.getName());
- }
- return name;
- }
- };
- container.add(listView);
- addOrReplace(views);
+// final WebMarkupContainer views = new WebMarkupContainer(ID_VIEWS);
+//
+// final Label viewButtonTitle = new Label(ID_VIEW_BUTTON_TITLE, "Hidden");
+// views.addOrReplace(viewButtonTitle);
+//
+// final Label viewButtonIcon = new Label(ID_VIEW_BUTTON_ICON, "");
+// views.addOrReplace(viewButtonIcon);
+//
+// final WebMarkupContainer container = new WebMarkupContainer(ID_VIEW_LIST);
+//
+// views.addOrReplace(container);
+// views.setOutputMarkupId(true);
+//
+// this.setOutputMarkupId(true);
+
+// final ListView<ComponentFactory> listView = new ListView<ComponentFactory>(ID_VIEW_ITEM, componentFactories) {
+//
+// private static final long serialVersionUID = 1L;
+//
+// @Override
+// protected void populateItem(ListItem<ComponentFactory> item) {
+//
+// final int underlyingViewNum = item.getIndex();
+//
+// final ComponentFactory componentFactory = item.getModelObject();
+// final AbstractLink link = new AjaxLink<Void>(ID_VIEW_LINK) {
+// private static final long serialVersionUID = 1L;
+// @Override
+// public void onClick(AjaxRequestTarget target) {
+// CollectionContentsLinksSelectorPanel linksSelectorPanel = CollectionContentsLinksSelectorPanel.this;
+// linksSelectorPanel.setViewHintAndBroadcast(underlyingViewNum, target);
+//
+// final EntityCollectionModel dummyModel = model.asDummy();
+// for(int i=0; i<MAX_NUM_UNDERLYING_VIEWS; i++) {
+// final Component component = underlyingViews[i];
+// if(component == null) {
+// continue;
+// }
+// final boolean isSelected = i == underlyingViewNum;
+// applyCssVisibility(component, isSelected);
+// component.setDefaultModel(isSelected? model: dummyModel);
+// }
+//
+// selectorPanel.selectedComponentFactory = componentFactory;
+// selectorPanel.selectedComponent = underlyingViews[underlyingViewNum];
+// selectorPanel.onSelect(target);
+// target.add(selectorPanel, views);
+// }
+//
+// @Override
+// protected void onComponentTag(ComponentTag tag) {
+// super.onComponentTag(tag);
+// Buttons.fixDisabledState(this, tag);
+// }
+// };
+//
+// IModel<String> title = nameFor(componentFactory);
+// Label viewItemTitleLabel = new Label(ID_VIEW_ITEM_TITLE, title);
+// link.add(viewItemTitleLabel);
+//
+// Label viewItemIcon = new Label(ID_VIEW_ITEM_ICON, "");
+// link.add(viewItemIcon);
+//
+// boolean isEnabled = componentFactory != selectorPanel.selectedComponentFactory;
+// if (!isEnabled) {
+// viewButtonTitle.setDefaultModel(title);
+// IModel<String> cssClass = cssClassFor(componentFactory, viewButtonIcon);
+// viewButtonIcon.add(AttributeModifier.replace("class", "ViewLinkItem " + cssClass.getObject()));
+// link.setVisible(false);
+// } else {
+// IModel<String> cssClass = cssClassFor(componentFactory, viewItemIcon);
+// viewItemIcon.add(new CssClassAppender(cssClass));
+// }
+//
+// item.add(link);
+// }
+//
+// private IModel<String> cssClassFor(final ComponentFactory componentFactory, Label viewIcon) {
+// IModel<String> cssClass = null;
+// if (componentFactory instanceof CollectionContentsAsFactory) {
+// CollectionContentsAsFactory collectionContentsAsFactory = (CollectionContentsAsFactory) componentFactory;
+// cssClass = collectionContentsAsFactory.getCssClass();
+// viewIcon.setDefaultModelObject("");
+// viewIcon.setEscapeModelStrings(true);
+// }
+// if (cssClass == null) {
+// String name = componentFactory.getName();
+// cssClass = Model.of(StringExtensions.asLowerDashed(name));
+// // Small hack: if there is no specific CSS class then we assume that background-image is used
+// // the span.ViewItemLink should have some content to show it
+// // FIX: find a way to do this with CSS (width and height don't seems to help)
+// viewIcon.setDefaultModelObject("     ");
+// viewIcon.setEscapeModelStrings(false);
+// }
+// return cssClass;
+// }
+//
+// private IModel<String> nameFor(final ComponentFactory componentFactory) {
+// IModel<String> name = null;
+// if (componentFactory instanceof CollectionContentsAsFactory) {
+// CollectionContentsAsFactory collectionContentsAsFactory = (CollectionContentsAsFactory) componentFactory;
+// name = collectionContentsAsFactory.getTitleLabel();
+// }
+// if (name == null) {
+// name = Model.of(componentFactory.getName());
+// }
+// return name;
+// }
+// };
+// container.add(listView);
+ addOrReplace(selectorDropdownPanel);
}
for(i=0; i<MAX_NUM_UNDERLYING_VIEWS; i++) {
@@ -271,50 +280,97 @@ public class CollectionContentsLinksSelectorPanel
}
}
+ @Override
+ public void onEvent(IEvent<?> event) {
+ super.onEvent(event);
-
- protected void setViewHintAndBroadcast(int viewNum, AjaxRequestTarget target) {
- final UiHintContainer uiHintContainer = getUiHintContainer();
- if(uiHintContainer == null) {
+ final IsisUiHintEvent uiHintEvent = IsisEnvelopeEvent.openLetter(event, IsisUiHintEvent.class);
+ if(uiHintEvent == null) {
return;
}
- uiHintContainer.setHint(CollectionContentsLinksSelectorPanel.this, UIHINT_VIEW, ""+viewNum);
- send(getPage(), Broadcast.EXACT, new IsisUiHintEvent(uiHintContainer, target));
- }
-
- /**
- * Iterates up the component hierarchy looking for a parent
- * {@link org.apache.isis.viewer.wicket.ui.components.collection.CollectionPanel}, and if so adds to ajax target so that it'll
- * be repainted.
- *
- * <p>
- * Yeah, agreed, it's a little bit hacky doing it this way, because it bakes
- * in knowledge that this component is created, somehow, by a parent {@link org.apache.isis.viewer.wicket.ui.components.collection.CollectionPanel}.
- * Perhaps it could be refactored to use a more general purpose observer pattern?
- *
- * <p>
- * In fact, I've since discovered that Wicket has an event bus, which is used by the
- * {@link UiHintContainer hinting mechanism}. So this ought to be relatively easy to do.
- */
- protected void onSelect(AjaxRequestTarget target) {
- Component component = this;
- while(component != null) {
- if(component instanceof CollectionPanel) {
- CollectionPanel collectionPanel = (CollectionPanel) component;
- boolean hasCount = collectionPanel.hasCount();
- if(hasCount) {
- collectionPanel.updateLabel(target);
- }
- if(additionalLinks != null) {
- applyCssVisibility(additionalLinks, hasCount);
+ final UiHintContainer uiHintContainer = uiHintEvent.getUiHintContainer();
+
+ int underlyingViewNum = 0;
+ String viewStr = uiHintContainer.getHint(this.selectorDropdownPanel, UIHINT_VIEW);
+ if(viewStr != null) {
+ try {
+ int view = Integer.parseInt(viewStr);
+ if(view >= 0 && view < componentFactories.size()) {
+ underlyingViewNum = view;
}
- return;
+ } catch(NumberFormatException ex) {
+ // ignore
+ }
+ }
+
+ final EntityCollectionModel dummyModel = getModel().asDummy();
+ for(int i=0; i<MAX_NUM_UNDERLYING_VIEWS; i++) {
+ final Component component = underlyingViews[i];
+ if(component == null) {
+ continue;
}
- component = component.getParent();
+ final boolean isSelected = i == underlyingViewNum;
+ applyCssVisibility(component, isSelected);
+ component.setDefaultModel(isSelected? getModel(): dummyModel);
+ }
+
+ this.selectedComponentFactory = componentFactory;
+ this.selectedComponent = underlyingViews[underlyingViewNum];
+
+
+ final AjaxRequestTarget target = uiHintEvent.getTarget();
+ if(target != null) {
+// selectorDropdownPanel.onSelect(target);
+ target.add(this, selectorDropdownPanel);
}
+
+
}
+
+// protected void setViewHintAndBroadcast(int viewNum, AjaxRequestTarget target) {
+// final UiHintContainer uiHintContainer = getUiHintContainer();
+// if(uiHintContainer == null) {
+// return;
+// }
+// uiHintContainer.setHint(CollectionContentsLinksSelectorPanel.this, UIHINT_VIEW, ""+viewNum);
+// send(getPage(), Broadcast.EXACT, new IsisUiHintEvent(uiHintContainer, target));
+// }
+
+// /**
+// * Iterates up the component hierarchy looking for a parent
+// * {@link org.apache.isis.viewer.wicket.ui.components.collection.CollectionPanel}, and if so adds to ajax target so that it'll
+// * be repainted.
+// *
+// * <p>
+// * Yeah, agreed, it's a little bit hacky doing it this way, because it bakes
+// * in knowledge that this component is created, somehow, by a parent {@link org.apache.isis.viewer.wicket.ui.components.collection.CollectionPanel}.
+// * Perhaps it could be refactored to use a more general purpose observer pattern?
+// *
+// * <p>
+// * In fact, I've since discovered that Wicket has an event bus, which is used by the
+// * {@link UiHintContainer hinting mechanism}. So this ought to be relatively easy to do.
+// */
+// protected void onSelect(AjaxRequestTarget target) {
+// Component component = this;
+// while(component != null) {
+// if(component instanceof CollectionPanel) {
+// CollectionPanel collectionPanel = (CollectionPanel) component;
+// boolean hasCount = collectionPanel.hasCount();
+// if(hasCount) {
+// collectionPanel.updateLabel(target);
+// }
+// if(additionalLinks != null) {
+// applyCssVisibility(additionalLinks, hasCount);
+// }
+// return;
+// }
+// component = component.getParent();
+// }
+// }
+
+
protected static void applyCssVisibility(final Component component, final boolean visible) {
if(component == null) {
return;
@@ -375,7 +431,7 @@ public class CollectionContentsLinksSelectorPanel
ArrayList<ComponentFactory> otherFactories = Lists.newArrayList(Collections2.filter(componentFactories, new Predicate<ComponentFactory>() {
@Override
public boolean apply(final ComponentFactory input) {
- return input != ignoreFactory;
+ return input != ignoreFactory && input.getClass() != CollectionContentsLinksSelectorPanelFactory.class;
}
}));
return ordered(otherFactories);
http://git-wip-us.apache.org/repos/asf/isis/blob/70af3c32/example/application/todoapp/dom/src/main/java/dom/todo/ToDoItemContributions.java
----------------------------------------------------------------------
diff --git a/example/application/todoapp/dom/src/main/java/dom/todo/ToDoItemContributions.java b/example/application/todoapp/dom/src/main/java/dom/todo/ToDoItemContributions.java
index e30378c..1b758f8 100644
--- a/example/application/todoapp/dom/src/main/java/dom/todo/ToDoItemContributions.java
+++ b/example/application/todoapp/dom/src/main/java/dom/todo/ToDoItemContributions.java
@@ -159,6 +159,7 @@ public class ToDoItemContributions extends AbstractFactoryAndRepository {
@NotInServiceMenu
@ActionSemantics(Of.SAFE)
@NotContributed(As.ACTION)
+ @Programmatic
public List<ToDoItem> similarTo(final ToDoItem toDoItem) {
final List<ToDoItem> similarToDoItems = allMatches(
new QueryDefault<ToDoItem>(ToDoItem.class,
[23/23] isis git commit: ISIS-537: starting work on moving bulk
actions up to panel header (renders but looks nasty and the selector does
nothing).
Posted by da...@apache.org.
ISIS-537: starting work on moving bulk actions up to panel header (renders but looks nasty and the selector does nothing).
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/5022f856
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/5022f856
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/5022f856
Branch: refs/heads/ISIS-939
Commit: 5022f8563f2d72372ed9ba8b9e9924b481d2774c
Parents: 92ffe2d
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Mon Nov 10 10:19:23 2014 +0000
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Mon Nov 10 10:21:51 2014 +0000
----------------------------------------------------------------------
.../ajaxtable/BulkActionsHelper.java | 99 ++++++++++++++++++++
.../CollectionContentsAsAjaxTablePanel.java | 16 ++--
2 files changed, 106 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/5022f856/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/BulkActionsHelper.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/BulkActionsHelper.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/BulkActionsHelper.java
new file mode 100644
index 0000000..e7b1b66
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/BulkActionsHelper.java
@@ -0,0 +1,99 @@
+/*
+ * 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.viewer.wicket.ui.components.collectioncontents.ajaxtable;
+
+import java.util.Collections;
+import java.util.List;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import org.apache.isis.applib.filter.Filters;
+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.context.IsisContext;
+import org.apache.isis.viewer.wicket.model.models.EntityCollectionModel;
+
+public class BulkActionsHelper {
+
+ private final EntityCollectionModel model;
+
+ public BulkActionsHelper(final EntityCollectionModel model) {
+ this.model = model;
+ }
+
+ private EntityCollectionModel getModel() {
+ return model;
+ }
+
+ public List<ObjectAction> getBulkActions() {
+ final EntityCollectionModel model = getModel();
+
+ if(model.isParented()) {
+ return Collections.emptyList();
+ }
+
+ final ObjectSpecification typeSpec = model.getTypeOfSpecification();
+
+ List<ObjectAction> objectActions = typeSpec.getObjectActions(ActionType.USER, Contributed.INCLUDED, Filters.<ObjectAction>any());
+
+ if ( isExploring() || isPrototyping()) {
+ List<ObjectAction> explorationActions = typeSpec.getObjectActions(ActionType.EXPLORATION, Contributed.INCLUDED, Filters.<ObjectAction>any());
+ List<ObjectAction> prototypeActions = typeSpec.getObjectActions(ActionType.PROTOTYPE, Contributed.INCLUDED, Filters.<ObjectAction>any());
+ objectActions.addAll(explorationActions);
+ objectActions.addAll(prototypeActions);
+ }
+ if (isDebugMode()) {
+ List<ObjectAction> debugActions = typeSpec.getObjectActions(ActionType.DEBUG, Contributed.INCLUDED, Filters.<ObjectAction>any());
+ objectActions.addAll(debugActions);
+ }
+
+ List<ObjectAction> flattenedActions = objectActions;
+
+ return Lists.newArrayList(Iterables.filter(flattenedActions, BULK));
+ }
+
+
+ @SuppressWarnings("deprecation")
+ private static final Predicate<ObjectAction> BULK = Filters.asPredicate(ObjectAction.Filters.bulk());
+
+
+ //region > from context
+
+ public boolean isExploring() {
+ return IsisContext.getDeploymentType().isExploring();
+ }
+ public boolean isPrototyping() {
+ return IsisContext.getDeploymentType().isPrototyping();
+ }
+
+ /**
+ * Protected so can be overridden in testing if required.
+ */
+ protected boolean isDebugMode() {
+ // TODO: need to figure out how to switch into debug mode;
+ // probably call a Debug toggle page, and stuff into
+ // Session.getMetaData()
+ return true;
+ }
+
+ //endregion
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/5022f856/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/CollectionContentsAsAjaxTablePanel.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/CollectionContentsAsAjaxTablePanel.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/CollectionContentsAsAjaxTablePanel.java
index 803a053..aca3535 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/CollectionContentsAsAjaxTablePanel.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/CollectionContentsAsAjaxTablePanel.java
@@ -21,12 +21,10 @@ package org.apache.isis.viewer.wicket.ui.components.collectioncontents.ajaxtable
import java.util.Collections;
import java.util.List;
-
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.inject.Inject;
-
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.ajax.markup.html.repeater.data.table.AjaxFallbackDefaultDataTable;
@@ -34,7 +32,6 @@ import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.model.Model;
-
import org.apache.isis.applib.annotation.Where;
import org.apache.isis.applib.filter.Filter;
import org.apache.isis.applib.filter.Filters;
@@ -76,9 +73,10 @@ public class CollectionContentsAsAjaxTablePanel extends PanelAbstract<EntityColl
private static final long serialVersionUID = 1L;
private static final String ID_TABLE = "table";
- private static final String ID_ENTITY_ACTIONS = "entityActions";
private static final String ID_ACTION_PROMPT_MODAL_WINDOW = "actionPromptModalWindow";
-
+
+ private static final String ID_ENTITY_ACTIONS = "entityActions";
+
@SuppressWarnings("deprecation")
private static final Predicate<ObjectAction> BULK = Filters.asPredicate(ObjectAction.Filters.bulk());
@@ -106,7 +104,7 @@ public class CollectionContentsAsAjaxTablePanel extends PanelAbstract<EntityColl
addPropertyColumnsIfRequired(columns);
final SortableDataProvider<ObjectAdapter,String> dataProvider = new CollectionContentsSortableDataProvider(model);
- dataTable = new IsisAjaxFallbackDataTable<ObjectAdapter,String>(ID_TABLE, columns, dataProvider, model.getPageSize());
+ dataTable = new IsisAjaxFallbackDataTable<>(ID_TABLE, columns, dataProvider, model.getPageSize());
addActionPromptModalWindow();
buildEntityActionsGui(bulkActions, this, toggleboxColumn);
@@ -152,16 +150,16 @@ public class CollectionContentsAsAjaxTablePanel extends PanelAbstract<EntityColl
}
private void buildEntityActionsGui(
- final List<ObjectAction> bulkActions,
+ final List<ObjectAction> bulkActions,
final ActionPromptProvider actionPromptProvider,
final ObjectAdapterToggleboxColumn toggleboxColumn) {
final EntityCollectionModel model = getModel();
-
+
if(bulkActions.isEmpty() || model.isParented()) {
permanentlyHide(ID_ENTITY_ACTIONS);
return;
}
-
+
if(!bulkActions.isEmpty()) {
final ActionLinkFactory linkFactory = new BulkActionsLinkFactory(model, dataTable, toggleboxColumn);
[16/23] isis git commit: ISIS-537: completed factoring out of
CollectionContentsSelectorHelper.
Posted by da...@apache.org.
ISIS-537: completed factoring out of CollectionContentsSelectorHelper.
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/7087fc25
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/7087fc25
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/7087fc25
Branch: refs/heads/ISIS-939
Commit: 7087fc25ece5113839975db3b83ae4d1c78d041a
Parents: 457b365
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Sun Nov 9 15:52:49 2014 +0000
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Mon Nov 10 10:21:43 2014 +0000
----------------------------------------------------------------------
...CollectionContentsSelectorDropdownPanel.java | 247 +--------------
.../CollectionContentsSelectorHelper.java | 97 +++++-
.../CollectionContentsLinksSelectorPanel.java | 315 +------------------
...ectionContentsSelectorDropdownPanelTest.java | 2 +-
4 files changed, 122 insertions(+), 539 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/7087fc25/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorDropdownPanel.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorDropdownPanel.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorDropdownPanel.java
index 0903d2a..37797c5 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorDropdownPanel.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorDropdownPanel.java
@@ -21,13 +21,8 @@ package org.apache.isis.viewer.wicket.ui.components.collectioncontents.selector.
import de.agilecoders.wicket.core.markup.html.bootstrap.button.Buttons;
-import java.util.ArrayList;
import java.util.List;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Collections2;
-import com.google.common.collect.Lists;
import org.apache.wicket.AttributeModifier;
-import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.event.Broadcast;
@@ -40,10 +35,7 @@ import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
-import org.apache.isis.applib.annotation.Render.Type;
import org.apache.isis.core.commons.lang.StringExtensions;
-import org.apache.isis.core.metamodel.facets.members.render.RenderFacet;
-import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
import org.apache.isis.viewer.wicket.model.hints.IsisUiHintEvent;
import org.apache.isis.viewer.wicket.model.hints.UiHintContainer;
import org.apache.isis.viewer.wicket.model.hints.UiHintPathSignificant;
@@ -51,13 +43,9 @@ import org.apache.isis.viewer.wicket.model.models.EntityCollectionModel;
import org.apache.isis.viewer.wicket.ui.CollectionContentsAsFactory;
import org.apache.isis.viewer.wicket.ui.ComponentFactory;
import org.apache.isis.viewer.wicket.ui.ComponentType;
-import org.apache.isis.viewer.wicket.ui.components.collectioncontents.ajaxtable.CollectionContentsAsAjaxTablePanelFactory;
-import org.apache.isis.viewer.wicket.ui.components.collectioncontents.selector.links.CollectionContentsLinksSelectorPanelFactory;
-import org.apache.isis.viewer.wicket.ui.components.collectioncontents.unresolved.CollectionContentsAsUnresolvedPanelFactory;
import org.apache.isis.viewer.wicket.ui.panels.PanelAbstract;
import org.apache.isis.viewer.wicket.ui.panels.PanelUtil;
import org.apache.isis.viewer.wicket.ui.util.CssClassAppender;
-import org.apache.isis.viewer.wicket.ui.util.CssClassRemover;
/**
* Provides a list of links for selecting other views that support
@@ -69,9 +57,6 @@ public class CollectionContentsSelectorDropdownPanel
private static final long serialVersionUID = 1L;
- private static final String INVISIBLE_CLASS = "link-selector-panel-invisible";
-// private static final int MAX_NUM_UNDERLYING_VIEWS = 10;
-
private static final String ID_VIEWS = "views";
private static final String ID_VIEW_LIST = "viewList";
private static final String ID_VIEW_LINK = "viewLink";
@@ -79,23 +64,18 @@ public class CollectionContentsSelectorDropdownPanel
private static final String ID_VIEW_ITEM_TITLE = "viewItemTitle";
private static final String ID_VIEW_ITEM_ICON = "viewItemIcon";
- private static final String UIHINT_VIEW = "view";
private static final String ID_VIEW_BUTTON_TITLE = "viewButtonTitle";
private static final String ID_VIEW_BUTTON_ICON = "viewButtonIcon";
private final ComponentType componentType;
+ private final CollectionContentsSelectorHelper selectorHelper;
private ComponentFactory selectedComponentFactory;
-// private Component selectedComponent;
-
-// /**
-// * May be <tt>null</tt>, depending upon the model implementation.
-// */
-// protected WebMarkupContainer additionalLinks;
- public CollectionContentsSelectorDropdownPanel(final String id, final EntityCollectionModel model, final ComponentFactory factory) {
+ public CollectionContentsSelectorDropdownPanel(final String id, final EntityCollectionModel model, final ComponentFactory ignoreFactory) {
super(id, model);
- this.componentType = factory.getComponentType();
+ this.componentType = ignoreFactory.getComponentType();
+ selectorHelper = new CollectionContentsSelectorHelper(model, getComponentFactoryRegistry(), ignoreFactory);
}
/**
@@ -103,36 +83,14 @@ public class CollectionContentsSelectorDropdownPanel
*/
public void onInitialize() {
super.onInitialize();
- ComponentFactory componentFactory = getComponentFactoryRegistry().findComponentFactoryElseFailFast(getComponentType(), getModel());
- addUnderlyingViews(getModel(), componentFactory);
+ addDropdown();
}
- private void addUnderlyingViews(final EntityCollectionModel model, final ComponentFactory factory) {
- final List<ComponentFactory> componentFactories = findOtherComponentFactories(model, factory);
-
- final int selected = honourViewHintElseDefault(componentFactories, model);
- final CollectionContentsSelectorDropdownPanel selectorPanel = this;
-
- // create all, hide the one not selected
-// final Component[] underlyingViews = new Component[MAX_NUM_UNDERLYING_VIEWS];
-// int i = 0;
-// final EntityCollectionModel emptyModel = model.asDummy();
-// for (ComponentFactory componentFactory : componentFactories) {
-// final String underlyingId = underlyingIdPrefix + "-" + i;
-//
-// Component underlyingView = componentFactory.createComponent(underlyingId,i==selected? model: emptyModel);
-// underlyingViews[i++] = underlyingView;
-// selectorPanel.addOrReplace(underlyingView);
-// }
-
-// // hide any unused placeholders
-// while(i<MAX_NUM_UNDERLYING_VIEWS) {
-// String underlyingId = underlyingIdPrefix + "-" + i;
-// permanentlyHide(underlyingId);
-// i++;
-// }
+ private void addDropdown() {
+ final List<ComponentFactory> componentFactories = selectorHelper.findOtherComponentFactories();
+ final int selected = selectorHelper.honourViewHintElseDefault(this);
// selector
if (componentFactories.size() <= 1) {
@@ -140,8 +98,8 @@ public class CollectionContentsSelectorDropdownPanel
} else {
final Model<ComponentFactory> componentFactoryModel = new Model<>();
- selectorPanel.selectedComponentFactory = componentFactories.get(selected);
- componentFactoryModel.setObject(selectorPanel.selectedComponentFactory);
+ this.selectedComponentFactory = componentFactories.get(selected);
+ componentFactoryModel.setObject(this.selectedComponentFactory);
final WebMarkupContainer views = new WebMarkupContainer(ID_VIEWS);
@@ -175,21 +133,8 @@ public class CollectionContentsSelectorDropdownPanel
CollectionContentsSelectorDropdownPanel linksSelectorPanel = CollectionContentsSelectorDropdownPanel.this;
linksSelectorPanel.setViewHintAndBroadcast(underlyingViewNum, target);
-// final EntityCollectionModel dummyModel = model.asDummy();
-// for(int i=0; i<MAX_NUM_UNDERLYING_VIEWS; i++) {
-// final Component component = underlyingViews[i];
-// if(component == null) {
-// continue;
-// }
-// final boolean isSelected = i == underlyingViewNum;
-// applyCssVisibility(component, isSelected);
-// component.setDefaultModel(isSelected? model: dummyModel);
-// }
-
- selectorPanel.selectedComponentFactory = componentFactory;
-// selectorPanel.selectedComponent = underlyingViews[underlyingViewNum];
-// selectorPanel.onSelect(target);
- target.add(selectorPanel, views);
+ CollectionContentsSelectorDropdownPanel.this.selectedComponentFactory = componentFactory;
+ target.add(CollectionContentsSelectorDropdownPanel.this, views);
}
@Override
@@ -206,7 +151,7 @@ public class CollectionContentsSelectorDropdownPanel
Label viewItemIcon = new Label(ID_VIEW_ITEM_ICON, "");
link.add(viewItemIcon);
- boolean isEnabled = componentFactory != selectorPanel.selectedComponentFactory;
+ boolean isEnabled = componentFactory != CollectionContentsSelectorDropdownPanel.this.selectedComponentFactory;
if (!isEnabled) {
viewButtonTitle.setDefaultModel(title);
IModel<String> cssClass = cssClassFor(componentFactory, viewButtonIcon);
@@ -255,17 +200,6 @@ public class CollectionContentsSelectorDropdownPanel
container.add(listView);
addOrReplace(views);
}
-
-// for(i=0; i<MAX_NUM_UNDERLYING_VIEWS; i++) {
-// Component component = underlyingViews[i];
-// if(component != null) {
-// if(i != selected) {
-// component.add(new CssClassAppender(INVISIBLE_CLASS));
-// } else {
-// selectedComponent = component;
-// }
-// }
-// }
}
@@ -275,167 +209,14 @@ public class CollectionContentsSelectorDropdownPanel
if(uiHintContainer == null) {
return;
}
- uiHintContainer.setHint(CollectionContentsSelectorDropdownPanel.this, UIHINT_VIEW, ""+viewNum);
+ uiHintContainer.setHint(CollectionContentsSelectorDropdownPanel.this, CollectionContentsSelectorHelper.UIHINT_VIEW, ""+viewNum);
send(getPage(), Broadcast.EXACT, new IsisUiHintEvent(uiHintContainer, target));
}
-// /**
-// * Iterates up the component hierarchy looking for a parent
-// * {@link org.apache.isis.viewer.wicket.ui.components.collection.CollectionPanel}, and if so adds to ajax target so that it'll
-// * be repainted.
-// *
-// * <p>
-// * Yeah, agreed, it's a little bit hacky doing it this way, because it bakes
-// * in knowledge that this component is created, somehow, by a parent {@link org.apache.isis.viewer.wicket.ui.components.collection.CollectionPanel}.
-// * Perhaps it could be refactored to use a more general purpose observer pattern?
-// *
-// * <p>
-// * In fact, I've since discovered that Wicket has an event bus, which is used by the
-// * {@link org.apache.isis.viewer.wicket.model.hints.UiHintContainer hinting mechanism}. So this ought to be relatively easy to do.
-// */
-// public void onSelect(AjaxRequestTarget target) {
-// Component component = this;
-// while(component != null) {
-// if(component instanceof CollectionPanel) {
-// CollectionPanel collectionPanel = (CollectionPanel) component;
-// boolean hasCount = collectionPanel.hasCount();
-// if(hasCount) {
-// collectionPanel.updateLabel(target);
-// }
-//// if(additionalLinks != null) {
-//// applyCssVisibility(additionalLinks, hasCount);
-//// }
-// return;
-// }
-// component = component.getParent();
-// }
-// }
-
-
- protected static void applyCssVisibility(final Component component, final boolean visible) {
- if(component == null) {
- return;
- }
- AttributeModifier modifier = visible ? new CssClassRemover(INVISIBLE_CLASS) : new CssClassAppender(INVISIBLE_CLASS);
- component.add(modifier);
- }
-
- protected int honourViewHintElseDefault(final List<ComponentFactory> componentFactories, final IModel<?> model) {
- // honour hints ...
- final UiHintContainer hintContainer = getUiHintContainer();
- if(hintContainer != null) {
- String viewStr = hintContainer.getHint(this, UIHINT_VIEW);
- if(viewStr != null) {
- try {
- int view = Integer.parseInt(viewStr);
- if(view >= 0 && view < componentFactories.size()) {
- return view;
- }
- } catch(NumberFormatException ex) {
- // ignore
- }
- }
- }
-
- // ... else default
- int initialFactory = determineInitialFactory(componentFactories, model);
- if(hintContainer != null) {
- hintContainer.setHint(this, UIHINT_VIEW, ""+initialFactory);
- // don't broadcast (no AjaxRequestTarget, still configuring initial setup)
- }
- return initialFactory;
- }
-
-
- /**
- * return the index of {@link org.apache.isis.viewer.wicket.ui.components.collectioncontents.unresolved.CollectionContentsAsUnresolvedPanelFactory unresolved panel} if present and not eager loading;
- * else the index of {@link org.apache.isis.viewer.wicket.ui.components.collectioncontents.ajaxtable.CollectionContentsAsAjaxTablePanelFactory ajax table} if present,
- * otherwise first factory.
- */
- protected int determineInitialFactory(final List<ComponentFactory> componentFactories, final IModel<?> model) {
- if(!hasRenderEagerlyFacet(model)) {
- for(int i=0; i<componentFactories.size(); i++) {
- if(componentFactories.get(i) instanceof CollectionContentsAsUnresolvedPanelFactory) {
- return i;
- }
- }
- }
- int ajaxTableIdx = findAjaxTable(componentFactories);
- if(ajaxTableIdx>=0) {
- return ajaxTableIdx;
- }
- return 0;
- }
-
- private List<ComponentFactory> findOtherComponentFactories(final EntityCollectionModel model, final ComponentFactory ignoreFactory) {
- final List<ComponentFactory> componentFactories = getComponentFactoryRegistry().findComponentFactories(componentType, model);
- ArrayList<ComponentFactory> otherFactories = Lists.newArrayList(Collections2.filter(componentFactories, new Predicate<ComponentFactory>() {
- @Override
- public boolean apply(final ComponentFactory input) {
- return input != ignoreFactory && input.getClass() != CollectionContentsLinksSelectorPanelFactory.class;
- }
- }));
- return ordered(otherFactories);
- }
-
- protected List<ComponentFactory> ordered(List<ComponentFactory> componentFactories) {
- return orderAjaxTableToEnd(componentFactories);
- }
-
-
@Override
public void renderHead(final IHeaderResponse response) {
super.renderHead(response);
PanelUtil.renderHead(response, CollectionContentsSelectorDropdownPanel.class);
}
-
- static List<ComponentFactory> orderAjaxTableToEnd(List<ComponentFactory> componentFactories) {
- int ajaxTableIdx = findAjaxTable(componentFactories);
- if(ajaxTableIdx>=0) {
- List<ComponentFactory> orderedFactories = Lists.newArrayList(componentFactories);
- ComponentFactory ajaxTableFactory = orderedFactories.remove(ajaxTableIdx);
- orderedFactories.add(ajaxTableFactory);
- return orderedFactories;
- } else {
- return componentFactories;
- }
- }
-
- private static int findAjaxTable(List<ComponentFactory> componentFactories) {
- for(int i=0; i<componentFactories.size(); i++) {
- if(componentFactories.get(i) instanceof CollectionContentsAsAjaxTablePanelFactory) {
- return i;
- }
- }
- return -1;
- }
-
-
- private static boolean hasRenderEagerlyFacet(IModel<?> model) {
- if(!(model instanceof EntityCollectionModel)) {
- return false;
- }
- final EntityCollectionModel entityCollectionModel = (EntityCollectionModel) model;
- if(!entityCollectionModel.isParented()) {
- return false;
- }
-
- final OneToManyAssociation collection =
- entityCollectionModel.getCollectionMemento().getCollection();
- RenderFacet renderFacet = collection.getFacet(RenderFacet.class);
- return renderFacet != null && renderFacet.value() == Type.EAGERLY;
- }
-
-
-// @Override
-// public Integer getCount() {
-// if(selectedComponent instanceof CollectionCountProvider) {
-// final CollectionCountProvider collectionCountProvider = (CollectionCountProvider) selectedComponent;
-// return collectionCountProvider.getCount();
-// } else {
-// return null;
-// }
-// }
-
}
http://git-wip-us.apache.org/repos/asf/isis/blob/7087fc25/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorHelper.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorHelper.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorHelper.java
index 6b796b5..1e3706c 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorHelper.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorHelper.java
@@ -24,34 +24,51 @@ import java.util.List;
import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;
+import org.apache.wicket.Component;
+import org.apache.wicket.model.IModel;
+import org.apache.isis.applib.annotation.Render;
+import org.apache.isis.core.metamodel.facets.members.render.RenderFacet;
+import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
+import org.apache.isis.viewer.wicket.model.hints.UiHintContainer;
import org.apache.isis.viewer.wicket.model.models.EntityCollectionModel;
import org.apache.isis.viewer.wicket.ui.ComponentFactory;
import org.apache.isis.viewer.wicket.ui.ComponentType;
import org.apache.isis.viewer.wicket.ui.app.registry.ComponentFactoryRegistry;
import org.apache.isis.viewer.wicket.ui.components.collectioncontents.ajaxtable.CollectionContentsAsAjaxTablePanelFactory;
import org.apache.isis.viewer.wicket.ui.components.collectioncontents.selector.links.CollectionContentsLinksSelectorPanelFactory;
+import org.apache.isis.viewer.wicket.ui.components.collectioncontents.unresolved.CollectionContentsAsUnresolvedPanelFactory;
public class CollectionContentsSelectorHelper {
+ static final String UIHINT_VIEW = "view";
private static final long serialVersionUID = 1L;
private final ComponentType componentType;
private final ComponentFactoryRegistry componentFactoryRegistry;
private final EntityCollectionModel model;
private final ComponentFactory ignoreFactory;
+ private final List<ComponentFactory> componentFactories;
public CollectionContentsSelectorHelper(
- final ComponentType componentType,
- final ComponentFactoryRegistry componentFactoryRegistry,
final EntityCollectionModel model,
+ final ComponentFactoryRegistry componentFactoryRegistry,
final ComponentFactory ignoreFactory) {
- this.componentType = componentType;
this.componentFactoryRegistry = componentFactoryRegistry;
this.model = model;
this.ignoreFactory = ignoreFactory;
+ this.componentType = ignoreFactory.getComponentType();
+
+ componentFactories = findOtherComponentFactories();
+
}
+ public ComponentFactory getComponentFactory() {
+ return componentFactoryRegistry.findComponentFactoryElseFailFast(componentType, model);
+ }
+
+
+
public List<ComponentFactory> findOtherComponentFactories() {
final List<ComponentFactory> componentFactories = componentFactoryRegistry.findComponentFactories(componentType, model);
@@ -64,12 +81,10 @@ public class CollectionContentsSelectorHelper {
return ordered(otherFactories);
}
- private static List<ComponentFactory> ordered(List<ComponentFactory> componentFactories) {
+ protected List<ComponentFactory> ordered(List<ComponentFactory> componentFactories) {
return orderAjaxTableToEnd(componentFactories);
}
-
-
static List<ComponentFactory> orderAjaxTableToEnd(List<ComponentFactory> componentFactories) {
int ajaxTableIdx = findAjaxTable(componentFactories);
if(ajaxTableIdx>=0) {
@@ -82,7 +97,7 @@ public class CollectionContentsSelectorHelper {
}
}
- public static int findAjaxTable(List<ComponentFactory> componentFactories) {
+ static int findAjaxTable(List<ComponentFactory> componentFactories) {
for(int i=0; i<componentFactories.size(); i++) {
if(componentFactories.get(i) instanceof CollectionContentsAsAjaxTablePanelFactory) {
return i;
@@ -93,4 +108,72 @@ public class CollectionContentsSelectorHelper {
+
+
+ public int honourViewHintElseDefault(final Component component) {
+ // honour hints ...
+ final UiHintContainer hintContainer = getUiHintContainer(component);
+ if(hintContainer != null) {
+ String viewStr = hintContainer.getHint(component, UIHINT_VIEW);
+ if(viewStr != null) {
+ try {
+ int view = Integer.parseInt(viewStr);
+ if(view >= 0 && view < componentFactories.size()) {
+ return view;
+ }
+ } catch(NumberFormatException ex) {
+ // ignore
+ }
+ }
+ }
+
+ // ... else default
+ int initialFactory = determineInitialFactory(componentFactories, model);
+ if(hintContainer != null) {
+ hintContainer.setHint(component, UIHINT_VIEW, ""+initialFactory);
+ // don't broadcast (no AjaxRequestTarget, still configuring initial setup)
+ }
+ return initialFactory;
+ }
+
+ public static UiHintContainer getUiHintContainer(final Component component) {
+ return UiHintContainer.Util.hintContainerOf(component);
+ }
+
+
+ /**
+ * return the index of {@link org.apache.isis.viewer.wicket.ui.components.collectioncontents.unresolved.CollectionContentsAsUnresolvedPanelFactory unresolved panel} if present and not eager loading;
+ * else the index of {@link org.apache.isis.viewer.wicket.ui.components.collectioncontents.ajaxtable.CollectionContentsAsAjaxTablePanelFactory ajax table} if present,
+ * otherwise first factory.
+ */
+ protected int determineInitialFactory(final List<ComponentFactory> componentFactories, final IModel<?> model) {
+ if(!hasRenderEagerlyFacet(model)) {
+ for(int i=0; i<componentFactories.size(); i++) {
+ if(componentFactories.get(i) instanceof CollectionContentsAsUnresolvedPanelFactory) {
+ return i;
+ }
+ }
+ }
+ int ajaxTableIdx = CollectionContentsSelectorHelper.findAjaxTable(componentFactories);
+ if(ajaxTableIdx>=0) {
+ return ajaxTableIdx;
+ }
+ return 0;
+ }
+
+ private static boolean hasRenderEagerlyFacet(IModel<?> model) {
+ if(!(model instanceof EntityCollectionModel)) {
+ return false;
+ }
+ final EntityCollectionModel entityCollectionModel = (EntityCollectionModel) model;
+ if(!entityCollectionModel.isParented()) {
+ return false;
+ }
+
+ final OneToManyAssociation collection =
+ entityCollectionModel.getCollectionMemento().getCollection();
+ RenderFacet renderFacet = collection.getFacet(RenderFacet.class);
+ return renderFacet != null && renderFacet.value() == Render.Type.EAGERLY;
+ }
+
}
http://git-wip-us.apache.org/repos/asf/isis/blob/7087fc25/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java
index f29244f..fd0a3da 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java
@@ -19,21 +19,13 @@
package org.apache.isis.viewer.wicket.ui.components.collectioncontents.selector.links;
-import java.util.ArrayList;
import java.util.List;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Collections2;
-import com.google.common.collect.Lists;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.event.IEvent;
import org.apache.wicket.markup.head.IHeaderResponse;
-import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
-import org.apache.isis.applib.annotation.Render.Type;
-import org.apache.isis.core.metamodel.facets.members.render.RenderFacet;
-import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
import org.apache.isis.viewer.wicket.model.hints.IsisEnvelopeEvent;
import org.apache.isis.viewer.wicket.model.hints.IsisUiHintEvent;
import org.apache.isis.viewer.wicket.model.hints.UiHintContainer;
@@ -42,9 +34,8 @@ import org.apache.isis.viewer.wicket.model.models.EntityCollectionModel;
import org.apache.isis.viewer.wicket.ui.ComponentFactory;
import org.apache.isis.viewer.wicket.ui.ComponentType;
import org.apache.isis.viewer.wicket.ui.components.collection.CollectionCountProvider;
-import org.apache.isis.viewer.wicket.ui.components.collectioncontents.ajaxtable.CollectionContentsAsAjaxTablePanelFactory;
import org.apache.isis.viewer.wicket.ui.components.collectioncontents.selector.dropdown.CollectionContentsSelectorDropdownPanel;
-import org.apache.isis.viewer.wicket.ui.components.collectioncontents.unresolved.CollectionContentsAsUnresolvedPanelFactory;
+import org.apache.isis.viewer.wicket.ui.components.collectioncontents.selector.dropdown.CollectionContentsSelectorHelper;
import org.apache.isis.viewer.wicket.ui.panels.PanelAbstract;
import org.apache.isis.viewer.wicket.ui.panels.PanelUtil;
import org.apache.isis.viewer.wicket.ui.util.CssClassAppender;
@@ -65,30 +56,17 @@ public class CollectionContentsLinksSelectorPanel
private static final String ID_SELECTOR_DROPDOWN = "selectorDropdown";
-// private static final String ID_VIEWS = "views";
-// private static final String ID_VIEW_LIST = "viewList";
-// private static final String ID_VIEW_LINK = "viewLink";
-// private static final String ID_VIEW_ITEM = "viewItem";
-// private static final String ID_VIEW_ITEM_TITLE = "viewItemTitle";
-// private static final String ID_VIEW_ITEM_ICON = "viewItemIcon";
-
private static final String UIHINT_VIEW = "view";
-// private static final String ID_VIEW_BUTTON_TITLE = "viewButtonTitle";
-// private static final String ID_VIEW_BUTTON_ICON = "viewButtonIcon";
- private final ComponentFactory componentFactory;
+ private final ComponentFactory ignoreFactory;
private final ComponentType componentType;
private final String underlyingIdPrefix;
+ private final CollectionContentsSelectorHelper selectorHelper;
private ComponentFactory selectedComponentFactory;
protected Component selectedComponent;
-// /**
-// * May be <tt>null</tt>, depending upon the model implementation.
-// */
-// protected WebMarkupContainer additionalLinks;
-
private Component[] underlyingViews;
private List<ComponentFactory> componentFactories;
private CollectionContentsSelectorDropdownPanel selectorDropdownPanel;
@@ -96,11 +74,14 @@ public class CollectionContentsLinksSelectorPanel
public CollectionContentsLinksSelectorPanel(
final String id,
final EntityCollectionModel model,
- final ComponentFactory factory) {
+ final ComponentFactory ignoreFactory) {
super(id, model);
- componentFactory = factory;
+ this.ignoreFactory = ignoreFactory;
this.underlyingIdPrefix = ComponentType.COLLECTION_CONTENTS.toString();
- this.componentType = factory.getComponentType();
+ this.componentType = ignoreFactory.getComponentType();
+ selectorHelper = new CollectionContentsSelectorHelper(model, getComponentFactoryRegistry(), ignoreFactory);
+
+ componentFactories = selectorHelper.findOtherComponentFactories();
}
/**
@@ -108,18 +89,14 @@ public class CollectionContentsLinksSelectorPanel
*/
public void onInitialize() {
super.onInitialize();
- ComponentFactory componentFactory = getComponentFactoryRegistry().findComponentFactoryElseFailFast(getComponentType(), getModel());
- addUnderlyingViews(componentFactory);
+ addUnderlyingViews();
}
- private void addUnderlyingViews(final ComponentFactory factory) {
+ private void addUnderlyingViews() {
final EntityCollectionModel model = getModel();
- componentFactories = findOtherComponentFactories(model, factory);
- final int selected = honourViewHintElseDefault(componentFactories, model);
-
- final CollectionContentsLinksSelectorPanel selectorPanel = this;
+ final int selected = selectorHelper.honourViewHintElseDefault(this);
// create all, hide the one not selected
underlyingViews = new Component[MAX_NUM_UNDERLYING_VIEWS];
@@ -130,7 +107,7 @@ public class CollectionContentsLinksSelectorPanel
Component underlyingView = componentFactory.createComponent(underlyingId,i==selected? model: emptyModel);
underlyingViews[i++] = underlyingView;
- selectorPanel.addOrReplace(underlyingView);
+ this.addOrReplace(underlyingView);
}
// hide any unused placeholders
@@ -142,129 +119,16 @@ public class CollectionContentsLinksSelectorPanel
// selector
if (componentFactories.size() <= 1) {
- //permanentlyHide(ID_VIEWS);
-
permanentlyHide(ID_SELECTOR_DROPDOWN);
} else {
final Model<ComponentFactory> componentFactoryModel = new Model<>();
- selectorPanel.selectedComponentFactory = componentFactories.get(selected);
- componentFactoryModel.setObject(selectorPanel.selectedComponentFactory);
+ this.selectedComponentFactory = componentFactories.get(selected);
+ componentFactoryModel.setObject(this.selectedComponentFactory);
- selectorDropdownPanel = new CollectionContentsSelectorDropdownPanel(ID_SELECTOR_DROPDOWN, getModel(), componentFactory);
+ selectorDropdownPanel = new CollectionContentsSelectorDropdownPanel(ID_SELECTOR_DROPDOWN, getModel(), ignoreFactory);
this.setOutputMarkupId(true);
-
-// final WebMarkupContainer views = new WebMarkupContainer(ID_VIEWS);
-//
-// final Label viewButtonTitle = new Label(ID_VIEW_BUTTON_TITLE, "Hidden");
-// views.addOrReplace(viewButtonTitle);
-//
-// final Label viewButtonIcon = new Label(ID_VIEW_BUTTON_ICON, "");
-// views.addOrReplace(viewButtonIcon);
-//
-// final WebMarkupContainer container = new WebMarkupContainer(ID_VIEW_LIST);
-//
-// views.addOrReplace(container);
-// views.setOutputMarkupId(true);
-//
-// this.setOutputMarkupId(true);
-
-// final ListView<ComponentFactory> listView = new ListView<ComponentFactory>(ID_VIEW_ITEM, componentFactories) {
-//
-// private static final long serialVersionUID = 1L;
-//
-// @Override
-// protected void populateItem(ListItem<ComponentFactory> item) {
-//
-// final int underlyingViewNum = item.getIndex();
-//
-// final ComponentFactory componentFactory = item.getModelObject();
-// final AbstractLink link = new AjaxLink<Void>(ID_VIEW_LINK) {
-// private static final long serialVersionUID = 1L;
-// @Override
-// public void onClick(AjaxRequestTarget target) {
-// CollectionContentsLinksSelectorPanel linksSelectorPanel = CollectionContentsLinksSelectorPanel.this;
-// linksSelectorPanel.setViewHintAndBroadcast(underlyingViewNum, target);
-//
-// final EntityCollectionModel dummyModel = model.asDummy();
-// for(int i=0; i<MAX_NUM_UNDERLYING_VIEWS; i++) {
-// final Component component = underlyingViews[i];
-// if(component == null) {
-// continue;
-// }
-// final boolean isSelected = i == underlyingViewNum;
-// applyCssVisibility(component, isSelected);
-// component.setDefaultModel(isSelected? model: dummyModel);
-// }
-//
-// selectorPanel.selectedComponentFactory = componentFactory;
-// selectorPanel.selectedComponent = underlyingViews[underlyingViewNum];
-// selectorPanel.onSelect(target);
-// target.add(selectorPanel, views);
-// }
-//
-// @Override
-// protected void onComponentTag(ComponentTag tag) {
-// super.onComponentTag(tag);
-// Buttons.fixDisabledState(this, tag);
-// }
-// };
-//
-// IModel<String> title = nameFor(componentFactory);
-// Label viewItemTitleLabel = new Label(ID_VIEW_ITEM_TITLE, title);
-// link.add(viewItemTitleLabel);
-//
-// Label viewItemIcon = new Label(ID_VIEW_ITEM_ICON, "");
-// link.add(viewItemIcon);
-//
-// boolean isEnabled = componentFactory != selectorPanel.selectedComponentFactory;
-// if (!isEnabled) {
-// viewButtonTitle.setDefaultModel(title);
-// IModel<String> cssClass = cssClassFor(componentFactory, viewButtonIcon);
-// viewButtonIcon.add(AttributeModifier.replace("class", "ViewLinkItem " + cssClass.getObject()));
-// link.setVisible(false);
-// } else {
-// IModel<String> cssClass = cssClassFor(componentFactory, viewItemIcon);
-// viewItemIcon.add(new CssClassAppender(cssClass));
-// }
-//
-// item.add(link);
-// }
-//
-// private IModel<String> cssClassFor(final ComponentFactory componentFactory, Label viewIcon) {
-// IModel<String> cssClass = null;
-// if (componentFactory instanceof CollectionContentsAsFactory) {
-// CollectionContentsAsFactory collectionContentsAsFactory = (CollectionContentsAsFactory) componentFactory;
-// cssClass = collectionContentsAsFactory.getCssClass();
-// viewIcon.setDefaultModelObject("");
-// viewIcon.setEscapeModelStrings(true);
-// }
-// if (cssClass == null) {
-// String name = componentFactory.getName();
-// cssClass = Model.of(StringExtensions.asLowerDashed(name));
-// // Small hack: if there is no specific CSS class then we assume that background-image is used
-// // the span.ViewItemLink should have some content to show it
-// // FIX: find a way to do this with CSS (width and height don't seems to help)
-// viewIcon.setDefaultModelObject("     ");
-// viewIcon.setEscapeModelStrings(false);
-// }
-// return cssClass;
-// }
-//
-// private IModel<String> nameFor(final ComponentFactory componentFactory) {
-// IModel<String> name = null;
-// if (componentFactory instanceof CollectionContentsAsFactory) {
-// CollectionContentsAsFactory collectionContentsAsFactory = (CollectionContentsAsFactory) componentFactory;
-// name = collectionContentsAsFactory.getTitleLabel();
-// }
-// if (name == null) {
-// name = Model.of(componentFactory.getName());
-// }
-// return name;
-// }
-// };
-// container.add(listView);
addOrReplace(selectorDropdownPanel);
}
@@ -314,63 +178,18 @@ public class CollectionContentsLinksSelectorPanel
component.setDefaultModel(isSelected? getModel(): dummyModel);
}
- this.selectedComponentFactory = componentFactory;
+ this.selectedComponentFactory = ignoreFactory;
this.selectedComponent = underlyingViews[underlyingViewNum];
final AjaxRequestTarget target = uiHintEvent.getTarget();
if(target != null) {
-// selectorDropdownPanel.onSelect(target);
target.add(this, selectorDropdownPanel);
}
-
}
-
-// protected void setViewHintAndBroadcast(int viewNum, AjaxRequestTarget target) {
-// final UiHintContainer uiHintContainer = getUiHintContainer();
-// if(uiHintContainer == null) {
-// return;
-// }
-// uiHintContainer.setHint(CollectionContentsLinksSelectorPanel.this, UIHINT_VIEW, ""+viewNum);
-// send(getPage(), Broadcast.EXACT, new IsisUiHintEvent(uiHintContainer, target));
-// }
-
-// /**
-// * Iterates up the component hierarchy looking for a parent
-// * {@link org.apache.isis.viewer.wicket.ui.components.collection.CollectionPanel}, and if so adds to ajax target so that it'll
-// * be repainted.
-// *
-// * <p>
-// * Yeah, agreed, it's a little bit hacky doing it this way, because it bakes
-// * in knowledge that this component is created, somehow, by a parent {@link org.apache.isis.viewer.wicket.ui.components.collection.CollectionPanel}.
-// * Perhaps it could be refactored to use a more general purpose observer pattern?
-// *
-// * <p>
-// * In fact, I've since discovered that Wicket has an event bus, which is used by the
-// * {@link UiHintContainer hinting mechanism}. So this ought to be relatively easy to do.
-// */
-// protected void onSelect(AjaxRequestTarget target) {
-// Component component = this;
-// while(component != null) {
-// if(component instanceof CollectionPanel) {
-// CollectionPanel collectionPanel = (CollectionPanel) component;
-// boolean hasCount = collectionPanel.hasCount();
-// if(hasCount) {
-// collectionPanel.updateLabel(target);
-// }
-// if(additionalLinks != null) {
-// applyCssVisibility(additionalLinks, hasCount);
-// }
-// return;
-// }
-// component = component.getParent();
-// }
-// }
-
-
protected static void applyCssVisibility(final Component component, final boolean visible) {
if(component == null) {
return;
@@ -379,69 +198,6 @@ public class CollectionContentsLinksSelectorPanel
component.add(modifier);
}
- protected int honourViewHintElseDefault(final List<ComponentFactory> componentFactories, final IModel<?> model) {
- // honour hints ...
- final UiHintContainer hintContainer = getUiHintContainer();
- if(hintContainer != null) {
- String viewStr = hintContainer.getHint(this, UIHINT_VIEW);
- if(viewStr != null) {
- try {
- int view = Integer.parseInt(viewStr);
- if(view >= 0 && view < componentFactories.size()) {
- return view;
- }
- } catch(NumberFormatException ex) {
- // ignore
- }
- }
- }
-
- // ... else default
- int initialFactory = determineInitialFactory(componentFactories, model);
- if(hintContainer != null) {
- hintContainer.setHint(this, UIHINT_VIEW, ""+initialFactory);
- // don't broadcast (no AjaxRequestTarget, still configuring initial setup)
- }
- return initialFactory;
- }
-
-
- /**
- * return the index of {@link CollectionContentsAsUnresolvedPanelFactory unresolved panel} if present and not eager loading;
- * else the index of {@link CollectionContentsAsAjaxTablePanelFactory ajax table} if present,
- * otherwise first factory.
- */
- protected int determineInitialFactory(final List<ComponentFactory> componentFactories, final IModel<?> model) {
- if(!hasRenderEagerlyFacet(model)) {
- for(int i=0; i<componentFactories.size(); i++) {
- if(componentFactories.get(i) instanceof CollectionContentsAsUnresolvedPanelFactory) {
- return i;
- }
- }
- }
- int ajaxTableIdx = findAjaxTable(componentFactories);
- if(ajaxTableIdx>=0) {
- return ajaxTableIdx;
- }
- return 0;
- }
-
- private List<ComponentFactory> findOtherComponentFactories(final EntityCollectionModel model, final ComponentFactory ignoreFactory) {
- final List<ComponentFactory> componentFactories = getComponentFactoryRegistry().findComponentFactories(componentType, model);
- ArrayList<ComponentFactory> otherFactories = Lists.newArrayList(Collections2.filter(componentFactories, new Predicate<ComponentFactory>() {
- @Override
- public boolean apply(final ComponentFactory input) {
- return input != ignoreFactory && input.getClass() != CollectionContentsLinksSelectorPanelFactory.class;
- }
- }));
- return ordered(otherFactories);
- }
-
- protected List<ComponentFactory> ordered(List<ComponentFactory> componentFactories) {
- return orderAjaxTableToEnd(componentFactories);
- }
-
-
@Override
public void renderHead(final IHeaderResponse response) {
super.renderHead(response);
@@ -449,43 +205,6 @@ public class CollectionContentsLinksSelectorPanel
}
- static List<ComponentFactory> orderAjaxTableToEnd(List<ComponentFactory> componentFactories) {
- int ajaxTableIdx = findAjaxTable(componentFactories);
- if(ajaxTableIdx>=0) {
- List<ComponentFactory> orderedFactories = Lists.newArrayList(componentFactories);
- ComponentFactory ajaxTableFactory = orderedFactories.remove(ajaxTableIdx);
- orderedFactories.add(ajaxTableFactory);
- return orderedFactories;
- } else {
- return componentFactories;
- }
- }
-
- private static int findAjaxTable(List<ComponentFactory> componentFactories) {
- for(int i=0; i<componentFactories.size(); i++) {
- if(componentFactories.get(i) instanceof CollectionContentsAsAjaxTablePanelFactory) {
- return i;
- }
- }
- return -1;
- }
-
-
- private static boolean hasRenderEagerlyFacet(IModel<?> model) {
- if(!(model instanceof EntityCollectionModel)) {
- return false;
- }
- final EntityCollectionModel entityCollectionModel = (EntityCollectionModel) model;
- if(!entityCollectionModel.isParented()) {
- return false;
- }
-
- final OneToManyAssociation collection =
- entityCollectionModel.getCollectionMemento().getCollection();
- RenderFacet renderFacet = collection.getFacet(RenderFacet.class);
- return renderFacet != null && renderFacet.value() == Type.EAGERLY;
- }
-
@Override
public Integer getCount() {
http://git-wip-us.apache.org/repos/asf/isis/blob/7087fc25/component/viewer/wicket/ui/src/test/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorDropdownPanelTest.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/test/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorDropdownPanelTest.java b/component/viewer/wicket/ui/src/test/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorDropdownPanelTest.java
index d116be4..6b94417 100644
--- a/component/viewer/wicket/ui/src/test/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorDropdownPanelTest.java
+++ b/component/viewer/wicket/ui/src/test/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorDropdownPanelTest.java
@@ -58,7 +58,7 @@ public class CollectionContentsSelectorDropdownPanelTest {
one,
ajaxTableComponentFactory,
two);
- List<ComponentFactory> orderAjaxTableToEnd = CollectionContentsSelectorDropdownPanel.orderAjaxTableToEnd(componentFactories);
+ List<ComponentFactory> orderAjaxTableToEnd = CollectionContentsSelectorHelper.orderAjaxTableToEnd(componentFactories);
assertThat(orderAjaxTableToEnd.get(0), is(one));
assertThat(orderAjaxTableToEnd.get(1), is(two));
assertThat(orderAjaxTableToEnd.get(2), is(ajaxTableComponentFactory));
[13/23] isis git commit: ISIS-537: collection actions now rendered in
the panel header.
Posted by da...@apache.org.
ISIS-537: collection actions now rendered in the panel header.
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/5918dd61
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/5918dd61
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/5918dd61
Branch: refs/heads/ISIS-939
Commit: 5918dd61c41c4a80aea25746d68206108c2e8e0f
Parents: bb08787
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Sun Nov 9 13:39:41 2014 +0000
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Mon Nov 10 10:21:40 2014 +0000
----------------------------------------------------------------------
.../additionallinks/EntityActionUtil.java | 25 +++++++---
.../components/collection/CollectionPanel.java | 3 +-
.../CollectionContentsLinksSelectorPanel.html | 2 -
.../CollectionContentsLinksSelectorPanel.java | 50 +-------------------
.../collections/EntityCollectionsPanel.html | 31 ++++++++++++
.../collections/EntityCollectionsPanel.java | 14 ++++--
.../wicket/ui/pages/bootstrap-overrides.css | 4 ++
7 files changed, 66 insertions(+), 63 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/5918dd61/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/additionallinks/EntityActionUtil.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/additionallinks/EntityActionUtil.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/additionallinks/EntityActionUtil.java
index e6d86cb..5382a4f 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/additionallinks/EntityActionUtil.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/additionallinks/EntityActionUtil.java
@@ -59,7 +59,17 @@ public final class EntityActionUtil {
final ObjectAssociation association,
final ActionPromptProvider actionPromptProvider,
final DeploymentType deploymentType) {
-
+
+ return entityActionsForAssociation(
+ entityModel, association, actionPromptProvider, deploymentType, ID_ADDITIONAL_LINK);
+ }
+
+ public static List<LinkAndLabel> entityActionsForAssociation(
+ final EntityModel entityModel,
+ final ObjectAssociation association,
+ final ActionPromptProvider actionPromptProvider,
+ final DeploymentType deploymentType,
+ final String linkId) {
final List<ObjectAction> associatedActions = Lists.newArrayList();
addActions(ActionType.USER, entityModel, association, associatedActions);
@@ -67,7 +77,7 @@ public final class EntityActionUtil {
addActions(ActionType.EXPLORATION, entityModel, association, associatedActions);
addActions(ActionType.PROTOTYPE, entityModel, association, associatedActions);
}
-
+
Collections.sort(associatedActions, new Comparator<ObjectAction>() {
@Override
@@ -75,16 +85,17 @@ public final class EntityActionUtil {
final MemberOrderFacet m1 = o1.getFacet(MemberOrderFacet.class);
final MemberOrderFacet m2 = o2.getFacet(MemberOrderFacet.class);
return memberOrderFacetComparator.compare(m1, m2);
- }});
-
+ }
+ });
+
final ActionLinkFactory linkFactory = new EntityActionLinkFactory(entityModel);
-
+
final ObjectAdapterMemento adapterMemento = entityModel.getObjectAdapterMemento();
return Lists.transform(associatedActions, new Function<ObjectAction, LinkAndLabel>(){
-
+
@Override
public LinkAndLabel apply(ObjectAction objectAction) {
- return linkFactory.newLink(adapterMemento, objectAction, ID_ADDITIONAL_LINK, actionPromptProvider);
+ return linkFactory.newLink(adapterMemento, objectAction, linkId, actionPromptProvider);
}});
}
http://git-wip-us.apache.org/repos/asf/isis/blob/5918dd61/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/CollectionPanel.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/CollectionPanel.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/CollectionPanel.java
index 0f26d28..ec68145 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/CollectionPanel.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/CollectionPanel.java
@@ -50,7 +50,6 @@ public class CollectionPanel extends PanelAbstract<EntityCollectionModel> implem
private static final long serialVersionUID = 1L;
- private static final String ID_COLLECTION = "collection";
private static final String ID_FEEDBACK = "feedback";
private static final String ID_ACTION_PROMPT_MODAL_WINDOW = "actionPromptModalWindow";
@@ -77,7 +76,7 @@ public class CollectionPanel extends PanelAbstract<EntityCollectionModel> implem
addActionPromptModalWindow();
- List<LinkAndLabel> entityActions = EntityActionUtil.entityActionsForAssociation(entityModel, otma, this, getDeploymentType());
+ List<LinkAndLabel> entityActions = EntityActionUtil.entityActionsForAssociation(entityModel, otma, this, getDeploymentType(), "additionalLink");
collectionModel.addEntityActions(entityActions);
}
http://git-wip-us.apache.org/repos/asf/isis/blob/5918dd61/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.html
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.html b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.html
index d35d523..1fbf7df 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.html
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.html
@@ -39,8 +39,6 @@
</ul>
</div>
- <span wicket:id="additionalLinks"></span>
-
<div class="views">
<div wicket:id="collectionContents-0" class="collectionContentsLinksSelectorPanel collectionContentsComponentType"></div>
<div wicket:id="collectionContents-1" class="collectionContentsLinksSelectorPanel collectionContentsComponentType"></div>
http://git-wip-us.apache.org/repos/asf/isis/blob/5918dd61/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java
index c68bf71..d0d987b 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java
@@ -28,7 +28,6 @@ import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
-import org.apache.wicket.MarkupContainer;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.event.Broadcast;
@@ -48,20 +47,16 @@ import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
import org.apache.isis.viewer.wicket.model.hints.IsisUiHintEvent;
import org.apache.isis.viewer.wicket.model.hints.UiHintContainer;
import org.apache.isis.viewer.wicket.model.hints.UiHintPathSignificant;
-import org.apache.isis.viewer.wicket.model.links.LinkAndLabel;
-import org.apache.isis.viewer.wicket.model.links.LinksProvider;
import org.apache.isis.viewer.wicket.model.models.EntityCollectionModel;
import org.apache.isis.viewer.wicket.ui.CollectionContentsAsFactory;
import org.apache.isis.viewer.wicket.ui.ComponentFactory;
import org.apache.isis.viewer.wicket.ui.ComponentType;
-import org.apache.isis.viewer.wicket.ui.components.additionallinks.AdditionalLinksPanel;
import org.apache.isis.viewer.wicket.ui.components.collection.CollectionCountProvider;
import org.apache.isis.viewer.wicket.ui.components.collection.CollectionPanel;
import org.apache.isis.viewer.wicket.ui.components.collectioncontents.ajaxtable.CollectionContentsAsAjaxTablePanelFactory;
import org.apache.isis.viewer.wicket.ui.components.collectioncontents.unresolved.CollectionContentsAsUnresolvedPanelFactory;
import org.apache.isis.viewer.wicket.ui.panels.PanelAbstract;
import org.apache.isis.viewer.wicket.ui.panels.PanelUtil;
-import org.apache.isis.viewer.wicket.ui.util.Components;
import org.apache.isis.viewer.wicket.ui.util.CssClassAppender;
import org.apache.isis.viewer.wicket.ui.util.CssClassRemover;
@@ -78,8 +73,6 @@ public class CollectionContentsLinksSelectorPanel
private static final String INVISIBLE_CLASS = "link-selector-panel-invisible";
private static final int MAX_NUM_UNDERLYING_VIEWS = 10;
- private static final String ID_ADDITIONAL_LINKS = "additionalLinks";
-
private static final String ID_VIEWS = "views";
private static final String ID_VIEW_LIST = "viewList";
private static final String ID_VIEW_LINK = "viewLink";
@@ -114,34 +107,10 @@ public class CollectionContentsLinksSelectorPanel
public void onInitialize() {
super.onInitialize();
ComponentFactory componentFactory = getComponentFactoryRegistry().findComponentFactoryElseFailFast(getComponentType(), getModel());
- addAdditionalLinks(getModel());
addUnderlyingViews(underlyingIdPrefix, getModel(), componentFactory);
- applyCssVisibility(additionalLinks, selectedComponent instanceof CollectionCountProvider);
}
- protected void addAdditionalLinks(final EntityCollectionModel model) {
- if(!(model instanceof LinksProvider)) {
- permanentlyHide(ID_ADDITIONAL_LINKS);
- return;
- }
- LinksProvider linksProvider = (LinksProvider) model;
- List<LinkAndLabel> links = linksProvider.getLinks();
-
- addAdditionalLinks(this, links);
- }
-
- protected void addAdditionalLinks(MarkupContainer markupContainer, List<LinkAndLabel> links) {
- if(links == null || links.isEmpty()) {
- Components.permanentlyHide(markupContainer, ID_ADDITIONAL_LINKS);
- return;
- }
- links = Lists.newArrayList(links); // copy, to serialize any lazy evaluation
-
- additionalLinks = new AdditionalLinksPanel(ID_ADDITIONAL_LINKS, links);
- markupContainer.addOrReplace(additionalLinks);
- }
-
private void addUnderlyingViews(final String underlyingIdPrefix, final EntityCollectionModel model, final ComponentFactory factory) {
final List<ComponentFactory> componentFactories = findOtherComponentFactories(model, factory);
@@ -152,7 +121,7 @@ public class CollectionContentsLinksSelectorPanel
// create all, hide the one not selected
final Component[] underlyingViews = new Component[MAX_NUM_UNDERLYING_VIEWS];
int i = 0;
- final EntityCollectionModel emptyModel = dummyOf(model);
+ final EntityCollectionModel emptyModel = model.asDummy();
for (ComponentFactory componentFactory : componentFactories) {
final String underlyingId = underlyingIdPrefix + "-" + i;
@@ -209,7 +178,7 @@ public class CollectionContentsLinksSelectorPanel
CollectionContentsLinksSelectorPanel linksSelectorPanel = CollectionContentsLinksSelectorPanel.this;
linksSelectorPanel.setViewHintAndBroadcast(underlyingViewNum, target);
- final EntityCollectionModel dummyModel = dummyOf(model);
+ final EntityCollectionModel dummyModel = model.asDummy();
for(int i=0; i<MAX_NUM_UNDERLYING_VIEWS; i++) {
final Component component = underlyingViews[i];
if(component == null) {
@@ -424,21 +393,6 @@ public class CollectionContentsLinksSelectorPanel
}
-
-
-
-
-
- /**
- * Ask for a dummy (empty) {@link Model} to pass into those components that are rendered but will be
- * made invisible using CSS styling.
- */
- protected EntityCollectionModel dummyOf(EntityCollectionModel model) {
- return model.asDummy();
- }
-
-
-
static List<ComponentFactory> orderAjaxTableToEnd(List<ComponentFactory> componentFactories) {
int ajaxTableIdx = findAjaxTable(componentFactories);
if(ajaxTableIdx>=0) {
http://git-wip-us.apache.org/repos/asf/isis/blob/5918dd61/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/collections/EntityCollectionsPanel.html
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/collections/EntityCollectionsPanel.html b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/collections/EntityCollectionsPanel.html
index 90fdc22..216d9c9 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/collections/EntityCollectionsPanel.html
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/collections/EntityCollectionsPanel.html
@@ -23,9 +23,40 @@
<div class="entityCollectionsPanel entityCollectionsComponentType">
<div wicket:id="collections" class="myBlockContainer">
<div wicket:id="collectionGroup" class="panel panel-default">
+
<div class="panel-heading">
<span wicket:id="collectionName" class="panel-title">[collection name]</span>
+ <div class="pull-right">
+
+ <!--
+ <div class="btn-group">
+ <a href="#" class="btn btn-default btn-sm">## Lock</a>
+ <a href="#" class="btn btn-default btn-sm">## Delete</a>
+ <a href="#" class="btn btn-default btn-sm">## Move</a>
+ </div>
+ -->
+
+ <div class="btn-group">
+ <div wicket:id="additionalLinks"></div>
+ </div>
+
+ <!--
+ <div class="btn-group">
+ <ul xxwicket:id="viewList" class="dropdown-menu dropdown-menu-right" role="menu">
+ <li xxwicket:id="viewItem" class="viewItem">
+ <a href="#" xxwicket:id="viewLink">
+ <span xxwicket:id="viewItemIcon" class="ViewLinkItem"></span> <span xxwicket:id="viewItemTitle" class="ViewLinkItemTitle">[link title]</span>
+ </a>
+ </li>
+ </ul>
+ </div>
+ -->
+
+ </div>
</div>
+
+
+
<div wicket:id="collection" class="collection panel-body">
[collection]
</div>
http://git-wip-us.apache.org/repos/asf/isis/blob/5918dd61/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/collections/EntityCollectionsPanel.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/collections/EntityCollectionsPanel.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/collections/EntityCollectionsPanel.java
index f18ba4a..55ad54b 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/collections/EntityCollectionsPanel.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/collections/EntityCollectionsPanel.java
@@ -20,11 +20,9 @@
package org.apache.isis.viewer.wicket.ui.components.entity.collections;
import java.util.List;
-
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.repeater.RepeatingView;
-
import org.apache.isis.applib.annotation.Where;
import org.apache.isis.applib.filter.Filter;
import org.apache.isis.applib.filter.Filters;
@@ -34,7 +32,10 @@ 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.ObjectAssociation;
import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
+import org.apache.isis.viewer.wicket.model.links.LinkAndLabel;
+import org.apache.isis.viewer.wicket.model.models.EntityCollectionModel;
import org.apache.isis.viewer.wicket.model.models.EntityModel;
+import org.apache.isis.viewer.wicket.ui.components.additionallinks.AdditionalLinksPanel;
import org.apache.isis.viewer.wicket.ui.components.collection.CollectionPanel;
import org.apache.isis.viewer.wicket.ui.components.widgets.containers.UiHintPathSignificantWebMarkupContainer;
import org.apache.isis.viewer.wicket.ui.panels.PanelAbstract;
@@ -54,6 +55,8 @@ public class EntityCollectionsPanel extends PanelAbstract<EntityModel> {
private static final String ID_COLLECTIONS = "collections";
private static final String ID_COLLECTION = "collection";
+ private static final String ID_ADDITIONAL_LINKS = "additionalLinks";
+
private Label labelComponent;
@@ -109,12 +112,15 @@ public class EntityCollectionsPanel extends PanelAbstract<EntityModel> {
final OneToManyAssociation otma = (OneToManyAssociation) association;
final CollectionPanel collectionPanel = new CollectionPanel(ID_COLLECTION, entityModel, otma);
+ fieldset.addOrReplace(collectionPanel);
labelComponent = collectionPanel.createLabel(ID_COLLECTION_NAME, association.getName());
-
fieldset.add(labelComponent);
- fieldset.addOrReplace(collectionPanel);
+ final EntityCollectionModel entityCollectionModel = collectionPanel.getModel();
+ List<LinkAndLabel> links = entityCollectionModel.getLinks();
+ AdditionalLinksPanel additionalLinks = new AdditionalLinksPanel(ID_ADDITIONAL_LINKS, links);
+ fieldset.addOrReplace(additionalLinks);
}
private List<ObjectAssociation> visibleCollections(final ObjectAdapter adapter, final ObjectSpecification noSpec) {
http://git-wip-us.apache.org/repos/asf/isis/blob/5918dd61/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/bootstrap-overrides.css
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/bootstrap-overrides.css b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/bootstrap-overrides.css
index 9c287ff..cb7ed79 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/bootstrap-overrides.css
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/bootstrap-overrides.css
@@ -158,3 +158,7 @@ div.label-left .choicesPlaceholder {
.modal-body textarea {
resize: none;
}
+
+.entityCollectionsPanel .panel-heading {
+ padding-bottom: 15px;
+}
\ No newline at end of file
[10/23] isis git commit: ISIS-537: deleting
LinksSelectorPanelAbstract, no longer used.
Posted by da...@apache.org.
ISIS-537: deleting LinksSelectorPanelAbstract, no longer used.
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/f8a8ea4f
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/f8a8ea4f
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/f8a8ea4f
Branch: refs/heads/ISIS-939
Commit: f8a8ea4f2e626361ccf727e979b590ee49615f3a
Parents: b1677ca
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Sun Nov 9 12:05:27 2014 +0000
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Mon Nov 10 10:21:36 2014 +0000
----------------------------------------------------------------------
.../wicket/ui/CollectionContentsAsFactory.java | 2 +-
.../ui/components/about/AboutPanelFactory.java | 4 -
.../additionallinks/EntityActionUtil.java | 7 +-
.../CollectionContentsLinksSelectorPanel.java | 9 +-
.../links/EntityLinksSelectorPanel.java | 9 +-
.../viewer/wicket/ui/panels/PanelAbstract.java | 1 +
.../isis/viewer/wicket/ui/panels/PanelUtil.java | 6 -
.../links/LinksSelectorPanelAbstract.css | 19 -
.../links/LinksSelectorPanelAbstract.html | 50 ---
.../links/LinksSelectorPanelAbstract.java | 376 -------------------
10 files changed, 10 insertions(+), 473 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/f8a8ea4f/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/CollectionContentsAsFactory.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/CollectionContentsAsFactory.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/CollectionContentsAsFactory.java
index ed5e1cf..0e98a3f 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/CollectionContentsAsFactory.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/CollectionContentsAsFactory.java
@@ -24,7 +24,7 @@ import org.apache.wicket.model.IModel;
* <p>
* An interface for all {@link org.apache.isis.viewer.wicket.ui.ComponentFactory component factories}
* (e.g. CollectionContentAsXyzFactory-ies) which want to provide specific title and CSS class(es)
- * for their representation in {@link org.apache.isis.viewer.wicket.ui.selector.links.LinksSelectorPanelAbstract}.
+ * for their representation in {@link org.apache.isis.viewer.wicket.ui.components.collectioncontents.selector.links.CollectionContentsLinksSelectorPanel}.
* </p>
* <p>
* If the {@link org.apache.isis.viewer.wicket.ui.ComponentFactory} doesn't implement this interface or the implementation
http://git-wip-us.apache.org/repos/asf/isis/blob/f8a8ea4f/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/about/AboutPanelFactory.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/about/AboutPanelFactory.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/about/AboutPanelFactory.java
index 91775d9..3439855 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/about/AboutPanelFactory.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/about/AboutPanelFactory.java
@@ -21,13 +21,9 @@ package org.apache.isis.viewer.wicket.ui.components.about;
import org.apache.wicket.Component;
import org.apache.wicket.model.IModel;
-import org.apache.wicket.request.resource.CssResourceReference;
-
import org.apache.isis.viewer.wicket.ui.ComponentFactory;
import org.apache.isis.viewer.wicket.ui.ComponentFactoryAbstract;
import org.apache.isis.viewer.wicket.ui.ComponentType;
-import org.apache.isis.viewer.wicket.ui.components.entity.selector.links.EntityLinksSelectorPanel;
-import org.apache.isis.viewer.wicket.ui.selector.links.LinksSelectorPanelAbstract;
/**
* {@link ComponentFactory} for {@link AboutPanel}.
http://git-wip-us.apache.org/repos/asf/isis/blob/f8a8ea4f/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/additionallinks/EntityActionUtil.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/additionallinks/EntityActionUtil.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/additionallinks/EntityActionUtil.java
index 5c2d62c..e6d86cb 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/additionallinks/EntityActionUtil.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/additionallinks/EntityActionUtil.java
@@ -45,10 +45,11 @@ import org.apache.isis.viewer.wicket.model.models.ActionPromptProvider;
import org.apache.isis.viewer.wicket.model.models.EntityModel;
import org.apache.isis.viewer.wicket.ui.components.entity.EntityActionLinkFactory;
import org.apache.isis.viewer.wicket.ui.components.widgets.cssmenu.ActionLinkFactory;
-import org.apache.isis.viewer.wicket.ui.selector.links.LinksSelectorPanelAbstract;
public final class EntityActionUtil {
-
+
+ public static final String ID_ADDITIONAL_LINK = "additionalLink";
+
private EntityActionUtil(){}
private final static MemberOrderFacetComparator memberOrderFacetComparator = new MemberOrderFacetComparator(false);
@@ -83,7 +84,7 @@ public final class EntityActionUtil {
@Override
public LinkAndLabel apply(ObjectAction objectAction) {
- return linkFactory.newLink(adapterMemento, objectAction, LinksSelectorPanelAbstract.ID_ADDITIONAL_LINK, actionPromptProvider);
+ return linkFactory.newLink(adapterMemento, objectAction, ID_ADDITIONAL_LINK, actionPromptProvider);
}});
}
http://git-wip-us.apache.org/repos/asf/isis/blob/f8a8ea4f/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java
index 096903c..d935b64 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java
@@ -60,8 +60,6 @@ import org.apache.isis.viewer.wicket.ui.components.collection.CollectionPanel;
import org.apache.isis.viewer.wicket.ui.components.collectioncontents.ajaxtable.CollectionContentsAsAjaxTablePanelFactory;
import org.apache.isis.viewer.wicket.ui.components.collectioncontents.unresolved.CollectionContentsAsUnresolvedPanelFactory;
import org.apache.isis.viewer.wicket.ui.panels.PanelAbstract;
-import org.apache.isis.viewer.wicket.ui.panels.PanelUtil;
-import org.apache.isis.viewer.wicket.ui.selector.links.LinksSelectorPanelAbstract;
import org.apache.isis.viewer.wicket.ui.util.Components;
import org.apache.isis.viewer.wicket.ui.util.CssClassAppender;
import org.apache.isis.viewer.wicket.ui.util.CssClassRemover;
@@ -70,10 +68,6 @@ import org.apache.isis.viewer.wicket.ui.util.CssClassRemover;
* Provides a list of links for selecting other views that support
* {@link ComponentType#COLLECTION_CONTENTS} with a backing
* {@link EntityCollectionModel}.
- *
- * <p>
- * Most of the heavy lifting is factored out into the superclass,
- * {@link LinksSelectorPanelAbstract}.
*/
public class CollectionContentsLinksSelectorPanel
extends PanelAbstract<EntityCollectionModel> implements UiHintPathSignificant, CollectionCountProvider {
@@ -425,7 +419,8 @@ public class CollectionContentsLinksSelectorPanel
@Override
public void renderHead(final IHeaderResponse response) {
super.renderHead(response);
- PanelUtil.renderHead(response, LinksSelectorPanelAbstract.class);
+ // TODO: mgrigorov remove this stuff once happy no longer needed at all.
+ // PanelUtil.renderHead(response, CollectionContentsLinksSelectorPanel.class);
}
http://git-wip-us.apache.org/repos/asf/isis/blob/f8a8ea4f/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/selector/links/EntityLinksSelectorPanel.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/selector/links/EntityLinksSelectorPanel.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/selector/links/EntityLinksSelectorPanel.java
index 7cab8d8..2adb5ca 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/selector/links/EntityLinksSelectorPanel.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/selector/links/EntityLinksSelectorPanel.java
@@ -53,8 +53,6 @@ import org.apache.isis.viewer.wicket.ui.ComponentFactory;
import org.apache.isis.viewer.wicket.ui.ComponentType;
import org.apache.isis.viewer.wicket.ui.components.additionallinks.AdditionalLinksPanel;
import org.apache.isis.viewer.wicket.ui.panels.PanelAbstract;
-import org.apache.isis.viewer.wicket.ui.panels.PanelUtil;
-import org.apache.isis.viewer.wicket.ui.selector.links.LinksSelectorPanelAbstract;
import org.apache.isis.viewer.wicket.ui.util.Components;
import org.apache.isis.viewer.wicket.ui.util.CssClassAppender;
import org.apache.isis.viewer.wicket.ui.util.CssClassRemover;
@@ -62,10 +60,6 @@ import org.apache.isis.viewer.wicket.ui.util.CssClassRemover;
/**
* Provides a list of links for selecting other views that support
* {@link ComponentType#ENTITY} with a backing {@link EntityModel}.
- *
- * <p>
- * Most of the heavy lifting is factored out into the superclass,
- * {@link LinksSelectorPanelAbstract}.
*/
public class EntityLinksSelectorPanel extends PanelAbstract<EntityModel> implements UiHintPathSignificant {
@@ -390,7 +384,8 @@ public class EntityLinksSelectorPanel extends PanelAbstract<EntityModel> impleme
@Override
public void renderHead(final IHeaderResponse response) {
super.renderHead(response);
- PanelUtil.renderHead(response, LinksSelectorPanelAbstract.class);
+ // TODO: mgrigorov remove this stuff once happy no longer needed at all.
+ // PanelUtil.renderHead(response, LinksSelectorPanelAbstract.class);
}
http://git-wip-us.apache.org/repos/asf/isis/blob/f8a8ea4f/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/PanelAbstract.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/PanelAbstract.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/PanelAbstract.java
index 690a0ff..daa7029 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/PanelAbstract.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/PanelAbstract.java
@@ -124,6 +124,7 @@ public abstract class PanelAbstract<T extends IModel<?>> extends Panel implement
*/
@Override
public void renderHead(final IHeaderResponse response) {
+ // TODO: mgrigorov remove this stuff once happy no longer needed at all.
// PanelUtil.renderHead(response, this.getClass());
}
http://git-wip-us.apache.org/repos/asf/isis/blob/f8a8ea4f/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/PanelUtil.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/PanelUtil.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/PanelUtil.java
index 0d46366..4c7af42 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/PanelUtil.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/PanelUtil.java
@@ -19,23 +19,17 @@
package org.apache.isis.viewer.wicket.ui.panels;
import com.google.common.base.Strings;
-
import org.apache.wicket.markup.head.CssHeaderItem;
import org.apache.wicket.markup.head.CssReferenceHeaderItem;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.request.resource.CssResourceReference;
-import org.apache.isis.viewer.wicket.ui.selector.links.LinksSelectorPanelAbstract;
-
public final class PanelUtil {
private PanelUtil(){}
/**
* The contribution to the header performed implicitly by {@link PanelAbstract}.
- *
- * <p>
- * Factored out for reuse by {@link LinksSelectorPanelAbstract}.
*/
public static void renderHead(final IHeaderResponse response, final Class<?> cls) {
final CssResourceReference cssResourceReference = cssResourceReferenceFor(cls);
http://git-wip-us.apache.org/repos/asf/isis/blob/f8a8ea4f/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/selector/links/LinksSelectorPanelAbstract.css
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/selector/links/LinksSelectorPanelAbstract.css b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/selector/links/LinksSelectorPanelAbstract.css
deleted file mode 100644
index 9f1612a..0000000
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/selector/links/LinksSelectorPanelAbstract.css
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * 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.
- */
-
http://git-wip-us.apache.org/repos/asf/isis/blob/f8a8ea4f/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/selector/links/LinksSelectorPanelAbstract.html
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/selector/links/LinksSelectorPanelAbstract.html b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/selector/links/LinksSelectorPanelAbstract.html
deleted file mode 100644
index 14418d1..0000000
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/selector/links/LinksSelectorPanelAbstract.html
+++ /dev/null
@@ -1,50 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns:wicket="http://wicket.apache.org">
- <body>
- <wicket:panel>
- <div class="linksSelectorPanel">
- <div class="btn-group viewLinks" wicket:id="views">
- <button type="button" class="btn btn-xs btn-info">
- <span wicket:id="viewButtonIcon" class="ViewLinkItem"></span>
- <span wicket:id="viewButtonTitle" class="ViewLinkItemTitle"></span>
- </button>
- <button type="button" class="btn btn-xs btn-info dropdown-toggle" data-toggle="dropdown">
- <span class="caret"></span>
- </button>
- <ul wicket:id="viewList" class="dropdown-menu dropdown-menu-right" role="menu">
- <li wicket:id="viewItem" class="viewItem">
- <a href="#" wicket:id="viewLink">
- <span wicket:id="viewItemIcon" class="ViewLinkItem"></span> <span wicket:id="viewItemTitle" class="ViewLinkItemTitle">[link title]</span>
- </a>
- </li>
- </ul>
- </div>
-
- <span wicket:id="additionalLinks"></span>
-
- <div class="views">
- <wicket:child/>
- </div>
- </div>
- </wicket:panel>
- </body>
-</html>
http://git-wip-us.apache.org/repos/asf/isis/blob/f8a8ea4f/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/selector/links/LinksSelectorPanelAbstract.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/selector/links/LinksSelectorPanelAbstract.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/selector/links/LinksSelectorPanelAbstract.java
deleted file mode 100644
index 2b6b96f..0000000
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/selector/links/LinksSelectorPanelAbstract.java
+++ /dev/null
@@ -1,376 +0,0 @@
-/*
- * 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.viewer.wicket.ui.selector.links;
-
-import de.agilecoders.wicket.core.markup.html.bootstrap.button.Buttons;
-
-import java.util.ArrayList;
-import java.util.List;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Collections2;
-import com.google.common.collect.Lists;
-import org.apache.wicket.AttributeModifier;
-import org.apache.wicket.Component;
-import org.apache.wicket.MarkupContainer;
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.ajax.markup.html.AjaxLink;
-import org.apache.wicket.event.Broadcast;
-import org.apache.wicket.markup.ComponentTag;
-import org.apache.wicket.markup.head.IHeaderResponse;
-import org.apache.wicket.markup.html.WebMarkupContainer;
-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.model.IModel;
-import org.apache.wicket.model.Model;
-import org.apache.isis.core.commons.lang.StringExtensions;
-import org.apache.isis.viewer.wicket.model.hints.IsisUiHintEvent;
-import org.apache.isis.viewer.wicket.model.hints.UiHintContainer;
-import org.apache.isis.viewer.wicket.model.hints.UiHintPathSignificant;
-import org.apache.isis.viewer.wicket.model.links.LinkAndLabel;
-import org.apache.isis.viewer.wicket.model.links.LinksProvider;
-import org.apache.isis.viewer.wicket.ui.CollectionContentsAsFactory;
-import org.apache.isis.viewer.wicket.ui.ComponentFactory;
-import org.apache.isis.viewer.wicket.ui.ComponentType;
-import org.apache.isis.viewer.wicket.ui.components.additionallinks.AdditionalLinksPanel;
-import org.apache.isis.viewer.wicket.ui.panels.PanelAbstract;
-import org.apache.isis.viewer.wicket.ui.panels.PanelUtil;
-import org.apache.isis.viewer.wicket.ui.util.Components;
-import org.apache.isis.viewer.wicket.ui.util.CssClassAppender;
-import org.apache.isis.viewer.wicket.ui.util.CssClassRemover;
-
-public abstract class LinksSelectorPanelAbstract<T extends IModel<?>> extends PanelAbstract<T> implements UiHintPathSignificant {
-
- private static final long serialVersionUID = 1L;
-
- private static final String INVISIBLE_CLASS = "link-selector-panel-invisible";
- private static final int MAX_NUM_UNDERLYING_VIEWS = 10;
-
- private static final String ID_ADDITIONAL_LINKS = "additionalLinks";
- public static final String ID_ADDITIONAL_LINK = "additionalLink";
-
- private static final String ID_VIEWS = "views";
- private static final String ID_VIEW_LIST = "viewList";
- private static final String ID_VIEW_LINK = "viewLink";
- private static final String ID_VIEW_ITEM = "viewItem";
- private static final String ID_VIEW_ITEM_TITLE = "viewItemTitle";
- private static final String ID_VIEW_ITEM_ICON = "viewItemIcon";
-
- private static final String UIHINT_VIEW = "view";
- private static final String ID_VIEW_BUTTON_TITLE = "viewButtonTitle";
- private static final String ID_VIEW_BUTTON_ICON = "viewButtonIcon";
-
- private final ComponentType componentType;
- private final String underlyingIdPrefix;
-
- private ComponentFactory selectedComponentFactory;
- protected Component selectedComponent;
-
- /**
- * May be <tt>null</tt>, depending upon the model implementation.
- *
- * @see #addAdditionalLinks(IModel)
- */
- protected WebMarkupContainer additionalLinks;
-
-
- public LinksSelectorPanelAbstract(final String id, final String underlyingIdPrefix, final T model, final ComponentFactory factory) {
- super(id, model);
- this.underlyingIdPrefix = underlyingIdPrefix;
- this.componentType = factory.getComponentType();
- }
-
- /**
- * Build UI only after added to parent.
- */
- public void onInitialize() {
- super.onInitialize();
- ComponentFactory componentFactory = getComponentFactoryRegistry().findComponentFactoryElseFailFast(getComponentType(), getModel());
- addAdditionalLinks(getModel());
- addUnderlyingViews(underlyingIdPrefix, getModel(), componentFactory);
- }
-
- protected void addAdditionalLinks(final T model) {
- if(!(model instanceof LinksProvider)) {
- permanentlyHide(ID_ADDITIONAL_LINKS);
- return;
- }
- LinksProvider linksProvider = (LinksProvider) model;
- List<LinkAndLabel> links = linksProvider.getLinks();
-
- addAdditionalLinks(this, links);
- }
-
- protected void addAdditionalLinks(MarkupContainer markupContainer, List<LinkAndLabel> links) {
- if(links == null || links.isEmpty()) {
- Components.permanentlyHide(markupContainer, ID_ADDITIONAL_LINKS);
- return;
- }
- links = Lists.newArrayList(links); // copy, to serialize any lazy evaluation
-
- additionalLinks = new AdditionalLinksPanel(ID_ADDITIONAL_LINKS, links);
- markupContainer.addOrReplace(additionalLinks);
- }
-
- private void addUnderlyingViews(final String underlyingIdPrefix, final T model, final ComponentFactory factory) {
- final List<ComponentFactory> componentFactories = findOtherComponentFactories(model, factory);
-
- final int selected = honourViewHintElseDefault(componentFactories, model);
-
- final LinksSelectorPanelAbstract<T> selectorPanel = LinksSelectorPanelAbstract.this;
-
- // create all, hide the one not selected
- final Component[] underlyingViews = new Component[MAX_NUM_UNDERLYING_VIEWS];
- int i = 0;
- final T emptyModel = dummyOf(model);
- for (ComponentFactory componentFactory : componentFactories) {
- final String underlyingId = underlyingIdPrefix + "-" + i;
-
- Component underlyingView = componentFactory.createComponent(underlyingId,i==selected? model: emptyModel);
- underlyingViews[i++] = underlyingView;
- selectorPanel.addOrReplace(underlyingView);
- }
-
- // hide any unused placeholders
- while(i<MAX_NUM_UNDERLYING_VIEWS) {
- String underlyingId = underlyingIdPrefix + "-" + i;
- permanentlyHide(underlyingId);
- i++;
- }
-
- // selector
- if (componentFactories.size() <= 1) {
- permanentlyHide(ID_VIEWS);
- } else {
- final Model<ComponentFactory> componentFactoryModel = new Model<>();
-
- selectorPanel.selectedComponentFactory = componentFactories.get(selected);
- componentFactoryModel.setObject(selectorPanel.selectedComponentFactory);
-
- final WebMarkupContainer views = new WebMarkupContainer(ID_VIEWS);
-
- final Label viewButtonTitle = new Label(ID_VIEW_BUTTON_TITLE, "Hidden");
- views.addOrReplace(viewButtonTitle);
-
- final Label viewButtonIcon = new Label(ID_VIEW_BUTTON_ICON, "");
- views.addOrReplace(viewButtonIcon);
-
- final WebMarkupContainer container = new WebMarkupContainer(ID_VIEW_LIST);
-
- views.addOrReplace(container);
- views.setOutputMarkupId(true);
-
- this.setOutputMarkupId(true);
-
- final ListView<ComponentFactory> listView = new ListView<ComponentFactory>(ID_VIEW_ITEM, componentFactories) {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- protected void populateItem(ListItem<ComponentFactory> item) {
-
- final int underlyingViewNum = item.getIndex();
-
- final ComponentFactory componentFactory = item.getModelObject();
- final AbstractLink link = new AjaxLink<Void>(ID_VIEW_LINK) {
- private static final long serialVersionUID = 1L;
- @Override
- public void onClick(AjaxRequestTarget target) {
- LinksSelectorPanelAbstract<T> linksSelectorPanel = LinksSelectorPanelAbstract.this;
- linksSelectorPanel.setViewHintAndBroadcast(underlyingViewNum, target);
-
- final T dummyModel = dummyOf(model);
- for(int i=0; i<MAX_NUM_UNDERLYING_VIEWS; i++) {
- final Component component = underlyingViews[i];
- if(component == null) {
- continue;
- }
- final boolean isSelected = i == underlyingViewNum;
- applyCssVisibility(component, isSelected);
- component.setDefaultModel(isSelected? model: dummyModel);
- }
-
- selectorPanel.selectedComponentFactory = componentFactory;
- selectorPanel.selectedComponent = underlyingViews[underlyingViewNum];
- selectorPanel.onSelect(target);
- target.add(selectorPanel, views);
- }
-
- @Override
- protected void onComponentTag(ComponentTag tag) {
- super.onComponentTag(tag);
- Buttons.fixDisabledState(this, tag);
- }
- };
-
- IModel<String> title = nameFor(componentFactory);
- Label viewItemTitleLabel = new Label(ID_VIEW_ITEM_TITLE, title);
- link.add(viewItemTitleLabel);
-
- Label viewItemIcon = new Label(ID_VIEW_ITEM_ICON, "");
- link.add(viewItemIcon);
-
- boolean isEnabled = componentFactory != selectorPanel.selectedComponentFactory;
- if (!isEnabled) {
- viewButtonTitle.setDefaultModel(title);
- IModel<String> cssClass = cssClassFor(componentFactory, viewButtonIcon);
- viewButtonIcon.add(AttributeModifier.replace("class", "ViewLinkItem " + cssClass.getObject()));
- link.setVisible(false);
- } else {
- IModel<String> cssClass = cssClassFor(componentFactory, viewItemIcon);
- viewItemIcon.add(new CssClassAppender(cssClass));
- }
-
- item.add(link);
- }
-
- private IModel<String> cssClassFor(final ComponentFactory componentFactory, Label viewIcon) {
- IModel<String> cssClass = null;
- if (componentFactory instanceof CollectionContentsAsFactory) {
- CollectionContentsAsFactory collectionContentsAsFactory = (CollectionContentsAsFactory) componentFactory;
- cssClass = collectionContentsAsFactory.getCssClass();
- viewIcon.setDefaultModelObject("");
- viewIcon.setEscapeModelStrings(true);
- }
- if (cssClass == null) {
- String name = componentFactory.getName();
- cssClass = Model.of(StringExtensions.asLowerDashed(name));
- // Small hack: if there is no specific CSS class then we assume that background-image is used
- // the span.ViewItemLink should have some content to show it
- // FIX: find a way to do this with CSS (width and height don't seems to help)
- viewIcon.setDefaultModelObject("     ");
- viewIcon.setEscapeModelStrings(false);
- }
- return cssClass;
- }
-
- private IModel<String> nameFor(final ComponentFactory componentFactory) {
- IModel<String> name = null;
- if (componentFactory instanceof CollectionContentsAsFactory) {
- CollectionContentsAsFactory collectionContentsAsFactory = (CollectionContentsAsFactory) componentFactory;
- name = collectionContentsAsFactory.getTitleLabel();
- }
- if (name == null) {
- name = Model.of(componentFactory.getName());
- }
- return name;
- }
- };
- container.add(listView);
- addOrReplace(views);
- }
-
- for(i=0; i<MAX_NUM_UNDERLYING_VIEWS; i++) {
- Component component = underlyingViews[i];
- if(component != null) {
- if(i != selected) {
- component.add(new CssClassAppender(INVISIBLE_CLASS));
- } else {
- selectedComponent = component;
- }
- }
- }
- }
-
-
-
- protected void setViewHintAndBroadcast(int viewNum, AjaxRequestTarget target) {
- final UiHintContainer uiHintContainer = getUiHintContainer();
- if(uiHintContainer == null) {
- return;
- }
- uiHintContainer.setHint(LinksSelectorPanelAbstract.this, UIHINT_VIEW, ""+viewNum);
- send(getPage(), Broadcast.EXACT, new IsisUiHintEvent(uiHintContainer, target));
- }
-
- /**
- * Overrideable hook.
- */
- protected void onSelect(AjaxRequestTarget target) {
- }
-
- /**
- * Ask for a dummy (empty) {@link Model} to pass into those components that are rendered but will be
- * made invisible using CSS styling.
- */
- protected abstract T dummyOf(T model);
-
- protected static void applyCssVisibility(final Component component, final boolean visible) {
- if(component == null) {
- return;
- }
- AttributeModifier modifier = visible ? new CssClassRemover(INVISIBLE_CLASS) : new CssClassAppender(INVISIBLE_CLASS);
- component.add(modifier);
- }
-
- protected int honourViewHintElseDefault(final List<ComponentFactory> componentFactories, final IModel<?> model) {
- // honour hints ...
- final UiHintContainer hintContainer = getUiHintContainer();
- if(hintContainer != null) {
- String viewStr = hintContainer.getHint(this, UIHINT_VIEW);
- if(viewStr != null) {
- try {
- int view = Integer.parseInt(viewStr);
- if(view >= 0 && view < componentFactories.size()) {
- return view;
- }
- } catch(NumberFormatException ex) {
- // ignore
- }
- }
- }
-
- // ... else default
- int initialFactory = determineInitialFactory(componentFactories, model);
- if(hintContainer != null) {
- hintContainer.setHint(this, UIHINT_VIEW, ""+initialFactory);
- // don't broadcast (no AjaxRequestTarget, still configuring initial setup)
- }
- return initialFactory;
- }
-
-
- protected abstract int determineInitialFactory(final List<ComponentFactory> componentFactories, final IModel<?> model);
-
- private List<ComponentFactory> findOtherComponentFactories(final T model, final ComponentFactory ignoreFactory) {
- final List<ComponentFactory> componentFactories = getComponentFactoryRegistry().findComponentFactories(componentType, model);
- ArrayList<ComponentFactory> otherFactories = Lists.newArrayList(Collections2.filter(componentFactories, new Predicate<ComponentFactory>() {
- @Override
- public boolean apply(final ComponentFactory input) {
- return input != ignoreFactory;
- }
- }));
- return ordered(otherFactories);
- }
-
- protected List<ComponentFactory> ordered(List<ComponentFactory> otherFactories) {
- return otherFactories;
- }
-
-
- @Override
- public void renderHead(final IHeaderResponse response) {
- super.renderHead(response);
- PanelUtil.renderHead(response, LinksSelectorPanelAbstract.class);
- }
-
-
-}
[03/23] isis git commit: ISIS-537 Use .input-sm for the select2 input
fields.
Posted by da...@apache.org.
ISIS-537 Use .input-sm for the select2 input fields.
https://trello.com/c/f60AAQps/116-tiny-adjustment-to-spacing-on-select2-drop-downs
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/8a2c825c
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/8a2c825c
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/8a2c825c
Branch: refs/heads/ISIS-939
Commit: 8a2c825c3375ca305411a3930aa5091e6b1a1564
Parents: d905d38
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Fri Nov 7 13:25:00 2014 +0200
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Fri Nov 7 13:25:00 2014 +0200
----------------------------------------------------------------------
.../components/widgets/valuechoices/ValueChoicesSelect2Panel.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/8a2c825c/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/valuechoices/ValueChoicesSelect2Panel.html
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/valuechoices/ValueChoicesSelect2Panel.html b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/valuechoices/ValueChoicesSelect2Panel.html
index 2dcef71..6722fb2 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/valuechoices/ValueChoicesSelect2Panel.html
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/valuechoices/ValueChoicesSelect2Panel.html
@@ -29,7 +29,7 @@
<label wicket:id="scalarName" class="scalarName control-label">[Label text]</label>
<div class="scalarValueWrapper">
<div class="choicesPlaceholder">
- <input wicket:id="scalarValue" type="hidden" class="choices form-control select2-remote" style="width: 99.8%;"/>
+ <input wicket:id="scalarValue" type="hidden" class="choices form-control input-sm select2-remote" style="width: 99.8%;"/>
</div>
<span wicket:id="feedback" class="help-block"></span>
<span wicket:id="additionalLinks"></span>
[18/23] isis git commit: ISIS-537: selector drop-down now moved to
EntityCollectionsPanel (ie into the panel header).
Posted by da...@apache.org.
ISIS-537: selector drop-down now moved to EntityCollectionsPanel (ie into the panel header).
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/2909e644
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/2909e644
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/2909e644
Branch: refs/heads/ISIS-939
Commit: 2909e644d354ed50d552aa1227fc3d7cb693cb86
Parents: f00d01f
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Mon Nov 10 07:37:03 2014 +0000
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Mon Nov 10 10:21:46 2014 +0000
----------------------------------------------------------------------
.../components/collection/CollectionPanel.java | 17 ++++-
.../dropdown/HasSelectorDropdownPanel.java | 23 +++++++
.../CollectionContentsLinksSelectorPanel.html | 1 -
.../CollectionContentsLinksSelectorPanel.java | 66 +++++++++++++-------
.../collections/EntityCollectionsPanel.html | 3 +
.../collections/EntityCollectionsPanel.java | 38 ++++++++++-
6 files changed, 123 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/2909e644/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/CollectionPanel.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/CollectionPanel.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/CollectionPanel.java
index ec68145..0b10d9c 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/CollectionPanel.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/CollectionPanel.java
@@ -38,6 +38,8 @@ import org.apache.isis.viewer.wicket.model.models.EntityModel;
import org.apache.isis.viewer.wicket.ui.ComponentType;
import org.apache.isis.viewer.wicket.ui.components.actionprompt.ActionPromptModalWindow;
import org.apache.isis.viewer.wicket.ui.components.additionallinks.EntityActionUtil;
+import org.apache.isis.viewer.wicket.ui.components.collectioncontents.selector.dropdown.CollectionContentsSelectorDropdownPanel;
+import org.apache.isis.viewer.wicket.ui.components.collectioncontents.selector.dropdown.HasSelectorDropdownPanel;
import org.apache.isis.viewer.wicket.ui.components.scalars.ScalarPanelAbstract;
import org.apache.isis.viewer.wicket.ui.panels.PanelAbstract;
@@ -45,7 +47,7 @@ import org.apache.isis.viewer.wicket.ui.panels.PanelAbstract;
* Panel for rendering entity collection; analogous to (any concrete subclass
* of) {@link ScalarPanelAbstract}.
*/
-public class CollectionPanel extends PanelAbstract<EntityCollectionModel> implements ActionPromptProvider {
+public class CollectionPanel extends PanelAbstract<EntityCollectionModel> implements ActionPromptProvider, HasSelectorDropdownPanel {
private static final long serialVersionUID = 1L;
@@ -148,4 +150,17 @@ public class CollectionPanel extends PanelAbstract<EntityCollectionModel> implem
}
+ //region > SelectorDropdownPanel (impl)
+
+ private CollectionContentsSelectorDropdownPanel selectorDropdownPanel;
+
+ @Override
+ public CollectionContentsSelectorDropdownPanel getSelectorDropdownPanel() {
+ return selectorDropdownPanel;
+ }
+ public void setSelectorDropdownPanel(CollectionContentsSelectorDropdownPanel selectorDropdownPanel) {
+ this.selectorDropdownPanel = selectorDropdownPanel;
+ }
+ //endregion
+
}
http://git-wip-us.apache.org/repos/asf/isis/blob/2909e644/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/HasSelectorDropdownPanel.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/HasSelectorDropdownPanel.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/HasSelectorDropdownPanel.java
new file mode 100644
index 0000000..9011edf
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/HasSelectorDropdownPanel.java
@@ -0,0 +1,23 @@
+/*
+ * 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.viewer.wicket.ui.components.collectioncontents.selector.dropdown;
+
+public interface HasSelectorDropdownPanel {
+ CollectionContentsSelectorDropdownPanel getSelectorDropdownPanel();
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/2909e644/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.html
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.html b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.html
index 853a400..0a6d242 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.html
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.html
@@ -22,7 +22,6 @@
<body>
<wicket:panel>
<div class="linksSelectorPanel">
- <span wicket:id="selectorDropdown"/>
<div class="views">
<div wicket:id="collectionContents-0" class="collectionContentsLinksSelectorPanel collectionContentsComponentType"></div>
http://git-wip-us.apache.org/repos/asf/isis/blob/2909e644/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java
index 627adb5..42616ff 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java
@@ -25,7 +25,6 @@ import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.event.IEvent;
import org.apache.wicket.markup.head.IHeaderResponse;
-import org.apache.wicket.model.Model;
import org.apache.isis.viewer.wicket.model.hints.IsisEnvelopeEvent;
import org.apache.isis.viewer.wicket.model.hints.IsisUiHintEvent;
import org.apache.isis.viewer.wicket.model.hints.UiHintContainer;
@@ -36,6 +35,7 @@ import org.apache.isis.viewer.wicket.ui.ComponentType;
import org.apache.isis.viewer.wicket.ui.components.collection.CollectionCountProvider;
import org.apache.isis.viewer.wicket.ui.components.collectioncontents.selector.dropdown.CollectionContentsSelectorDropdownPanel;
import org.apache.isis.viewer.wicket.ui.components.collectioncontents.selector.dropdown.CollectionContentsSelectorHelper;
+import org.apache.isis.viewer.wicket.ui.components.collectioncontents.selector.dropdown.HasSelectorDropdownPanel;
import org.apache.isis.viewer.wicket.ui.panels.PanelAbstract;
import org.apache.isis.viewer.wicket.ui.panels.PanelUtil;
import org.apache.isis.viewer.wicket.ui.util.CssClassAppender;
@@ -54,7 +54,7 @@ public class CollectionContentsLinksSelectorPanel
private static final String INVISIBLE_CLASS = "link-selector-panel-invisible";
private static final int MAX_NUM_UNDERLYING_VIEWS = 10;
- private static final String ID_SELECTOR_DROPDOWN = "selectorDropdown";
+// private static final String ID_SELECTOR_DROPDOWN = "selectorDropdown";
private static final String UIHINT_VIEW = "view";
@@ -65,10 +65,9 @@ public class CollectionContentsLinksSelectorPanel
private final CollectionContentsSelectorHelper selectorHelper;
private ComponentFactory selectedComponentFactory;
- protected Component selectedComponent;
+ private Component selectedComponent;
private Component[] underlyingViews;
- private List<ComponentFactory> componentFactories;
private CollectionContentsSelectorDropdownPanel selectorDropdownPanel;
public CollectionContentsLinksSelectorPanel(
@@ -81,7 +80,6 @@ public class CollectionContentsLinksSelectorPanel
this.componentType = ignoreFactory.getComponentType();
selectorHelper = new CollectionContentsSelectorHelper(model, getComponentFactoryRegistry(), ignoreFactory);
- componentFactories = selectorHelper.findOtherComponentFactories();
}
/**
@@ -96,7 +94,8 @@ public class CollectionContentsLinksSelectorPanel
private void addUnderlyingViews() {
final EntityCollectionModel model = getModel();
- final int selected = selectorHelper.honourViewHintElseDefault(selectorDropdownPanel);
+ final int selected = selectorHelper.honourViewHintElseDefault(getSelectorDropdownPanel());
+ final List<ComponentFactory> componentFactories = selectorHelper.findOtherComponentFactories();
// create all, hide the one not selected
underlyingViews = new Component[MAX_NUM_UNDERLYING_VIEWS];
@@ -118,19 +117,20 @@ public class CollectionContentsLinksSelectorPanel
}
// selector
- if (componentFactories.size() <= 1) {
- permanentlyHide(ID_SELECTOR_DROPDOWN);
- } else {
- final Model<ComponentFactory> componentFactoryModel = new Model<>();
-
- this.selectedComponentFactory = componentFactories.get(selected);
- componentFactoryModel.setObject(this.selectedComponentFactory);
-
- selectorDropdownPanel = new CollectionContentsSelectorDropdownPanel(ID_SELECTOR_DROPDOWN, getModel(), ignoreFactory);
-
- this.setOutputMarkupId(true);
- addOrReplace(selectorDropdownPanel);
- }
+// if (componentFactories.size() <= 1) {
+// permanentlyHide(ID_SELECTOR_DROPDOWN);
+// } else {
+// final Model<ComponentFactory> componentFactoryModel = new Model<>();
+//
+// this.selectedComponentFactory = componentFactories.get(selected);
+// componentFactoryModel.setObject(this.selectedComponentFactory);
+//
+// selectorDropdownPanel = new CollectionContentsSelectorDropdownPanel(ID_SELECTOR_DROPDOWN, getModel(), ignoreFactory);
+//
+// addOrReplace(selectorDropdownPanel);
+// }
+
+ this.setOutputMarkupId(true);
for(i=0; i<MAX_NUM_UNDERLYING_VIEWS; i++) {
Component component = underlyingViews[i];
@@ -155,7 +155,10 @@ public class CollectionContentsLinksSelectorPanel
final UiHintContainer uiHintContainer = uiHintEvent.getUiHintContainer();
int underlyingViewNum = 0;
- String viewStr = uiHintContainer.getHint(this.selectorDropdownPanel, UIHINT_VIEW);
+ String viewStr = uiHintContainer.getHint(this.getSelectorDropdownPanel(), UIHINT_VIEW);
+
+ List<ComponentFactory> componentFactories = selectorHelper.findOtherComponentFactories();
+
if(viewStr != null) {
try {
int view = Integer.parseInt(viewStr);
@@ -184,7 +187,7 @@ public class CollectionContentsLinksSelectorPanel
final AjaxRequestTarget target = uiHintEvent.getTarget();
if(target != null) {
- target.add(this, selectorDropdownPanel);
+ target.add(this, getSelectorDropdownPanel());
}
}
@@ -216,4 +219,25 @@ public class CollectionContentsLinksSelectorPanel
}
}
+ /**
+ * Searches up the component hierarchy looking for a parent that implements
+ * {@link org.apache.isis.viewer.wicket.ui.components.collectioncontents.selector.dropdown.HasSelectorDropdownPanel}.
+ * @return
+ */
+ private CollectionContentsSelectorDropdownPanel getSelectorDropdownPanel() {
+ Component component = this;
+ while(component != null) {
+ if(component instanceof HasSelectorDropdownPanel) {
+ final CollectionContentsSelectorDropdownPanel selectorDropdownPanel1 = ((HasSelectorDropdownPanel) component).getSelectorDropdownPanel();
+ if(selectorDropdownPanel1 == null) {
+ throw new IllegalStateException("Found parent that implements HasSelectorDropdownPanel, but no SelectorDropdownPanel available (is null)");
+
+ }
+ return selectorDropdownPanel1;
+ }
+ component = component.getParent();
+ }
+ throw new IllegalStateException("Could not locate parent that implements HasSelectorDropdownPanel");
+ }
+
}
http://git-wip-us.apache.org/repos/asf/isis/blob/2909e644/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/collections/EntityCollectionsPanel.html
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/collections/EntityCollectionsPanel.html b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/collections/EntityCollectionsPanel.html
index 216d9c9..106afa7 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/collections/EntityCollectionsPanel.html
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/collections/EntityCollectionsPanel.html
@@ -39,6 +39,9 @@
<div class="btn-group">
<div wicket:id="additionalLinks"></div>
</div>
+ <div class="btn-group">
+ <span wicket:id="selectorDropdown"/>
+ </div>
<!--
<div class="btn-group">
http://git-wip-us.apache.org/repos/asf/isis/blob/2909e644/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/collections/EntityCollectionsPanel.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/collections/EntityCollectionsPanel.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/collections/EntityCollectionsPanel.java
index 55ad54b..1a8649c 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/collections/EntityCollectionsPanel.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/collections/EntityCollectionsPanel.java
@@ -20,9 +20,11 @@
package org.apache.isis.viewer.wicket.ui.components.entity.collections;
import java.util.List;
+import org.apache.wicket.Component;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.repeater.RepeatingView;
+import org.apache.wicket.model.Model;
import org.apache.isis.applib.annotation.Where;
import org.apache.isis.applib.filter.Filter;
import org.apache.isis.applib.filter.Filters;
@@ -35,8 +37,12 @@ import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
import org.apache.isis.viewer.wicket.model.links.LinkAndLabel;
import org.apache.isis.viewer.wicket.model.models.EntityCollectionModel;
import org.apache.isis.viewer.wicket.model.models.EntityModel;
+import org.apache.isis.viewer.wicket.ui.ComponentFactory;
import org.apache.isis.viewer.wicket.ui.components.additionallinks.AdditionalLinksPanel;
import org.apache.isis.viewer.wicket.ui.components.collection.CollectionPanel;
+import org.apache.isis.viewer.wicket.ui.components.collectioncontents.selector.dropdown.CollectionContentsSelectorDropdownPanel;
+import org.apache.isis.viewer.wicket.ui.components.collectioncontents.selector.dropdown.CollectionContentsSelectorHelper;
+import org.apache.isis.viewer.wicket.ui.components.collectioncontents.selector.links.CollectionContentsLinksSelectorPanelFactory;
import org.apache.isis.viewer.wicket.ui.components.widgets.containers.UiHintPathSignificantWebMarkupContainer;
import org.apache.isis.viewer.wicket.ui.panels.PanelAbstract;
import org.apache.isis.viewer.wicket.ui.util.CssClassAppender;
@@ -57,11 +63,15 @@ public class EntityCollectionsPanel extends PanelAbstract<EntityModel> {
private static final String ID_ADDITIONAL_LINKS = "additionalLinks";
- private Label labelComponent;
+ private static final String ID_SELECTOR_DROPDOWN = "selectorDropdown";
+ private ComponentFactory selectedComponentFactory;
+ private Component selectedComponent;
+
public EntityCollectionsPanel(final String id, final EntityModel entityModel) {
super(id, entityModel);
+
buildGui();
}
@@ -114,13 +124,37 @@ public class EntityCollectionsPanel extends PanelAbstract<EntityModel> {
final CollectionPanel collectionPanel = new CollectionPanel(ID_COLLECTION, entityModel, otma);
fieldset.addOrReplace(collectionPanel);
- labelComponent = collectionPanel.createLabel(ID_COLLECTION_NAME, association.getName());
+ Label labelComponent = collectionPanel.createLabel(ID_COLLECTION_NAME, association.getName());
+
fieldset.add(labelComponent);
final EntityCollectionModel entityCollectionModel = collectionPanel.getModel();
List<LinkAndLabel> links = entityCollectionModel.getLinks();
AdditionalLinksPanel additionalLinks = new AdditionalLinksPanel(ID_ADDITIONAL_LINKS, links);
fieldset.addOrReplace(additionalLinks);
+
+ CollectionContentsSelectorHelper selectorHelper = new CollectionContentsSelectorHelper(entityCollectionModel, getComponentFactoryRegistry(), new CollectionContentsLinksSelectorPanelFactory());
+
+ final List<ComponentFactory> componentFactories = selectorHelper.findOtherComponentFactories();
+
+ if (componentFactories.size() <= 1) {
+ permanentlyHide(ID_SELECTOR_DROPDOWN);
+ } else {
+ CollectionContentsSelectorDropdownPanel selectorDropdownPanel;
+ selectorDropdownPanel = new CollectionContentsSelectorDropdownPanel(ID_SELECTOR_DROPDOWN, entityCollectionModel, new CollectionContentsLinksSelectorPanelFactory());
+
+ final Model<ComponentFactory> componentFactoryModel = new Model<>();
+
+ final int selected = selectorHelper.honourViewHintElseDefault(selectorDropdownPanel);
+ this.selectedComponentFactory = componentFactories.get(selected);
+ componentFactoryModel.setObject(this.selectedComponentFactory);
+
+ this.setOutputMarkupId(true);
+ fieldset.addOrReplace(selectorDropdownPanel);
+
+ collectionPanel.setSelectorDropdownPanel(selectorDropdownPanel);
+ }
+
}
private List<ObjectAssociation> visibleCollections(final ObjectAdapter adapter, final ObjectSpecification noSpec) {
[21/23] isis git commit: ISIS-537: tidy up of (entity) collections
panel;
standalone collections panel no longer failing (but still need to sort out CSS
and bulk actions)
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/isis/blob/92ffe2d2/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/HasSelectorDropdownPanel.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/HasSelectorDropdownPanel.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/HasSelectorDropdownPanel.java
deleted file mode 100644
index 9011edf..0000000
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/HasSelectorDropdownPanel.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * 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.viewer.wicket.ui.components.collectioncontents.selector.dropdown;
-
-public interface HasSelectorDropdownPanel {
- CollectionContentsSelectorDropdownPanel getSelectorDropdownPanel();
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/92ffe2d2/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.css
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.css b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.css
deleted file mode 100644
index 8c3902e..0000000
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.css
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.
- */
-.linksSelectorPanel .viewLinks {
- float:right;
- display:block;
-}
-
-.linksSelectorPanel ul.dropdown-menu {
- min-width: 0;
-}
-
-.linksSelectorPanel ul.dropdown-menu li.viewItem {
- min-width: 0;
-}
-
-.linksSelectorPanel ul.viewList li.viewItem:first-child span {
- border-radius:4px 0 0 4px;
- -moz-border-radius:4px 0 0 4px;
- -webkit-border-radius:4px 0 0 4px;
-}
-
-.linksSelectorPanel ul.viewList li.viewItem:last-child span {
- border-radius:0 4px 4px 0;
- -moz-border-radius:0 4px 4px 0;
- -webkit-border-radius:0 4px 4px 0;
-}
-
-
-.linksSelectorPanel .link-selector-panel-invisible {
- display:none;
-}
-
-.linksSelectorPanel .list-inline {
- margin-left: 0;
-}
-
-.linksSelectorPanel .list-inline li {
- padding-left: 0;
-}
-
-
-.collectionContentsLinksSelectorPanel select {
- margin-bottom: 1em;
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/92ffe2d2/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.html
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.html b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.html
deleted file mode 100644
index 0a6d242..0000000
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.html
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns:wicket="http://wicket.apache.org">
-<body>
-<wicket:panel>
- <div class="linksSelectorPanel">
-
- <div class="views">
- <div wicket:id="collectionContents-0" class="collectionContentsLinksSelectorPanel collectionContentsComponentType"></div>
- <div wicket:id="collectionContents-1" class="collectionContentsLinksSelectorPanel collectionContentsComponentType"></div>
- <div wicket:id="collectionContents-2" class="collectionContentsLinksSelectorPanel collectionContentsComponentType"></div>
- <div wicket:id="collectionContents-3" class="collectionContentsLinksSelectorPanel collectionContentsComponentType"></div>
- <div wicket:id="collectionContents-4" class="collectionContentsLinksSelectorPanel collectionContentsComponentType"></div>
- <div wicket:id="collectionContents-5" class="collectionContentsLinksSelectorPanel collectionContentsComponentType"></div>
- <div wicket:id="collectionContents-6" class="collectionContentsLinksSelectorPanel collectionContentsComponentType"></div>
- <div wicket:id="collectionContents-7" class="collectionContentsLinksSelectorPanel collectionContentsComponentType"></div>
- <div wicket:id="collectionContents-8" class="collectionContentsLinksSelectorPanel collectionContentsComponentType"></div>
- <div wicket:id="collectionContents-9" class="collectionContentsLinksSelectorPanel collectionContentsComponentType"></div>
- </div>
- </div>
-</wicket:panel>
-</body>
-</html>
http://git-wip-us.apache.org/repos/asf/isis/blob/92ffe2d2/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java
deleted file mode 100644
index 42616ff..0000000
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- * 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.viewer.wicket.ui.components.collectioncontents.selector.links;
-
-import java.util.List;
-import org.apache.wicket.AttributeModifier;
-import org.apache.wicket.Component;
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.event.IEvent;
-import org.apache.wicket.markup.head.IHeaderResponse;
-import org.apache.isis.viewer.wicket.model.hints.IsisEnvelopeEvent;
-import org.apache.isis.viewer.wicket.model.hints.IsisUiHintEvent;
-import org.apache.isis.viewer.wicket.model.hints.UiHintContainer;
-import org.apache.isis.viewer.wicket.model.hints.UiHintPathSignificant;
-import org.apache.isis.viewer.wicket.model.models.EntityCollectionModel;
-import org.apache.isis.viewer.wicket.ui.ComponentFactory;
-import org.apache.isis.viewer.wicket.ui.ComponentType;
-import org.apache.isis.viewer.wicket.ui.components.collection.CollectionCountProvider;
-import org.apache.isis.viewer.wicket.ui.components.collectioncontents.selector.dropdown.CollectionContentsSelectorDropdownPanel;
-import org.apache.isis.viewer.wicket.ui.components.collectioncontents.selector.dropdown.CollectionContentsSelectorHelper;
-import org.apache.isis.viewer.wicket.ui.components.collectioncontents.selector.dropdown.HasSelectorDropdownPanel;
-import org.apache.isis.viewer.wicket.ui.panels.PanelAbstract;
-import org.apache.isis.viewer.wicket.ui.panels.PanelUtil;
-import org.apache.isis.viewer.wicket.ui.util.CssClassAppender;
-import org.apache.isis.viewer.wicket.ui.util.CssClassRemover;
-
-/**
- * Provides a list of links for selecting other views that support
- * {@link ComponentType#COLLECTION_CONTENTS} with a backing
- * {@link EntityCollectionModel}.
- */
-public class CollectionContentsLinksSelectorPanel
- extends PanelAbstract<EntityCollectionModel> implements UiHintPathSignificant, CollectionCountProvider {
-
- private static final long serialVersionUID = 1L;
-
- private static final String INVISIBLE_CLASS = "link-selector-panel-invisible";
- private static final int MAX_NUM_UNDERLYING_VIEWS = 10;
-
-// private static final String ID_SELECTOR_DROPDOWN = "selectorDropdown";
-
- private static final String UIHINT_VIEW = "view";
-
- private final ComponentFactory ignoreFactory;
-
- private final ComponentType componentType;
- private final String underlyingIdPrefix;
- private final CollectionContentsSelectorHelper selectorHelper;
-
- private ComponentFactory selectedComponentFactory;
- private Component selectedComponent;
-
- private Component[] underlyingViews;
- private CollectionContentsSelectorDropdownPanel selectorDropdownPanel;
-
- public CollectionContentsLinksSelectorPanel(
- final String id,
- final EntityCollectionModel model,
- final ComponentFactory ignoreFactory) {
- super(id, model);
- this.ignoreFactory = ignoreFactory;
- this.underlyingIdPrefix = ComponentType.COLLECTION_CONTENTS.toString();
- this.componentType = ignoreFactory.getComponentType();
- selectorHelper = new CollectionContentsSelectorHelper(model, getComponentFactoryRegistry(), ignoreFactory);
-
- }
-
- /**
- * Build UI only after added to parent.
- */
- public void onInitialize() {
- super.onInitialize();
- addUnderlyingViews();
- }
-
-
- private void addUnderlyingViews() {
- final EntityCollectionModel model = getModel();
-
- final int selected = selectorHelper.honourViewHintElseDefault(getSelectorDropdownPanel());
- final List<ComponentFactory> componentFactories = selectorHelper.findOtherComponentFactories();
-
- // create all, hide the one not selected
- underlyingViews = new Component[MAX_NUM_UNDERLYING_VIEWS];
- int i = 0;
- final EntityCollectionModel emptyModel = model.asDummy();
- for (ComponentFactory componentFactory : componentFactories) {
- final String underlyingId = underlyingIdPrefix + "-" + i;
-
- Component underlyingView = componentFactory.createComponent(underlyingId,i==selected? model: emptyModel);
- underlyingViews[i++] = underlyingView;
- this.addOrReplace(underlyingView);
- }
-
- // hide any unused placeholders
- while(i<MAX_NUM_UNDERLYING_VIEWS) {
- String underlyingId = underlyingIdPrefix + "-" + i;
- permanentlyHide(underlyingId);
- i++;
- }
-
- // selector
-// if (componentFactories.size() <= 1) {
-// permanentlyHide(ID_SELECTOR_DROPDOWN);
-// } else {
-// final Model<ComponentFactory> componentFactoryModel = new Model<>();
-//
-// this.selectedComponentFactory = componentFactories.get(selected);
-// componentFactoryModel.setObject(this.selectedComponentFactory);
-//
-// selectorDropdownPanel = new CollectionContentsSelectorDropdownPanel(ID_SELECTOR_DROPDOWN, getModel(), ignoreFactory);
-//
-// addOrReplace(selectorDropdownPanel);
-// }
-
- this.setOutputMarkupId(true);
-
- for(i=0; i<MAX_NUM_UNDERLYING_VIEWS; i++) {
- Component component = underlyingViews[i];
- if(component != null) {
- if(i != selected) {
- component.add(new CssClassAppender(INVISIBLE_CLASS));
- } else {
- selectedComponent = component;
- }
- }
- }
- }
-
- @Override
- public void onEvent(IEvent<?> event) {
- super.onEvent(event);
-
- final IsisUiHintEvent uiHintEvent = IsisEnvelopeEvent.openLetter(event, IsisUiHintEvent.class);
- if(uiHintEvent == null) {
- return;
- }
- final UiHintContainer uiHintContainer = uiHintEvent.getUiHintContainer();
-
- int underlyingViewNum = 0;
- String viewStr = uiHintContainer.getHint(this.getSelectorDropdownPanel(), UIHINT_VIEW);
-
- List<ComponentFactory> componentFactories = selectorHelper.findOtherComponentFactories();
-
- if(viewStr != null) {
- try {
- int view = Integer.parseInt(viewStr);
- if(view >= 0 && view < componentFactories.size()) {
- underlyingViewNum = view;
- }
- } catch(NumberFormatException ex) {
- // ignore
- }
- }
-
- final EntityCollectionModel dummyModel = getModel().asDummy();
- for(int i=0; i<MAX_NUM_UNDERLYING_VIEWS; i++) {
- final Component component = underlyingViews[i];
- if(component == null) {
- continue;
- }
- final boolean isSelected = i == underlyingViewNum;
- applyCssVisibility(component, isSelected);
- component.setDefaultModel(isSelected? getModel(): dummyModel);
- }
-
- this.selectedComponentFactory = ignoreFactory;
- this.selectedComponent = underlyingViews[underlyingViewNum];
-
-
- final AjaxRequestTarget target = uiHintEvent.getTarget();
- if(target != null) {
- target.add(this, getSelectorDropdownPanel());
- }
-
- }
-
-
- protected static void applyCssVisibility(final Component component, final boolean visible) {
- if(component == null) {
- return;
- }
- AttributeModifier modifier = visible ? new CssClassRemover(INVISIBLE_CLASS) : new CssClassAppender(INVISIBLE_CLASS);
- component.add(modifier);
- }
-
- @Override
- public void renderHead(final IHeaderResponse response) {
- super.renderHead(response);
- PanelUtil.renderHead(response, CollectionContentsLinksSelectorPanel.class);
- }
-
-
-
- @Override
- public Integer getCount() {
- if(selectedComponent instanceof CollectionCountProvider) {
- final CollectionCountProvider collectionCountProvider = (CollectionCountProvider) selectedComponent;
- return collectionCountProvider.getCount();
- } else {
- return null;
- }
- }
-
- /**
- * Searches up the component hierarchy looking for a parent that implements
- * {@link org.apache.isis.viewer.wicket.ui.components.collectioncontents.selector.dropdown.HasSelectorDropdownPanel}.
- * @return
- */
- private CollectionContentsSelectorDropdownPanel getSelectorDropdownPanel() {
- Component component = this;
- while(component != null) {
- if(component instanceof HasSelectorDropdownPanel) {
- final CollectionContentsSelectorDropdownPanel selectorDropdownPanel1 = ((HasSelectorDropdownPanel) component).getSelectorDropdownPanel();
- if(selectorDropdownPanel1 == null) {
- throw new IllegalStateException("Found parent that implements HasSelectorDropdownPanel, but no SelectorDropdownPanel available (is null)");
-
- }
- return selectorDropdownPanel1;
- }
- component = component.getParent();
- }
- throw new IllegalStateException("Could not locate parent that implements HasSelectorDropdownPanel");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/92ffe2d2/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanelFactory.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanelFactory.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanelFactory.java
deleted file mode 100644
index a93790e..0000000
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanelFactory.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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.viewer.wicket.ui.components.collectioncontents.selector.links;
-
-import org.apache.wicket.Component;
-import org.apache.wicket.model.IModel;
-
-import org.apache.isis.viewer.wicket.model.models.EntityCollectionModel;
-import org.apache.isis.viewer.wicket.ui.ComponentFactory;
-import org.apache.isis.viewer.wicket.ui.ComponentFactoryAbstract;
-import org.apache.isis.viewer.wicket.ui.ComponentType;
-
-/**
- * {@link ComponentFactory} for {@link CollectionContentsLinksSelectorPanel}.
- */
-public class CollectionContentsLinksSelectorPanelFactory extends ComponentFactoryAbstract {
-
- private static final long serialVersionUID = 1L;
-
- public CollectionContentsLinksSelectorPanelFactory() {
- super(ComponentType.COLLECTION_CONTENTS,
- CollectionContentsLinksSelectorPanel.class);
- }
-
- @Override
- public ApplicationAdvice appliesTo(final IModel<?> model) {
- return appliesIf(model instanceof EntityCollectionModel);
- }
-
- @Override
- public Component createComponent(final String id, final IModel<?> model) {
- final EntityCollectionModel collectionModel = (EntityCollectionModel) model;
- return new CollectionContentsLinksSelectorPanel(id, collectionModel, this);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/92ffe2d2/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/summary/CollectionContentsAsSummary.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/summary/CollectionContentsAsSummary.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/summary/CollectionContentsAsSummary.java
index 4d0bf49..32809e5 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/summary/CollectionContentsAsSummary.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/summary/CollectionContentsAsSummary.java
@@ -42,7 +42,7 @@ 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.ObjectAssociation;
import org.apache.isis.viewer.wicket.model.models.EntityCollectionModel;
-import org.apache.isis.viewer.wicket.ui.components.collection.CollectionCountProvider;
+import org.apache.isis.viewer.wicket.ui.components.collection.count.CollectionCountProvider;
import org.apache.isis.viewer.wicket.ui.panels.PanelAbstract;
import org.apache.isis.viewer.wicket.ui.panels.PanelUtil;
http://git-wip-us.apache.org/repos/asf/isis/blob/92ffe2d2/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/collections/EntityCollectionsPanel.html
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/collections/EntityCollectionsPanel.html b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/collections/EntityCollectionsPanel.html
index 106afa7..9d0ac51 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/collections/EntityCollectionsPanel.html
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/collections/EntityCollectionsPanel.html
@@ -28,14 +28,6 @@
<span wicket:id="collectionName" class="panel-title">[collection name]</span>
<div class="pull-right">
- <!--
- <div class="btn-group">
- <a href="#" class="btn btn-default btn-sm">## Lock</a>
- <a href="#" class="btn btn-default btn-sm">## Delete</a>
- <a href="#" class="btn btn-default btn-sm">## Move</a>
- </div>
- -->
-
<div class="btn-group">
<div wicket:id="additionalLinks"></div>
</div>
@@ -43,23 +35,9 @@
<span wicket:id="selectorDropdown"/>
</div>
- <!--
- <div class="btn-group">
- <ul xxwicket:id="viewList" class="dropdown-menu dropdown-menu-right" role="menu">
- <li xxwicket:id="viewItem" class="viewItem">
- <a href="#" xxwicket:id="viewLink">
- <span xxwicket:id="viewItemIcon" class="ViewLinkItem"></span> <span xxwicket:id="viewItemTitle" class="ViewLinkItemTitle">[link title]</span>
- </a>
- </li>
- </ul>
- </div>
- -->
-
</div>
</div>
-
-
<div wicket:id="collection" class="collection panel-body">
[collection]
</div>
http://git-wip-us.apache.org/repos/asf/isis/blob/92ffe2d2/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/collections/EntityCollectionsPanel.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/collections/EntityCollectionsPanel.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/collections/EntityCollectionsPanel.java
index 1a8649c..876177d 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/collections/EntityCollectionsPanel.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/collections/EntityCollectionsPanel.java
@@ -20,7 +20,6 @@
package org.apache.isis.viewer.wicket.ui.components.entity.collections;
import java.util.List;
-import org.apache.wicket.Component;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.repeater.RepeatingView;
@@ -40,9 +39,9 @@ import org.apache.isis.viewer.wicket.model.models.EntityModel;
import org.apache.isis.viewer.wicket.ui.ComponentFactory;
import org.apache.isis.viewer.wicket.ui.components.additionallinks.AdditionalLinksPanel;
import org.apache.isis.viewer.wicket.ui.components.collection.CollectionPanel;
-import org.apache.isis.viewer.wicket.ui.components.collectioncontents.selector.dropdown.CollectionContentsSelectorDropdownPanel;
-import org.apache.isis.viewer.wicket.ui.components.collectioncontents.selector.dropdown.CollectionContentsSelectorHelper;
-import org.apache.isis.viewer.wicket.ui.components.collectioncontents.selector.links.CollectionContentsLinksSelectorPanelFactory;
+import org.apache.isis.viewer.wicket.ui.components.collection.selector.CollectionSelectorHelper;
+import org.apache.isis.viewer.wicket.ui.components.collection.selector.CollectionSelectorPanel;
+import org.apache.isis.viewer.wicket.ui.components.collectioncontents.multiple.CollectionContentsMultipleViewsPanelFactory;
import org.apache.isis.viewer.wicket.ui.components.widgets.containers.UiHintPathSignificantWebMarkupContainer;
import org.apache.isis.viewer.wicket.ui.panels.PanelAbstract;
import org.apache.isis.viewer.wicket.ui.util.CssClassAppender;
@@ -62,13 +61,8 @@ public class EntityCollectionsPanel extends PanelAbstract<EntityModel> {
private static final String ID_COLLECTION = "collection";
private static final String ID_ADDITIONAL_LINKS = "additionalLinks";
-
private static final String ID_SELECTOR_DROPDOWN = "selectorDropdown";
-
- private ComponentFactory selectedComponentFactory;
- private Component selectedComponent;
-
public EntityCollectionsPanel(final String id, final EntityModel entityModel) {
super(id, entityModel);
@@ -130,24 +124,26 @@ public class EntityCollectionsPanel extends PanelAbstract<EntityModel> {
final EntityCollectionModel entityCollectionModel = collectionPanel.getModel();
List<LinkAndLabel> links = entityCollectionModel.getLinks();
+
AdditionalLinksPanel additionalLinks = new AdditionalLinksPanel(ID_ADDITIONAL_LINKS, links);
fieldset.addOrReplace(additionalLinks);
- CollectionContentsSelectorHelper selectorHelper = new CollectionContentsSelectorHelper(entityCollectionModel, getComponentFactoryRegistry(), new CollectionContentsLinksSelectorPanelFactory());
+ final CollectionSelectorHelper selectorHelper = new CollectionSelectorHelper(entityCollectionModel, getComponentFactoryRegistry(), new CollectionContentsMultipleViewsPanelFactory());
final List<ComponentFactory> componentFactories = selectorHelper.findOtherComponentFactories();
if (componentFactories.size() <= 1) {
permanentlyHide(ID_SELECTOR_DROPDOWN);
} else {
- CollectionContentsSelectorDropdownPanel selectorDropdownPanel;
- selectorDropdownPanel = new CollectionContentsSelectorDropdownPanel(ID_SELECTOR_DROPDOWN, entityCollectionModel, new CollectionContentsLinksSelectorPanelFactory());
+ CollectionSelectorPanel selectorDropdownPanel;
+ selectorDropdownPanel = new CollectionSelectorPanel(ID_SELECTOR_DROPDOWN, entityCollectionModel, new CollectionContentsMultipleViewsPanelFactory());
final Model<ComponentFactory> componentFactoryModel = new Model<>();
final int selected = selectorHelper.honourViewHintElseDefault(selectorDropdownPanel);
- this.selectedComponentFactory = componentFactories.get(selected);
- componentFactoryModel.setObject(this.selectedComponentFactory);
+
+ ComponentFactory selectedComponentFactory = componentFactories.get(selected);
+ componentFactoryModel.setObject(selectedComponentFactory);
this.setOutputMarkupId(true);
fieldset.addOrReplace(selectorDropdownPanel);
http://git-wip-us.apache.org/repos/asf/isis/blob/92ffe2d2/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/standalonecollection/StandaloneCollectionPanel.css
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/standalonecollection/StandaloneCollectionPanel.css b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/standalonecollection/StandaloneCollectionPanel.css
index b88fe0c..eea4518 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/standalonecollection/StandaloneCollectionPanel.css
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/standalonecollection/StandaloneCollectionPanel.css
@@ -39,4 +39,4 @@ div.standaloneCollectionPanel .iconAndTitle {
line-height:150%;
clear:both;
}
-
\ No newline at end of file
+
http://git-wip-us.apache.org/repos/asf/isis/blob/92ffe2d2/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/standalonecollection/StandaloneCollectionPanel.html
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/standalonecollection/StandaloneCollectionPanel.html b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/standalonecollection/StandaloneCollectionPanel.html
index e664e3a..d09c0bd 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/standalonecollection/StandaloneCollectionPanel.html
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/standalonecollection/StandaloneCollectionPanel.html
@@ -24,12 +24,29 @@
lang="en">
<body>
<wicket:panel>
+
<div class="standaloneCollectionPanel actionComponentType myBlockContainer panel panel-default">
<div class="iconAndTitle panel-heading actionPanelHeaderNew">
<div wicket:id="actionName" class="actionName panel-title">[action name]</div>
+
+ <div class="pull-right">
+
+ <!--
+ <div class="btn-group">
+ <div xxxwicket:id="additionalLinks"></div>
+ </div>
+ -->
+ <div class="btn-group">
+ <span wicket:id="selectorDropdown"/>
+ </div>
+
+ </div>
+
</div>
+
<div wicket:id="collectionContents" class="panel-body"></div>
</div>
+
</wicket:panel>
</body>
</html>
http://git-wip-us.apache.org/repos/asf/isis/blob/92ffe2d2/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/standalonecollection/StandaloneCollectionPanel.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/standalonecollection/StandaloneCollectionPanel.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/standalonecollection/StandaloneCollectionPanel.java
index 80fd5fe..7ac4640 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/standalonecollection/StandaloneCollectionPanel.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/standalonecollection/StandaloneCollectionPanel.java
@@ -19,22 +19,32 @@
package org.apache.isis.viewer.wicket.ui.components.standalonecollection;
+import java.util.List;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.Model;
import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
import org.apache.isis.viewer.wicket.model.models.ActionModel;
import org.apache.isis.viewer.wicket.model.models.EntityCollectionModel;
+import org.apache.isis.viewer.wicket.ui.ComponentFactory;
import org.apache.isis.viewer.wicket.ui.ComponentType;
import org.apache.isis.viewer.wicket.ui.app.registry.ComponentFactoryRegistry;
-import org.apache.isis.viewer.wicket.ui.components.collection.CollectionCountProvider;
+import org.apache.isis.viewer.wicket.ui.components.collection.count.CollectionCountProvider;
+import org.apache.isis.viewer.wicket.ui.components.collection.selector.CollectionSelectorHelper;
+import org.apache.isis.viewer.wicket.ui.components.collection.selector.CollectionSelectorPanel;
+import org.apache.isis.viewer.wicket.ui.components.collection.selector.CollectionSelectorProvider;
+import org.apache.isis.viewer.wicket.ui.components.collectioncontents.multiple.CollectionContentsMultipleViewsPanelFactory;
import org.apache.isis.viewer.wicket.ui.panels.PanelAbstract;
-public class StandaloneCollectionPanel extends PanelAbstract<EntityCollectionModel> implements CollectionCountProvider {
+public class StandaloneCollectionPanel extends PanelAbstract<EntityCollectionModel>
+ implements CollectionCountProvider, CollectionSelectorProvider {
private static final long serialVersionUID = 1L;
private static final String ID_ACTION_NAME = "actionName";
+ private static final String ID_ADDITIONAL_LINKS = "additionalLinks";
+ private static final String ID_SELECTOR_DROPDOWN = "selectorDropdown";
+ private CollectionSelectorPanel selectorDropdownPanel;
public StandaloneCollectionPanel(final String id, final EntityCollectionModel entityCollectionModel) {
super(id, entityCollectionModel);
@@ -42,11 +52,34 @@ public class StandaloneCollectionPanel extends PanelAbstract<EntityCollectionMod
}
private void buildGui(final EntityCollectionModel entityCollectionModel) {
-
+
ActionModel actionModel = entityCollectionModel.getActionModelHint();
ObjectAction action = actionModel.getActionMemento().getAction();
addOrReplace(new Label(StandaloneCollectionPanel.ID_ACTION_NAME, Model.of(action.getName())));
-
+
+ final CollectionSelectorHelper selectorHelper = new CollectionSelectorHelper(entityCollectionModel, getComponentFactoryRegistry(), new CollectionContentsMultipleViewsPanelFactory());
+
+ final List<ComponentFactory> componentFactories = selectorHelper.findOtherComponentFactories();
+
+ if (componentFactories.size() <= 1) {
+ permanentlyHide(ID_SELECTOR_DROPDOWN);
+ } else {
+ CollectionSelectorPanel selectorDropdownPanel;
+ selectorDropdownPanel = new CollectionSelectorPanel(ID_SELECTOR_DROPDOWN, entityCollectionModel, new CollectionContentsMultipleViewsPanelFactory());
+
+ final Model<ComponentFactory> componentFactoryModel = new Model<>();
+
+ final int selected = selectorHelper.honourViewHintElseDefault(selectorDropdownPanel);
+
+ ComponentFactory selectedComponentFactory = componentFactories.get(selected);
+ componentFactoryModel.setObject(selectedComponentFactory);
+
+ this.setOutputMarkupId(true);
+ addOrReplace(selectorDropdownPanel);
+
+ this.selectorDropdownPanel = selectorDropdownPanel;
+ }
+
final ComponentFactoryRegistry componentFactoryRegistry = getComponentFactoryRegistry();
componentFactoryRegistry.addOrReplaceComponent(this, ComponentType.COLLECTION_CONTENTS, entityCollectionModel);
}
@@ -57,4 +90,8 @@ public class StandaloneCollectionPanel extends PanelAbstract<EntityCollectionMod
return model.getCount();
}
+ @Override
+ public CollectionSelectorPanel getSelectorDropdownPanel() {
+ return selectorDropdownPanel;
+ }
}
http://git-wip-us.apache.org/repos/asf/isis/blob/92ffe2d2/component/viewer/wicket/ui/src/test/java/org/apache/isis/viewer/wicket/ui/components/collection/selector/CollectionContentsSelectorDropdownPanelTest.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/test/java/org/apache/isis/viewer/wicket/ui/components/collection/selector/CollectionContentsSelectorDropdownPanelTest.java b/component/viewer/wicket/ui/src/test/java/org/apache/isis/viewer/wicket/ui/components/collection/selector/CollectionContentsSelectorDropdownPanelTest.java
new file mode 100644
index 0000000..408dd28
--- /dev/null
+++ b/component/viewer/wicket/ui/src/test/java/org/apache/isis/viewer/wicket/ui/components/collection/selector/CollectionContentsSelectorDropdownPanelTest.java
@@ -0,0 +1,67 @@
+/*
+ * 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.viewer.wicket.ui.components.collection.selector;
+
+import java.util.Arrays;
+import java.util.List;
+import org.jmock.auto.Mock;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2.Mode;
+import org.apache.isis.viewer.wicket.ui.ComponentFactory;
+import org.apache.isis.viewer.wicket.ui.components.collectioncontents.ajaxtable.CollectionContentsAsAjaxTablePanelFactory;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+public class CollectionContentsSelectorDropdownPanelTest {
+
+ @Rule
+ public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
+
+ @Mock
+ private ComponentFactory one;
+
+ @Mock
+ private ComponentFactory two;
+
+ private ComponentFactory ajaxTableComponentFactory;
+
+ @Before
+ public void setUp() throws Exception {
+ ajaxTableComponentFactory = new CollectionContentsAsAjaxTablePanelFactory();
+ }
+
+ @Test
+ public void testOrderAjaxTableToEnd() {
+
+ List<ComponentFactory> componentFactories =
+ Arrays.<ComponentFactory>asList(
+ one,
+ ajaxTableComponentFactory,
+ two);
+ List<ComponentFactory> orderAjaxTableToEnd = CollectionSelectorHelper.orderAjaxTableToEnd(componentFactories);
+ assertThat(orderAjaxTableToEnd.get(0), is(one));
+ assertThat(orderAjaxTableToEnd.get(1), is(two));
+ assertThat(orderAjaxTableToEnd.get(2), is(ajaxTableComponentFactory));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/92ffe2d2/component/viewer/wicket/ui/src/test/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorDropdownPanelTest.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/test/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorDropdownPanelTest.java b/component/viewer/wicket/ui/src/test/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorDropdownPanelTest.java
deleted file mode 100644
index 6b94417..0000000
--- a/component/viewer/wicket/ui/src/test/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorDropdownPanelTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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.viewer.wicket.ui.components.collectioncontents.selector.dropdown;
-
-import java.util.Arrays;
-import java.util.List;
-import org.jmock.auto.Mock;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
-import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2.Mode;
-import org.apache.isis.viewer.wicket.ui.ComponentFactory;
-import org.apache.isis.viewer.wicket.ui.components.collectioncontents.ajaxtable.CollectionContentsAsAjaxTablePanelFactory;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-public class CollectionContentsSelectorDropdownPanelTest {
-
- @Rule
- public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
-
- @Mock
- private ComponentFactory one;
-
- @Mock
- private ComponentFactory two;
-
- private ComponentFactory ajaxTableComponentFactory;
-
- @Before
- public void setUp() throws Exception {
- ajaxTableComponentFactory = new CollectionContentsAsAjaxTablePanelFactory();
- }
-
- @Test
- public void testOrderAjaxTableToEnd() {
-
- List<ComponentFactory> componentFactories =
- Arrays.<ComponentFactory>asList(
- one,
- ajaxTableComponentFactory,
- two);
- List<ComponentFactory> orderAjaxTableToEnd = CollectionContentsSelectorHelper.orderAjaxTableToEnd(componentFactories);
- assertThat(orderAjaxTableToEnd.get(0), is(one));
- assertThat(orderAjaxTableToEnd.get(1), is(two));
- assertThat(orderAjaxTableToEnd.get(2), is(ajaxTableComponentFactory));
- }
-
-}
[17/23] isis git commit: ISIS-537: mostly refactored,
however hints not honoured for LinkSelectorPanel.
Posted by da...@apache.org.
ISIS-537: mostly refactored, however hints not honoured for LinkSelectorPanel.
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/f00d01fa
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/f00d01fa
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/f00d01fa
Branch: refs/heads/ISIS-939
Commit: f00d01fa28a35a4cf7ea8ac69950e5e9cb5c9d3c
Parents: 7087fc2
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Sun Nov 9 16:05:49 2014 +0000
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Mon Nov 10 10:21:45 2014 +0000
----------------------------------------------------------------------
...CollectionContentsSelectorDropdownPanel.html | 4 +-
.../CollectionContentsSelectorHelper.java | 69 ++++++++++----------
.../CollectionContentsLinksSelectorPanel.html | 19 ------
.../CollectionContentsLinksSelectorPanel.java | 2 +-
4 files changed, 36 insertions(+), 58 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/f00d01fa/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorDropdownPanel.html
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorDropdownPanel.html b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorDropdownPanel.html
index ea2a4d8..8bec51a 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorDropdownPanel.html
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorDropdownPanel.html
@@ -23,11 +23,11 @@
<wicket:panel>
<div class="linksSelectorPanel">
<div class="btn-group viewLinks" wicket:id="views">
- <button type="button" class="btn btn-xs btn-info">
+ <button type="button" class="btn btn-sm btn-info">
<span wicket:id="viewButtonIcon" class="ViewLinkItem"></span>
<span wicket:id="viewButtonTitle" class="ViewLinkItemTitle"></span>
</button>
- <button type="button" class="btn btn-xs btn-info dropdown-toggle" data-toggle="dropdown">
+ <button type="button" class="btn btn-sm btn-info dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</button>
<ul wicket:id="viewList" class="dropdown-menu dropdown-menu-right" role="menu">
http://git-wip-us.apache.org/repos/asf/isis/blob/f00d01fa/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorHelper.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorHelper.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorHelper.java
index 1e3706c..06eed95 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorHelper.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorHelper.java
@@ -67,9 +67,6 @@ public class CollectionContentsSelectorHelper {
return componentFactoryRegistry.findComponentFactoryElseFailFast(componentType, model);
}
-
-
-
public List<ComponentFactory> findOtherComponentFactories() {
final List<ComponentFactory> componentFactories = componentFactoryRegistry.findComponentFactories(componentType, model);
ArrayList<ComponentFactory> otherFactories = Lists.newArrayList(Collections2.filter(componentFactories, new Predicate<ComponentFactory>() {
@@ -81,35 +78,6 @@ public class CollectionContentsSelectorHelper {
return ordered(otherFactories);
}
- protected List<ComponentFactory> ordered(List<ComponentFactory> componentFactories) {
- return orderAjaxTableToEnd(componentFactories);
- }
-
- static List<ComponentFactory> orderAjaxTableToEnd(List<ComponentFactory> componentFactories) {
- int ajaxTableIdx = findAjaxTable(componentFactories);
- if(ajaxTableIdx>=0) {
- List<ComponentFactory> orderedFactories = Lists.newArrayList(componentFactories);
- ComponentFactory ajaxTableFactory = orderedFactories.remove(ajaxTableIdx);
- orderedFactories.add(ajaxTableFactory);
- return orderedFactories;
- } else {
- return componentFactories;
- }
- }
-
- static int findAjaxTable(List<ComponentFactory> componentFactories) {
- for(int i=0; i<componentFactories.size(); i++) {
- if(componentFactories.get(i) instanceof CollectionContentsAsAjaxTablePanelFactory) {
- return i;
- }
- }
- return -1;
- }
-
-
-
-
-
public int honourViewHintElseDefault(final Component component) {
// honour hints ...
final UiHintContainer hintContainer = getUiHintContainer(component);
@@ -128,7 +96,7 @@ public class CollectionContentsSelectorHelper {
}
// ... else default
- int initialFactory = determineInitialFactory(componentFactories, model);
+ int initialFactory = determineInitialFactory();
if(hintContainer != null) {
hintContainer.setHint(component, UIHINT_VIEW, ""+initialFactory);
// don't broadcast (no AjaxRequestTarget, still configuring initial setup)
@@ -136,17 +104,41 @@ public class CollectionContentsSelectorHelper {
return initialFactory;
}
- public static UiHintContainer getUiHintContainer(final Component component) {
- return UiHintContainer.Util.hintContainerOf(component);
+ private static List<ComponentFactory> ordered(List<ComponentFactory> componentFactories) {
+ return orderAjaxTableToEnd(componentFactories);
}
+ static List<ComponentFactory> orderAjaxTableToEnd(List<ComponentFactory> componentFactories) {
+ int ajaxTableIdx = findAjaxTable(componentFactories);
+ if(ajaxTableIdx>=0) {
+ List<ComponentFactory> orderedFactories = Lists.newArrayList(componentFactories);
+ ComponentFactory ajaxTableFactory = orderedFactories.remove(ajaxTableIdx);
+ orderedFactories.add(ajaxTableFactory);
+ return orderedFactories;
+ } else {
+ return componentFactories;
+ }
+ }
+
+ private static int findAjaxTable(List<ComponentFactory> componentFactories) {
+ for(int i=0; i<componentFactories.size(); i++) {
+ if(componentFactories.get(i) instanceof CollectionContentsAsAjaxTablePanelFactory) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+
+
+
/**
* return the index of {@link org.apache.isis.viewer.wicket.ui.components.collectioncontents.unresolved.CollectionContentsAsUnresolvedPanelFactory unresolved panel} if present and not eager loading;
* else the index of {@link org.apache.isis.viewer.wicket.ui.components.collectioncontents.ajaxtable.CollectionContentsAsAjaxTablePanelFactory ajax table} if present,
* otherwise first factory.
*/
- protected int determineInitialFactory(final List<ComponentFactory> componentFactories, final IModel<?> model) {
+ protected int determineInitialFactory() {
if(!hasRenderEagerlyFacet(model)) {
for(int i=0; i<componentFactories.size(); i++) {
if(componentFactories.get(i) instanceof CollectionContentsAsUnresolvedPanelFactory) {
@@ -161,6 +153,11 @@ public class CollectionContentsSelectorHelper {
return 0;
}
+ private static UiHintContainer getUiHintContainer(final Component component) {
+ return UiHintContainer.Util.hintContainerOf(component);
+ }
+
+
private static boolean hasRenderEagerlyFacet(IModel<?> model) {
if(!(model instanceof EntityCollectionModel)) {
return false;
http://git-wip-us.apache.org/repos/asf/isis/blob/f00d01fa/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.html
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.html b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.html
index 2903711..853a400 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.html
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.html
@@ -24,25 +24,6 @@
<div class="linksSelectorPanel">
<span wicket:id="selectorDropdown"/>
- <!--
- <div class="btn-group viewLinks" xxwicket:id="views">
- <button type="button" class="btn btn-xs btn-info">
- <span xxwicket:id="viewButtonIcon" class="ViewLinkItem"></span>
- <span xxwicket:id="viewButtonTitle" class="ViewLinkItemTitle"></span>
- </button>
- <button type="button" class="btn btn-xs btn-info dropdown-toggle" data-toggle="dropdown">
- <span class="caret"></span>
- </button>
- <ul xxwicket:id="viewList" class="dropdown-menu dropdown-menu-right" role="menu">
- <li xxwicket:id="viewItem" class="viewItem">
- <a href="#" xxwicket:id="viewLink">
- <span xxwicket:id="viewItemIcon" class="ViewLinkItem"></span> <span xxwicket:id="viewItemTitle" class="ViewLinkItemTitle">[link title]</span>
- </a>
- </li>
- </ul>
- </div>
- -->
-
<div class="views">
<div wicket:id="collectionContents-0" class="collectionContentsLinksSelectorPanel collectionContentsComponentType"></div>
<div wicket:id="collectionContents-1" class="collectionContentsLinksSelectorPanel collectionContentsComponentType"></div>
http://git-wip-us.apache.org/repos/asf/isis/blob/f00d01fa/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java
index fd0a3da..627adb5 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java
@@ -96,7 +96,7 @@ public class CollectionContentsLinksSelectorPanel
private void addUnderlyingViews() {
final EntityCollectionModel model = getModel();
- final int selected = selectorHelper.honourViewHintElseDefault(this);
+ final int selected = selectorHelper.honourViewHintElseDefault(selectorDropdownPanel);
// create all, hide the one not selected
underlyingViews = new Component[MAX_NUM_UNDERLYING_VIEWS];
[22/23] isis git commit: ISIS-537: tidy up of (entity) collections
panel;
standalone collections panel no longer failing (but still need to sort out CSS
and bulk actions)
Posted by da...@apache.org.
ISIS-537: tidy up of (entity) collections panel; standalone collections panel no longer failing (but still need to sort out CSS and bulk actions)
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/92ffe2d2
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/92ffe2d2
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/92ffe2d2
Branch: refs/heads/ISIS-939
Commit: 92ffe2d2c1a0a7771c5c822f94d1d60111a55e77
Parents: 3b39738
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Mon Nov 10 09:59:43 2014 +0000
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Mon Nov 10 10:21:50 2014 +0000
----------------------------------------------------------------------
.../ComponentFactoryRegistrarDefault.java | 4 +-
.../wicket/ui/CollectionContentsAsFactory.java | 2 +-
.../collection/CollectionCountProvider.java | 21 --
.../components/collection/CollectionPanel.java | 67 ++---
.../count/CollectionCountProvider.java | 21 ++
.../selector/CollectionSelectorHelper.java | 174 +++++++++++++
.../selector/CollectionSelectorPanel.html | 44 ++++
.../selector/CollectionSelectorPanel.java | 220 +++++++++++++++++
.../selector/CollectionSelectorProvider.java | 23 ++
.../selector/UNUSED_CollectionSelectorPanel.css | 60 +++++
.../CollectionContentsAsAjaxTablePanel.java | 2 +-
.../CollectionContentsMultipleViewsPanel.css | 60 +++++
.../CollectionContentsMultipleViewsPanel.html | 41 ++++
.../CollectionContentsMultipleViewsPanel.java | 226 +++++++++++++++++
...ectionContentsMultipleViewsPanelFactory.java | 53 ++++
...CollectionContentsSelectorDropdownPanel.html | 44 ----
...CollectionContentsSelectorDropdownPanel.java | 222 -----------------
.../CollectionContentsSelectorHelper.java | 176 --------------
...ionContentsSelectorSelectorDropdownPanel.css | 60 -----
.../dropdown/HasSelectorDropdownPanel.java | 23 --
.../CollectionContentsLinksSelectorPanel.css | 60 -----
.../CollectionContentsLinksSelectorPanel.html | 41 ----
.../CollectionContentsLinksSelectorPanel.java | 243 -------------------
...ectionContentsLinksSelectorPanelFactory.java | 53 ----
.../summary/CollectionContentsAsSummary.java | 2 +-
.../collections/EntityCollectionsPanel.html | 22 --
.../collections/EntityCollectionsPanel.java | 24 +-
.../StandaloneCollectionPanel.css | 2 +-
.../StandaloneCollectionPanel.html | 17 ++
.../StandaloneCollectionPanel.java | 45 +++-
...ectionContentsSelectorDropdownPanelTest.java | 67 +++++
...ectionContentsSelectorDropdownPanelTest.java | 67 -----
32 files changed, 1081 insertions(+), 1105 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/92ffe2d2/component/viewer/wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/registries/components/ComponentFactoryRegistrarDefault.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/registries/components/ComponentFactoryRegistrarDefault.java b/component/viewer/wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/registries/components/ComponentFactoryRegistrarDefault.java
index 21a3f2c..ed48dea 100644
--- a/component/viewer/wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/registries/components/ComponentFactoryRegistrarDefault.java
+++ b/component/viewer/wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/registries/components/ComponentFactoryRegistrarDefault.java
@@ -32,7 +32,7 @@ import org.apache.isis.viewer.wicket.ui.components.appactions.cssmenu.AppActions
import org.apache.isis.viewer.wicket.ui.components.bookmarkedpages.BookmarkedPagesPanelFactory;
import org.apache.isis.viewer.wicket.ui.components.collection.CollectionPanelFactory;
import org.apache.isis.viewer.wicket.ui.components.collectioncontents.ajaxtable.CollectionContentsAsAjaxTablePanelFactory;
-import org.apache.isis.viewer.wicket.ui.components.collectioncontents.selector.links.CollectionContentsLinksSelectorPanelFactory;
+import org.apache.isis.viewer.wicket.ui.components.collectioncontents.multiple.CollectionContentsMultipleViewsPanelFactory;
import org.apache.isis.viewer.wicket.ui.components.collectioncontents.summary.CollectionContentsAsSummaryFactory;
import org.apache.isis.viewer.wicket.ui.components.collectioncontents.unresolved.CollectionContentsAsUnresolvedPanelFactory;
import org.apache.isis.viewer.wicket.ui.components.empty.EmptyCollectionPanelFactory;
@@ -96,7 +96,7 @@ public class ComponentFactoryRegistrarDefault implements ComponentFactoryRegistr
protected void addLinksSelectorFactories(final ComponentFactoryList componentFactories) {
componentFactories.add(new EntityLinksSelectorPanelFactory());
- componentFactories.add(new CollectionContentsLinksSelectorPanelFactory());
+ componentFactories.add(new CollectionContentsMultipleViewsPanelFactory());
}
protected void addComponentFactoriesUsingServiceLoader(final ComponentFactoryList componentFactories) {
http://git-wip-us.apache.org/repos/asf/isis/blob/92ffe2d2/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/CollectionContentsAsFactory.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/CollectionContentsAsFactory.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/CollectionContentsAsFactory.java
index 0e98a3f..440b0ff 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/CollectionContentsAsFactory.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/CollectionContentsAsFactory.java
@@ -24,7 +24,7 @@ import org.apache.wicket.model.IModel;
* <p>
* An interface for all {@link org.apache.isis.viewer.wicket.ui.ComponentFactory component factories}
* (e.g. CollectionContentAsXyzFactory-ies) which want to provide specific title and CSS class(es)
- * for their representation in {@link org.apache.isis.viewer.wicket.ui.components.collectioncontents.selector.links.CollectionContentsLinksSelectorPanel}.
+ * for their representation in {@link org.apache.isis.viewer.wicket.ui.components.collectioncontents.multiple.CollectionContentsMultipleViewsPanel}.
* </p>
* <p>
* If the {@link org.apache.isis.viewer.wicket.ui.ComponentFactory} doesn't implement this interface or the implementation
http://git-wip-us.apache.org/repos/asf/isis/blob/92ffe2d2/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/CollectionCountProvider.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/CollectionCountProvider.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/CollectionCountProvider.java
deleted file mode 100644
index dd4beca..0000000
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/CollectionCountProvider.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/**
- * 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.viewer.wicket.ui.components.collection;
-
-public interface CollectionCountProvider {
- Integer getCount();
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/92ffe2d2/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/CollectionPanel.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/CollectionPanel.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/CollectionPanel.java
index 0b10d9c..02e9ced 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/CollectionPanel.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/CollectionPanel.java
@@ -22,12 +22,9 @@ package org.apache.isis.viewer.wicket.ui.components.collection;
import de.agilecoders.wicket.core.markup.html.bootstrap.common.NotificationPanel;
import java.util.List;
-
import org.apache.wicket.Component;
-import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.feedback.ComponentFeedbackMessageFilter;
import org.apache.wicket.markup.html.basic.Label;
-
import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
import org.apache.isis.core.runtime.system.DeploymentType;
import org.apache.isis.core.runtime.system.context.IsisContext;
@@ -38,8 +35,8 @@ import org.apache.isis.viewer.wicket.model.models.EntityModel;
import org.apache.isis.viewer.wicket.ui.ComponentType;
import org.apache.isis.viewer.wicket.ui.components.actionprompt.ActionPromptModalWindow;
import org.apache.isis.viewer.wicket.ui.components.additionallinks.EntityActionUtil;
-import org.apache.isis.viewer.wicket.ui.components.collectioncontents.selector.dropdown.CollectionContentsSelectorDropdownPanel;
-import org.apache.isis.viewer.wicket.ui.components.collectioncontents.selector.dropdown.HasSelectorDropdownPanel;
+import org.apache.isis.viewer.wicket.ui.components.collection.selector.CollectionSelectorPanel;
+import org.apache.isis.viewer.wicket.ui.components.collection.selector.CollectionSelectorProvider;
import org.apache.isis.viewer.wicket.ui.components.scalars.ScalarPanelAbstract;
import org.apache.isis.viewer.wicket.ui.panels.PanelAbstract;
@@ -47,7 +44,7 @@ import org.apache.isis.viewer.wicket.ui.panels.PanelAbstract;
* Panel for rendering entity collection; analogous to (any concrete subclass
* of) {@link ScalarPanelAbstract}.
*/
-public class CollectionPanel extends PanelAbstract<EntityCollectionModel> implements ActionPromptProvider, HasSelectorDropdownPanel {
+public class CollectionPanel extends PanelAbstract<EntityCollectionModel> implements ActionPromptProvider, CollectionSelectorProvider {
private static final long serialVersionUID = 1L;
@@ -57,7 +54,6 @@ public class CollectionPanel extends PanelAbstract<EntityCollectionModel> implem
private Component collectionContents;
- private String collectionName;
private Label label;
public CollectionPanel(final String id, final EntityModel entityModel, OneToManyAssociation otma) {
@@ -95,42 +91,26 @@ public class CollectionPanel extends PanelAbstract<EntityCollectionModel> implem
}
public Label createLabel(final String id, final String collectionName) {
- this.collectionName = collectionName;
this.label = new Label(id, collectionName);
- label.setOutputMarkupId(true);
- return this.label;
+ label.setOutputMarkupId(true);
+ return this.label;
}
- public void updateLabel(AjaxRequestTarget target) {
- target.add(label);
- }
+ //region > SelectorDropdownPanel (impl)
- /**
- * Returns true if a collection count is available from the rendered component
- * (ie an eagerly rendered/expanded view).
- */
- public boolean hasCount() {
- if(label == null) {
- return false;
- }
- final Integer count = getCount();
- label.setDefaultModelObject(collectionName);
- return count != null;
- }
+ private CollectionSelectorPanel selectorDropdownPanel;
- private Integer getCount() {
- if(collectionContents instanceof CollectionCountProvider) {
- final CollectionCountProvider collectionCountProvider = (CollectionCountProvider) collectionContents;
- return collectionCountProvider.getCount();
- } else {
- return null;
- }
+ @Override
+ public CollectionSelectorPanel getSelectorDropdownPanel() {
+ return selectorDropdownPanel;
+ }
+ public void setSelectorDropdownPanel(CollectionSelectorPanel selectorDropdownPanel) {
+ this.selectorDropdownPanel = selectorDropdownPanel;
}
+ //endregion
+
-
- // ///////////////////////////////////////////////////////////////////
- // ActionPromptModalWindowProvider
- // ///////////////////////////////////////////////////////////////////
+ //region > ActionPromptModalWindowProvider
private ActionPromptModalWindow actionPromptModalWindow;
public ActionPromptModalWindow getActionPrompt() {
@@ -141,26 +121,15 @@ public class CollectionPanel extends PanelAbstract<EntityCollectionModel> implem
this.actionPromptModalWindow = ActionPromptModalWindow.newModalWindow(ID_ACTION_PROMPT_MODAL_WINDOW);
addOrReplace(actionPromptModalWindow);
}
+ //endregion
- // ///////////////////////////////////////////////////////////////////
+ //region > dependencies
protected DeploymentType getDeploymentType() {
return IsisContext.getDeploymentType();
}
-
- //region > SelectorDropdownPanel (impl)
-
- private CollectionContentsSelectorDropdownPanel selectorDropdownPanel;
-
- @Override
- public CollectionContentsSelectorDropdownPanel getSelectorDropdownPanel() {
- return selectorDropdownPanel;
- }
- public void setSelectorDropdownPanel(CollectionContentsSelectorDropdownPanel selectorDropdownPanel) {
- this.selectorDropdownPanel = selectorDropdownPanel;
- }
//endregion
}
http://git-wip-us.apache.org/repos/asf/isis/blob/92ffe2d2/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/count/CollectionCountProvider.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/count/CollectionCountProvider.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/count/CollectionCountProvider.java
new file mode 100644
index 0000000..0ff411f
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/count/CollectionCountProvider.java
@@ -0,0 +1,21 @@
+/**
+ * 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.viewer.wicket.ui.components.collection.count;
+
+public interface CollectionCountProvider {
+ Integer getCount();
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/92ffe2d2/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/selector/CollectionSelectorHelper.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/selector/CollectionSelectorHelper.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/selector/CollectionSelectorHelper.java
new file mode 100644
index 0000000..dfcdbf5
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/selector/CollectionSelectorHelper.java
@@ -0,0 +1,174 @@
+/*
+ * 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.viewer.wicket.ui.components.collection.selector;
+
+import java.util.ArrayList;
+import java.util.List;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
+import com.google.common.collect.Lists;
+import org.apache.wicket.Component;
+import org.apache.wicket.model.IModel;
+import org.apache.isis.applib.annotation.Render;
+import org.apache.isis.core.metamodel.facets.members.render.RenderFacet;
+import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
+import org.apache.isis.viewer.wicket.model.hints.UiHintContainer;
+import org.apache.isis.viewer.wicket.model.models.EntityCollectionModel;
+import org.apache.isis.viewer.wicket.ui.ComponentFactory;
+import org.apache.isis.viewer.wicket.ui.ComponentType;
+import org.apache.isis.viewer.wicket.ui.app.registry.ComponentFactoryRegistry;
+import org.apache.isis.viewer.wicket.ui.components.collectioncontents.ajaxtable.CollectionContentsAsAjaxTablePanelFactory;
+import org.apache.isis.viewer.wicket.ui.components.collectioncontents.multiple.CollectionContentsMultipleViewsPanelFactory;
+import org.apache.isis.viewer.wicket.ui.components.collectioncontents.unresolved.CollectionContentsAsUnresolvedPanelFactory;
+
+public class CollectionSelectorHelper {
+
+ static final String UIHINT_EVENT_VIEW_KEY = "view";
+
+ private final ComponentType componentType;
+ private final ComponentFactoryRegistry componentFactoryRegistry;
+ private final EntityCollectionModel model;
+ private final ComponentFactory ignoreFactory;
+ private final List<ComponentFactory> componentFactories;
+
+
+ public CollectionSelectorHelper(
+ final EntityCollectionModel model,
+ final ComponentFactoryRegistry componentFactoryRegistry,
+ final ComponentFactory ignoreFactory) {
+ this.componentFactoryRegistry = componentFactoryRegistry;
+ this.model = model;
+ this.ignoreFactory = ignoreFactory;
+ this.componentType = ignoreFactory.getComponentType();
+
+ componentFactories = findOtherComponentFactories();
+ }
+
+ public List<ComponentFactory> findOtherComponentFactories() {
+ final List<ComponentFactory> componentFactories = componentFactoryRegistry.findComponentFactories(componentType, model);
+ ArrayList<ComponentFactory> otherFactories = Lists.newArrayList(Collections2.filter(componentFactories, new Predicate<ComponentFactory>() {
+ @Override
+ public boolean apply(final ComponentFactory input) {
+ return input != ignoreFactory && input.getClass() != CollectionContentsMultipleViewsPanelFactory.class;
+ }
+ }));
+ return ordered(otherFactories);
+ }
+
+ public int honourViewHintElseDefault(final Component component) {
+ // honour hints ...
+ final UiHintContainer hintContainer = getUiHintContainer(component);
+ if(hintContainer != null) {
+ String viewStr = hintContainer.getHint(component, UIHINT_EVENT_VIEW_KEY);
+ if(viewStr != null) {
+ try {
+ int view = Integer.parseInt(viewStr);
+ if(view >= 0 && view < componentFactories.size()) {
+ return view;
+ }
+ } catch(NumberFormatException ex) {
+ // ignore
+ }
+ }
+ }
+
+ // ... else default
+ int initialFactory = determineInitialFactory();
+ if(hintContainer != null) {
+ hintContainer.setHint(component, UIHINT_EVENT_VIEW_KEY, ""+initialFactory);
+ // don't broadcast (no AjaxRequestTarget, still configuring initial setup)
+ }
+ return initialFactory;
+ }
+
+ //region > helpers
+
+ private static List<ComponentFactory> ordered(List<ComponentFactory> componentFactories) {
+ return orderAjaxTableToEnd(componentFactories);
+ }
+
+ static List<ComponentFactory> orderAjaxTableToEnd(List<ComponentFactory> componentFactories) {
+ int ajaxTableIdx = findAjaxTable(componentFactories);
+ if(ajaxTableIdx>=0) {
+ List<ComponentFactory> orderedFactories = Lists.newArrayList(componentFactories);
+ ComponentFactory ajaxTableFactory = orderedFactories.remove(ajaxTableIdx);
+ orderedFactories.add(ajaxTableFactory);
+ return orderedFactories;
+ } else {
+ return componentFactories;
+ }
+ }
+
+ private static int findAjaxTable(List<ComponentFactory> componentFactories) {
+ for(int i=0; i<componentFactories.size(); i++) {
+ if(componentFactories.get(i) instanceof CollectionContentsAsAjaxTablePanelFactory) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+
+
+
+
+ /**
+ * return the index of {@link org.apache.isis.viewer.wicket.ui.components.collectioncontents.unresolved.CollectionContentsAsUnresolvedPanelFactory unresolved panel} if present and not eager loading;
+ * else the index of {@link org.apache.isis.viewer.wicket.ui.components.collectioncontents.ajaxtable.CollectionContentsAsAjaxTablePanelFactory ajax table} if present,
+ * otherwise first factory.
+ */
+ protected int determineInitialFactory() {
+ if(!hasRenderEagerlyFacet(model)) {
+ for(int i=0; i<componentFactories.size(); i++) {
+ if(componentFactories.get(i) instanceof CollectionContentsAsUnresolvedPanelFactory) {
+ return i;
+ }
+ }
+ }
+ int ajaxTableIdx = CollectionSelectorHelper.findAjaxTable(componentFactories);
+ if(ajaxTableIdx>=0) {
+ return ajaxTableIdx;
+ }
+ return 0;
+ }
+
+ private static UiHintContainer getUiHintContainer(final Component component) {
+ return UiHintContainer.Util.hintContainerOf(component);
+ }
+
+
+ private static boolean hasRenderEagerlyFacet(IModel<?> model) {
+ if(!(model instanceof EntityCollectionModel)) {
+ return false;
+ }
+ final EntityCollectionModel entityCollectionModel = (EntityCollectionModel) model;
+ if(!entityCollectionModel.isParented()) {
+ return false;
+ }
+
+ final OneToManyAssociation collection =
+ entityCollectionModel.getCollectionMemento().getCollection();
+ RenderFacet renderFacet = collection.getFacet(RenderFacet.class);
+ return renderFacet != null && renderFacet.value() == Render.Type.EAGERLY;
+ }
+
+ //endregion
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/92ffe2d2/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/selector/CollectionSelectorPanel.html
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/selector/CollectionSelectorPanel.html b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/selector/CollectionSelectorPanel.html
new file mode 100644
index 0000000..8bec51a
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/selector/CollectionSelectorPanel.html
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns:wicket="http://wicket.apache.org">
+<body>
+<wicket:panel>
+ <div class="linksSelectorPanel">
+ <div class="btn-group viewLinks" wicket:id="views">
+ <button type="button" class="btn btn-sm btn-info">
+ <span wicket:id="viewButtonIcon" class="ViewLinkItem"></span>
+ <span wicket:id="viewButtonTitle" class="ViewLinkItemTitle"></span>
+ </button>
+ <button type="button" class="btn btn-sm btn-info dropdown-toggle" data-toggle="dropdown">
+ <span class="caret"></span>
+ </button>
+ <ul wicket:id="viewList" class="dropdown-menu dropdown-menu-right" role="menu">
+ <li wicket:id="viewItem" class="viewItem">
+ <a href="#" wicket:id="viewLink">
+ <span wicket:id="viewItemIcon" class="ViewLinkItem"></span> <span wicket:id="viewItemTitle" class="ViewLinkItemTitle">[link title]</span>
+ </a>
+ </li>
+ </ul>
+ </div>
+ </div>
+</wicket:panel>
+</body>
+</html>
http://git-wip-us.apache.org/repos/asf/isis/blob/92ffe2d2/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/selector/CollectionSelectorPanel.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/selector/CollectionSelectorPanel.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/selector/CollectionSelectorPanel.java
new file mode 100644
index 0000000..cb8d0f2
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/selector/CollectionSelectorPanel.java
@@ -0,0 +1,220 @@
+/*
+ * 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.viewer.wicket.ui.components.collection.selector;
+
+import de.agilecoders.wicket.core.markup.html.bootstrap.button.Buttons;
+
+import java.util.List;
+import org.apache.wicket.AttributeModifier;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.markup.html.AjaxLink;
+import org.apache.wicket.event.Broadcast;
+import org.apache.wicket.markup.ComponentTag;
+import org.apache.wicket.markup.head.IHeaderResponse;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+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.model.IModel;
+import org.apache.wicket.model.Model;
+import org.apache.isis.core.commons.lang.StringExtensions;
+import org.apache.isis.viewer.wicket.model.hints.IsisUiHintEvent;
+import org.apache.isis.viewer.wicket.model.hints.UiHintContainer;
+import org.apache.isis.viewer.wicket.model.hints.UiHintPathSignificant;
+import org.apache.isis.viewer.wicket.model.models.EntityCollectionModel;
+import org.apache.isis.viewer.wicket.ui.CollectionContentsAsFactory;
+import org.apache.isis.viewer.wicket.ui.ComponentFactory;
+import org.apache.isis.viewer.wicket.ui.ComponentType;
+import org.apache.isis.viewer.wicket.ui.panels.PanelAbstract;
+import org.apache.isis.viewer.wicket.ui.util.CssClassAppender;
+
+/**
+ * Provides a list of links for selecting other views that support
+ * {@link org.apache.isis.viewer.wicket.ui.ComponentType#COLLECTION_CONTENTS} with a backing
+ * {@link org.apache.isis.viewer.wicket.model.models.EntityCollectionModel}.
+ */
+public class CollectionSelectorPanel
+ extends PanelAbstract<EntityCollectionModel> implements UiHintPathSignificant /*, CollectionCountProvider*/ {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final String ID_VIEWS = "views";
+ private static final String ID_VIEW_LIST = "viewList";
+ private static final String ID_VIEW_LINK = "viewLink";
+ private static final String ID_VIEW_ITEM = "viewItem";
+ private static final String ID_VIEW_ITEM_TITLE = "viewItemTitle";
+ private static final String ID_VIEW_ITEM_ICON = "viewItemIcon";
+
+ private static final String ID_VIEW_BUTTON_TITLE = "viewButtonTitle";
+ private static final String ID_VIEW_BUTTON_ICON = "viewButtonIcon";
+
+ private final ComponentType componentType;
+ private final CollectionSelectorHelper selectorHelper;
+
+ private ComponentFactory selectedComponentFactory;
+
+ public CollectionSelectorPanel(final String id, final EntityCollectionModel model, final ComponentFactory ignoreFactory) {
+ super(id, model);
+ this.componentType = ignoreFactory.getComponentType();
+ selectorHelper = new CollectionSelectorHelper(model, getComponentFactoryRegistry(), ignoreFactory);
+ }
+
+ /**
+ * Build UI only after added to parent.
+ */
+ public void onInitialize() {
+ super.onInitialize();
+ addDropdown();
+ }
+
+
+
+ private void addDropdown() {
+ final List<ComponentFactory> componentFactories = selectorHelper.findOtherComponentFactories();
+ final int selected = selectorHelper.honourViewHintElseDefault(this);
+
+ // selector
+ if (componentFactories.size() <= 1) {
+ permanentlyHide(ID_VIEWS);
+ } else {
+ final Model<ComponentFactory> componentFactoryModel = new Model<>();
+
+ this.selectedComponentFactory = componentFactories.get(selected);
+ componentFactoryModel.setObject(this.selectedComponentFactory);
+
+ final WebMarkupContainer views = new WebMarkupContainer(ID_VIEWS);
+
+ final Label viewButtonTitle = new Label(ID_VIEW_BUTTON_TITLE, "Hidden");
+ views.addOrReplace(viewButtonTitle);
+
+ final Label viewButtonIcon = new Label(ID_VIEW_BUTTON_ICON, "");
+ views.addOrReplace(viewButtonIcon);
+
+ final WebMarkupContainer container = new WebMarkupContainer(ID_VIEW_LIST);
+
+ views.addOrReplace(container);
+ views.setOutputMarkupId(true);
+
+ this.setOutputMarkupId(true);
+
+ final ListView<ComponentFactory> listView = new ListView<ComponentFactory>(ID_VIEW_ITEM, componentFactories) {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void populateItem(ListItem<ComponentFactory> item) {
+
+ final int underlyingViewNum = item.getIndex();
+
+ final ComponentFactory componentFactory = item.getModelObject();
+ final AbstractLink link = new AjaxLink<Void>(ID_VIEW_LINK) {
+ private static final long serialVersionUID = 1L;
+ @Override
+ public void onClick(AjaxRequestTarget target) {
+ CollectionSelectorPanel linksSelectorPanel = CollectionSelectorPanel.this;
+ linksSelectorPanel.setViewHintAndBroadcast(underlyingViewNum, target);
+
+ CollectionSelectorPanel.this.selectedComponentFactory = componentFactory;
+ target.add(CollectionSelectorPanel.this, views);
+ }
+
+ @Override
+ protected void onComponentTag(ComponentTag tag) {
+ super.onComponentTag(tag);
+ Buttons.fixDisabledState(this, tag);
+ }
+ };
+
+ IModel<String> title = nameFor(componentFactory);
+ Label viewItemTitleLabel = new Label(ID_VIEW_ITEM_TITLE, title);
+ link.add(viewItemTitleLabel);
+
+ Label viewItemIcon = new Label(ID_VIEW_ITEM_ICON, "");
+ link.add(viewItemIcon);
+
+ boolean isEnabled = componentFactory != CollectionSelectorPanel.this.selectedComponentFactory;
+ if (!isEnabled) {
+ viewButtonTitle.setDefaultModel(title);
+ IModel<String> cssClass = cssClassFor(componentFactory, viewButtonIcon);
+ viewButtonIcon.add(AttributeModifier.replace("class", "ViewLinkItem " + cssClass.getObject()));
+ link.setVisible(false);
+ } else {
+ IModel<String> cssClass = cssClassFor(componentFactory, viewItemIcon);
+ viewItemIcon.add(new CssClassAppender(cssClass));
+ }
+
+ item.add(link);
+ }
+
+ private IModel<String> cssClassFor(final ComponentFactory componentFactory, Label viewIcon) {
+ IModel<String> cssClass = null;
+ if (componentFactory instanceof CollectionContentsAsFactory) {
+ CollectionContentsAsFactory collectionContentsAsFactory = (CollectionContentsAsFactory) componentFactory;
+ cssClass = collectionContentsAsFactory.getCssClass();
+ viewIcon.setDefaultModelObject("");
+ viewIcon.setEscapeModelStrings(true);
+ }
+ if (cssClass == null) {
+ String name = componentFactory.getName();
+ cssClass = Model.of(StringExtensions.asLowerDashed(name));
+ // Small hack: if there is no specific CSS class then we assume that background-image is used
+ // the span.ViewItemLink should have some content to show it
+ // FIX: find a way to do this with CSS (width and height don't seems to help)
+ viewIcon.setDefaultModelObject("     ");
+ viewIcon.setEscapeModelStrings(false);
+ }
+ return cssClass;
+ }
+
+ private IModel<String> nameFor(final ComponentFactory componentFactory) {
+ IModel<String> name = null;
+ if (componentFactory instanceof CollectionContentsAsFactory) {
+ CollectionContentsAsFactory collectionContentsAsFactory = (CollectionContentsAsFactory) componentFactory;
+ name = collectionContentsAsFactory.getTitleLabel();
+ }
+ if (name == null) {
+ name = Model.of(componentFactory.getName());
+ }
+ return name;
+ }
+ };
+ container.add(listView);
+ addOrReplace(views);
+ }
+ }
+
+
+ protected void setViewHintAndBroadcast(int viewNum, AjaxRequestTarget target) {
+ final UiHintContainer uiHintContainer = getUiHintContainer();
+ if(uiHintContainer == null) {
+ return;
+ }
+ uiHintContainer.setHint(CollectionSelectorPanel.this, CollectionSelectorHelper.UIHINT_EVENT_VIEW_KEY, ""+viewNum);
+ send(getPage(), Broadcast.EXACT, new IsisUiHintEvent(uiHintContainer, target));
+ }
+
+ @Override
+ public void renderHead(final IHeaderResponse response) {
+ super.renderHead(response);
+ //PanelUtil.renderHead(response, CollectionSelectorPanel.class);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/92ffe2d2/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/selector/CollectionSelectorProvider.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/selector/CollectionSelectorProvider.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/selector/CollectionSelectorProvider.java
new file mode 100644
index 0000000..08132ec
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/selector/CollectionSelectorProvider.java
@@ -0,0 +1,23 @@
+/*
+ * 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.viewer.wicket.ui.components.collection.selector;
+
+public interface CollectionSelectorProvider {
+ CollectionSelectorPanel getSelectorDropdownPanel();
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/92ffe2d2/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/selector/UNUSED_CollectionSelectorPanel.css
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/selector/UNUSED_CollectionSelectorPanel.css b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/selector/UNUSED_CollectionSelectorPanel.css
new file mode 100644
index 0000000..8c3902e
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/selector/UNUSED_CollectionSelectorPanel.css
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ */
+.linksSelectorPanel .viewLinks {
+ float:right;
+ display:block;
+}
+
+.linksSelectorPanel ul.dropdown-menu {
+ min-width: 0;
+}
+
+.linksSelectorPanel ul.dropdown-menu li.viewItem {
+ min-width: 0;
+}
+
+.linksSelectorPanel ul.viewList li.viewItem:first-child span {
+ border-radius:4px 0 0 4px;
+ -moz-border-radius:4px 0 0 4px;
+ -webkit-border-radius:4px 0 0 4px;
+}
+
+.linksSelectorPanel ul.viewList li.viewItem:last-child span {
+ border-radius:0 4px 4px 0;
+ -moz-border-radius:0 4px 4px 0;
+ -webkit-border-radius:0 4px 4px 0;
+}
+
+
+.linksSelectorPanel .link-selector-panel-invisible {
+ display:none;
+}
+
+.linksSelectorPanel .list-inline {
+ margin-left: 0;
+}
+
+.linksSelectorPanel .list-inline li {
+ padding-left: 0;
+}
+
+
+.collectionContentsLinksSelectorPanel select {
+ margin-bottom: 1em;
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/92ffe2d2/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/CollectionContentsAsAjaxTablePanel.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/CollectionContentsAsAjaxTablePanel.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/CollectionContentsAsAjaxTablePanel.java
index 498751c..803a053 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/CollectionContentsAsAjaxTablePanel.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/CollectionContentsAsAjaxTablePanel.java
@@ -56,7 +56,7 @@ import org.apache.isis.viewer.wicket.model.mementos.ObjectAdapterMemento;
import org.apache.isis.viewer.wicket.model.models.ActionPromptProvider;
import org.apache.isis.viewer.wicket.model.models.EntityCollectionModel;
import org.apache.isis.viewer.wicket.ui.components.actionprompt.ActionPromptModalWindow;
-import org.apache.isis.viewer.wicket.ui.components.collection.CollectionCountProvider;
+import org.apache.isis.viewer.wicket.ui.components.collection.count.CollectionCountProvider;
import org.apache.isis.viewer.wicket.ui.components.collectioncontents.ajaxtable.columns.ColumnAbstract;
import org.apache.isis.viewer.wicket.ui.components.collectioncontents.ajaxtable.columns.ObjectAdapterPropertyColumn;
import org.apache.isis.viewer.wicket.ui.components.collectioncontents.ajaxtable.columns.ObjectAdapterTitleColumn;
http://git-wip-us.apache.org/repos/asf/isis/blob/92ffe2d2/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/multiple/CollectionContentsMultipleViewsPanel.css
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/multiple/CollectionContentsMultipleViewsPanel.css b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/multiple/CollectionContentsMultipleViewsPanel.css
new file mode 100644
index 0000000..8c3902e
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/multiple/CollectionContentsMultipleViewsPanel.css
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ */
+.linksSelectorPanel .viewLinks {
+ float:right;
+ display:block;
+}
+
+.linksSelectorPanel ul.dropdown-menu {
+ min-width: 0;
+}
+
+.linksSelectorPanel ul.dropdown-menu li.viewItem {
+ min-width: 0;
+}
+
+.linksSelectorPanel ul.viewList li.viewItem:first-child span {
+ border-radius:4px 0 0 4px;
+ -moz-border-radius:4px 0 0 4px;
+ -webkit-border-radius:4px 0 0 4px;
+}
+
+.linksSelectorPanel ul.viewList li.viewItem:last-child span {
+ border-radius:0 4px 4px 0;
+ -moz-border-radius:0 4px 4px 0;
+ -webkit-border-radius:0 4px 4px 0;
+}
+
+
+.linksSelectorPanel .link-selector-panel-invisible {
+ display:none;
+}
+
+.linksSelectorPanel .list-inline {
+ margin-left: 0;
+}
+
+.linksSelectorPanel .list-inline li {
+ padding-left: 0;
+}
+
+
+.collectionContentsLinksSelectorPanel select {
+ margin-bottom: 1em;
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/92ffe2d2/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/multiple/CollectionContentsMultipleViewsPanel.html
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/multiple/CollectionContentsMultipleViewsPanel.html b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/multiple/CollectionContentsMultipleViewsPanel.html
new file mode 100644
index 0000000..0a6d242
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/multiple/CollectionContentsMultipleViewsPanel.html
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns:wicket="http://wicket.apache.org">
+<body>
+<wicket:panel>
+ <div class="linksSelectorPanel">
+
+ <div class="views">
+ <div wicket:id="collectionContents-0" class="collectionContentsLinksSelectorPanel collectionContentsComponentType"></div>
+ <div wicket:id="collectionContents-1" class="collectionContentsLinksSelectorPanel collectionContentsComponentType"></div>
+ <div wicket:id="collectionContents-2" class="collectionContentsLinksSelectorPanel collectionContentsComponentType"></div>
+ <div wicket:id="collectionContents-3" class="collectionContentsLinksSelectorPanel collectionContentsComponentType"></div>
+ <div wicket:id="collectionContents-4" class="collectionContentsLinksSelectorPanel collectionContentsComponentType"></div>
+ <div wicket:id="collectionContents-5" class="collectionContentsLinksSelectorPanel collectionContentsComponentType"></div>
+ <div wicket:id="collectionContents-6" class="collectionContentsLinksSelectorPanel collectionContentsComponentType"></div>
+ <div wicket:id="collectionContents-7" class="collectionContentsLinksSelectorPanel collectionContentsComponentType"></div>
+ <div wicket:id="collectionContents-8" class="collectionContentsLinksSelectorPanel collectionContentsComponentType"></div>
+ <div wicket:id="collectionContents-9" class="collectionContentsLinksSelectorPanel collectionContentsComponentType"></div>
+ </div>
+ </div>
+</wicket:panel>
+</body>
+</html>
http://git-wip-us.apache.org/repos/asf/isis/blob/92ffe2d2/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/multiple/CollectionContentsMultipleViewsPanel.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/multiple/CollectionContentsMultipleViewsPanel.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/multiple/CollectionContentsMultipleViewsPanel.java
new file mode 100644
index 0000000..49db84a
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/multiple/CollectionContentsMultipleViewsPanel.java
@@ -0,0 +1,226 @@
+/*
+ * 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.viewer.wicket.ui.components.collectioncontents.multiple;
+
+import java.util.List;
+import org.apache.wicket.AttributeModifier;
+import org.apache.wicket.Component;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.event.IEvent;
+import org.apache.wicket.markup.head.IHeaderResponse;
+import org.apache.isis.viewer.wicket.model.hints.IsisEnvelopeEvent;
+import org.apache.isis.viewer.wicket.model.hints.IsisUiHintEvent;
+import org.apache.isis.viewer.wicket.model.hints.UiHintContainer;
+import org.apache.isis.viewer.wicket.model.hints.UiHintPathSignificant;
+import org.apache.isis.viewer.wicket.model.models.EntityCollectionModel;
+import org.apache.isis.viewer.wicket.ui.ComponentFactory;
+import org.apache.isis.viewer.wicket.ui.ComponentType;
+import org.apache.isis.viewer.wicket.ui.components.collection.count.CollectionCountProvider;
+import org.apache.isis.viewer.wicket.ui.components.collection.selector.CollectionSelectorPanel;
+import org.apache.isis.viewer.wicket.ui.components.collection.selector.CollectionSelectorHelper;
+import org.apache.isis.viewer.wicket.ui.components.collection.selector.CollectionSelectorProvider;
+import org.apache.isis.viewer.wicket.ui.panels.PanelAbstract;
+import org.apache.isis.viewer.wicket.ui.panels.PanelUtil;
+import org.apache.isis.viewer.wicket.ui.util.CssClassAppender;
+import org.apache.isis.viewer.wicket.ui.util.CssClassRemover;
+
+/**
+ * Subscribes to events generated by {@link org.apache.isis.viewer.wicket.ui.components.collection.selector.CollectionSelectorPanel}, rendering the appropriate {@link ComponentType#COLLECTION_CONTENTS}
+ * view for a backing {@link EntityCollectionModel}.
+ */
+public class CollectionContentsMultipleViewsPanel
+ extends PanelAbstract<EntityCollectionModel> implements UiHintPathSignificant, CollectionCountProvider {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final String INVISIBLE_CLASS = "link-selector-panel-invisible";
+ private static final int MAX_NUM_UNDERLYING_VIEWS = 10;
+
+ private static final String UIHINT_VIEW = "view";
+
+ private final ComponentFactory ignoreFactory;
+
+ private final ComponentType componentType;
+ private final String underlyingIdPrefix;
+ private final CollectionSelectorHelper selectorHelper;
+
+ private ComponentFactory selectedComponentFactory;
+ private Component selectedComponent;
+
+ private Component[] underlyingViews;
+ private CollectionSelectorPanel selectorDropdownPanel;
+
+ public CollectionContentsMultipleViewsPanel(
+ final String id,
+ final EntityCollectionModel model,
+ final ComponentFactory ignoreFactory) {
+ super(id, model);
+ this.ignoreFactory = ignoreFactory;
+ this.underlyingIdPrefix = ComponentType.COLLECTION_CONTENTS.toString();
+ this.componentType = ignoreFactory.getComponentType();
+ selectorHelper = new CollectionSelectorHelper(model, getComponentFactoryRegistry(), ignoreFactory);
+
+ }
+
+ /**
+ * Build UI only after added to parent.
+ */
+ public void onInitialize() {
+ super.onInitialize();
+ addUnderlyingViews();
+ }
+
+
+ private void addUnderlyingViews() {
+ final EntityCollectionModel model = getModel();
+
+ final int selected = selectorHelper.honourViewHintElseDefault(getSelectorDropdownPanel());
+ final List<ComponentFactory> componentFactories = selectorHelper.findOtherComponentFactories();
+
+ // create all, hide the one not selected
+ underlyingViews = new Component[MAX_NUM_UNDERLYING_VIEWS];
+ int i = 0;
+ final EntityCollectionModel emptyModel = model.asDummy();
+ for (ComponentFactory componentFactory : componentFactories) {
+ final String underlyingId = underlyingIdPrefix + "-" + i;
+
+ Component underlyingView = componentFactory.createComponent(underlyingId,i==selected? model: emptyModel);
+ underlyingViews[i++] = underlyingView;
+ this.addOrReplace(underlyingView);
+ }
+
+ // hide any unused placeholders
+ while(i<MAX_NUM_UNDERLYING_VIEWS) {
+ String underlyingId = underlyingIdPrefix + "-" + i;
+ permanentlyHide(underlyingId);
+ i++;
+ }
+
+ this.setOutputMarkupId(true);
+
+ for(i=0; i<MAX_NUM_UNDERLYING_VIEWS; i++) {
+ Component component = underlyingViews[i];
+ if(component != null) {
+ if(i != selected) {
+ component.add(new CssClassAppender(INVISIBLE_CLASS));
+ } else {
+ selectedComponent = component;
+ }
+ }
+ }
+ }
+
+ @Override
+ public void onEvent(IEvent<?> event) {
+ super.onEvent(event);
+
+ final IsisUiHintEvent uiHintEvent = IsisEnvelopeEvent.openLetter(event, IsisUiHintEvent.class);
+ if(uiHintEvent == null) {
+ return;
+ }
+ final UiHintContainer uiHintContainer = uiHintEvent.getUiHintContainer();
+
+ int underlyingViewNum = 0;
+ String viewStr = uiHintContainer.getHint(this.getSelectorDropdownPanel(), UIHINT_VIEW);
+
+ List<ComponentFactory> componentFactories = selectorHelper.findOtherComponentFactories();
+
+ if(viewStr != null) {
+ try {
+ int view = Integer.parseInt(viewStr);
+ if(view >= 0 && view < componentFactories.size()) {
+ underlyingViewNum = view;
+ }
+ } catch(NumberFormatException ex) {
+ // ignore
+ }
+ }
+
+ final EntityCollectionModel dummyModel = getModel().asDummy();
+ for(int i=0; i<MAX_NUM_UNDERLYING_VIEWS; i++) {
+ final Component component = underlyingViews[i];
+ if(component == null) {
+ continue;
+ }
+ final boolean isSelected = i == underlyingViewNum;
+ applyCssVisibility(component, isSelected);
+ component.setDefaultModel(isSelected? getModel(): dummyModel);
+ }
+
+ this.selectedComponentFactory = ignoreFactory;
+ this.selectedComponent = underlyingViews[underlyingViewNum];
+
+
+ final AjaxRequestTarget target = uiHintEvent.getTarget();
+ if(target != null) {
+ target.add(this, getSelectorDropdownPanel());
+ }
+
+ }
+
+
+ protected static void applyCssVisibility(final Component component, final boolean visible) {
+ if(component == null) {
+ return;
+ }
+ AttributeModifier modifier = visible ? new CssClassRemover(INVISIBLE_CLASS) : new CssClassAppender(INVISIBLE_CLASS);
+ component.add(modifier);
+ }
+
+ @Override
+ public void renderHead(final IHeaderResponse response) {
+ super.renderHead(response);
+ PanelUtil.renderHead(response, CollectionContentsMultipleViewsPanel.class);
+ }
+
+
+
+ @Override
+ public Integer getCount() {
+ if(selectedComponent instanceof CollectionCountProvider) {
+ final CollectionCountProvider collectionCountProvider = (CollectionCountProvider) selectedComponent;
+ return collectionCountProvider.getCount();
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Searches up the component hierarchy looking for a parent that implements
+ * {@link org.apache.isis.viewer.wicket.ui.components.collection.selector.CollectionSelectorProvider}.
+ * @return
+ */
+ private CollectionSelectorPanel getSelectorDropdownPanel() {
+ Component component = this;
+ while(component != null) {
+ if(component instanceof CollectionSelectorProvider) {
+ final CollectionSelectorPanel selectorDropdownPanel1 = ((CollectionSelectorProvider) component).getSelectorDropdownPanel();
+ if(selectorDropdownPanel1 == null) {
+ throw new IllegalStateException("Found parent that implements HasSelectorDropdownPanel, but no SelectorDropdownPanel available (is null)");
+
+ }
+ return selectorDropdownPanel1;
+ }
+ component = component.getParent();
+ }
+ throw new IllegalStateException("Could not locate parent that implements HasSelectorDropdownPanel");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/92ffe2d2/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/multiple/CollectionContentsMultipleViewsPanelFactory.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/multiple/CollectionContentsMultipleViewsPanelFactory.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/multiple/CollectionContentsMultipleViewsPanelFactory.java
new file mode 100644
index 0000000..53b8092
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/multiple/CollectionContentsMultipleViewsPanelFactory.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 org.apache.isis.viewer.wicket.ui.components.collectioncontents.multiple;
+
+import org.apache.wicket.Component;
+import org.apache.wicket.model.IModel;
+
+import org.apache.isis.viewer.wicket.model.models.EntityCollectionModel;
+import org.apache.isis.viewer.wicket.ui.ComponentFactory;
+import org.apache.isis.viewer.wicket.ui.ComponentFactoryAbstract;
+import org.apache.isis.viewer.wicket.ui.ComponentType;
+
+/**
+ * {@link ComponentFactory} for {@link CollectionContentsMultipleViewsPanel}.
+ */
+public class CollectionContentsMultipleViewsPanelFactory extends ComponentFactoryAbstract {
+
+ private static final long serialVersionUID = 1L;
+
+ public CollectionContentsMultipleViewsPanelFactory() {
+ super(ComponentType.COLLECTION_CONTENTS,
+ CollectionContentsMultipleViewsPanel.class);
+ }
+
+ @Override
+ public ApplicationAdvice appliesTo(final IModel<?> model) {
+ return appliesIf(model instanceof EntityCollectionModel);
+ }
+
+ @Override
+ public Component createComponent(final String id, final IModel<?> model) {
+ final EntityCollectionModel collectionModel = (EntityCollectionModel) model;
+ return new CollectionContentsMultipleViewsPanel(id, collectionModel, this);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/92ffe2d2/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorDropdownPanel.html
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorDropdownPanel.html b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorDropdownPanel.html
deleted file mode 100644
index 8bec51a..0000000
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorDropdownPanel.html
+++ /dev/null
@@ -1,44 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns:wicket="http://wicket.apache.org">
-<body>
-<wicket:panel>
- <div class="linksSelectorPanel">
- <div class="btn-group viewLinks" wicket:id="views">
- <button type="button" class="btn btn-sm btn-info">
- <span wicket:id="viewButtonIcon" class="ViewLinkItem"></span>
- <span wicket:id="viewButtonTitle" class="ViewLinkItemTitle"></span>
- </button>
- <button type="button" class="btn btn-sm btn-info dropdown-toggle" data-toggle="dropdown">
- <span class="caret"></span>
- </button>
- <ul wicket:id="viewList" class="dropdown-menu dropdown-menu-right" role="menu">
- <li wicket:id="viewItem" class="viewItem">
- <a href="#" wicket:id="viewLink">
- <span wicket:id="viewItemIcon" class="ViewLinkItem"></span> <span wicket:id="viewItemTitle" class="ViewLinkItemTitle">[link title]</span>
- </a>
- </li>
- </ul>
- </div>
- </div>
-</wicket:panel>
-</body>
-</html>
http://git-wip-us.apache.org/repos/asf/isis/blob/92ffe2d2/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorDropdownPanel.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorDropdownPanel.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorDropdownPanel.java
deleted file mode 100644
index 37797c5..0000000
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorDropdownPanel.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * 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.viewer.wicket.ui.components.collectioncontents.selector.dropdown;
-
-import de.agilecoders.wicket.core.markup.html.bootstrap.button.Buttons;
-
-import java.util.List;
-import org.apache.wicket.AttributeModifier;
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.ajax.markup.html.AjaxLink;
-import org.apache.wicket.event.Broadcast;
-import org.apache.wicket.markup.ComponentTag;
-import org.apache.wicket.markup.head.IHeaderResponse;
-import org.apache.wicket.markup.html.WebMarkupContainer;
-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.model.IModel;
-import org.apache.wicket.model.Model;
-import org.apache.isis.core.commons.lang.StringExtensions;
-import org.apache.isis.viewer.wicket.model.hints.IsisUiHintEvent;
-import org.apache.isis.viewer.wicket.model.hints.UiHintContainer;
-import org.apache.isis.viewer.wicket.model.hints.UiHintPathSignificant;
-import org.apache.isis.viewer.wicket.model.models.EntityCollectionModel;
-import org.apache.isis.viewer.wicket.ui.CollectionContentsAsFactory;
-import org.apache.isis.viewer.wicket.ui.ComponentFactory;
-import org.apache.isis.viewer.wicket.ui.ComponentType;
-import org.apache.isis.viewer.wicket.ui.panels.PanelAbstract;
-import org.apache.isis.viewer.wicket.ui.panels.PanelUtil;
-import org.apache.isis.viewer.wicket.ui.util.CssClassAppender;
-
-/**
- * Provides a list of links for selecting other views that support
- * {@link org.apache.isis.viewer.wicket.ui.ComponentType#COLLECTION_CONTENTS} with a backing
- * {@link org.apache.isis.viewer.wicket.model.models.EntityCollectionModel}.
- */
-public class CollectionContentsSelectorDropdownPanel
- extends PanelAbstract<EntityCollectionModel> implements UiHintPathSignificant /*, CollectionCountProvider*/ {
-
- private static final long serialVersionUID = 1L;
-
- private static final String ID_VIEWS = "views";
- private static final String ID_VIEW_LIST = "viewList";
- private static final String ID_VIEW_LINK = "viewLink";
- private static final String ID_VIEW_ITEM = "viewItem";
- private static final String ID_VIEW_ITEM_TITLE = "viewItemTitle";
- private static final String ID_VIEW_ITEM_ICON = "viewItemIcon";
-
- private static final String ID_VIEW_BUTTON_TITLE = "viewButtonTitle";
- private static final String ID_VIEW_BUTTON_ICON = "viewButtonIcon";
-
- private final ComponentType componentType;
- private final CollectionContentsSelectorHelper selectorHelper;
-
- private ComponentFactory selectedComponentFactory;
-
- public CollectionContentsSelectorDropdownPanel(final String id, final EntityCollectionModel model, final ComponentFactory ignoreFactory) {
- super(id, model);
- this.componentType = ignoreFactory.getComponentType();
- selectorHelper = new CollectionContentsSelectorHelper(model, getComponentFactoryRegistry(), ignoreFactory);
- }
-
- /**
- * Build UI only after added to parent.
- */
- public void onInitialize() {
- super.onInitialize();
- addDropdown();
- }
-
-
-
- private void addDropdown() {
- final List<ComponentFactory> componentFactories = selectorHelper.findOtherComponentFactories();
- final int selected = selectorHelper.honourViewHintElseDefault(this);
-
- // selector
- if (componentFactories.size() <= 1) {
- permanentlyHide(ID_VIEWS);
- } else {
- final Model<ComponentFactory> componentFactoryModel = new Model<>();
-
- this.selectedComponentFactory = componentFactories.get(selected);
- componentFactoryModel.setObject(this.selectedComponentFactory);
-
- final WebMarkupContainer views = new WebMarkupContainer(ID_VIEWS);
-
- final Label viewButtonTitle = new Label(ID_VIEW_BUTTON_TITLE, "Hidden");
- views.addOrReplace(viewButtonTitle);
-
- final Label viewButtonIcon = new Label(ID_VIEW_BUTTON_ICON, "");
- views.addOrReplace(viewButtonIcon);
-
- final WebMarkupContainer container = new WebMarkupContainer(ID_VIEW_LIST);
-
- views.addOrReplace(container);
- views.setOutputMarkupId(true);
-
- this.setOutputMarkupId(true);
-
- final ListView<ComponentFactory> listView = new ListView<ComponentFactory>(ID_VIEW_ITEM, componentFactories) {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- protected void populateItem(ListItem<ComponentFactory> item) {
-
- final int underlyingViewNum = item.getIndex();
-
- final ComponentFactory componentFactory = item.getModelObject();
- final AbstractLink link = new AjaxLink<Void>(ID_VIEW_LINK) {
- private static final long serialVersionUID = 1L;
- @Override
- public void onClick(AjaxRequestTarget target) {
- CollectionContentsSelectorDropdownPanel linksSelectorPanel = CollectionContentsSelectorDropdownPanel.this;
- linksSelectorPanel.setViewHintAndBroadcast(underlyingViewNum, target);
-
- CollectionContentsSelectorDropdownPanel.this.selectedComponentFactory = componentFactory;
- target.add(CollectionContentsSelectorDropdownPanel.this, views);
- }
-
- @Override
- protected void onComponentTag(ComponentTag tag) {
- super.onComponentTag(tag);
- Buttons.fixDisabledState(this, tag);
- }
- };
-
- IModel<String> title = nameFor(componentFactory);
- Label viewItemTitleLabel = new Label(ID_VIEW_ITEM_TITLE, title);
- link.add(viewItemTitleLabel);
-
- Label viewItemIcon = new Label(ID_VIEW_ITEM_ICON, "");
- link.add(viewItemIcon);
-
- boolean isEnabled = componentFactory != CollectionContentsSelectorDropdownPanel.this.selectedComponentFactory;
- if (!isEnabled) {
- viewButtonTitle.setDefaultModel(title);
- IModel<String> cssClass = cssClassFor(componentFactory, viewButtonIcon);
- viewButtonIcon.add(AttributeModifier.replace("class", "ViewLinkItem " + cssClass.getObject()));
- link.setVisible(false);
- } else {
- IModel<String> cssClass = cssClassFor(componentFactory, viewItemIcon);
- viewItemIcon.add(new CssClassAppender(cssClass));
- }
-
- item.add(link);
- }
-
- private IModel<String> cssClassFor(final ComponentFactory componentFactory, Label viewIcon) {
- IModel<String> cssClass = null;
- if (componentFactory instanceof CollectionContentsAsFactory) {
- CollectionContentsAsFactory collectionContentsAsFactory = (CollectionContentsAsFactory) componentFactory;
- cssClass = collectionContentsAsFactory.getCssClass();
- viewIcon.setDefaultModelObject("");
- viewIcon.setEscapeModelStrings(true);
- }
- if (cssClass == null) {
- String name = componentFactory.getName();
- cssClass = Model.of(StringExtensions.asLowerDashed(name));
- // Small hack: if there is no specific CSS class then we assume that background-image is used
- // the span.ViewItemLink should have some content to show it
- // FIX: find a way to do this with CSS (width and height don't seems to help)
- viewIcon.setDefaultModelObject("     ");
- viewIcon.setEscapeModelStrings(false);
- }
- return cssClass;
- }
-
- private IModel<String> nameFor(final ComponentFactory componentFactory) {
- IModel<String> name = null;
- if (componentFactory instanceof CollectionContentsAsFactory) {
- CollectionContentsAsFactory collectionContentsAsFactory = (CollectionContentsAsFactory) componentFactory;
- name = collectionContentsAsFactory.getTitleLabel();
- }
- if (name == null) {
- name = Model.of(componentFactory.getName());
- }
- return name;
- }
- };
- container.add(listView);
- addOrReplace(views);
- }
- }
-
-
-
- protected void setViewHintAndBroadcast(int viewNum, AjaxRequestTarget target) {
- final UiHintContainer uiHintContainer = getUiHintContainer();
- if(uiHintContainer == null) {
- return;
- }
- uiHintContainer.setHint(CollectionContentsSelectorDropdownPanel.this, CollectionContentsSelectorHelper.UIHINT_VIEW, ""+viewNum);
- send(getPage(), Broadcast.EXACT, new IsisUiHintEvent(uiHintContainer, target));
- }
-
- @Override
- public void renderHead(final IHeaderResponse response) {
- super.renderHead(response);
- PanelUtil.renderHead(response, CollectionContentsSelectorDropdownPanel.class);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/92ffe2d2/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorHelper.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorHelper.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorHelper.java
deleted file mode 100644
index 06eed95..0000000
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorHelper.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * 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.viewer.wicket.ui.components.collectioncontents.selector.dropdown;
-
-import java.util.ArrayList;
-import java.util.List;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Collections2;
-import com.google.common.collect.Lists;
-import org.apache.wicket.Component;
-import org.apache.wicket.model.IModel;
-import org.apache.isis.applib.annotation.Render;
-import org.apache.isis.core.metamodel.facets.members.render.RenderFacet;
-import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
-import org.apache.isis.viewer.wicket.model.hints.UiHintContainer;
-import org.apache.isis.viewer.wicket.model.models.EntityCollectionModel;
-import org.apache.isis.viewer.wicket.ui.ComponentFactory;
-import org.apache.isis.viewer.wicket.ui.ComponentType;
-import org.apache.isis.viewer.wicket.ui.app.registry.ComponentFactoryRegistry;
-import org.apache.isis.viewer.wicket.ui.components.collectioncontents.ajaxtable.CollectionContentsAsAjaxTablePanelFactory;
-import org.apache.isis.viewer.wicket.ui.components.collectioncontents.selector.links.CollectionContentsLinksSelectorPanelFactory;
-import org.apache.isis.viewer.wicket.ui.components.collectioncontents.unresolved.CollectionContentsAsUnresolvedPanelFactory;
-
-public class CollectionContentsSelectorHelper {
-
- static final String UIHINT_VIEW = "view";
- private static final long serialVersionUID = 1L;
-
- private final ComponentType componentType;
- private final ComponentFactoryRegistry componentFactoryRegistry;
- private final EntityCollectionModel model;
- private final ComponentFactory ignoreFactory;
- private final List<ComponentFactory> componentFactories;
-
-
- public CollectionContentsSelectorHelper(
- final EntityCollectionModel model,
- final ComponentFactoryRegistry componentFactoryRegistry,
- final ComponentFactory ignoreFactory) {
- this.componentFactoryRegistry = componentFactoryRegistry;
- this.model = model;
- this.ignoreFactory = ignoreFactory;
- this.componentType = ignoreFactory.getComponentType();
-
- componentFactories = findOtherComponentFactories();
-
- }
-
- public ComponentFactory getComponentFactory() {
- return componentFactoryRegistry.findComponentFactoryElseFailFast(componentType, model);
- }
-
- public List<ComponentFactory> findOtherComponentFactories() {
- final List<ComponentFactory> componentFactories = componentFactoryRegistry.findComponentFactories(componentType, model);
- ArrayList<ComponentFactory> otherFactories = Lists.newArrayList(Collections2.filter(componentFactories, new Predicate<ComponentFactory>() {
- @Override
- public boolean apply(final ComponentFactory input) {
- return input != ignoreFactory && input.getClass() != CollectionContentsLinksSelectorPanelFactory.class;
- }
- }));
- return ordered(otherFactories);
- }
-
- public int honourViewHintElseDefault(final Component component) {
- // honour hints ...
- final UiHintContainer hintContainer = getUiHintContainer(component);
- if(hintContainer != null) {
- String viewStr = hintContainer.getHint(component, UIHINT_VIEW);
- if(viewStr != null) {
- try {
- int view = Integer.parseInt(viewStr);
- if(view >= 0 && view < componentFactories.size()) {
- return view;
- }
- } catch(NumberFormatException ex) {
- // ignore
- }
- }
- }
-
- // ... else default
- int initialFactory = determineInitialFactory();
- if(hintContainer != null) {
- hintContainer.setHint(component, UIHINT_VIEW, ""+initialFactory);
- // don't broadcast (no AjaxRequestTarget, still configuring initial setup)
- }
- return initialFactory;
- }
-
- private static List<ComponentFactory> ordered(List<ComponentFactory> componentFactories) {
- return orderAjaxTableToEnd(componentFactories);
- }
-
- static List<ComponentFactory> orderAjaxTableToEnd(List<ComponentFactory> componentFactories) {
- int ajaxTableIdx = findAjaxTable(componentFactories);
- if(ajaxTableIdx>=0) {
- List<ComponentFactory> orderedFactories = Lists.newArrayList(componentFactories);
- ComponentFactory ajaxTableFactory = orderedFactories.remove(ajaxTableIdx);
- orderedFactories.add(ajaxTableFactory);
- return orderedFactories;
- } else {
- return componentFactories;
- }
- }
-
- private static int findAjaxTable(List<ComponentFactory> componentFactories) {
- for(int i=0; i<componentFactories.size(); i++) {
- if(componentFactories.get(i) instanceof CollectionContentsAsAjaxTablePanelFactory) {
- return i;
- }
- }
- return -1;
- }
-
-
-
-
-
- /**
- * return the index of {@link org.apache.isis.viewer.wicket.ui.components.collectioncontents.unresolved.CollectionContentsAsUnresolvedPanelFactory unresolved panel} if present and not eager loading;
- * else the index of {@link org.apache.isis.viewer.wicket.ui.components.collectioncontents.ajaxtable.CollectionContentsAsAjaxTablePanelFactory ajax table} if present,
- * otherwise first factory.
- */
- protected int determineInitialFactory() {
- if(!hasRenderEagerlyFacet(model)) {
- for(int i=0; i<componentFactories.size(); i++) {
- if(componentFactories.get(i) instanceof CollectionContentsAsUnresolvedPanelFactory) {
- return i;
- }
- }
- }
- int ajaxTableIdx = CollectionContentsSelectorHelper.findAjaxTable(componentFactories);
- if(ajaxTableIdx>=0) {
- return ajaxTableIdx;
- }
- return 0;
- }
-
- private static UiHintContainer getUiHintContainer(final Component component) {
- return UiHintContainer.Util.hintContainerOf(component);
- }
-
-
- private static boolean hasRenderEagerlyFacet(IModel<?> model) {
- if(!(model instanceof EntityCollectionModel)) {
- return false;
- }
- final EntityCollectionModel entityCollectionModel = (EntityCollectionModel) model;
- if(!entityCollectionModel.isParented()) {
- return false;
- }
-
- final OneToManyAssociation collection =
- entityCollectionModel.getCollectionMemento().getCollection();
- RenderFacet renderFacet = collection.getFacet(RenderFacet.class);
- return renderFacet != null && renderFacet.value() == Render.Type.EAGERLY;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/92ffe2d2/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorSelectorDropdownPanel.css
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorSelectorDropdownPanel.css b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorSelectorDropdownPanel.css
deleted file mode 100644
index 8c3902e..0000000
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/dropdown/CollectionContentsSelectorSelectorDropdownPanel.css
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.
- */
-.linksSelectorPanel .viewLinks {
- float:right;
- display:block;
-}
-
-.linksSelectorPanel ul.dropdown-menu {
- min-width: 0;
-}
-
-.linksSelectorPanel ul.dropdown-menu li.viewItem {
- min-width: 0;
-}
-
-.linksSelectorPanel ul.viewList li.viewItem:first-child span {
- border-radius:4px 0 0 4px;
- -moz-border-radius:4px 0 0 4px;
- -webkit-border-radius:4px 0 0 4px;
-}
-
-.linksSelectorPanel ul.viewList li.viewItem:last-child span {
- border-radius:0 4px 4px 0;
- -moz-border-radius:0 4px 4px 0;
- -webkit-border-radius:0 4px 4px 0;
-}
-
-
-.linksSelectorPanel .link-selector-panel-invisible {
- display:none;
-}
-
-.linksSelectorPanel .list-inline {
- margin-left: 0;
-}
-
-.linksSelectorPanel .list-inline li {
- padding-left: 0;
-}
-
-
-.collectionContentsLinksSelectorPanel select {
- margin-bottom: 1em;
-}
[05/23] isis git commit: ISIS-537 Change the name of the theme
chooser cookie to be more inline with the names of the properties
Posted by da...@apache.org.
ISIS-537 Change the name of the theme chooser cookie to be more inline with the names of the properties
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/39027056
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/39027056
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/39027056
Branch: refs/heads/ISIS-939
Commit: 390270568fa2520812414ad892039bb591354187
Parents: 8c0a5ac
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Sat Nov 8 23:38:27 2014 +0200
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Sat Nov 8 23:38:27 2014 +0200
----------------------------------------------------------------------
.../wicket/ui/components/widgets/themepicker/ThemeChooser.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/39027056/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/themepicker/ThemeChooser.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/themepicker/ThemeChooser.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/themepicker/ThemeChooser.java
index bd951c1..7ea8b6c 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/themepicker/ThemeChooser.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/themepicker/ThemeChooser.java
@@ -56,7 +56,7 @@ public class ThemeChooser extends Panel {
/**
* The name of the cookie that stores the last user selection
*/
- private static final String ISIS_THEME_COOKIE_NAME = "isis.themeChooser.theme";
+ private static final String ISIS_THEME_COOKIE_NAME = "isis.viewer.wicket.themes.selected";
/**
* Constructor
[19/23] isis git commit: ISIS-943: Make ObjectContracts more resilient
Posted by da...@apache.org.
ISIS-943: Make ObjectContracts more resilient
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/b1a0f1de
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/b1a0f1de
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/b1a0f1de
Branch: refs/heads/ISIS-939
Commit: b1a0f1de8685661366154b156d50466363804ee8
Parents: 2909e64
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Fri Nov 7 17:12:07 2014 +0000
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Mon Nov 10 10:21:47 2014 +0000
----------------------------------------------------------------------
.../isis/applib/util/ObjectContracts.java | 11 ++-
.../applib/util/ObjectContractsTest_equals.java | 91 ++++++++++++++++++++
2 files changed, 100 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/b1a0f1de/core/applib/src/main/java/org/apache/isis/applib/util/ObjectContracts.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/util/ObjectContracts.java b/core/applib/src/main/java/org/apache/isis/applib/util/ObjectContracts.java
index 3e88c72..281fa52 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/util/ObjectContracts.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/util/ObjectContracts.java
@@ -16,13 +16,11 @@
*/
package org.apache.isis.applib.util;
-import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Comparator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-
import com.google.common.base.Function;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
@@ -73,6 +71,15 @@ public class ObjectContracts {
}
public static boolean equals(Object p, Object q, String propertyNames) {
+ if(p==null && q==null) {
+ return true;
+ }
+ if(p==null || q==null) {
+ return false;
+ }
+ if(p.getClass() != q.getClass()) {
+ return false;
+ }
for (final Clause clause : iterable(propertyNames)) {
final Object pValue = clause.getValueOf(p);
final Object qValue = clause.getValueOf(q);
http://git-wip-us.apache.org/repos/asf/isis/blob/b1a0f1de/core/applib/src/test/java/org/apache/isis/applib/util/ObjectContractsTest_equals.java
----------------------------------------------------------------------
diff --git a/core/applib/src/test/java/org/apache/isis/applib/util/ObjectContractsTest_equals.java b/core/applib/src/test/java/org/apache/isis/applib/util/ObjectContractsTest_equals.java
new file mode 100644
index 0000000..5526e4f
--- /dev/null
+++ b/core/applib/src/test/java/org/apache/isis/applib/util/ObjectContractsTest_equals.java
@@ -0,0 +1,91 @@
+/**
+ * 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.applib.util;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class ObjectContractsTest_equals {
+
+ static class Invoice4 {
+ private static final String KEY_PROPERTIES = "number";
+
+ private String number;
+ public String getNumber() {
+ return number;
+ }
+ public void setNumber(String number) {
+ this.number = number;
+ }
+ @Override
+ public int hashCode() {
+ return ObjectContracts.hashCode(this, KEY_PROPERTIES);
+ }
+ @Override
+ public boolean equals(Object obj) {
+ return ObjectContracts.equals(this, obj, KEY_PROPERTIES);
+ }
+
+ }
+
+ private Invoice4 p;
+ private Invoice4 q;
+ private Invoice4 r;
+ private String x;
+
+ @Before
+ public void setUp() throws Exception {
+ p = new Invoice4();
+ p.setNumber("123");
+ q = new Invoice4();
+ q.setNumber("123");
+ r = new Invoice4();
+ r.setNumber("456");
+
+ x = "this is not an invoice";
+ }
+
+ @Test
+ public void happyCase() throws Exception {
+ assertTrue(ObjectContracts.equals(p, q, "number"));
+ }
+
+ @Test
+ public void nullsAreEqual() throws Exception {
+ assertTrue(ObjectContracts.equals(null, null, "number"));
+ }
+
+ @Test
+ public void notEqualDifferentValues() throws Exception {
+ assertFalse(ObjectContracts.equals(p, r, "number"));
+ }
+
+ @Test
+ public void notEqualDifferentTypes() throws Exception {
+ assertFalse(ObjectContracts.equals(p, x, "number"));
+ }
+
+ @Test
+ public void notEqualNull() throws Exception {
+ assertFalse(ObjectContracts.equals(p, null, "number"));
+ }
+
+
+}
[06/23] isis git commit: ISIS-537 Use Bootstrap grid offset classes
instead of empty columns. Suggested by Bootlint 0.8.0
Posted by da...@apache.org.
ISIS-537 Use Bootstrap grid offset classes instead of empty columns. Suggested by Bootlint 0.8.0
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/f4321aea
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/f4321aea
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/f4321aea
Branch: refs/heads/ISIS-939
Commit: f4321aeaf5de39a016ae57432921651f91cf6e05
Parents: 3902705
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Mon Nov 10 10:26:30 2014 +0200
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Mon Nov 10 10:26:30 2014 +0200
----------------------------------------------------------------------
.../org/apache/isis/viewer/wicket/ui/pages/about/AboutPage.html | 4 +---
.../viewer/wicket/ui/pages/actionprompt/ActionPromptPage.html | 4 +---
.../org/apache/isis/viewer/wicket/ui/pages/home/HomePage.html | 4 +---
3 files changed, 3 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/f4321aea/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/about/AboutPage.html
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/about/AboutPage.html b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/about/AboutPage.html
index 855ca14..eb3a892 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/about/AboutPage.html
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/about/AboutPage.html
@@ -33,11 +33,9 @@
<div>
<div wicket:id="bookmarks"></div>
<div class="row">
- <div class="col-xs-2"></div>
- <div class="col-xs-8">
+ <div class="col-xs-offset-2 col-xs-8">
<div wicket:id="about"></div>
</div>
- <div class="col-xs-2"></div>
</div>
</div>
</div>
http://git-wip-us.apache.org/repos/asf/isis/blob/f4321aea/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/actionprompt/ActionPromptPage.html
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/actionprompt/ActionPromptPage.html b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/actionprompt/ActionPromptPage.html
index 7a9b7cf..4fd4f02 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/actionprompt/ActionPromptPage.html
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/actionprompt/ActionPromptPage.html
@@ -27,11 +27,9 @@
<div class="actionPromptPage">
<div wicket:id="bookmarks"></div>
<div class="row">
- <div class="col-xs-2"></div>
- <div class="col-xs-8">
+ <div class="col-xs-offset-2 col-xs-8">
<div wicket:id="actionPrompt"></div>
</div>
- <div class="col-xs-2"></div>
</div>
</div>
</wicket:extend>
http://git-wip-us.apache.org/repos/asf/isis/blob/f4321aea/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/home/HomePage.html
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/home/HomePage.html b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/home/HomePage.html
index 8c79daa..a63f302 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/home/HomePage.html
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/home/HomePage.html
@@ -28,11 +28,9 @@
<div wicket:id="bookmarks"></div>
<div wicket:id="welcome"></div>
<div class="row">
- <div class="col-xs-2"></div>
- <div class="col-xs-8">
+ <div class="col-xs-offset-2 col-xs-8">
<div wicket:id="actionPrompt"></div>
</div>
- <div class="col-xs-2"></div>
</div>
</div>
</wicket:extend>
[07/23] isis git commit: ISIS-537: removing a TODO:mgrigorov
(comments only)
Posted by da...@apache.org.
ISIS-537: removing a TODO:mgrigorov (comments only)
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/27545b0b
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/27545b0b
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/27545b0b
Branch: refs/heads/ISIS-939
Commit: 27545b0b7882d13f471a76b0c30027ad9ffec131
Parents: f4321ae
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Fri Nov 7 17:14:24 2014 +0000
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Mon Nov 10 10:21:33 2014 +0000
----------------------------------------------------------------------
.../links/CollectionContentsLinksSelectorPanelFactory.java | 5 -----
1 file changed, 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/27545b0b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanelFactory.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanelFactory.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanelFactory.java
index 6dff6d9..a93790e 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanelFactory.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanelFactory.java
@@ -29,12 +29,7 @@ import org.apache.isis.viewer.wicket.ui.ComponentType;
/**
* {@link ComponentFactory} for {@link CollectionContentsLinksSelectorPanel}.
- *
- * <p>
- * Either this class or {@link CollectionContentsDropDownSelectorPanelFactory} should be
- * registered, but not both.
*/
-// TODO mgrigorov: there is no more CollectionContentsDropDownSelectorPanelFactory. Fix the javadoc
public class CollectionContentsLinksSelectorPanelFactory extends ComponentFactoryAbstract {
private static final long serialVersionUID = 1L;
[11/23] isis git commit: ISIS-537: render selector panel-specific CSS
to ensure that unselected views are not shown.
Posted by da...@apache.org.
ISIS-537: render selector panel-specific CSS to ensure that unselected views are not shown.
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/49126416
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/49126416
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/49126416
Branch: refs/heads/ISIS-939
Commit: 49126416efaffabed867565917927ccb11ea6611
Parents: f8a8ea4
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Sun Nov 9 12:17:15 2014 +0000
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Mon Nov 10 10:21:38 2014 +0000
----------------------------------------------------------------------
.../selector/links/CollectionContentsLinksSelectorPanel.java | 4 ++--
.../entity/selector/links/EntityLinksSelectorPanel.java | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/49126416/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java
index d935b64..c68bf71 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/selector/links/CollectionContentsLinksSelectorPanel.java
@@ -60,6 +60,7 @@ import org.apache.isis.viewer.wicket.ui.components.collection.CollectionPanel;
import org.apache.isis.viewer.wicket.ui.components.collectioncontents.ajaxtable.CollectionContentsAsAjaxTablePanelFactory;
import org.apache.isis.viewer.wicket.ui.components.collectioncontents.unresolved.CollectionContentsAsUnresolvedPanelFactory;
import org.apache.isis.viewer.wicket.ui.panels.PanelAbstract;
+import org.apache.isis.viewer.wicket.ui.panels.PanelUtil;
import org.apache.isis.viewer.wicket.ui.util.Components;
import org.apache.isis.viewer.wicket.ui.util.CssClassAppender;
import org.apache.isis.viewer.wicket.ui.util.CssClassRemover;
@@ -419,8 +420,7 @@ public class CollectionContentsLinksSelectorPanel
@Override
public void renderHead(final IHeaderResponse response) {
super.renderHead(response);
- // TODO: mgrigorov remove this stuff once happy no longer needed at all.
- // PanelUtil.renderHead(response, CollectionContentsLinksSelectorPanel.class);
+ PanelUtil.renderHead(response, CollectionContentsLinksSelectorPanel.class);
}
http://git-wip-us.apache.org/repos/asf/isis/blob/49126416/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/selector/links/EntityLinksSelectorPanel.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/selector/links/EntityLinksSelectorPanel.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/selector/links/EntityLinksSelectorPanel.java
index 2adb5ca..459b692 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/selector/links/EntityLinksSelectorPanel.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/selector/links/EntityLinksSelectorPanel.java
@@ -53,6 +53,7 @@ import org.apache.isis.viewer.wicket.ui.ComponentFactory;
import org.apache.isis.viewer.wicket.ui.ComponentType;
import org.apache.isis.viewer.wicket.ui.components.additionallinks.AdditionalLinksPanel;
import org.apache.isis.viewer.wicket.ui.panels.PanelAbstract;
+import org.apache.isis.viewer.wicket.ui.panels.PanelUtil;
import org.apache.isis.viewer.wicket.ui.util.Components;
import org.apache.isis.viewer.wicket.ui.util.CssClassAppender;
import org.apache.isis.viewer.wicket.ui.util.CssClassRemover;
@@ -384,8 +385,7 @@ public class EntityLinksSelectorPanel extends PanelAbstract<EntityModel> impleme
@Override
public void renderHead(final IHeaderResponse response) {
super.renderHead(response);
- // TODO: mgrigorov remove this stuff once happy no longer needed at all.
- // PanelUtil.renderHead(response, LinksSelectorPanelAbstract.class);
+ PanelUtil.renderHead(response, EntityLinksSelectorPanel.class);
}