http://git-wip-us.apache.org/repos/asf/isis/blob/fb0f1273/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/actions/layout/ActionLayoutAnnotationFacetFactoryTest.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/actions/layout/ActionLayoutAnnotationFacetFactoryTest.java b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/actions/layout/ActionLayoutAnnotationFacetFactoryTest.java deleted file mode 100644 index 8d4ce10..0000000 --- a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/actions/layout/ActionLayoutAnnotationFacetFactoryTest.java +++ /dev/null @@ -1,192 +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.core.metamodel.facets.actions.layout; - -import java.lang.reflect.Method; - -import org.jmock.Expectations; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import org.apache.isis.applib.annotation.ActionLayout; -import org.apache.isis.core.metamodel.facetapi.Facet; -import org.apache.isis.core.metamodel.facets.AbstractFacetFactoryJUnit4TestCase; -import org.apache.isis.core.metamodel.facets.FacetFactory.ProcessMethodContext; -import org.apache.isis.core.metamodel.facets.actions.position.ActionPositionFacet; -import org.apache.isis.core.metamodel.facets.actions.position.ActionPositionFacetFallback; -import org.apache.isis.core.metamodel.facets.members.cssclassfa.CssClassFaFacet; -import org.apache.isis.core.metamodel.facets.members.cssclassfa.CssClassFaPosition; -import org.apache.isis.core.metamodel.facets.object.domainservice.DomainServiceFacet; -import org.apache.isis.core.metamodel.facets.object.mixin.MixinFacet; - -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.instanceOf; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.notNullValue; -import static org.junit.Assert.assertThat; - -public class ActionLayoutAnnotationFacetFactoryTest extends AbstractFacetFactoryJUnit4TestCase { - - ActionLayoutFacetFactory facetFactory; - - @Before - public void setUp() throws Exception { - facetFactory = new ActionLayoutFacetFactory(); - facetFactory.setSpecificationLoader(mockSpecificationLoaderSpi); - } - - @Test - public void testActionLayoutAnnotationPickedUp() { - - class Customer { - @SuppressWarnings("unused") - @ActionLayout(position = ActionLayout.Position.PANEL) - public String foz() { - return null; - } - } - final Method method = findMethod(Customer.class, "foz"); - - context.checking(new Expectations() { - { - allowing(mockSpecificationLoaderSpi).loadSpecification(Customer.class); - will(returnValue(mockObjSpec)); - - allowing(mockObjSpec).getFacet(MixinFacet.class); - will(returnValue(null)); - - allowing(mockObjSpec).getFacet(DomainServiceFacet.class); - will(returnValue(null)); - } - }); - - facetFactory.process(new ProcessMethodContext(Customer.class, null, null, method, mockMethodRemover, - facetedMethod)); - - final Facet facet = facetedMethod.getFacet(ActionPositionFacet.class); - Assert.assertNotNull(facet); - Assert.assertTrue(facet instanceof ActionPositionFacetForActionLayoutAnnotation); - final ActionPositionFacetForActionLayoutAnnotation actionLayoutFacetAnnotation = (ActionPositionFacetForActionLayoutAnnotation) facet; - Assert.assertEquals(ActionLayout.Position.PANEL, actionLayoutFacetAnnotation.position()); - } - - @Test - public void testActionLayoutFallbackPickedUp() { - - class Customer { - @SuppressWarnings("unused") - // no @ActionLayout - public String foo() { - return null; - } - } - final Method method = findMethod(Customer.class, "foo"); - - context.checking(new Expectations() { - { - allowing(mockSpecificationLoaderSpi).loadSpecification(Customer.class); - will(returnValue(mockObjSpec)); - - allowing(mockObjSpec).getFacet(MixinFacet.class); - will(returnValue(null)); - - allowing(mockObjSpec).getFacet(DomainServiceFacet.class); - will(returnValue(null)); - } - }); - - facetFactory.process(new ProcessMethodContext(Customer.class, null, null, method, mockMethodRemover, - facetedMethod)); - - final Facet facet = facetedMethod.getFacet(ActionPositionFacet.class); - Assert.assertNotNull(facet); - Assert.assertTrue(facet instanceof ActionPositionFacetFallback); - } - - public static class CssClassFa extends ActionLayoutAnnotationFacetFactoryTest { - - @Test - public void testDefaultPosition() { - - class Customer { - @SuppressWarnings("unused") - @ActionLayout(cssClassFa = "font-awesome") - public String foz() { - return null; - } - } - final Method method = findMethod(Customer.class, "foz"); - - context.checking(new Expectations() { - { - allowing(mockSpecificationLoaderSpi).loadSpecification(Customer.class); - will(returnValue(mockObjSpec)); - - allowing(mockObjSpec).getFacet(DomainServiceFacet.class); - will(returnValue(null)); - } - }); - - facetFactory.process(new ProcessMethodContext(Customer.class, null, null, method, mockMethodRemover, - facetedMethod)); - - Facet facet = facetedMethod.getFacet(CssClassFaFacet.class); - assertThat(facet, is(notNullValue())); - assertThat(facet, is(instanceOf(CssClassFaFacetForActionLayoutAnnotation.class))); - CssClassFaFacetForActionLayoutAnnotation classFaFacetForActionLayoutAnnotation = (CssClassFaFacetForActionLayoutAnnotation) facet; - assertThat(classFaFacetForActionLayoutAnnotation.value(), is(equalTo("fa fa-fw fa-font-awesome"))); - assertThat(classFaFacetForActionLayoutAnnotation.getPosition(), is(CssClassFaPosition.LEFT)); - } - - @Test - public void testRightPosition() { - - class Customer { - @SuppressWarnings("unused") - @ActionLayout(cssClassFa = "font-awesome", cssClassFaPosition = ActionLayout.CssClassFaPosition.RIGHT) - public String foz() { - return null; - } - } - final Method method = findMethod(Customer.class, "foz"); - - context.checking(new Expectations() { - { - allowing(mockSpecificationLoaderSpi).loadSpecification(Customer.class); - will(returnValue(mockObjSpec)); - - allowing(mockObjSpec).getFacet(DomainServiceFacet.class); - will(returnValue(null)); - } - }); - - facetFactory.process(new ProcessMethodContext(Customer.class, null, null, method, mockMethodRemover, - facetedMethod)); - - Facet facet = facetedMethod.getFacet(CssClassFaFacet.class); - assertThat(facet, is(notNullValue())); - assertThat(facet, is(instanceOf(CssClassFaFacetForActionLayoutAnnotation.class))); - CssClassFaFacetForActionLayoutAnnotation classFaFacetForActionLayoutAnnotation = (CssClassFaFacetForActionLayoutAnnotation) facet; - assertThat(classFaFacetForActionLayoutAnnotation.value(), is(equalTo("fa fa-fw fa-font-awesome"))); - assertThat(classFaFacetForActionLayoutAnnotation.getPosition(), is(CssClassFaPosition.RIGHT)); - } - - } - -}
http://git-wip-us.apache.org/repos/asf/isis/blob/fb0f1273/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/actions/layout/ActionLayoutXmlLayoutAnnotationFacetFactoryTest.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/actions/layout/ActionLayoutXmlLayoutAnnotationFacetFactoryTest.java b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/actions/layout/ActionLayoutXmlLayoutAnnotationFacetFactoryTest.java new file mode 100644 index 0000000..18f4a69 --- /dev/null +++ b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/actions/layout/ActionLayoutXmlLayoutAnnotationFacetFactoryTest.java @@ -0,0 +1,192 @@ +/* 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.actions.layout; + +import java.lang.reflect.Method; + +import org.jmock.Expectations; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import org.apache.isis.applib.annotation.ActionLayout; +import org.apache.isis.core.metamodel.facetapi.Facet; +import org.apache.isis.core.metamodel.facets.AbstractFacetFactoryJUnit4TestCase; +import org.apache.isis.core.metamodel.facets.FacetFactory.ProcessMethodContext; +import org.apache.isis.core.metamodel.facets.actions.position.ActionPositionFacet; +import org.apache.isis.core.metamodel.facets.actions.position.ActionPositionFacetFallback; +import org.apache.isis.core.metamodel.facets.members.cssclassfa.CssClassFaFacet; +import org.apache.isis.core.metamodel.facets.members.cssclassfa.CssClassFaPosition; +import org.apache.isis.core.metamodel.facets.object.domainservice.DomainServiceFacet; +import org.apache.isis.core.metamodel.facets.object.mixin.MixinFacet; + +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; +import static org.junit.Assert.assertThat; + +public class ActionLayoutXmlLayoutAnnotationFacetFactoryTest extends AbstractFacetFactoryJUnit4TestCase { + + ActionLayoutFacetFactory facetFactory; + + @Before + public void setUp() throws Exception { + facetFactory = new ActionLayoutFacetFactory(); + facetFactory.setSpecificationLoader(mockSpecificationLoaderSpi); + } + + @Test + public void testActionLayoutAnnotationPickedUp() { + + class Customer { + @SuppressWarnings("unused") + @ActionLayout(position = ActionLayout.Position.PANEL) + public String foz() { + return null; + } + } + final Method method = findMethod(Customer.class, "foz"); + + context.checking(new Expectations() { + { + allowing(mockSpecificationLoaderSpi).loadSpecification(Customer.class); + will(returnValue(mockObjSpec)); + + allowing(mockObjSpec).getFacet(MixinFacet.class); + will(returnValue(null)); + + allowing(mockObjSpec).getFacet(DomainServiceFacet.class); + will(returnValue(null)); + } + }); + + facetFactory.process(new ProcessMethodContext(Customer.class, null, null, method, mockMethodRemover, + facetedMethod)); + + final Facet facet = facetedMethod.getFacet(ActionPositionFacet.class); + Assert.assertNotNull(facet); + Assert.assertTrue(facet instanceof ActionPositionFacetForActionLayoutAnnotation); + final ActionPositionFacetForActionLayoutAnnotation actionLayoutFacetAnnotation = (ActionPositionFacetForActionLayoutAnnotation) facet; + Assert.assertEquals(ActionLayout.Position.PANEL, actionLayoutFacetAnnotation.position()); + } + + @Test + public void testActionLayoutFallbackPickedUp() { + + class Customer { + @SuppressWarnings("unused") + // no @ActionLayout + public String foo() { + return null; + } + } + final Method method = findMethod(Customer.class, "foo"); + + context.checking(new Expectations() { + { + allowing(mockSpecificationLoaderSpi).loadSpecification(Customer.class); + will(returnValue(mockObjSpec)); + + allowing(mockObjSpec).getFacet(MixinFacet.class); + will(returnValue(null)); + + allowing(mockObjSpec).getFacet(DomainServiceFacet.class); + will(returnValue(null)); + } + }); + + facetFactory.process(new ProcessMethodContext(Customer.class, null, null, method, mockMethodRemover, + facetedMethod)); + + final Facet facet = facetedMethod.getFacet(ActionPositionFacet.class); + Assert.assertNotNull(facet); + Assert.assertTrue(facet instanceof ActionPositionFacetFallback); + } + + public static class CssClassFa extends ActionLayoutXmlLayoutAnnotationFacetFactoryTest { + + @Test + public void testDefaultPosition() { + + class Customer { + @SuppressWarnings("unused") + @ActionLayout(cssClassFa = "font-awesome") + public String foz() { + return null; + } + } + final Method method = findMethod(Customer.class, "foz"); + + context.checking(new Expectations() { + { + allowing(mockSpecificationLoaderSpi).loadSpecification(Customer.class); + will(returnValue(mockObjSpec)); + + allowing(mockObjSpec).getFacet(DomainServiceFacet.class); + will(returnValue(null)); + } + }); + + facetFactory.process(new ProcessMethodContext(Customer.class, null, null, method, mockMethodRemover, + facetedMethod)); + + Facet facet = facetedMethod.getFacet(CssClassFaFacet.class); + assertThat(facet, is(notNullValue())); + assertThat(facet, is(instanceOf(CssClassFaFacetForActionLayoutAnnotation.class))); + CssClassFaFacetForActionLayoutAnnotation classFaFacetForActionLayoutAnnotation = (CssClassFaFacetForActionLayoutAnnotation) facet; + assertThat(classFaFacetForActionLayoutAnnotation.value(), is(equalTo("fa fa-fw fa-font-awesome"))); + assertThat(classFaFacetForActionLayoutAnnotation.getPosition(), is(CssClassFaPosition.LEFT)); + } + + @Test + public void testRightPosition() { + + class Customer { + @SuppressWarnings("unused") + @ActionLayout(cssClassFa = "font-awesome", cssClassFaPosition = ActionLayout.CssClassFaPosition.RIGHT) + public String foz() { + return null; + } + } + final Method method = findMethod(Customer.class, "foz"); + + context.checking(new Expectations() { + { + allowing(mockSpecificationLoaderSpi).loadSpecification(Customer.class); + will(returnValue(mockObjSpec)); + + allowing(mockObjSpec).getFacet(DomainServiceFacet.class); + will(returnValue(null)); + } + }); + + facetFactory.process(new ProcessMethodContext(Customer.class, null, null, method, mockMethodRemover, + facetedMethod)); + + Facet facet = facetedMethod.getFacet(CssClassFaFacet.class); + assertThat(facet, is(notNullValue())); + assertThat(facet, is(instanceOf(CssClassFaFacetForActionLayoutAnnotation.class))); + CssClassFaFacetForActionLayoutAnnotation classFaFacetForActionLayoutAnnotation = (CssClassFaFacetForActionLayoutAnnotation) facet; + assertThat(classFaFacetForActionLayoutAnnotation.value(), is(equalTo("fa fa-fw fa-font-awesome"))); + assertThat(classFaFacetForActionLayoutAnnotation.getPosition(), is(CssClassFaPosition.RIGHT)); + } + + } + +} http://git-wip-us.apache.org/repos/asf/isis/blob/fb0f1273/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/object/layoutxml/LayoutXmlFacetDefaultTest.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/object/layoutxml/LayoutXmlFacetDefaultTest.java b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/object/layoutxml/LayoutXmlFacetDefaultTest.java deleted file mode 100644 index 4a843bd..0000000 --- a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/object/layoutxml/LayoutXmlFacetDefaultTest.java +++ /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. - */ -package org.apache.isis.core.metamodel.facets.object.layoutxml; - -import java.util.concurrent.atomic.AtomicReference; - -import org.junit.Test; - -import org.apache.isis.applib.layout.v1_0.PropertyGroup; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; - -public class LayoutXmlFacetDefaultTest { - - @Test - public void xxx() throws Exception { - - final AtomicReference<PropertyGroup> x = new AtomicReference<>(); - - PropertyGroup firstValue = new PropertyGroup(); - PropertyGroup otherValue = new PropertyGroup(); - - assertThat(x.get(), is(nullValue())); - - boolean b = x.compareAndSet(null, firstValue); - assertThat(b, is(true)); - assertThat(x.get(), is(firstValue)); - - boolean b2 = x.compareAndSet(null, firstValue); - assertThat(b2, is(false)); - assertThat(x.get(), is(firstValue)); - - boolean b3 = x.compareAndSet(null, otherValue); - assertThat(b3, is(false)); - assertThat(x.get(), is(firstValue)); - - boolean b4 = x.compareAndSet(firstValue, otherValue); - assertThat(b4, is(true)); - assertThat(x.get(), is(otherValue)); - - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/isis/blob/fb0f1273/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/object/layoutxml/ObjectLayoutMetadataFacetDefaultTest.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/object/layoutxml/ObjectLayoutMetadataFacetDefaultTest.java b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/object/layoutxml/ObjectLayoutMetadataFacetDefaultTest.java new file mode 100644 index 0000000..5ff3426 --- /dev/null +++ b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/object/layoutxml/ObjectLayoutMetadataFacetDefaultTest.java @@ -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. + */ +package org.apache.isis.core.metamodel.facets.object.layoutxml; + +import java.util.concurrent.atomic.AtomicReference; + +import org.junit.Test; + +import org.apache.isis.applib.layout.v1_0.PropertyGroup; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.nullValue; +import static org.junit.Assert.assertThat; + +public class ObjectLayoutMetadataFacetDefaultTest { + + @Test + public void xxx() throws Exception { + + final AtomicReference<PropertyGroup> x = new AtomicReference<>(); + + PropertyGroup firstValue = new PropertyGroup(); + PropertyGroup otherValue = new PropertyGroup(); + + assertThat(x.get(), is(nullValue())); + + boolean b = x.compareAndSet(null, firstValue); + assertThat(b, is(true)); + assertThat(x.get(), is(firstValue)); + + boolean b2 = x.compareAndSet(null, firstValue); + assertThat(b2, is(false)); + assertThat(x.get(), is(firstValue)); + + boolean b3 = x.compareAndSet(null, otherValue); + assertThat(b3, is(false)); + assertThat(x.get(), is(firstValue)); + + boolean b4 = x.compareAndSet(firstValue, otherValue); + assertThat(b4, is(true)); + assertThat(x.get(), is(otherValue)); + + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/isis/blob/fb0f1273/core/metamodel/src/test/java/org/apache/isis/core/metamodel/layoutxml/v1_0/DomainObjectTest.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/layoutxml/v1_0/DomainObjectTest.java b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/layoutxml/v1_0/DomainObjectTest.java deleted file mode 100644 index a8d06c0..0000000 --- a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/layoutxml/v1_0/DomainObjectTest.java +++ /dev/null @@ -1,121 +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.core.metamodel.layoutxml.v1_0; - -import java.util.Map; - -import javax.xml.bind.Marshaller; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Lists; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import org.apache.isis.applib.layout.v1_0.Action; -import org.apache.isis.applib.layout.v1_0.Collection; -import org.apache.isis.applib.layout.v1_0.Column; -import org.apache.isis.applib.layout.v1_0.DomainObject; -import org.apache.isis.applib.layout.v1_0.Property; -import org.apache.isis.applib.layout.v1_0.PropertyGroup; -import org.apache.isis.applib.layout.v1_0.Tab; -import org.apache.isis.applib.layout.v1_0.TabGroup; -import org.apache.isis.applib.services.jaxb.JaxbService; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - -public class DomainObjectTest { - - private JaxbService jaxbService; - - @Before - public void setUp() throws Exception { - jaxbService = new JaxbService.Simple(); - } - - @After - public void tearDown() throws Exception { - - } - - @Test - public void xxx() throws Exception { - - final DomainObject domainObject = new DomainObject(); - - TabGroup tabGroup = domainObject.getTabGroups().get(0); - Tab tab = tabGroup.getTabs().get(0); - tab.setName("Common"); - Column left = tab.getLeft(); - - PropertyGroup leftPropGroup = new PropertyGroup(); - left.setPropertyGroups(Lists.<PropertyGroup>newArrayList()); - left.getPropertyGroups().add(leftPropGroup); - leftPropGroup.setName("General"); - - Collection similarToColl = new Collection(); - left.setCollections(Lists.<Collection>newArrayList()); - left.getCollections().add(similarToColl); - similarToColl.setId("similarTo"); - - Property nameProperty = leftPropGroup.getProperties().get(0); - nameProperty.setId("name"); - - Action updateNameAction = new Action(); - updateNameAction.setId("updateName"); - nameProperty.setActions(Lists.<Action>newArrayList()); - nameProperty.getActions().add(updateNameAction); - - Action deleteAction = new Action(); - deleteAction.setId("delete"); - domainObject.setActions(Lists.<Action>newArrayList()); - domainObject.getActions().add(deleteAction); - - String xml = jaxbService.toXml(domainObject, - ImmutableMap.<String,Object>of( - Marshaller.JAXB_SCHEMA_LOCATION, - "http://isis.apache.org/schema/applib/layout http://isis.apache.org/schema/applib/layout/layout-1.0.xsd" - )); - System.out.println(xml); - - DomainObject domainObjectRoundtripped = jaxbService.fromXml(DomainObject.class, xml); - String xmlRoundtripped = jaxbService.toXml(domainObjectRoundtripped, - ImmutableMap.<String,Object>of( - Marshaller.JAXB_SCHEMA_LOCATION, - "http://isis.apache.org/schema/applib/layout http://isis.apache.org/schema/applib/layout/layout-1.0.xsd" - )); - assertThat(xml, is(equalTo(xmlRoundtripped))); - - - System.out.println("=========="); - - dumpXsd(domainObject); - } - - protected void dumpXsd(final DomainObject domainObject) { - Map<String, String> schemas = jaxbService.toXsd(domainObject, JaxbService.IsisSchemas.INCLUDE); - for (Map.Entry<String, String> entry : schemas.entrySet()) { - //System.out.println(entry.getKey() + ":"); - System.out.println(entry.getValue()); - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/isis/blob/fb0f1273/core/metamodel/src/test/java/org/apache/isis/core/metamodel/layoutxml/v1_0/ObjectLayoutMetadataTest.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/layoutxml/v1_0/ObjectLayoutMetadataTest.java b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/layoutxml/v1_0/ObjectLayoutMetadataTest.java new file mode 100644 index 0000000..73df1fb --- /dev/null +++ b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/layoutxml/v1_0/ObjectLayoutMetadataTest.java @@ -0,0 +1,121 @@ +/* + * 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.layoutxml.v1_0; + +import java.util.Map; + +import javax.xml.bind.Marshaller; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Lists; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import org.apache.isis.applib.layout.v1_0.ActionLayoutMetadata; +import org.apache.isis.applib.layout.v1_0.CollectionLayoutMetadata; +import org.apache.isis.applib.layout.v1_0.Column; +import org.apache.isis.applib.layout.v1_0.ObjectLayoutMetadata; +import org.apache.isis.applib.layout.v1_0.PropertyLayoutMetadata; +import org.apache.isis.applib.layout.v1_0.PropertyGroup; +import org.apache.isis.applib.layout.v1_0.Tab; +import org.apache.isis.applib.layout.v1_0.TabGroup; +import org.apache.isis.applib.services.jaxb.JaxbService; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +public class ObjectLayoutMetadataTest { + + private JaxbService jaxbService; + + @Before + public void setUp() throws Exception { + jaxbService = new JaxbService.Simple(); + } + + @After + public void tearDown() throws Exception { + + } + + @Test + public void xxx() throws Exception { + + final ObjectLayoutMetadata objectLayoutMetadata = new ObjectLayoutMetadata(); + + TabGroup tabGroup = objectLayoutMetadata.getTabGroups().get(0); + Tab tab = tabGroup.getTabs().get(0); + tab.setName("Common"); + Column left = tab.getLeft(); + + PropertyGroup leftPropGroup = new PropertyGroup(); + left.setPropertyGroups(Lists.<PropertyGroup>newArrayList()); + left.getPropertyGroups().add(leftPropGroup); + leftPropGroup.setName("General"); + + CollectionLayoutMetadata similarToColl = new CollectionLayoutMetadata(); + left.setCollections(Lists.<CollectionLayoutMetadata>newArrayList()); + left.getCollections().add(similarToColl); + similarToColl.setId("similarTo"); + + PropertyLayoutMetadata namePropertyLayoutMetadata = leftPropGroup.getProperties().get(0); + namePropertyLayoutMetadata.setId("name"); + + ActionLayoutMetadata updateNameActionLayoutMetadata = new ActionLayoutMetadata(); + updateNameActionLayoutMetadata.setId("updateName"); + namePropertyLayoutMetadata.setActions(Lists.<ActionLayoutMetadata>newArrayList()); + namePropertyLayoutMetadata.getActions().add(updateNameActionLayoutMetadata); + + ActionLayoutMetadata deleteActionLayoutMetadata = new ActionLayoutMetadata(); + deleteActionLayoutMetadata.setId("delete"); + objectLayoutMetadata.setActions(Lists.<ActionLayoutMetadata>newArrayList()); + objectLayoutMetadata.getActions().add(deleteActionLayoutMetadata); + + String xml = jaxbService.toXml(objectLayoutMetadata, + ImmutableMap.<String,Object>of( + Marshaller.JAXB_SCHEMA_LOCATION, + "http://isis.apache.org/schema/applib/layout http://isis.apache.org/schema/applib/layout/layout-1.0.xsd" + )); + System.out.println(xml); + + ObjectLayoutMetadata objectLayoutMetadataRoundtripped = jaxbService.fromXml(ObjectLayoutMetadata.class, xml); + String xmlRoundtripped = jaxbService.toXml(objectLayoutMetadataRoundtripped, + ImmutableMap.<String,Object>of( + Marshaller.JAXB_SCHEMA_LOCATION, + "http://isis.apache.org/schema/applib/layout http://isis.apache.org/schema/applib/layout/layout-1.0.xsd" + )); + assertThat(xml, is(equalTo(xmlRoundtripped))); + + + System.out.println("=========="); + + dumpXsd(objectLayoutMetadata); + } + + protected void dumpXsd(final ObjectLayoutMetadata objectLayoutMetadata) { + Map<String, String> schemas = jaxbService.toXsd(objectLayoutMetadata, JaxbService.IsisSchemas.INCLUDE); + for (Map.Entry<String, String> entry : schemas.entrySet()) { + //System.out.println(entry.getKey() + ":"); + System.out.println(entry.getValue()); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/isis/blob/fb0f1273/core/runtime/src/test/java/org/apache/isis/core/runtime/system/ObjectActionDefaultTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/isis/core/runtime/system/ObjectActionDefaultTest.java b/core/runtime/src/test/java/org/apache/isis/core/runtime/system/ObjectActionDefaultTest.java deleted file mode 100644 index 7e446c1..0000000 --- a/core/runtime/src/test/java/org/apache/isis/core/runtime/system/ObjectActionDefaultTest.java +++ /dev/null @@ -1,107 +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.core.runtime.system; - -import org.jmock.Expectations; -import org.jmock.auto.Mock; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; - -import org.apache.isis.applib.Identifier; -import org.apache.isis.core.commons.authentication.AuthenticationSessionProvider; -import org.apache.isis.core.metamodel.runtimecontext.PersistenceSessionService; -import org.apache.isis.core.metamodel.runtimecontext.MessageBrokerService; -import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager; -import org.apache.isis.core.metamodel.facets.FacetedMethod; -import org.apache.isis.core.metamodel.facets.all.named.NamedFacet; -import org.apache.isis.core.metamodel.facets.all.named.NamedFacetAbstract; -import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector; -import org.apache.isis.core.metamodel.spec.SpecificationLoader; -import org.apache.isis.core.metamodel.spec.feature.ObjectMemberDependencies; -import org.apache.isis.core.metamodel.specloader.specimpl.ObjectActionDefault; -import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2; -import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2.Mode; - -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; - -public class ObjectActionDefaultTest { - - @Rule - public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES); - - - private ObjectActionDefault action; - - @Mock - private FacetedMethod mockFacetedMethod; - - @Mock - private AuthenticationSessionProvider mockAuthenticationSessionProvider; - @Mock - private SpecificationLoader mockSpecificationLookup; - @Mock - private AdapterManager mockAdapterManager; - @Mock - private ServicesInjector mockServicesInjector; - @Mock - private MessageBrokerService mockMessageBrokerService; - @Mock - private PersistenceSessionService mockPersistenceSessionService; - - @Before - public void setUp() throws Exception { - - context.checking(new Expectations() { - { - one(mockFacetedMethod).getIdentifier(); - will(returnValue(Identifier.actionIdentifier("Customer", "reduceheadcount"))); - } - }); - - action = new ObjectActionDefault(mockFacetedMethod, new ObjectMemberDependencies( - mockSpecificationLookup, mockServicesInjector, - mockPersistenceSessionService)); - } - - - @Test - public void testNameDefaultsToActionsMethodName() { - final String name = "Reduceheadcount"; - final NamedFacet facet = new NamedFacetAbstract(name, true, mockFacetedMethod) { - }; - context.checking(new Expectations() { - { - one(mockFacetedMethod).getFacet(NamedFacet.class); - will(returnValue(facet)); - } - }); - assertThat(action.getName(), is(equalTo(name))); - } - - @Test - public void testId() { - assertEquals("reduceheadcount", action.getId()); - } - -} http://git-wip-us.apache.org/repos/asf/isis/blob/fb0f1273/core/runtime/src/test/java/org/apache/isis/core/runtime/system/ObjectActionLayoutXmlDefaultTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/isis/core/runtime/system/ObjectActionLayoutXmlDefaultTest.java b/core/runtime/src/test/java/org/apache/isis/core/runtime/system/ObjectActionLayoutXmlDefaultTest.java new file mode 100644 index 0000000..3bdb185 --- /dev/null +++ b/core/runtime/src/test/java/org/apache/isis/core/runtime/system/ObjectActionLayoutXmlDefaultTest.java @@ -0,0 +1,107 @@ +/* + * 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.runtime.system; + +import org.jmock.Expectations; +import org.jmock.auto.Mock; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import org.apache.isis.applib.Identifier; +import org.apache.isis.core.commons.authentication.AuthenticationSessionProvider; +import org.apache.isis.core.metamodel.runtimecontext.PersistenceSessionService; +import org.apache.isis.core.metamodel.runtimecontext.MessageBrokerService; +import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager; +import org.apache.isis.core.metamodel.facets.FacetedMethod; +import org.apache.isis.core.metamodel.facets.all.named.NamedFacet; +import org.apache.isis.core.metamodel.facets.all.named.NamedFacetAbstract; +import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector; +import org.apache.isis.core.metamodel.spec.SpecificationLoader; +import org.apache.isis.core.metamodel.spec.feature.ObjectMemberDependencies; +import org.apache.isis.core.metamodel.specloader.specimpl.ObjectActionDefault; +import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2; +import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2.Mode; + +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; + +public class ObjectActionLayoutXmlDefaultTest { + + @Rule + public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES); + + + private ObjectActionDefault action; + + @Mock + private FacetedMethod mockFacetedMethod; + + @Mock + private AuthenticationSessionProvider mockAuthenticationSessionProvider; + @Mock + private SpecificationLoader mockSpecificationLookup; + @Mock + private AdapterManager mockAdapterManager; + @Mock + private ServicesInjector mockServicesInjector; + @Mock + private MessageBrokerService mockMessageBrokerService; + @Mock + private PersistenceSessionService mockPersistenceSessionService; + + @Before + public void setUp() throws Exception { + + context.checking(new Expectations() { + { + one(mockFacetedMethod).getIdentifier(); + will(returnValue(Identifier.actionIdentifier("Customer", "reduceheadcount"))); + } + }); + + action = new ObjectActionDefault(mockFacetedMethod, new ObjectMemberDependencies( + mockSpecificationLookup, mockServicesInjector, + mockPersistenceSessionService)); + } + + + @Test + public void testNameDefaultsToActionsMethodName() { + final String name = "Reduceheadcount"; + final NamedFacet facet = new NamedFacetAbstract(name, true, mockFacetedMethod) { + }; + context.checking(new Expectations() { + { + one(mockFacetedMethod).getFacet(NamedFacet.class); + will(returnValue(facet)); + } + }); + assertThat(action.getName(), is(equalTo(name))); + } + + @Test + public void testId() { + assertEquals("reduceheadcount", action.getId()); + } + +} http://git-wip-us.apache.org/repos/asf/isis/blob/fb0f1273/core/viewer-wicket-impl/src/main/java/org/apache/isis/viewer/wicket/viewer/integration/wicket/WebRequestCycleForIsis.java ---------------------------------------------------------------------- diff --git a/core/viewer-wicket-impl/src/main/java/org/apache/isis/viewer/wicket/viewer/integration/wicket/WebRequestCycleForIsis.java b/core/viewer-wicket-impl/src/main/java/org/apache/isis/viewer/wicket/viewer/integration/wicket/WebRequestCycleForIsis.java index 603d1e9..64d239d 100644 --- a/core/viewer-wicket-impl/src/main/java/org/apache/isis/viewer/wicket/viewer/integration/wicket/WebRequestCycleForIsis.java +++ b/core/viewer-wicket-impl/src/main/java/org/apache/isis/viewer/wicket/viewer/integration/wicket/WebRequestCycleForIsis.java @@ -206,7 +206,7 @@ public class WebRequestCycleForIsis extends AbstractRequestCycleListener { try { Constructor<? extends Page> constructor = signInPageClass.getConstructor(PageParameters.class, ExceptionModel.class); signInPage = constructor.newInstance(parameters, exceptionModel); - } catch (Exception _) { + } catch (Exception ex) { try { IPageFactory pageFactory = Application.get().getPageFactory(); signInPage = pageFactory.newPage(signInPageClass, parameters); http://git-wip-us.apache.org/repos/asf/isis/blob/fb0f1273/core/viewer-wicket-model/src/test/java/org/apache/isis/viewer/wicket/model/models/ActionModelTest.java ---------------------------------------------------------------------- diff --git a/core/viewer-wicket-model/src/test/java/org/apache/isis/viewer/wicket/model/models/ActionModelTest.java b/core/viewer-wicket-model/src/test/java/org/apache/isis/viewer/wicket/model/models/ActionModelTest.java index f7b5baa..d9741f1 100644 --- a/core/viewer-wicket-model/src/test/java/org/apache/isis/viewer/wicket/model/models/ActionModelTest.java +++ b/core/viewer-wicket-model/src/test/java/org/apache/isis/viewer/wicket/model/models/ActionModelTest.java @@ -19,15 +19,15 @@ package org.apache.isis.viewer.wicket.model.models; +import java.util.Map; + +import org.junit.Test; + import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.nullValue; import static org.junit.Assert.assertThat; -import java.util.Map; - -import org.junit.Test; - public class ActionModelTest { @Test http://git-wip-us.apache.org/repos/asf/isis/blob/fb0f1273/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/combined/EntityCombinedPanelFactory.java ---------------------------------------------------------------------- diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/combined/EntityCombinedPanelFactory.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/combined/EntityCombinedPanelFactory.java index 14c1473..1602ff0 100644 --- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/combined/EntityCombinedPanelFactory.java +++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/combined/EntityCombinedPanelFactory.java @@ -22,7 +22,7 @@ package org.apache.isis.viewer.wicket.ui.components.entity.combined; import org.apache.wicket.Component; import org.apache.wicket.model.IModel; -import org.apache.isis.core.metamodel.facets.object.layoutxml.LayoutXmlFacet; +import org.apache.isis.core.metamodel.facets.object.layoutxml.ObjectLayoutMetadataFacet; import org.apache.isis.core.metamodel.spec.ObjectSpecification; import org.apache.isis.viewer.wicket.model.models.EntityModel; import org.apache.isis.viewer.wicket.ui.ComponentFactory; @@ -46,7 +46,7 @@ public class EntityCombinedPanelFactory extends EntityComponentFactoryAbstract { protected ApplicationAdvice doAppliesTo(final EntityModel entityModel) { final ObjectSpecification specification = entityModel.getTypeOfSpecification(); // opposite to the EntityTabbedPanelFactory - return appliesIf(!specification.containsDoOpFacet(LayoutXmlFacet.class)); + return appliesIf(!specification.containsDoOpFacet(ObjectLayoutMetadataFacet.class)); } @Override http://git-wip-us.apache.org/repos/asf/isis/blob/fb0f1273/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/properties/EntityPropertiesForm.java ---------------------------------------------------------------------- diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/properties/EntityPropertiesForm.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/properties/EntityPropertiesForm.java index 5901d08..225dcdd 100644 --- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/properties/EntityPropertiesForm.java +++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/properties/EntityPropertiesForm.java @@ -21,10 +21,7 @@ package org.apache.isis.viewer.wicket.ui.components.entity.properties; import java.util.List; import java.util.Map; -import javax.annotation.Nullable; - -import com.google.common.base.Function; -import com.google.common.collect.Iterables; +import com.google.common.collect.FluentIterable; import com.google.common.collect.Lists; import org.apache.wicket.Component; @@ -159,10 +156,12 @@ public class EntityPropertiesForm extends FormAbstract<ObjectAdapter> implements final ColumnSpans columnSpans; if(tabMetaDataIfAny != null) { + final Column middle = tabMetaDataIfAny.getMiddle(); + final Column right = tabMetaDataIfAny.getRight(); columnSpans = ColumnSpans.asSpans( tabMetaDataIfAny.getLeft().getSpan(), - tabMetaDataIfAny.getMiddle().getSpan(), - tabMetaDataIfAny.getRight().getSpan()); + middle != null? middle.getSpan(): 0, + right != null? right.getSpan(): 0); } else { final MemberGroupLayoutFacet memberGroupLayoutFacet = entityModel.getObject().getSpecification().getFacet(MemberGroupLayoutFacet.class); @@ -177,7 +176,7 @@ public class EntityPropertiesForm extends FormAbstract<ObjectAdapter> implements boolean addedProperties; if(columnSpans.getLeft() > 0) { - addedProperties = addMembersInColumn(leftColumn, MemberGroupLayoutHint.LEFT, tabMetaDataIfAny, columnSpans); + addedProperties = addPropertiesInColumn(leftColumn, MemberGroupLayoutHint.LEFT, tabMetaDataIfAny, columnSpans); addButtons(leftColumn); addFeedbackGui(leftColumn); } else { @@ -195,7 +194,7 @@ public class EntityPropertiesForm extends FormAbstract<ObjectAdapter> implements if(columnSpans.getMiddle() > 0) { MarkupContainer middleColumn = new WebMarkupContainer(ID_MIDDLE_COLUMN); add(middleColumn); - addMembersInColumn(middleColumn, MemberGroupLayoutHint.MIDDLE, tabMetaDataIfAny, columnSpans); + addPropertiesInColumn(middleColumn, MemberGroupLayoutHint.MIDDLE, tabMetaDataIfAny, columnSpans); } else { Components.permanentlyHide(this, ID_MIDDLE_COLUMN); } @@ -204,7 +203,7 @@ public class EntityPropertiesForm extends FormAbstract<ObjectAdapter> implements if(columnSpans.getRight() > 0) { MarkupContainer rightColumn = new WebMarkupContainer(ID_RIGHT_COLUMN); add(rightColumn); - addMembersInColumn(rightColumn, MemberGroupLayoutHint.RIGHT, tabMetaDataIfAny, columnSpans); + addPropertiesInColumn(rightColumn, MemberGroupLayoutHint.RIGHT, tabMetaDataIfAny, columnSpans); } else { Components.permanentlyHide(this, ID_RIGHT_COLUMN); } @@ -234,7 +233,7 @@ public class EntityPropertiesForm extends FormAbstract<ObjectAdapter> implements } } - private boolean addMembersInColumn( + private boolean addPropertiesInColumn( final MarkupContainer markupContainer, final MemberGroupLayoutHint hint, final Tab tabMetaDataIfAny, @@ -247,17 +246,18 @@ public class EntityPropertiesForm extends FormAbstract<ObjectAdapter> implements final Column columnMetaDataIfAny = tabMetaDataIfAny != null ? hint.from(tabMetaDataIfAny) : null; - // if in a tab, then collections are also rendered. final List<ObjectAssociation> properties = visibleAssociations(adapter, ObjectAssociation.Filters.PROPERTIES); final RepeatingView memberGroupRv = new RepeatingView(ID_MEMBER_GROUP); markupContainer.add(memberGroupRv); - final Map<String, List<ObjectAssociation>> associationsByGroup = - ObjectAssociation.Util.groupByMemberOrderName(properties); + final Map<String, List<ObjectAssociation>> associationsByGroup = ObjectAssociation.Util.groupByMemberOrderName(properties); final List<String> groupNames = tabMetaDataIfAny != null - ? Lists.newArrayList(Iterables.transform(columnMetaDataIfAny.getPropertyGroups(), propertyGroupName())) + ? FluentIterable + .from(columnMetaDataIfAny.getPropertyGroups()) + .transform(PropertyGroup.Util.nameOf()) + .toList() : ObjectSpecifications.orderByMemberGroups(objSpec, associationsByGroup.keySet(), hint); for(final String groupName: groupNames) { @@ -308,15 +308,6 @@ public class EntityPropertiesForm extends FormAbstract<ObjectAdapter> implements return !groupNames.isEmpty(); } - private static Function<? super PropertyGroup, String> propertyGroupName() { - return new Function<PropertyGroup, String>() { - @Nullable @Override - public String apply(@Nullable final PropertyGroup propertyGroup) { - return propertyGroup.getName(); - } - }; - } - private void addPropertyToForm( final EntityModel entityModel, final OneToOneAssociation otoa, http://git-wip-us.apache.org/repos/asf/isis/blob/fb0f1273/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/tabgroups/EntityTabGroupsPanel.java ---------------------------------------------------------------------- diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/tabgroups/EntityTabGroupsPanel.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/tabgroups/EntityTabGroupsPanel.java index e8438e1..cce3292 100644 --- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/tabgroups/EntityTabGroupsPanel.java +++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/tabgroups/EntityTabGroupsPanel.java @@ -21,6 +21,7 @@ package org.apache.isis.viewer.wicket.ui.components.entity.tabgroups; import java.util.List; +import com.google.common.collect.FluentIterable; import com.google.common.collect.Lists; import org.apache.wicket.extensions.markup.html.tabs.AbstractTab; @@ -30,13 +31,13 @@ import org.apache.wicket.markup.html.list.ListView; import org.apache.wicket.markup.html.panel.Panel; import org.apache.wicket.model.Model; -import org.apache.isis.applib.layout.v1_0.DomainObject; +import org.apache.isis.applib.layout.v1_0.ObjectLayoutMetadata; import org.apache.isis.applib.layout.v1_0.Tab; import org.apache.isis.applib.layout.v1_0.TabGroup; import org.apache.isis.applib.services.jaxb.JaxbService; import org.apache.isis.core.metamodel.adapter.ObjectAdapter; import org.apache.isis.core.metamodel.facets.members.cssclass.CssClassFacet; -import org.apache.isis.core.metamodel.facets.object.layoutxml.LayoutXmlFacet; +import org.apache.isis.core.metamodel.facets.object.layoutxml.ObjectLayoutMetadataFacet; import org.apache.isis.viewer.wicket.model.models.EntityModel; import org.apache.isis.viewer.wicket.ui.ComponentType; import org.apache.isis.viewer.wicket.ui.panels.PanelAbstract; @@ -71,16 +72,19 @@ public class EntityTabGroupsPanel extends PanelAbstract<EntityModel> { } // forces metadata to be derived && synced - final LayoutXmlFacet layoutXmlFacet = model.getTypeOfSpecification().getFacet(LayoutXmlFacet.class); - final DomainObject domainObject = layoutXmlFacet.getLayoutMetadata(); + final ObjectLayoutMetadataFacet objectLayoutMetadataFacet = model.getTypeOfSpecification().getFacet(ObjectLayoutMetadataFacet.class); + final ObjectLayoutMetadata objectLayoutMetadata = objectLayoutMetadataFacet.getMetadata(); // TODO: debugging, remove - final String xml = getServicesInjector().lookupService(JaxbService.class).toXml(domainObject); + final String xml = getServicesInjector().lookupService(JaxbService.class).toXml(objectLayoutMetadata); System.out.println(xml); addOrReplace(ComponentType.ENTITY_SUMMARY, model); - final List<TabGroup> tabGroups = domainObject.getTabGroups(); + final List<TabGroup> tabGroups = FluentIterable + .from(objectLayoutMetadata.getTabGroups()) + .filter(TabGroup.Predicates.notEmpty()) + .toList(); final ListView<TabGroup> tabGroupsList = new ListView<TabGroup>(ID_TAB_GROUPS, tabGroups) { @@ -89,10 +93,12 @@ public class EntityTabGroupsPanel extends PanelAbstract<EntityModel> { final List<ITab> tabs = Lists.newArrayList(); final TabGroup tabGroup = item.getModelObject(); - final List<Tab> tabList = tabGroup.getTabs(); + final List<Tab> tabList = FluentIterable + .from(tabGroup.getTabs()) + .filter(Tab.Predicates.notEmpty()) + .toList(); for (final Tab tab : tabList) { - tabs.add(new AbstractTab(Model.of(tab.getName())) { private static final long serialVersionUID = 1L; @@ -115,10 +121,9 @@ public class EntityTabGroupsPanel extends PanelAbstract<EntityModel> { super(id); final EntityModel modelWithTabHints = new EntityModel(model.getPageParameters()); - model.setTabMetadata(tab); + modelWithTabHints.setTabMetadata(tab); getComponentFactoryRegistry().addOrReplaceComponent(this, ID_ENTITY_PROPERTIES_AND_COLLECTIONS, ComponentType.ENTITY_PROPERTIES, modelWithTabHints); - } } } http://git-wip-us.apache.org/repos/asf/isis/blob/fb0f1273/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/tabgroups/EntityTabGroupsPanelFactory.java ---------------------------------------------------------------------- diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/tabgroups/EntityTabGroupsPanelFactory.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/tabgroups/EntityTabGroupsPanelFactory.java index 825ea59..05e3b68 100644 --- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/tabgroups/EntityTabGroupsPanelFactory.java +++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/tabgroups/EntityTabGroupsPanelFactory.java @@ -22,7 +22,7 @@ package org.apache.isis.viewer.wicket.ui.components.entity.tabgroups; import org.apache.wicket.Component; import org.apache.wicket.model.IModel; -import org.apache.isis.core.metamodel.facets.object.layoutxml.LayoutXmlFacet; +import org.apache.isis.core.metamodel.facets.object.layoutxml.ObjectLayoutMetadataFacet; import org.apache.isis.core.metamodel.spec.ObjectSpecification; import org.apache.isis.viewer.wicket.model.models.EntityModel; import org.apache.isis.viewer.wicket.ui.ComponentFactory; @@ -45,7 +45,7 @@ public class EntityTabGroupsPanelFactory extends EntityComponentFactoryAbstract @Override protected ApplicationAdvice doAppliesTo(final EntityModel entityModel) { final ObjectSpecification specification = entityModel.getTypeOfSpecification(); - return appliesIf(specification.containsDoOpFacet(LayoutXmlFacet.class)); + return appliesIf(specification.containsDoOpFacet(ObjectLayoutMetadataFacet.class)); } @Override http://git-wip-us.apache.org/repos/asf/isis/blob/fb0f1273/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/entity/EntityPage.java ---------------------------------------------------------------------- diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/entity/EntityPage.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/entity/EntityPage.java index acc3a36..e068168 100644 --- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/entity/EntityPage.java +++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/entity/EntityPage.java @@ -131,10 +131,19 @@ public class EntityPage extends PageAbstract { - // the next bit is a work-around for JRebel integration... - // ... even though the IsisJRebelPlugin calls invalidateCache, it seems that there is - // some caching elsewhere in the Wicket viewer meaning that stale metadata is referenced. - // doing an additional call here seems to be sufficient, though not exactly sure why... :-( + // + // invalidate the cache so that can do dynamic reloading of layout metadata etc. + // + // Note that it's necessary to load the page twice. (I think) that the first time is to load the new + // Java class files into the webapp (but too "late" to be used), the second then works. + // Moving this functionality earlier on in the web request pipeline (eg WebRequestCycleForIsis) + // made no difference. + // + // what might help is using some sort of daemon process to monitor when the class files change, and then + // reload (a la JRebel). Don't think DCEVM by itself is enough, but possibly using + // https://github.com/fakereplace/fakereplace or https://github.com/spring-projects/spring-loaded + // might instead suffice since they provide a java agent similar to JRebel. + // if(!getDeploymentType().isProduction()) { getSpecificationLoader().invalidateCacheFor(objectAdapter.getObject()); } http://git-wip-us.apache.org/repos/asf/isis/blob/fb0f1273/example/application/simpleapp/dom/src/main/java/domainapp/dom/simple/SimpleObject.layout.xml ---------------------------------------------------------------------- diff --git a/example/application/simpleapp/dom/src/main/java/domainapp/dom/simple/SimpleObject.layout.xml b/example/application/simpleapp/dom/src/main/java/domainapp/dom/simple/SimpleObject.layout.xml index d367269..8d69476 100644 --- a/example/application/simpleapp/dom/src/main/java/domainapp/dom/simple/SimpleObject.layout.xml +++ b/example/application/simpleapp/dom/src/main/java/domainapp/dom/simple/SimpleObject.layout.xml @@ -1,7 +1,5 @@ -DELIBERATE SYNTAX ERROR TO DISABLE NEW RENDERING - <?xml version="1.0" encoding="UTF-8" standalone="yes"?> -<domainObject xsi:schemaLocation="http://isis.apache.org/schema/applib/layout http://isis.apache.org/schema/applib/layout/layout-1.0.xsd" xmlns="http://isis.apache.org/schema/applib/layout" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> +<objectLayout xsi:schemaLocation="http://isis.apache.org/schema/applib/layout http://isis.apache.org/schema/applib/layout/layout-1.0.xsd" xmlns="http://isis.apache.org/schema/applib/layout" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <actions> <action id="delete"/> </actions> @@ -16,23 +14,27 @@ DELIBERATE SYNTAX ERROR TO DISABLE NEW RENDERING </property> </propertyGroup> </left> - </tab> - <tab name="Other"> - <left span="4"> + <middle span="4"> + </middle> + <right span="4"> <propertyGroup name="Metadata"> <actions> <action id="downloadJdoMetadata"/> </actions> <property id="versionSequence"/> </propertyGroup> + </right> + </tab> + <tab name="Other"> + <left span="4"> </left> </tab> </tabGroup> <tabGroup> <tab name="Similar To"> <left span="12"> - <collection id="similarTo"/> + <collection id="similarTox"/> </left> </tab> </tabGroup> -</domainObject> \ No newline at end of file +</objectLayout> \ No newline at end of file