Updated Branches: refs/heads/master 5adf0eb13 -> 7c6cce876
ISIS-403: improved bookmarking in Wicket viewer @Bookmarkable annotation Bookmark Panel moved to side. Project: http://git-wip-us.apache.org/repos/asf/isis/repo Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/7c6cce87 Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/7c6cce87 Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/7c6cce87 Branch: refs/heads/master Commit: 7c6cce8761d401fb9a15203bd7dda9c95b09e6fb Parents: 5adf0eb Author: Dan Haywood <[email protected]> Authored: Fri May 10 06:52:50 2013 +0200 Committer: Dan Haywood <[email protected]> Committed: Fri May 10 06:52:50 2013 +0200 ---------------------------------------------------------------------- .../viewer/wicket/model/models/ActionModel.java | 8 +- .../wicket/model/models/BookmarkedPagesModel.java | 57 ++++++++++- .../bookmarkedpages/BookmarkedPagesPanel.css | 69 +++++++++--- .../bookmarkedpages/BookmarkedPagesPanel.html | 32 ++++--- .../bookmarkedpages/BookmarkedPagesPanel.java | 21 +++- .../ui/components/bookmarkedpages/slide-panel.js | 43 ++++++++ .../CollectionContentsSortableDataProvider.java | 1 + .../isis/viewer/wicket/ui/pages/PageAbstract.css | 1 + .../viewer/wicket/ui/pages/entity/EntityPage.java | 17 +++- .../selector/links/LinksSelectorPanelAbstract.css | 4 + .../selector/links/LinksSelectorPanelAbstract.html | 14 +--- .../selector/links/LinksSelectorPanelAbstract.java | 3 - .../isis/applib/annotation/BookmarkPolicy.java | 16 +++ .../isis/applib/annotation/Bookmarkable.java | 41 +++++++ .../object/bookmarkable/BookmarkPolicyFacet.java | 32 ++++++ .../bookmarkable/BookmarkPolicyFacetAbstract.java | 48 +++++++++ .../bookmarkable/BookmarkPolicyFacetFallback.java | 32 ++++++ ...okmarkPolicyFacetViaBookmarkableAnnotation.java | 32 ++++++ .../BookmarkableAnnotationFacetFactory.java | 48 +++++++++ .../annotation/TitleFacetViaTitleAnnotation.java | 2 +- .../dflt/ProgrammingModelFacetsJava5.java | 2 + .../AggregatedAnnotationFacetFactoryTest.java | 2 +- .../BookmarkableAnnotationFacetFactoryTest.java | 83 +++++++++++++++ .../src/main/webapp/WEB-INF/isis.properties | 14 +++ 24 files changed, 565 insertions(+), 57 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/isis/blob/7c6cce87/component/viewer/wicket/model/src/main/java/org/apache/isis/viewer/wicket/model/models/ActionModel.java ---------------------------------------------------------------------- diff --git a/component/viewer/wicket/model/src/main/java/org/apache/isis/viewer/wicket/model/models/ActionModel.java b/component/viewer/wicket/model/src/main/java/org/apache/isis/viewer/wicket/model/models/ActionModel.java index c36f96b..eba7d23 100644 --- a/component/viewer/wicket/model/src/main/java/org/apache/isis/viewer/wicket/model/models/ActionModel.java +++ b/component/viewer/wicket/model/src/main/java/org/apache/isis/viewer/wicket/model/models/ActionModel.java @@ -521,6 +521,11 @@ public class ActionModel extends BookmarkableModel<ObjectAdapter> { } } + public boolean hasSafeActionSemantics() { + return getActionMemento().getAction().getSemantics() == ActionSemantics.Of.SAFE; + } + + ////////////////////////////////////////////////// // Dependencies (from context) ////////////////////////////////////////////////// @@ -529,9 +534,6 @@ public class ActionModel extends BookmarkableModel<ObjectAdapter> { return IsisContext.getOidMarshaller(); } - public boolean hasSafeActionSemantics() { - return getActionMemento().getAction().getSemantics() == ActionSemantics.Of.SAFE; - } } http://git-wip-us.apache.org/repos/asf/isis/blob/7c6cce87/component/viewer/wicket/model/src/main/java/org/apache/isis/viewer/wicket/model/models/BookmarkedPagesModel.java ---------------------------------------------------------------------- diff --git a/component/viewer/wicket/model/src/main/java/org/apache/isis/viewer/wicket/model/models/BookmarkedPagesModel.java b/component/viewer/wicket/model/src/main/java/org/apache/isis/viewer/wicket/model/models/BookmarkedPagesModel.java index 968fdbc..d755c34 100644 --- a/component/viewer/wicket/model/src/main/java/org/apache/isis/viewer/wicket/model/models/BookmarkedPagesModel.java +++ b/component/viewer/wicket/model/src/main/java/org/apache/isis/viewer/wicket/model/models/BookmarkedPagesModel.java @@ -19,6 +19,8 @@ package org.apache.isis.viewer.wicket.model.models; +import java.util.Collections; +import java.util.Comparator; import java.util.Iterator; import java.util.List; @@ -27,9 +29,12 @@ import com.google.common.collect.Iterators; import com.google.common.collect.Lists; import org.apache.wicket.request.mapper.parameter.PageParameters; -import org.apache.wicket.util.string.StringValue; +import org.apache.isis.core.metamodel.adapter.oid.OidMarshaller; import org.apache.isis.core.metamodel.adapter.oid.RootOid; +import org.apache.isis.core.metamodel.spec.ObjectSpecId; +import org.apache.isis.core.metamodel.spec.ObjectSpecification; +import org.apache.isis.core.metamodel.spec.SpecificationLoader; import org.apache.isis.core.runtime.system.context.IsisContext; import org.apache.isis.viewer.wicket.model.mementos.PageParameterNames; @@ -83,9 +88,45 @@ public class BookmarkedPagesModel extends ModelAbstract<List<PageParameters>> im // if get here, then didn't find. list.add(candidatePP); + Collections.sort(list, new Comparator<PageParameters>() { + + @Override + public int compare(PageParameters o1, PageParameters o2) { + PageType pageType1 = PageParameterNames.PAGE_TYPE.getEnumFrom(o1, PageType.class); + PageType pageType2 = PageParameterNames.PAGE_TYPE.getEnumFrom(o2, PageType.class); + + final int pageTypeComparison = pageType1.compareTo(pageType2); + if(pageTypeComparison != 0) { + return pageTypeComparison; + } + + if(pageType1 == PageType.ENTITY) { + // sort by entity type + final String className1 = classNameOf(o1); + final String className2 = classNameOf(o2); + + final int classNameComparison = className1.compareTo(className2); + if(classNameComparison != 0) { + return classNameComparison; + } + } + String title1 = PageParameterNames.PAGE_TITLE.getStringFrom(o1); + String title2 = PageParameterNames.PAGE_TITLE.getStringFrom(o2); + return title1.compareTo(title2); + } + + private String classNameOf(PageParameters o1) { + String oidStr1 = PageParameterNames.OBJECT_OID.getStringFrom(o1); + RootOid oid1 = getOidMarshaller().unmarshal(oidStr1, RootOid.class); + ObjectSpecId objectSpecId1 = oid1.getObjectSpecId(); + final String className1 = getSpecificationLoader().lookupBySpecId(objectSpecId1).getIdentifier().getClassName(); + return className1; + } + }); current = candidatePP; } + @Override protected List<PageParameters> load() { return list; @@ -120,4 +161,18 @@ public class BookmarkedPagesModel extends ModelAbstract<List<PageParameters>> im return list.isEmpty(); } + + + ////////////////////////////////////////////////// + // Dependencies (from context) + ////////////////////////////////////////////////// + + protected OidMarshaller getOidMarshaller() { + return IsisContext.getOidMarshaller(); + } + + protected SpecificationLoader getSpecificationLoader() { + return IsisContext.getSpecificationLoader(); + } + } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/isis/blob/7c6cce87/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/bookmarkedpages/BookmarkedPagesPanel.css ---------------------------------------------------------------------- diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/bookmarkedpages/BookmarkedPagesPanel.css b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/bookmarkedpages/BookmarkedPagesPanel.css index 976e879..f94d1de 100644 --- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/bookmarkedpages/BookmarkedPagesPanel.css +++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/bookmarkedpages/BookmarkedPagesPanel.css @@ -21,30 +21,30 @@ font-size: 0.7em; text-transform:uppercase; font-weight:bold; - float:left; width:100%; margin-bottom:5px; } .bookmarkedPagesPanel .bookmarkedPagesList { - display: inline; + margin-top:30px; + } .bookmarkedPagesPanel .bookmarkedPageItem { - display: inline; + margin-top:10px; + margin-bottom:10px; } .bookmarkedPagesPanel span.bookmarkedPageImageAndTitle { margin-right: 5px; margin-bottom:5px; - float:left; border-radius:4px; -moz-border-radius:4px; -webkit-border-radius:4px; background-color:#F0EFEA; - padding:1px 6px 1px 6px; + padding:10px 10px 3px 10px; } .bookmarkedPagesPanel span.bookmarkedPageImageAndTitle:hover { @@ -52,21 +52,21 @@ } .bookmarkedPagesPanel .bookmarkedPagesList a img.bookmarkedPageImage { - float:left; + /*float:left;*/ background-color: transparent; width: 16px; height: 16px; - padding:3px 0px 0px 3px; + /*padding:3px 0px 0px 3px;*/ } .bookmarkedPagesPanel .bookmarkedPagesList span.bookmarkedPageTitle { - float:left; - display:block; font-style:normal !important; - padding:3px 0px 0px 3px; + + vertical-align: top; + padding-left: 5px; } -.bookmarkedPagesPanel .bookmarkedPagesList a span.bookmarkedPageTitle { +.bookmarkedPagesPanel span.bookmarkedPageTitle { background-color:#F0EFEA; } @@ -76,20 +76,55 @@ } .bookmarkedPagesPanel .clearBookmarks { - display: inline; color: rgb(128,0,0); } .bookmarkedPagesPanel .clearBookmarks { - background: url('images/icon_clear.png') no-repeat center center transparent !important; border-radius: 4px 4px 4px 4px; color: #46413B; display: block; - float: left; font-style: normal !important; - margin-bottom: 5px; + margin-top: 30px; + margin-bottom: 10px; margin-right: 5px; - padding:3px 8px 3px 8px; - text-indent: -999em; + margin-left: 10px; } +.bookmarkedPagesPanel .currentBookmark span.bookmarkedPageImageAndTitle, +.bookmarkedPagesPanel .currentBookmark span.bookmarkedPageTitle { + background-color:#FFFFFF; +} + + +.showPanelTab { + border-radius: 0px 8px 8px 0px; + width:10px; + height:720px; + position:fixed; + left:0px; + top:120px; + display:block; + cursor:pointer; + background-color: #40C0CB; + z-index: 2; + + text-transform:uppercase; + font-weight:bold; +} + +#panel { + border-radius: 0px 8px 8px 0px; + position:fixed; + left:0px; + top:80px; + background-color:#F0EFEA; + height:800px; + width:0;/*new line*/ + z-index: 1; +} +#panel .content { + width:290px; + margin-left:30px; + + display: none; +} http://git-wip-us.apache.org/repos/asf/isis/blob/7c6cce87/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/bookmarkedpages/BookmarkedPagesPanel.html ---------------------------------------------------------------------- diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/bookmarkedpages/BookmarkedPagesPanel.html b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/bookmarkedpages/BookmarkedPagesPanel.html index d3205f9..221c4ea 100644 --- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/bookmarkedpages/BookmarkedPagesPanel.html +++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/bookmarkedpages/BookmarkedPagesPanel.html @@ -24,19 +24,25 @@ lang="en"> <body> <wicket:panel> - <div id="bookmarkedPages" class="bookmarkedPagesPanel bookmarkedPagesComponentType"> - <ul wicket:id="bookmarkList" class="bookmarkedPagesList"> - <li wicket:id="bookmarkedPageItem" class="bookmarkedPageItem"> - <a href="#" wicket:id="bookmarkedPageLink"> - <span class="bookmarkedPageImageAndTitle"> - <img wicket:id="bookmarkedPageImage" class="bookmarkedPageImage"/> - <span wicket:id="bookmarkedPageTitle" class="bookmarkedPageTitle">[link title]</span> - </span> - </a> - </li> - </ul> - <a href="#" wicket:id="clearBookmarks" class="clearBookmarks" title="Clear Bookmarks">clear</a> - </div> + <div class="showPanelTab"> + </div> + <div id="panel"> <!--the hidden panel --> + <div class="content"> + <div id="bookmarkedPages" class="bookmarkedPagesPanel bookmarkedPagesComponentType"> + <a href="#" wicket:id="clearBookmarks" class="clearBookmarks" title="Clear Bookmarks">clear</a> + <ul wicket:id="bookmarkList" class="bookmarkedPagesList"> + <li wicket:id="bookmarkedPageItem" class="bookmarkedPageItem"> + <a href="#" wicket:id="bookmarkedPageLink"> + <span class="bookmarkedPageImageAndTitle"> + <img wicket:id="bookmarkedPageImage" class="bookmarkedPageImage"/> + <span wicket:id="bookmarkedPageTitle" class="bookmarkedPageTitle">[link title]</span> + </span> + </a> + </li> + </ul> + </div> + </div> + </div> </wicket:panel> </body> </html> http://git-wip-us.apache.org/repos/asf/isis/blob/7c6cce87/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/bookmarkedpages/BookmarkedPagesPanel.java ---------------------------------------------------------------------- diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/bookmarkedpages/BookmarkedPagesPanel.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/bookmarkedpages/BookmarkedPagesPanel.java index 5eb7a69..558c310 100644 --- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/bookmarkedpages/BookmarkedPagesPanel.java +++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/bookmarkedpages/BookmarkedPagesPanel.java @@ -24,6 +24,8 @@ import com.google.inject.Inject; import org.apache.wicket.Page; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.markup.html.AjaxLink; +import org.apache.wicket.markup.head.IHeaderResponse; +import org.apache.wicket.markup.head.JavaScriptReferenceHeaderItem; import org.apache.wicket.markup.html.WebMarkupContainer; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.image.Image; @@ -31,6 +33,7 @@ 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.request.mapper.parameter.PageParameters; +import org.apache.wicket.request.resource.JavaScriptResourceReference; import org.apache.wicket.request.resource.ResourceReference; import org.apache.isis.core.metamodel.adapter.oid.RootOid; @@ -44,6 +47,7 @@ import org.apache.isis.viewer.wicket.model.models.ImageResourceCache; import org.apache.isis.viewer.wicket.model.models.PageType; import org.apache.isis.viewer.wicket.ui.pages.PageClassRegistry; import org.apache.isis.viewer.wicket.ui.panels.PanelAbstract; +import org.apache.isis.viewer.wicket.ui.util.CssClassAppender; import org.apache.isis.viewer.wicket.ui.util.Links; public class BookmarkedPagesPanel extends PanelAbstract<BookmarkedPagesModel> { @@ -59,6 +63,8 @@ public class BookmarkedPagesPanel extends PanelAbstract<BookmarkedPagesModel> { private static final String CLEAR_BOOKMARKS = "clearBookmarks"; + private static final JavaScriptResourceReference SLIDE_PANEL_JS = new JavaScriptResourceReference(BookmarkedPagesPanel.class, "slide-panel.js"); + @Inject private PageClassRegistry pageClassRegistry; @@ -69,7 +75,13 @@ public class BookmarkedPagesPanel extends PanelAbstract<BookmarkedPagesModel> { private void buildGui() { - final WebMarkupContainer container = new WebMarkupContainer(ID_BOOKMARK_LIST); + final WebMarkupContainer container = new WebMarkupContainer(ID_BOOKMARK_LIST) { + private static final long serialVersionUID = 1L; + @Override + public void renderHead(IHeaderResponse response) { + response.render(JavaScriptReferenceHeaderItem.forReference(SLIDE_PANEL_JS)); + } + }; // allow to be updated by AjaxLink container.setOutputMarkupId(true); add(container); @@ -106,9 +118,12 @@ public class BookmarkedPagesPanel extends PanelAbstract<BookmarkedPagesModel> { link.addOrReplace(image); String title = BookmarkedPagesModel.titleFrom(pageParameters); - link.add(new Label(ID_BOOKMARKED_PAGE_TITLE, title)); - + final Label label = new Label(ID_BOOKMARKED_PAGE_TITLE, title); + link.add(label); item.add(link); + if(bookmarkedPagesModel.isCurrent(pageParameters)) { + item.add(new CssClassAppender("currentBookmark")); + } } }; container.add(listView); http://git-wip-us.apache.org/repos/asf/isis/blob/7c6cce87/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/bookmarkedpages/slide-panel.js ---------------------------------------------------------------------- diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/bookmarkedpages/slide-panel.js b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/bookmarkedpages/slide-panel.js new file mode 100644 index 0000000..a8e4c9d --- /dev/null +++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/bookmarkedpages/slide-panel.js @@ -0,0 +1,43 @@ +/* + * 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. + */ +$(document).ready(function(){ + + $('.showPanelTab').mouseenter( + function(){ + $('#panel').stop().animate( + {width:"400px", opacity:0.95}, 250, + function() { + $('.content').fadeIn('125'); + } + ); + $('.showPanelTab').animate({opacity: 0.5}); + } + ); + + $('#panel').mouseleave( + function(){ + $('.content').fadeOut('125', + function() { + $('#panel').stop().animate({width:"0", opacity:0.1}, 125); + } + ); + $('.showPanelTab').animate({opacity: 1.0}); + } + ); +}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/isis/blob/7c6cce87/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/CollectionContentsSortableDataProvider.java ---------------------------------------------------------------------- diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/CollectionContentsSortableDataProvider.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/CollectionContentsSortableDataProvider.java index aefdae1..843476e 100644 --- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/CollectionContentsSortableDataProvider.java +++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/CollectionContentsSortableDataProvider.java @@ -66,4 +66,5 @@ public class CollectionContentsSortableDataProvider extends SortableDataProvider model.detach(); } + } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/isis/blob/7c6cce87/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/PageAbstract.css ---------------------------------------------------------------------- diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/PageAbstract.css b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/PageAbstract.css index efd8544..5980c52 100644 --- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/PageAbstract.css +++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/PageAbstract.css @@ -832,3 +832,4 @@ div#jGrowl div.jGrowl-closer { .properties .property .isisBlobPanel .additionalLinkList { padding-top: 0px; } + http://git-wip-us.apache.org/repos/asf/isis/blob/7c6cce87/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/entity/EntityPage.java ---------------------------------------------------------------------- diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/entity/EntityPage.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/entity/EntityPage.java index 70aa076..06b6d1b 100644 --- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/entity/EntityPage.java +++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/entity/EntityPage.java @@ -23,9 +23,13 @@ import org.apache.wicket.authroles.authorization.strategies.role.annotations.Aut import org.apache.wicket.markup.html.link.BookmarkablePageLink; import org.apache.wicket.request.mapper.parameter.PageParameters; +import org.apache.isis.applib.annotation.BookmarkPolicy; import org.apache.isis.core.metamodel.adapter.ObjectAdapter; import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager.ConcurrencyChecking; import org.apache.isis.core.metamodel.adapter.version.ConcurrencyException; +import org.apache.isis.core.metamodel.facets.object.bookmarkable.BookmarkPolicyFacet; +import org.apache.isis.core.metamodel.spec.ObjectSpecId; +import org.apache.isis.core.metamodel.spec.ObjectSpecification; import org.apache.isis.viewer.wicket.model.models.EntityModel; import org.apache.isis.viewer.wicket.ui.ComponentType; import org.apache.isis.viewer.wicket.ui.pages.PageAbstract; @@ -49,7 +53,7 @@ public class EntityPage extends PageAbstract { this.model = new EntityModel(pageParameters); addChildComponents(model); - bookmarkPage(model); + bookmarkIfBookmarkable(model); addBookmarkedPages(); } @@ -67,10 +71,19 @@ public class EntityPage extends PageAbstract { model.setException(exIfAny); addChildComponents(model); - bookmarkPage(model); + bookmarkIfBookmarkable(model); addBookmarkedPages(); } + protected void bookmarkIfBookmarkable(EntityModel model) { + final ObjectSpecId specId = model.getObjectAdapterMemento().getObjectSpecId(); + final ObjectSpecification objectSpec = getSpecificationLoader().lookupBySpecId(specId); + final BookmarkPolicyFacet facet = objectSpec.getFacet(BookmarkPolicyFacet.class); + if(facet != null && facet.value() == BookmarkPolicy.ROOT) { + bookmarkPage(model); + } + } + /** * A rather crude way of intercepting the redirect-and-post strategy. http://git-wip-us.apache.org/repos/asf/isis/blob/7c6cce87/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 16a4a82..84eb141 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 @@ -111,4 +111,8 @@ a span.ViewLinkItem.table { .linksSelectorPanel .link-selector-panel-invisible { display:none; +} + +.linksSelectorPanel ul.additionalLinkList { + margin-bottom:10px; } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/isis/blob/7c6cce87/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 index b61bc8d..58817f0 100644 --- 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 @@ -32,19 +32,7 @@ </ul> </span> <span wicket:id="additionalLinks"/> - <!-- - <span xwicket:id="additionalLinks" class="additionalLinks"> - <ul xwicket:id="additionalLinkList" class="additionalLinkList"> - <li xwicket:id="additionalLinkItem" class="additionalLinkItem"> - <a href="#" xwicket:id="additionalLink"> - <span xwicket:id="additionalLinkTitle" class="additionalLinkItem">[link title]</span> - </a> - </li> - </ul> - </span> - --> - - <br class="clear"/> + <span class="clear"/> <div class="views"> <wicket:child/> http://git-wip-us.apache.org/repos/asf/isis/blob/7c6cce87/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 c21a016..4c9d8ea 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 @@ -60,10 +60,7 @@ public abstract class LinksSelectorPanelAbstract<T extends IModel<?>> extends Pa private static final int MAX_NUM_UNDERLYING_VIEWS = 10; private static final String ID_ADDITIONAL_LINKS = "additionalLinks"; - private static final String ID_ADDITIONAL_LINK_LIST = "additionalLinkList"; public static final String ID_ADDITIONAL_LINK = "additionalLink"; - private static final String ID_ADDITIONAL_LINK_ITEM = "additionalLinkItem"; - private static final String ID_ADDITIONAL_LINK_TITLE = "additionalLinkTitle"; private static final String ID_VIEWS = "views"; private static final String ID_VIEW_LIST = "viewList"; http://git-wip-us.apache.org/repos/asf/isis/blob/7c6cce87/core/applib/src/main/java/org/apache/isis/applib/annotation/BookmarkPolicy.java ---------------------------------------------------------------------- diff --git a/core/applib/src/main/java/org/apache/isis/applib/annotation/BookmarkPolicy.java b/core/applib/src/main/java/org/apache/isis/applib/annotation/BookmarkPolicy.java new file mode 100644 index 0000000..2edd6cd --- /dev/null +++ b/core/applib/src/main/java/org/apache/isis/applib/annotation/BookmarkPolicy.java @@ -0,0 +1,16 @@ +package org.apache.isis.applib.annotation; + +public enum BookmarkPolicy { + /** + * Can be bookmarked, and is a top-level 'root' (or parent) bookmark. + */ + ROOT, + /** + * Can be bookmarked, but only as a child or some other parent/root bookmark + */ + AS_CHILD, + /** + * An unimportant entity that should never be bookmarked. + */ + NEVER +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/isis/blob/7c6cce87/core/applib/src/main/java/org/apache/isis/applib/annotation/Bookmarkable.java ---------------------------------------------------------------------- diff --git a/core/applib/src/main/java/org/apache/isis/applib/annotation/Bookmarkable.java b/core/applib/src/main/java/org/apache/isis/applib/annotation/Bookmarkable.java new file mode 100644 index 0000000..6b6f6e0 --- /dev/null +++ b/core/applib/src/main/java/org/apache/isis/applib/annotation/Bookmarkable.java @@ -0,0 +1,41 @@ +/* + * 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.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Indicates the policy by which the entity can be bookmarked. + * + * <p> + * Three policies are defined, which control how bookmarked entities are organized. + * + */ +@Inherited +@Target({ ElementType.TYPE }) +@Retention(RetentionPolicy.RUNTIME) +public @interface Bookmarkable { + + BookmarkPolicy value() default BookmarkPolicy.ROOT; +} http://git-wip-us.apache.org/repos/asf/isis/blob/7c6cce87/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/bookmarkable/BookmarkPolicyFacet.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/bookmarkable/BookmarkPolicyFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/bookmarkable/BookmarkPolicyFacet.java new file mode 100644 index 0000000..1ef3769 --- /dev/null +++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/bookmarkable/BookmarkPolicyFacet.java @@ -0,0 +1,32 @@ +/* + * 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.core.metamodel.facets.object.bookmarkable; + + +import org.apache.isis.applib.annotation.BookmarkPolicy; +import org.apache.isis.applib.annotation.Bookmarkable; +import org.apache.isis.core.metamodel.facets.SingleValueFacet; + + +/** + * Corresponds to annotating the class with the {@link Bookmarkable} annotation. + */ +public interface BookmarkPolicyFacet extends SingleValueFacet<BookmarkPolicy> { + +} http://git-wip-us.apache.org/repos/asf/isis/blob/7c6cce87/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/bookmarkable/BookmarkPolicyFacetAbstract.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/bookmarkable/BookmarkPolicyFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/bookmarkable/BookmarkPolicyFacetAbstract.java new file mode 100644 index 0000000..58f74db --- /dev/null +++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/bookmarkable/BookmarkPolicyFacetAbstract.java @@ -0,0 +1,48 @@ +/* + * 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.core.metamodel.facets.object.bookmarkable; + + +import org.apache.isis.applib.annotation.BookmarkPolicy; +import org.apache.isis.core.metamodel.facetapi.Facet; +import org.apache.isis.core.metamodel.facetapi.FacetAbstract; +import org.apache.isis.core.metamodel.facetapi.FacetHolder; + + +public abstract class BookmarkPolicyFacetAbstract extends FacetAbstract implements + BookmarkPolicyFacet { + + + public static Class<? extends Facet> type() { + return BookmarkPolicyFacet.class; + } + + private final BookmarkPolicy bookmarkPolicy; + + public BookmarkPolicyFacetAbstract(FacetHolder facetHolder, BookmarkPolicy bookmarkPolicy) { + super(BookmarkPolicyFacetAbstract.type(), facetHolder, Derivation.NOT_DERIVED); + this.bookmarkPolicy = bookmarkPolicy; + } + + @Override + public BookmarkPolicy value() { + return bookmarkPolicy; + } + +} http://git-wip-us.apache.org/repos/asf/isis/blob/7c6cce87/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/bookmarkable/BookmarkPolicyFacetFallback.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/bookmarkable/BookmarkPolicyFacetFallback.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/bookmarkable/BookmarkPolicyFacetFallback.java new file mode 100644 index 0000000..3a9dfaa --- /dev/null +++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/bookmarkable/BookmarkPolicyFacetFallback.java @@ -0,0 +1,32 @@ +/* + * 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.core.metamodel.facets.object.bookmarkable; + +import org.apache.isis.applib.annotation.BookmarkPolicy; +import org.apache.isis.core.metamodel.facetapi.FacetHolder; + + +public class BookmarkPolicyFacetFallback extends BookmarkPolicyFacetAbstract { + + public BookmarkPolicyFacetFallback(FacetHolder facetHolder) { + super(facetHolder, BookmarkPolicy.NEVER); + } + + +} http://git-wip-us.apache.org/repos/asf/isis/blob/7c6cce87/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/bookmarkable/BookmarkPolicyFacetViaBookmarkableAnnotation.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/bookmarkable/BookmarkPolicyFacetViaBookmarkableAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/bookmarkable/BookmarkPolicyFacetViaBookmarkableAnnotation.java new file mode 100644 index 0000000..aa65c6b --- /dev/null +++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/bookmarkable/BookmarkPolicyFacetViaBookmarkableAnnotation.java @@ -0,0 +1,32 @@ +/* + * 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.core.metamodel.facets.object.bookmarkable; + +import org.apache.isis.applib.annotation.BookmarkPolicy; +import org.apache.isis.core.metamodel.facetapi.FacetHolder; + + +public class BookmarkPolicyFacetViaBookmarkableAnnotation extends BookmarkPolicyFacetAbstract { + + public BookmarkPolicyFacetViaBookmarkableAnnotation(FacetHolder facetHolder, BookmarkPolicy bookmarkPolicy) { + super(facetHolder, bookmarkPolicy); + } + + +} http://git-wip-us.apache.org/repos/asf/isis/blob/7c6cce87/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/object/bookmarkable/annotation/BookmarkableAnnotationFacetFactory.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/object/bookmarkable/annotation/BookmarkableAnnotationFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/object/bookmarkable/annotation/BookmarkableAnnotationFacetFactory.java new file mode 100644 index 0000000..71574d6 --- /dev/null +++ b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/object/bookmarkable/annotation/BookmarkableAnnotationFacetFactory.java @@ -0,0 +1,48 @@ +/* + * 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.core.progmodel.facets.object.bookmarkable.annotation; + +import org.apache.isis.applib.annotation.Bookmarkable; +import org.apache.isis.core.metamodel.facetapi.FacetHolder; +import org.apache.isis.core.metamodel.facetapi.FacetUtil; +import org.apache.isis.core.metamodel.facetapi.FeatureType; +import org.apache.isis.core.metamodel.facets.Annotations; +import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract; +import org.apache.isis.core.metamodel.facets.object.bookmarkable.BookmarkPolicyFacet; +import org.apache.isis.core.metamodel.facets.object.bookmarkable.BookmarkPolicyFacetFallback; +import org.apache.isis.core.metamodel.facets.object.bookmarkable.BookmarkPolicyFacetViaBookmarkableAnnotation; + +public class BookmarkableAnnotationFacetFactory extends FacetFactoryAbstract { + + public BookmarkableAnnotationFacetFactory() { + super(FeatureType.OBJECTS_ONLY); + } + + @Override + public void process(final ProcessClassContext processClassContext) { + final Bookmarkable annotation = Annotations.getAnnotation(processClassContext.getCls(), Bookmarkable.class); + FacetUtil.addFacet(create(annotation, processClassContext.getFacetHolder())); + } + + private BookmarkPolicyFacet create(final Bookmarkable annotation, final FacetHolder holder) { + return annotation == null ? new BookmarkPolicyFacetFallback(holder) : new BookmarkPolicyFacetViaBookmarkableAnnotation(holder, annotation.value()); + } + +} http://git-wip-us.apache.org/repos/asf/isis/blob/7c6cce87/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/object/title/annotation/TitleFacetViaTitleAnnotation.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/object/title/annotation/TitleFacetViaTitleAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/object/title/annotation/TitleFacetViaTitleAnnotation.java index b8ca514..dd690a6 100644 --- a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/object/title/annotation/TitleFacetViaTitleAnnotation.java +++ b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/object/title/annotation/TitleFacetViaTitleAnnotation.java @@ -128,7 +128,7 @@ public class TitleFacetViaTitleAnnotation extends TitleFacetAbstract { final ObjectAdapter titlePartAdapter = adapterManager.adapterFor(titlePart); if(Objects.equal(contextAdapter, titlePartAdapter)) { continue; - } + } String title = titleOf(titlePartAdapter); if (Strings.isNullOrEmpty(title)) { // ... use the toString() otherwise http://git-wip-us.apache.org/repos/asf/isis/blob/7c6cce87/core/metamodel/src/main/java/org/apache/isis/progmodels/dflt/ProgrammingModelFacetsJava5.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/progmodels/dflt/ProgrammingModelFacetsJava5.java b/core/metamodel/src/main/java/org/apache/isis/progmodels/dflt/ProgrammingModelFacetsJava5.java index cf39798..86507dd 100644 --- a/core/metamodel/src/main/java/org/apache/isis/progmodels/dflt/ProgrammingModelFacetsJava5.java +++ b/core/metamodel/src/main/java/org/apache/isis/progmodels/dflt/ProgrammingModelFacetsJava5.java @@ -64,6 +64,7 @@ import org.apache.isis.core.progmodel.facets.members.order.MemberOrderAnnotation import org.apache.isis.core.progmodel.facets.members.resolve.RenderOrResolveAnnotationFacetFactory; import org.apache.isis.core.progmodel.facets.object.aggregated.annotation.AggregatedAnnotationFacetFactory; import org.apache.isis.core.progmodel.facets.object.autocomplete.annotation.AutoCompleteAnnotationFacetFactory; +import org.apache.isis.core.progmodel.facets.object.bookmarkable.annotation.BookmarkableAnnotationFacetFactory; import org.apache.isis.core.progmodel.facets.object.bounded.annotation.BoundedAnnotationFacetFactory; import org.apache.isis.core.progmodel.facets.object.bounded.markerifc.BoundedMarkerInterfaceFacetFactory; import org.apache.isis.core.progmodel.facets.object.callbacks.create.CreatedCallbackFacetFactory; @@ -303,6 +304,7 @@ public final class ProgrammingModelFacetsJava5 extends ProgrammingModelAbstract addFactory(MemberGroupsAnnotationElseFallbackFacetFactory.class); addFactory(AggregatedAnnotationFacetFactory.class); + addFactory(BookmarkableAnnotationFacetFactory.class); addFactory(BoundedAnnotationFacetFactory.class); addFactory(BoundedMarkerInterfaceFacetFactory.class); addFactory(DebugAnnotationFacetFactory.class); http://git-wip-us.apache.org/repos/asf/isis/blob/7c6cce87/core/metamodel/src/test/java/org/apache/isis/core/progmodel/facets/object/aggregated/AggregatedAnnotationFacetFactoryTest.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/test/java/org/apache/isis/core/progmodel/facets/object/aggregated/AggregatedAnnotationFacetFactoryTest.java b/core/metamodel/src/test/java/org/apache/isis/core/progmodel/facets/object/aggregated/AggregatedAnnotationFacetFactoryTest.java index 2b261d9..d6df8c2 100644 --- a/core/metamodel/src/test/java/org/apache/isis/core/progmodel/facets/object/aggregated/AggregatedAnnotationFacetFactoryTest.java +++ b/core/metamodel/src/test/java/org/apache/isis/core/progmodel/facets/object/aggregated/AggregatedAnnotationFacetFactoryTest.java @@ -44,7 +44,7 @@ public class AggregatedAnnotationFacetFactoryTest extends AbstractFacetFactoryTe super.tearDown(); } - public void testImmutableAnnotationPickedUpOnClassAndDefaultsToAlways() { + public void testAggregatedAnnotationPickedUpOnClass() { @Aggregated class Customer { } http://git-wip-us.apache.org/repos/asf/isis/blob/7c6cce87/core/metamodel/src/test/java/org/apache/isis/core/progmodel/facets/object/bookmarkable/BookmarkableAnnotationFacetFactoryTest.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/test/java/org/apache/isis/core/progmodel/facets/object/bookmarkable/BookmarkableAnnotationFacetFactoryTest.java b/core/metamodel/src/test/java/org/apache/isis/core/progmodel/facets/object/bookmarkable/BookmarkableAnnotationFacetFactoryTest.java new file mode 100644 index 0000000..ce57411 --- /dev/null +++ b/core/metamodel/src/test/java/org/apache/isis/core/progmodel/facets/object/bookmarkable/BookmarkableAnnotationFacetFactoryTest.java @@ -0,0 +1,83 @@ +/* + * 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.core.progmodel.facets.object.bookmarkable; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +import org.apache.isis.applib.annotation.BookmarkPolicy; +import org.apache.isis.applib.annotation.Bookmarkable; +import org.apache.isis.core.metamodel.facetapi.Facet; +import org.apache.isis.core.metamodel.facets.FacetFactory.ProcessClassContext; +import org.apache.isis.core.metamodel.facets.object.bookmarkable.BookmarkPolicyFacet; +import org.apache.isis.core.metamodel.facets.object.bookmarkable.BookmarkPolicyFacetFallback; +import org.apache.isis.core.metamodel.facets.object.bookmarkable.BookmarkPolicyFacetViaBookmarkableAnnotation; +import org.apache.isis.core.progmodel.facets.AbstractFacetFactoryTest; +import org.apache.isis.core.progmodel.facets.object.bookmarkable.annotation.BookmarkableAnnotationFacetFactory; + +public class BookmarkableAnnotationFacetFactoryTest extends AbstractFacetFactoryTest { + + private BookmarkableAnnotationFacetFactory facetFactory; + + @Override + protected void setUp() throws Exception { + super.setUp(); + + facetFactory = new BookmarkableAnnotationFacetFactory(); + } + + @Override + protected void tearDown() throws Exception { + facetFactory = null; + super.tearDown(); + } + + public void testBookmarkableAnnotationPickedUpOnClass() { + @Bookmarkable(BookmarkPolicy.AS_CHILD) + class Customer { + } + + facetFactory.process(new ProcessClassContext(Customer.class, methodRemover, facetedMethod)); + + final Facet facet = facetedMethod.getFacet(BookmarkPolicyFacet.class); + assertNotNull(facet); + assertTrue(facet instanceof BookmarkPolicyFacetViaBookmarkableAnnotation); + BookmarkPolicyFacet bookmarkableFacet = (BookmarkPolicyFacet) facet; + assertThat(bookmarkableFacet.value(), is(BookmarkPolicy.AS_CHILD)); + + assertNoMethodsRemoved(); + } + + public void testBookmarkablePolicyInferredPickedUpOnClassAndDefaultsToAlways() { + class Customer { + } + + facetFactory.process(new ProcessClassContext(Customer.class, methodRemover, facetedMethod)); + + final Facet facet = facetedMethod.getFacet(BookmarkPolicyFacet.class); + assertNotNull(facet); + assertTrue(facet instanceof BookmarkPolicyFacetFallback); + BookmarkPolicyFacet bookmarkableFacet = (BookmarkPolicyFacet) facet; + assertThat(bookmarkableFacet.value(), is(BookmarkPolicy.NEVER)); + + assertNoMethodsRemoved(); + } + +} http://git-wip-us.apache.org/repos/asf/isis/blob/7c6cce87/example/application/quickstart_wicket_restful_jdo/viewer-webapp/src/main/webapp/WEB-INF/isis.properties ---------------------------------------------------------------------- diff --git a/example/application/quickstart_wicket_restful_jdo/viewer-webapp/src/main/webapp/WEB-INF/isis.properties b/example/application/quickstart_wicket_restful_jdo/viewer-webapp/src/main/webapp/WEB-INF/isis.properties index a623430..8d35c45 100644 --- a/example/application/quickstart_wicket_restful_jdo/viewer-webapp/src/main/webapp/WEB-INF/isis.properties +++ b/example/application/quickstart_wicket_restful_jdo/viewer-webapp/src/main/webapp/WEB-INF/isis.properties @@ -137,6 +137,20 @@ isis.user-profile-store=in-memory ################################################################################# # +# Value facet defaults +# +# (see also viewer-specific config files, eg viewer_wicket.properties) +# +################################################################################# + +# as used by @Title of a date +isis.value.format.date=dd-MM-yyyy + + + + +################################################################################# +# # Application Services and fixtures # #################################################################################
