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 2015/11/06 08:16:30 UTC

[02/11] isis git commit: ISIS-1151: Added DefaultView facets to set a default view for collections

ISIS-1151: Added DefaultView facets to set a default view for collections


Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/da077bc8
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/da077bc8
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/da077bc8

Branch: refs/heads/master
Commit: da077bc851dcebdd6dea010c2f600bedb61bf613
Parents: 271ae4b
Author: Sander Ginn <sa...@Sanders-MacBook-Pro.local>
Authored: Wed Oct 28 13:52:12 2015 +0100
Committer: Sander Ginn <sa...@Sanders-MacBook-Pro.local>
Committed: Wed Nov 4 10:18:28 2015 +0100

----------------------------------------------------------------------
 .../defaultview/DefaultViewFacet.java           | 26 +++++++++++
 .../defaultview/DefaultViewFacetAbstract.java   | 35 +++++++++++++++
 ...tViewFacetForCollectionLayoutAnnotation.java | 41 +++++++++++++++++
 ...ewFacetOnCollectionFromLayoutProperties.java | 46 ++++++++++++++++++++
 4 files changed, 148 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/da077bc8/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/defaultview/DefaultViewFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/defaultview/DefaultViewFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/defaultview/DefaultViewFacet.java
new file mode 100644
index 0000000..9174275
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/defaultview/DefaultViewFacet.java
@@ -0,0 +1,26 @@
+/*
+ *
+ *  Copyright 2012-2015 Eurocommercial Properties NV
+ *
+ *
+ *  Licensed 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.collections.collection.defaultview;
+
+import org.apache.isis.core.metamodel.facets.SingleStringValueFacet;
+
+public interface DefaultViewFacet extends SingleStringValueFacet {
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/da077bc8/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/defaultview/DefaultViewFacetAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/defaultview/DefaultViewFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/defaultview/DefaultViewFacetAbstract.java
new file mode 100644
index 0000000..c2548f3
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/defaultview/DefaultViewFacetAbstract.java
@@ -0,0 +1,35 @@
+/*
+ *
+ *  Copyright 2012-2015 Eurocommercial Properties NV
+ *
+ *
+ *  Licensed 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.collections.collection.defaultview;
+
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.SingleStringValueFacetAbstract;
+
+public class DefaultViewFacetAbstract extends SingleStringValueFacetAbstract implements DefaultViewFacet {
+
+    public static Class<? extends Facet> type() {
+        return DefaultViewFacet.class;
+    }
+
+    public DefaultViewFacetAbstract(final String value, final FacetHolder holder) {
+        super(type(), holder, value);
+    }
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/da077bc8/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/defaultview/DefaultViewFacetForCollectionLayoutAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/defaultview/DefaultViewFacetForCollectionLayoutAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/defaultview/DefaultViewFacetForCollectionLayoutAnnotation.java
new file mode 100644
index 0000000..a9f174d
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/defaultview/DefaultViewFacetForCollectionLayoutAnnotation.java
@@ -0,0 +1,41 @@
+/*
+ *
+ *  Copyright 2012-2015 Eurocommercial Properties NV
+ *
+ *
+ *  Licensed 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.collections.collection.defaultview;
+
+import com.google.common.base.Strings;
+
+import org.apache.isis.applib.annotation.CollectionLayout;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+
+public class DefaultViewFacetForCollectionLayoutAnnotation extends DefaultViewFacetAbstract {
+
+    private DefaultViewFacetForCollectionLayoutAnnotation(String value, FacetHolder holder) {
+        super(value, holder);
+    }
+
+    public static DefaultViewFacet create(CollectionLayout collectionLayout, FacetHolder holder) {
+        if (collectionLayout == null) {
+            return null;
+        }
+
+        final String defaultView = Strings.emptyToNull(collectionLayout.defaultView());
+        return defaultView != null ? new DefaultViewFacetForCollectionLayoutAnnotation(defaultView, holder) : null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/da077bc8/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/defaultview/DefaultViewFacetOnCollectionFromLayoutProperties.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/defaultview/DefaultViewFacetOnCollectionFromLayoutProperties.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/defaultview/DefaultViewFacetOnCollectionFromLayoutProperties.java
new file mode 100644
index 0000000..03ab346
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/defaultview/DefaultViewFacetOnCollectionFromLayoutProperties.java
@@ -0,0 +1,46 @@
+/*
+ *
+ *  Copyright 2012-2015 Eurocommercial Properties NV
+ *
+ *
+ *  Licensed 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.collections.collection.defaultview;
+
+import java.util.Properties;
+
+import com.google.common.base.Strings;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+
+public class DefaultViewFacetOnCollectionFromLayoutProperties extends DefaultViewFacetAbstract {
+
+    private DefaultViewFacetOnCollectionFromLayoutProperties(String defaultView, FacetHolder holder) {
+        super(defaultView, holder);
+    }
+
+    public static DefaultViewFacet create(Properties properties, FacetHolder holder) {
+        final String defaultView = defaultView(properties);
+        return defaultView != null ? new DefaultViewFacetOnCollectionFromLayoutProperties(defaultView, holder) : null;
+    }
+
+    public static String defaultView(Properties properties) {
+        if (properties == null) {
+            return null;
+        }
+
+        return Strings.emptyToNull(properties.getProperty("defaultView"));
+    }
+}