ISIS-537: changing @LabelAt to @PropertyLayout and @ParameterLayout. Also: fixing unit test for @ActionLayout facet.
Project: http://git-wip-us.apache.org/repos/asf/isis/repo Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/3969f34c Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/3969f34c Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/3969f34c Branch: refs/heads/master Commit: 3969f34c59eac644e2e1b7ba313be65c18e0e58a Parents: f58902e Author: Dan Haywood <[email protected]> Authored: Thu Nov 27 17:05:54 2014 +0000 Committer: Dan Haywood <[email protected]> Committed: Thu Nov 27 17:05:54 2014 +0000 ---------------------------------------------------------------------- .../components/scalars/ScalarPanelAbstract.java | 12 ++-- .../isis/applib/annotation/ActionLayout.java | 9 +++ .../apache/isis/applib/annotation/LabelAt.java | 38 ---------- .../isis/applib/annotation/LabelPosition.java | 31 ++++++++ .../isis/applib/annotation/ParameterLayout.java | 39 +++++++++++ .../isis/applib/annotation/PropertyLayout.java | 35 +++++++++ .../layout/ActionLayoutFacetFactory.java | 5 +- .../facets/fallback/FallbackFacetFactory.java | 22 +++--- .../fallback/LabelAtFacetFromConfiguration.java | 30 -------- .../PropParamLayoutFacetFromConfiguration.java | 30 ++++++++ .../LabelAtFacetOnParameterAnnotation.java | 32 --------- ...abelAtFacetOnParameterAnnotationFactory.java | 59 ---------------- ...LayoutFacetForParameterLayoutAnnotation.java | 32 +++++++++ ...acetForParameterLayoutAnnotationFactory.java | 59 ++++++++++++++++ ...tiLineFacetOnParameterAnnotationFactory.java | 8 +-- .../LabelAtFacetOnPropertyAnnotation.java | 32 --------- .../LabelAtFacetOnPropertyFactory.java | 66 ----------------- .../LabelAtFacetOnPropertyFromProperties.java | 37 ---------- ...mLayoutFacetForPropertyLayoutAnnotation.java | 32 +++++++++ ...FacetForPropertyLayoutAnnotationFactory.java | 66 +++++++++++++++++ ...aramLayoutFacetOnPropertyFromProperties.java | 37 ++++++++++ .../MultiLineFacetOnPropertyFactory.java | 8 +-- .../facets/propparam/labelat/LabelAtFacet.java | 32 --------- .../propparam/labelat/LabelAtFacetAbstract.java | 50 ------------- .../LabelAtFacetInferredFromMultiLineFacet.java | 38 ---------- .../propparam/layout/PropParamLayoutFacet.java | 36 ++++++++++ .../layout/PropParamLayoutFacetAbstract.java | 50 +++++++++++++ ...amLayoutFacetInferredFromMultiLineFacet.java | 38 ++++++++++ .../layoutmetadata/LabelAtFacetRepr.java | 22 ------ .../metamodel/layoutmetadata/MemberRepr.java | 2 +- .../layoutmetadata/PropertyLayoutFacetRepr.java | 22 ++++++ .../json/LayoutMetadataReaderFromJson.java | 6 +- .../dflt/ProgrammingModelFacetsJava5.java | 8 +-- .../ActionLayoutAnnotationFacetFactoryTest.java | 4 +- ...ForParameterLayoutAnnotationFactoryTest.java | 50 +++++++++++++ ...tForPropertyLayoutAnnotationFactoryTest.java | 53 ++++++++++++++ .../LabelAtAnnotationFacetFactoryTest.java | 74 -------------------- .../src/main/webapp/WEB-INF/isis.properties | 4 +- .../src/main/java/dom/todo/ToDoItem.layout.json | 8 +-- .../src/main/webapp/WEB-INF/isis.properties | 4 +- 40 files changed, 667 insertions(+), 553 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/isis/blob/3969f34c/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelAbstract.java ---------------------------------------------------------------------- diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelAbstract.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelAbstract.java index c391f44..2edf2ea 100644 --- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelAbstract.java +++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelAbstract.java @@ -37,7 +37,7 @@ import org.apache.isis.applib.annotation.ActionLayout; import org.apache.isis.applib.annotation.Where; 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.propparam.labelat.LabelAtFacet; +import org.apache.isis.core.metamodel.facets.propparam.layout.PropParamLayoutFacet; import org.apache.isis.core.runtime.system.DeploymentType; import org.apache.isis.core.runtime.system.context.IsisContext; import org.apache.isis.viewer.wicket.model.links.LinkAndLabel; @@ -311,7 +311,7 @@ public abstract class ScalarPanelAbstract extends PanelAbstract<ScalarModel> imp } /** - * Applies the {@literal @}{@link org.apache.isis.applib.annotation.LabelAt LabelAt} facet and also CSS based on + * Applies the {@literal @}{@link org.apache.isis.core.metamodel.facets.propparam.layout.PropParamLayoutFacet} and also CSS based on * whether any of the associated actions have {@literal @}{@link org.apache.isis.applib.annotation.ActionLayout layout} positioned to * the {@link org.apache.isis.applib.annotation.ActionLayout.Position#RIGHT right}. * @@ -319,7 +319,7 @@ public abstract class ScalarPanelAbstract extends PanelAbstract<ScalarModel> imp * @param entityActionLinks */ protected void addPositioningCssTo(final MarkupContainer markupContainer, final List<LinkAndLabel> entityActionLinks) { - CssClassAppender.appendCssClassTo(markupContainer, determineLabelAtCss(getModel())); + CssClassAppender.appendCssClassTo(markupContainer, determinePropParamLayoutCss(getModel())); CssClassAppender.appendCssClassTo(markupContainer, determineActionLayoutPositioningCss(entityActionLinks)); } @@ -331,10 +331,10 @@ public abstract class ScalarPanelAbstract extends PanelAbstract<ScalarModel> imp AdditionalLinksPanel.addAdditionalLinks(labelIfRegular, ID_ASSOCIATED_ACTION_LINKS_RIGHT, entityActionsRight, AdditionalLinksPanel.Style.DROPDOWN); } - private static String determineLabelAtCss(ScalarModel model) { - final LabelAtFacet facet = model.getFacet(LabelAtFacet.class); + private static String determinePropParamLayoutCss(ScalarModel model) { + final PropParamLayoutFacet facet = model.getFacet(PropParamLayoutFacet.class); if (facet != null) { - switch (facet.value()) { + switch (facet.label()) { case LEFT: return "label-left"; case NONE: http://git-wip-us.apache.org/repos/asf/isis/blob/3969f34c/core/applib/src/main/java/org/apache/isis/applib/annotation/ActionLayout.java ---------------------------------------------------------------------- diff --git a/core/applib/src/main/java/org/apache/isis/applib/annotation/ActionLayout.java b/core/applib/src/main/java/org/apache/isis/applib/annotation/ActionLayout.java index 0614d1b..1984c8c 100644 --- a/core/applib/src/main/java/org/apache/isis/applib/annotation/ActionLayout.java +++ b/core/applib/src/main/java/org/apache/isis/applib/annotation/ActionLayout.java @@ -19,9 +19,18 @@ 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; + /** * Layout hints for actions. */ +@Inherited +@Target({ ElementType.METHOD }) +@Retention(RetentionPolicy.RUNTIME) public @interface ActionLayout { /** http://git-wip-us.apache.org/repos/asf/isis/blob/3969f34c/core/applib/src/main/java/org/apache/isis/applib/annotation/LabelAt.java ---------------------------------------------------------------------- diff --git a/core/applib/src/main/java/org/apache/isis/applib/annotation/LabelAt.java b/core/applib/src/main/java/org/apache/isis/applib/annotation/LabelAt.java deleted file mode 100644 index 723a9ed..0000000 --- a/core/applib/src/main/java/org/apache/isis/applib/annotation/LabelAt.java +++ /dev/null @@ -1,38 +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.applib.annotation; - -import java.lang.annotation.*; - -/** - * Indicates where a property or action parameter's label should be rendered. - */ -@Inherited -@Target({ ElementType.METHOD, ElementType.PARAMETER }) -@Retention(RetentionPolicy.RUNTIME) -public @interface LabelAt { - public enum Position { - LEFT, - TOP, - NONE - } - Position value(); -} - http://git-wip-us.apache.org/repos/asf/isis/blob/3969f34c/core/applib/src/main/java/org/apache/isis/applib/annotation/LabelPosition.java ---------------------------------------------------------------------- diff --git a/core/applib/src/main/java/org/apache/isis/applib/annotation/LabelPosition.java b/core/applib/src/main/java/org/apache/isis/applib/annotation/LabelPosition.java new file mode 100644 index 0000000..93d559b --- /dev/null +++ b/core/applib/src/main/java/org/apache/isis/applib/annotation/LabelPosition.java @@ -0,0 +1,31 @@ +/* + * 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; + +/** + * The positioning of a label for a property or action parameter. + * + * @see org.apache.isis.applib.annotation.PropertyLayout + * @see org.apache.isis.applib.annotation.ParameterLayout + */ +public enum LabelPosition { + LEFT, + TOP, + NONE +} http://git-wip-us.apache.org/repos/asf/isis/blob/3969f34c/core/applib/src/main/java/org/apache/isis/applib/annotation/ParameterLayout.java ---------------------------------------------------------------------- diff --git a/core/applib/src/main/java/org/apache/isis/applib/annotation/ParameterLayout.java b/core/applib/src/main/java/org/apache/isis/applib/annotation/ParameterLayout.java new file mode 100644 index 0000000..b8ddf4e --- /dev/null +++ b/core/applib/src/main/java/org/apache/isis/applib/annotation/ParameterLayout.java @@ -0,0 +1,39 @@ +/* + * 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; + +/** + * Layout hints for action parameters. + * + * @see org.apache.isis.applib.annotation.PropertyLayout + */ +@Inherited +@Target({ ElementType.PARAMETER }) +@Retention(RetentionPolicy.RUNTIME) +public @interface ParameterLayout { + LabelPosition labelPosition(); +} + http://git-wip-us.apache.org/repos/asf/isis/blob/3969f34c/core/applib/src/main/java/org/apache/isis/applib/annotation/PropertyLayout.java ---------------------------------------------------------------------- diff --git a/core/applib/src/main/java/org/apache/isis/applib/annotation/PropertyLayout.java b/core/applib/src/main/java/org/apache/isis/applib/annotation/PropertyLayout.java new file mode 100644 index 0000000..bce1f80 --- /dev/null +++ b/core/applib/src/main/java/org/apache/isis/applib/annotation/PropertyLayout.java @@ -0,0 +1,35 @@ +/* + * 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.*; + +/** + * Layout hints for properties. + * + * @see org.apache.isis.applib.annotation.ParameterLayout + */ +@Inherited +@Target({ ElementType.METHOD }) +@Retention(RetentionPolicy.RUNTIME) +public @interface PropertyLayout { + LabelPosition labelPosition(); +} + http://git-wip-us.apache.org/repos/asf/isis/blob/3969f34c/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/layout/ActionLayoutFacetFactory.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/layout/ActionLayoutFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/layout/ActionLayoutFacetFactory.java index bf1b3de..c694083 100644 --- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/layout/ActionLayoutFacetFactory.java +++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/layout/ActionLayoutFacetFactory.java @@ -40,7 +40,10 @@ public class ActionLayoutFacetFactory extends FacetFactoryAbstract implements Co if(facet == null) { facet = createFromAnnotationIfPossible(processMethodContext); } - + if(facet == null) { + facet = new ActionLayoutFacetFallback(processMethodContext.getFacetHolder()); + } + // no-op if null FacetUtil.addFacet(facet); } http://git-wip-us.apache.org/repos/asf/isis/blob/3969f34c/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/fallback/FallbackFacetFactory.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/fallback/FallbackFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/fallback/FallbackFacetFactory.java index 7e9dc5b..7fdac1f 100644 --- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/fallback/FallbackFacetFactory.java +++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/fallback/FallbackFacetFactory.java @@ -23,7 +23,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import com.google.common.collect.Lists; -import org.apache.isis.applib.annotation.LabelAt; +import org.apache.isis.applib.annotation.LabelPosition; import org.apache.isis.core.commons.config.IsisConfiguration; import org.apache.isis.core.commons.config.IsisConfigurationAware; import org.apache.isis.core.metamodel.facetapi.Facet; @@ -105,7 +105,7 @@ public class FallbackFacetFactory extends FacetFactoryAbstract implements IsisCo facets.add(new MaxLengthFacetUnlimited(facetHolder)); facets.add(new MultiLineFacetNone(true, facetHolder)); - facets.add(newLabelAtFacetIfAny(facetHolder, "properties", "property", "props", "prop")); + facets.add(newPropParamLayoutFacetIfAny(facetHolder, "propertyLayout")); } if (featureType.isAction()) { facets.add(new ActionDefaultsFacetNone(facetHolder)); @@ -131,18 +131,19 @@ public class FallbackFacetFactory extends FacetFactoryAbstract implements IsisCo facets.add(new MaxLengthFacetUnlimited(typedHolder)); - facets.add(newLabelAtFacetIfAny(typedHolder, "parameters", "parameter", "params", "param")); + facets.add(newPropParamLayoutFacetIfAny(typedHolder, "parameterLayout")); } FacetUtil.addFacets(facets); } - private Facet newLabelAtFacetIfAny(FacetHolder facetHolder, final String... propOrParam) { - final String labelAt = getLabelAtConfigSetting(propOrParam); - if(labelAt != null) { + private Facet newPropParamLayoutFacetIfAny(final FacetHolder facetHolder, final String layoutKey) { + final String[] subKeys = new String[]{ "labelPosition", "label"}; + final String propParamLayout = getPropParamLayoutConfigSetting(layoutKey, subKeys); + if(propParamLayout != null) { try { - final LabelAt.Position position = LabelAt.Position.valueOf(labelAt); - return new LabelAtFacetFromConfiguration(position, facetHolder); + final LabelPosition labelPosition = LabelPosition.valueOf(propParamLayout); + return new PropParamLayoutFacetFromConfiguration(labelPosition, facetHolder); } catch(IllegalArgumentException ex) { // ignore } @@ -154,9 +155,10 @@ public class FallbackFacetFactory extends FacetFactoryAbstract implements IsisCo return getConfiguration().getInteger("isis.viewers.paged." + subkey, defaultValue); } - private String getLabelAtConfigSetting(String... subkeys) { + private String getPropParamLayoutConfigSetting(final String layout, String... subkeys) { for (String subkey : subkeys) { - final String value = getConfiguration().getString("isis.viewers.labelAt." + subkey); + final String layoutKey = "isis.viewers." + layout + "." + subkey; + final String value = getConfiguration().getString(layoutKey); if(value != null) { return value; } http://git-wip-us.apache.org/repos/asf/isis/blob/3969f34c/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/fallback/LabelAtFacetFromConfiguration.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/fallback/LabelAtFacetFromConfiguration.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/fallback/LabelAtFacetFromConfiguration.java deleted file mode 100644 index cd3425e..0000000 --- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/fallback/LabelAtFacetFromConfiguration.java +++ /dev/null @@ -1,30 +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.fallback; - -import org.apache.isis.applib.annotation.LabelAt; -import org.apache.isis.core.metamodel.facetapi.FacetHolder; -import org.apache.isis.core.metamodel.facets.propparam.labelat.LabelAtFacetAbstract; - -public class LabelAtFacetFromConfiguration extends LabelAtFacetAbstract { - - public LabelAtFacetFromConfiguration(LabelAt.Position position, FacetHolder facetHolder) { - super(position, facetHolder); - } -} http://git-wip-us.apache.org/repos/asf/isis/blob/3969f34c/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/fallback/PropParamLayoutFacetFromConfiguration.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/fallback/PropParamLayoutFacetFromConfiguration.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/fallback/PropParamLayoutFacetFromConfiguration.java new file mode 100644 index 0000000..a5ba4b0 --- /dev/null +++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/fallback/PropParamLayoutFacetFromConfiguration.java @@ -0,0 +1,30 @@ +/* + * 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.fallback; + +import org.apache.isis.applib.annotation.LabelPosition; +import org.apache.isis.core.metamodel.facetapi.FacetHolder; +import org.apache.isis.core.metamodel.facets.propparam.layout.PropParamLayoutFacetAbstract; + +public class PropParamLayoutFacetFromConfiguration extends PropParamLayoutFacetAbstract { + + public PropParamLayoutFacetFromConfiguration(LabelPosition labelPosition, FacetHolder facetHolder) { + super(labelPosition, facetHolder); + } +} http://git-wip-us.apache.org/repos/asf/isis/blob/3969f34c/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/labelat/annotation/LabelAtFacetOnParameterAnnotation.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/labelat/annotation/LabelAtFacetOnParameterAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/labelat/annotation/LabelAtFacetOnParameterAnnotation.java deleted file mode 100644 index 3db5180..0000000 --- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/labelat/annotation/LabelAtFacetOnParameterAnnotation.java +++ /dev/null @@ -1,32 +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.param.labelat.annotation; - -import org.apache.isis.applib.annotation.LabelAt; -import org.apache.isis.core.metamodel.facetapi.FacetHolder; -import org.apache.isis.core.metamodel.facets.propparam.labelat.LabelAtFacetAbstract; - -public class LabelAtFacetOnParameterAnnotation extends LabelAtFacetAbstract { - - public LabelAtFacetOnParameterAnnotation(final LabelAt.Position value, final FacetHolder holder) { - super(value, holder); - } - -} http://git-wip-us.apache.org/repos/asf/isis/blob/3969f34c/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/labelat/annotation/LabelAtFacetOnParameterAnnotationFactory.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/labelat/annotation/LabelAtFacetOnParameterAnnotationFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/labelat/annotation/LabelAtFacetOnParameterAnnotationFactory.java deleted file mode 100644 index 22622d73..0000000 --- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/labelat/annotation/LabelAtFacetOnParameterAnnotationFactory.java +++ /dev/null @@ -1,59 +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.param.labelat.annotation; - -import java.lang.annotation.Annotation; -import org.apache.isis.applib.annotation.LabelAt; -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.propparam.labelat.LabelAtFacet; - -public class LabelAtFacetOnParameterAnnotationFactory extends FacetFactoryAbstract { - - public LabelAtFacetOnParameterAnnotationFactory() { - super(FeatureType.PARAMETERS_ONLY); - } - - @Override - public void processParams(final ProcessParameterContext processParameterContext) { - final Class<?>[] parameterTypes = processParameterContext.getMethod().getParameterTypes(); - if (processParameterContext.getParamNum() >= parameterTypes.length) { - // ignore - return; - } - - final Annotation[] parameterAnnotations = Annotations.getParameterAnnotations(processParameterContext.getMethod())[processParameterContext.getParamNum()]; - for (final Annotation parameterAnnotation : parameterAnnotations) { - if (parameterAnnotation instanceof LabelAt) { - final LabelAt annotation = (LabelAt) parameterAnnotation; - FacetUtil.addFacet(create(annotation, processParameterContext.getFacetHolder())); - return; - } - } - } - - private LabelAtFacet create(final LabelAt annotation, final FacetHolder holder) { - return (annotation != null) ? new LabelAtFacetOnParameterAnnotation(annotation.value(), holder) : null; - } - -} http://git-wip-us.apache.org/repos/asf/isis/blob/3969f34c/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/layout/annotation/PropParamLayoutFacetForParameterLayoutAnnotation.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/layout/annotation/PropParamLayoutFacetForParameterLayoutAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/layout/annotation/PropParamLayoutFacetForParameterLayoutAnnotation.java new file mode 100644 index 0000000..558c81d --- /dev/null +++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/layout/annotation/PropParamLayoutFacetForParameterLayoutAnnotation.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.param.layout.annotation; + +import org.apache.isis.applib.annotation.LabelPosition; +import org.apache.isis.core.metamodel.facetapi.FacetHolder; +import org.apache.isis.core.metamodel.facets.propparam.layout.PropParamLayoutFacetAbstract; + +public class PropParamLayoutFacetForParameterLayoutAnnotation extends PropParamLayoutFacetAbstract { + + public PropParamLayoutFacetForParameterLayoutAnnotation(final LabelPosition value, final FacetHolder holder) { + super(value, holder); + } + +} http://git-wip-us.apache.org/repos/asf/isis/blob/3969f34c/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/layout/annotation/PropParamLayoutFacetForParameterLayoutAnnotationFactory.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/layout/annotation/PropParamLayoutFacetForParameterLayoutAnnotationFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/layout/annotation/PropParamLayoutFacetForParameterLayoutAnnotationFactory.java new file mode 100644 index 0000000..92a1256 --- /dev/null +++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/layout/annotation/PropParamLayoutFacetForParameterLayoutAnnotationFactory.java @@ -0,0 +1,59 @@ +/* + * 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.param.layout.annotation; + +import java.lang.annotation.Annotation; +import org.apache.isis.applib.annotation.ParameterLayout; +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.propparam.layout.PropParamLayoutFacet; + +public class PropParamLayoutFacetForParameterLayoutAnnotationFactory extends FacetFactoryAbstract { + + public PropParamLayoutFacetForParameterLayoutAnnotationFactory() { + super(FeatureType.PARAMETERS_ONLY); + } + + @Override + public void processParams(final ProcessParameterContext processParameterContext) { + final Class<?>[] parameterTypes = processParameterContext.getMethod().getParameterTypes(); + if (processParameterContext.getParamNum() >= parameterTypes.length) { + // ignore + return; + } + + final Annotation[] parameterAnnotations = Annotations.getParameterAnnotations(processParameterContext.getMethod())[processParameterContext.getParamNum()]; + for (final Annotation parameterAnnotation : parameterAnnotations) { + if (parameterAnnotation instanceof ParameterLayout) { + final ParameterLayout annotation = (ParameterLayout) parameterAnnotation; + FacetUtil.addFacet(create(annotation, processParameterContext.getFacetHolder())); + return; + } + } + } + + private PropParamLayoutFacet create(final ParameterLayout annotation, final FacetHolder holder) { + return (annotation != null) ? new PropParamLayoutFacetForParameterLayoutAnnotation(annotation.labelPosition(), holder) : null; + } + +} http://git-wip-us.apache.org/repos/asf/isis/blob/3969f34c/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/multiline/annotation/MultiLineFacetOnParameterAnnotationFactory.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/multiline/annotation/MultiLineFacetOnParameterAnnotationFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/multiline/annotation/MultiLineFacetOnParameterAnnotationFactory.java index 064cf21..2232223 100644 --- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/multiline/annotation/MultiLineFacetOnParameterAnnotationFactory.java +++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/param/multiline/annotation/MultiLineFacetOnParameterAnnotationFactory.java @@ -26,7 +26,7 @@ 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.propparam.labelat.LabelAtFacetInferredFromMultiLineFacet; +import org.apache.isis.core.metamodel.facets.propparam.layout.PropParamLayoutFacetInferredFromMultiLineFacet; import org.apache.isis.core.metamodel.facets.propparam.multiline.MultiLineFacet; public class MultiLineFacetOnParameterAnnotationFactory extends FacetFactoryAbstract { @@ -62,14 +62,14 @@ public class MultiLineFacetOnParameterAnnotationFactory extends FacetFactoryAbst FacetUtil.addFacet(facet); // no-op if null - inferLabelAtFacet(facet); + inferPropParamLayoutFacet(facet); } - private static void inferLabelAtFacet(MultiLineFacet facet) { + private static void inferPropParamLayoutFacet(MultiLineFacet facet) { if (facet == null) { return; } - FacetUtil.addFacet(new LabelAtFacetInferredFromMultiLineFacet(facet.getFacetHolder())); + FacetUtil.addFacet(new PropParamLayoutFacetInferredFromMultiLineFacet(facet.getFacetHolder())); } private MultiLineFacet create(final MultiLine annotation, final FacetHolder holder) { http://git-wip-us.apache.org/repos/asf/isis/blob/3969f34c/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/labelat/annotation/LabelAtFacetOnPropertyAnnotation.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/labelat/annotation/LabelAtFacetOnPropertyAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/labelat/annotation/LabelAtFacetOnPropertyAnnotation.java deleted file mode 100644 index 8c0e1f3..0000000 --- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/labelat/annotation/LabelAtFacetOnPropertyAnnotation.java +++ /dev/null @@ -1,32 +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.properties.labelat.annotation; - -import org.apache.isis.applib.annotation.LabelAt; -import org.apache.isis.core.metamodel.facetapi.FacetHolder; -import org.apache.isis.core.metamodel.facets.propparam.labelat.LabelAtFacetAbstract; - -public class LabelAtFacetOnPropertyAnnotation extends LabelAtFacetAbstract { - - public LabelAtFacetOnPropertyAnnotation(final LabelAt.Position value, final FacetHolder holder) { - super(value, holder); - } - -} http://git-wip-us.apache.org/repos/asf/isis/blob/3969f34c/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/labelat/annotation/LabelAtFacetOnPropertyFactory.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/labelat/annotation/LabelAtFacetOnPropertyFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/labelat/annotation/LabelAtFacetOnPropertyFactory.java deleted file mode 100644 index cae5970..0000000 --- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/labelat/annotation/LabelAtFacetOnPropertyFactory.java +++ /dev/null @@ -1,66 +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.properties.labelat.annotation; - -import java.util.Properties; -import org.apache.isis.applib.annotation.LabelAt; -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.ContributeeMemberFacetFactory; -import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract; -import org.apache.isis.core.metamodel.facets.propparam.labelat.LabelAtFacet; - -public class LabelAtFacetOnPropertyFactory extends FacetFactoryAbstract implements ContributeeMemberFacetFactory { - - public LabelAtFacetOnPropertyFactory() { - super(FeatureType.PROPERTIES_ONLY); - } - - @Override - public void process(final ProcessMethodContext processMethodContext) { - LabelAtFacet facet = createFromMetadataPropertiesIfPossible(processMethodContext); - if(facet == null) { - facet = createFromAnnotationIfPossible(processMethodContext); - } - - // no-op if null - FacetUtil.addFacet(facet); - } - - @Override - public void process(ProcessContributeeMemberContext processMemberContext) { - } - - private static LabelAtFacet createFromMetadataPropertiesIfPossible( - final ProcessContextWithMetadataProperties<? extends FacetHolder> pcwmp) { - - final FacetHolder holder = pcwmp.getFacetHolder(); - - final Properties properties = pcwmp.metadataProperties("labelAt"); - return properties != null ? new LabelAtFacetOnPropertyFromProperties(properties, holder) : null; - } - - private static LabelAtFacetOnPropertyAnnotation createFromAnnotationIfPossible(final ProcessMethodContext processMethodContext) { - final LabelAt annotation = Annotations.getAnnotation(processMethodContext.getMethod(), LabelAt.class); - return (annotation != null) ? new LabelAtFacetOnPropertyAnnotation(annotation.value(), processMethodContext.getFacetHolder()) : null; - } -} http://git-wip-us.apache.org/repos/asf/isis/blob/3969f34c/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/labelat/annotation/LabelAtFacetOnPropertyFromProperties.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/labelat/annotation/LabelAtFacetOnPropertyFromProperties.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/labelat/annotation/LabelAtFacetOnPropertyFromProperties.java deleted file mode 100644 index d6bd907..0000000 --- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/labelat/annotation/LabelAtFacetOnPropertyFromProperties.java +++ /dev/null @@ -1,37 +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.properties.labelat.annotation; - -import java.util.Properties; -import org.apache.isis.applib.annotation.LabelAt; -import org.apache.isis.core.metamodel.facetapi.FacetHolder; -import org.apache.isis.core.metamodel.facets.propparam.labelat.LabelAtFacetAbstract; - -public class LabelAtFacetOnPropertyFromProperties extends LabelAtFacetAbstract { - - public LabelAtFacetOnPropertyFromProperties(Properties properties, FacetHolder holder) { - super(valueFrom(properties), holder); - } - - private static LabelAt.Position valueFrom(Properties properties) { - return LabelAt.Position.valueOf(properties.getProperty("value")); - } - -} http://git-wip-us.apache.org/repos/asf/isis/blob/3969f34c/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/annotation/PropParamLayoutFacetForPropertyLayoutAnnotation.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/annotation/PropParamLayoutFacetForPropertyLayoutAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/annotation/PropParamLayoutFacetForPropertyLayoutAnnotation.java new file mode 100644 index 0000000..ef9e350 --- /dev/null +++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/annotation/PropParamLayoutFacetForPropertyLayoutAnnotation.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.properties.layout.annotation; + +import org.apache.isis.applib.annotation.LabelPosition; +import org.apache.isis.core.metamodel.facetapi.FacetHolder; +import org.apache.isis.core.metamodel.facets.propparam.layout.PropParamLayoutFacetAbstract; + +public class PropParamLayoutFacetForPropertyLayoutAnnotation extends PropParamLayoutFacetAbstract { + + public PropParamLayoutFacetForPropertyLayoutAnnotation(final LabelPosition value, final FacetHolder holder) { + super(value, holder); + } + +} http://git-wip-us.apache.org/repos/asf/isis/blob/3969f34c/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/annotation/PropParamLayoutFacetForPropertyLayoutAnnotationFactory.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/annotation/PropParamLayoutFacetForPropertyLayoutAnnotationFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/annotation/PropParamLayoutFacetForPropertyLayoutAnnotationFactory.java new file mode 100644 index 0000000..74cd386 --- /dev/null +++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/annotation/PropParamLayoutFacetForPropertyLayoutAnnotationFactory.java @@ -0,0 +1,66 @@ +/* + * 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.properties.layout.annotation; + +import java.util.Properties; +import org.apache.isis.applib.annotation.PropertyLayout; +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.ContributeeMemberFacetFactory; +import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract; +import org.apache.isis.core.metamodel.facets.propparam.layout.PropParamLayoutFacet; + +public class PropParamLayoutFacetForPropertyLayoutAnnotationFactory extends FacetFactoryAbstract implements ContributeeMemberFacetFactory { + + public PropParamLayoutFacetForPropertyLayoutAnnotationFactory() { + super(FeatureType.PROPERTIES_ONLY); + } + + @Override + public void process(final ProcessMethodContext processMethodContext) { + PropParamLayoutFacet facet = createFromMetadataPropertiesIfPossible(processMethodContext); + if(facet == null) { + facet = createFromAnnotationIfPossible(processMethodContext); + } + + // no-op if null + FacetUtil.addFacet(facet); + } + + @Override + public void process(ProcessContributeeMemberContext processMemberContext) { + } + + private static PropParamLayoutFacet createFromMetadataPropertiesIfPossible( + final ProcessContextWithMetadataProperties<? extends FacetHolder> pcwmp) { + + final FacetHolder holder = pcwmp.getFacetHolder(); + + final Properties properties = pcwmp.metadataProperties("propertyLayout"); + return properties != null ? new PropParamLayoutFacetOnPropertyFromProperties(properties, holder) : null; + } + + private static PropParamLayoutFacetForPropertyLayoutAnnotation createFromAnnotationIfPossible(final ProcessMethodContext processMethodContext) { + final PropertyLayout annotation = Annotations.getAnnotation(processMethodContext.getMethod(), PropertyLayout.class); + return (annotation != null) ? new PropParamLayoutFacetForPropertyLayoutAnnotation(annotation.labelPosition(), processMethodContext.getFacetHolder()) : null; + } +} http://git-wip-us.apache.org/repos/asf/isis/blob/3969f34c/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/annotation/PropParamLayoutFacetOnPropertyFromProperties.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/annotation/PropParamLayoutFacetOnPropertyFromProperties.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/annotation/PropParamLayoutFacetOnPropertyFromProperties.java new file mode 100644 index 0000000..e01b5d0 --- /dev/null +++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/layout/annotation/PropParamLayoutFacetOnPropertyFromProperties.java @@ -0,0 +1,37 @@ +/* + * 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.properties.layout.annotation; + +import java.util.Properties; +import org.apache.isis.applib.annotation.LabelPosition; +import org.apache.isis.core.metamodel.facetapi.FacetHolder; +import org.apache.isis.core.metamodel.facets.propparam.layout.PropParamLayoutFacetAbstract; + +public class PropParamLayoutFacetOnPropertyFromProperties extends PropParamLayoutFacetAbstract { + + public PropParamLayoutFacetOnPropertyFromProperties(Properties properties, FacetHolder holder) { + super(valueFrom(properties), holder); + } + + private static LabelPosition valueFrom(Properties properties) { + return LabelPosition.valueOf(properties.getProperty("labelPosition")); + } + +} http://git-wip-us.apache.org/repos/asf/isis/blob/3969f34c/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/multiline/annotation/MultiLineFacetOnPropertyFactory.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/multiline/annotation/MultiLineFacetOnPropertyFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/multiline/annotation/MultiLineFacetOnPropertyFactory.java index 72a8976..a9c2a4a 100644 --- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/multiline/annotation/MultiLineFacetOnPropertyFactory.java +++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/multiline/annotation/MultiLineFacetOnPropertyFactory.java @@ -27,7 +27,7 @@ import org.apache.isis.core.metamodel.facetapi.FeatureType; import org.apache.isis.core.metamodel.facets.Annotations; import org.apache.isis.core.metamodel.facets.ContributeeMemberFacetFactory; import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract; -import org.apache.isis.core.metamodel.facets.propparam.labelat.LabelAtFacetInferredFromMultiLineFacet; +import org.apache.isis.core.metamodel.facets.propparam.layout.PropParamLayoutFacetInferredFromMultiLineFacet; import org.apache.isis.core.metamodel.facets.propparam.multiline.MultiLineFacet; public class MultiLineFacetOnPropertyFactory extends FacetFactoryAbstract implements ContributeeMemberFacetFactory { @@ -47,14 +47,14 @@ public class MultiLineFacetOnPropertyFactory extends FacetFactoryAbstract implem FacetUtil.addFacet(facet); // no-op if null - inferLabelAtFacet(facet); + inferPropParamLayoutFacet(facet); } - private static void inferLabelAtFacet(MultiLineFacet facet) { + private static void inferPropParamLayoutFacet(MultiLineFacet facet) { if (facet == null) { return; } - FacetUtil.addFacet(new LabelAtFacetInferredFromMultiLineFacet(facet.getFacetHolder())); + FacetUtil.addFacet(new PropParamLayoutFacetInferredFromMultiLineFacet(facet.getFacetHolder())); } @Override http://git-wip-us.apache.org/repos/asf/isis/blob/3969f34c/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/labelat/LabelAtFacet.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/labelat/LabelAtFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/labelat/LabelAtFacet.java deleted file mode 100644 index 500a379..0000000 --- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/labelat/LabelAtFacet.java +++ /dev/null @@ -1,32 +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.propparam.labelat; - -import org.apache.isis.applib.annotation.LabelAt; -import org.apache.isis.core.metamodel.facets.MultipleValueFacet; - -/** - * The positioning of a property or action parameter's label. - */ -public interface LabelAtFacet extends MultipleValueFacet { - - public LabelAt.Position value(); - -} http://git-wip-us.apache.org/repos/asf/isis/blob/3969f34c/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/labelat/LabelAtFacetAbstract.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/labelat/LabelAtFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/labelat/LabelAtFacetAbstract.java deleted file mode 100644 index d62dd5d..0000000 --- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/labelat/LabelAtFacetAbstract.java +++ /dev/null @@ -1,50 +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.propparam.labelat; - -import org.apache.isis.applib.annotation.LabelAt; -import org.apache.isis.core.metamodel.facetapi.Facet; -import org.apache.isis.core.metamodel.facetapi.FacetHolder; -import org.apache.isis.core.metamodel.facets.MultipleValueFacetAbstract; - -public abstract class LabelAtFacetAbstract extends MultipleValueFacetAbstract implements LabelAtFacet { - - public static Class<? extends Facet> type() { - return LabelAtFacet.class; - } - - private final LabelAt.Position value; - - public LabelAtFacetAbstract(final LabelAt.Position value, final FacetHolder holder) { - super(type(), holder); - this.value = value; - } - - @Override - public LabelAt.Position value() { - return value; - } - - @Override - protected String toStringValues() { - return "position=" + value; - } - -} http://git-wip-us.apache.org/repos/asf/isis/blob/3969f34c/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/labelat/LabelAtFacetInferredFromMultiLineFacet.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/labelat/LabelAtFacetInferredFromMultiLineFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/labelat/LabelAtFacetInferredFromMultiLineFacet.java deleted file mode 100644 index bdbce68..0000000 --- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/labelat/LabelAtFacetInferredFromMultiLineFacet.java +++ /dev/null @@ -1,38 +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.propparam.labelat; - -import org.apache.isis.applib.annotation.LabelAt; -import org.apache.isis.core.metamodel.facetapi.FacetHolder; - -/** - * If multi-line then position the label at the top. - * - * <p> - * This can still be overridden using the {@link org.apache.isis.applib.annotation.LabelAt} annotation / layout.json. - * </p> - */ -public class LabelAtFacetInferredFromMultiLineFacet extends LabelAtFacetAbstract { - - public LabelAtFacetInferredFromMultiLineFacet(final FacetHolder holder) { - super(LabelAt.Position.TOP, holder); - } - -} http://git-wip-us.apache.org/repos/asf/isis/blob/3969f34c/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/layout/PropParamLayoutFacet.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/layout/PropParamLayoutFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/layout/PropParamLayoutFacet.java new file mode 100644 index 0000000..71a8f73 --- /dev/null +++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/layout/PropParamLayoutFacet.java @@ -0,0 +1,36 @@ +/* + * 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.propparam.layout; + +import org.apache.isis.applib.annotation.LabelPosition; +import org.apache.isis.core.metamodel.facetapi.Facet; + +/** + * Corresponds to either {@literal @}{@link org.apache.isis.applib.annotation.PropertyLayout} (for a property) or + *{@literal @}{@link org.apache.isis.applib.annotation.ParameterLayout} (for an action parameter). + */ +public interface PropParamLayoutFacet extends Facet { + + /** + * The positioning of a property or action parameter's label. + */ + public LabelPosition label(); + +} http://git-wip-us.apache.org/repos/asf/isis/blob/3969f34c/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/layout/PropParamLayoutFacetAbstract.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/layout/PropParamLayoutFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/layout/PropParamLayoutFacetAbstract.java new file mode 100644 index 0000000..60c02f2 --- /dev/null +++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/layout/PropParamLayoutFacetAbstract.java @@ -0,0 +1,50 @@ +/* + * 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.propparam.layout; + +import org.apache.isis.applib.annotation.LabelPosition; +import org.apache.isis.core.metamodel.facetapi.Facet; +import org.apache.isis.core.metamodel.facetapi.FacetHolder; +import org.apache.isis.core.metamodel.facets.MultipleValueFacetAbstract; + +public abstract class PropParamLayoutFacetAbstract extends MultipleValueFacetAbstract implements PropParamLayoutFacet { + + public static Class<? extends Facet> type() { + return PropParamLayoutFacet.class; + } + + private final LabelPosition value; + + public PropParamLayoutFacetAbstract(final LabelPosition value, final FacetHolder holder) { + super(type(), holder); + this.value = value; + } + + @Override + public LabelPosition label() { + return value; + } + + @Override + protected String toStringValues() { + return "position=" + value; + } + +} http://git-wip-us.apache.org/repos/asf/isis/blob/3969f34c/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/layout/PropParamLayoutFacetInferredFromMultiLineFacet.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/layout/PropParamLayoutFacetInferredFromMultiLineFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/layout/PropParamLayoutFacetInferredFromMultiLineFacet.java new file mode 100644 index 0000000..ee6119e --- /dev/null +++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/propparam/layout/PropParamLayoutFacetInferredFromMultiLineFacet.java @@ -0,0 +1,38 @@ +/* + * 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.propparam.layout; + +import org.apache.isis.applib.annotation.LabelPosition; +import org.apache.isis.core.metamodel.facetapi.FacetHolder; + +/** + * If multi-line then position the label at the top. + * + * <p> + * This can still be overridden using the {@link org.apache.isis.applib.annotation.PropertyLayout} annotation / layout.json. + * </p> + */ +public class PropParamLayoutFacetInferredFromMultiLineFacet extends PropParamLayoutFacetAbstract { + + public PropParamLayoutFacetInferredFromMultiLineFacet(final FacetHolder holder) { + super(LabelPosition.TOP, holder); + } + +} http://git-wip-us.apache.org/repos/asf/isis/blob/3969f34c/core/metamodel/src/main/java/org/apache/isis/core/metamodel/layoutmetadata/LabelAtFacetRepr.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/layoutmetadata/LabelAtFacetRepr.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/layoutmetadata/LabelAtFacetRepr.java deleted file mode 100644 index 945cfb3..0000000 --- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/layoutmetadata/LabelAtFacetRepr.java +++ /dev/null @@ -1,22 +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.layoutmetadata; - - -public class LabelAtFacetRepr { - public String value; -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/isis/blob/3969f34c/core/metamodel/src/main/java/org/apache/isis/core/metamodel/layoutmetadata/MemberRepr.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/layoutmetadata/MemberRepr.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/layoutmetadata/MemberRepr.java index 14167bf..d5d2e7e 100644 --- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/layoutmetadata/MemberRepr.java +++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/layoutmetadata/MemberRepr.java @@ -37,5 +37,5 @@ public class MemberRepr { // TODO mgrigorov: should we add public CssClassFaFacetRepr cssClassFa; ? public TypicalLengthFacetRepr typicalLength; public MultiLineFacetRepr multiLine; - public LabelAtFacetRepr labelAt; + public PropertyLayoutFacetRepr propertyLayout; } http://git-wip-us.apache.org/repos/asf/isis/blob/3969f34c/core/metamodel/src/main/java/org/apache/isis/core/metamodel/layoutmetadata/PropertyLayoutFacetRepr.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/layoutmetadata/PropertyLayoutFacetRepr.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/layoutmetadata/PropertyLayoutFacetRepr.java new file mode 100644 index 0000000..59ca0b3 --- /dev/null +++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/layoutmetadata/PropertyLayoutFacetRepr.java @@ -0,0 +1,22 @@ +/** + * 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.layoutmetadata; + + +public class PropertyLayoutFacetRepr { + public String labelPosition; +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/isis/blob/3969f34c/core/metamodel/src/main/java/org/apache/isis/core/metamodel/layoutmetadata/json/LayoutMetadataReaderFromJson.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/layoutmetadata/json/LayoutMetadataReaderFromJson.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/layoutmetadata/json/LayoutMetadataReaderFromJson.java index 71cff36..d62db96 100644 --- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/layoutmetadata/json/LayoutMetadataReaderFromJson.java +++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/layoutmetadata/json/LayoutMetadataReaderFromJson.java @@ -157,9 +157,9 @@ public class LayoutMetadataReaderFromJson implements LayoutMetadataReader { if(multiLine!= null) { props.setProperty("member." + memberName + ".multiLine.numberOfLines", ""+multiLine.numberOfLines); } - final LabelAtFacetRepr labelAt = memberRepr.labelAt; - if(labelAt!= null) { - props.setProperty("member." + memberName + ".labelAt.value", ""+labelAt.value); + final PropertyLayoutFacetRepr propertyLayout = memberRepr.propertyLayout; + if(propertyLayout!= null) { + props.setProperty("member." + memberName + ".propertyLayout.labelPosition", ""+propertyLayout.labelPosition); } final PagedFacetRepr paged = memberRepr.paged; if(paged != null) { http://git-wip-us.apache.org/repos/asf/isis/blob/3969f34c/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 4030f20..ba149cb 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 @@ -140,7 +140,7 @@ import org.apache.isis.core.metamodel.facets.param.choices.methodnum.ActionParam import org.apache.isis.core.metamodel.facets.param.defaults.fromtype.ActionParameterDefaultFacetDerivedFromTypeFactory; import org.apache.isis.core.metamodel.facets.param.defaults.methodnum.ActionParameterDefaultsFacetViaMethodFactory; import org.apache.isis.core.metamodel.facets.param.describedas.annotderived.DescribedAsFacetOnParameterAnnotationElseDerivedFromTypeFactory; -import org.apache.isis.core.metamodel.facets.param.labelat.annotation.LabelAtFacetOnParameterAnnotationFactory; +import org.apache.isis.core.metamodel.facets.param.layout.annotation.PropParamLayoutFacetForParameterLayoutAnnotationFactory; import org.apache.isis.core.metamodel.facets.param.mandatory.annotation.MandatoryFacetOnParameterInvertedByOptionalAnnotationFactory; import org.apache.isis.core.metamodel.facets.param.mandatory.dflt.MandatoryFacetOnParametersDefaultFactory; import org.apache.isis.core.metamodel.facets.param.multiline.annotation.MultiLineFacetOnParameterAnnotationFactory; @@ -162,7 +162,7 @@ import org.apache.isis.core.metamodel.facets.properties.defaults.method.Property import org.apache.isis.core.metamodel.facets.properties.disabled.fromimmutable.DisabledFacetOnPropertyDerivedFromImmutableFactory; import org.apache.isis.core.metamodel.facets.properties.disabled.inferred.DisabledFacetOnPropertyInferredFactory; import org.apache.isis.core.metamodel.facets.properties.interaction.PropertyInteractionFacetFactory; -import org.apache.isis.core.metamodel.facets.properties.labelat.annotation.LabelAtFacetOnPropertyFactory; +import org.apache.isis.core.metamodel.facets.properties.layout.annotation.PropParamLayoutFacetForPropertyLayoutAnnotationFactory; import org.apache.isis.core.metamodel.facets.properties.mandatory.annotation.mandatory.MandatoryFacetOnPropertyMandatoryAnnotationFactory; import org.apache.isis.core.metamodel.facets.properties.mandatory.annotation.optional.MandatoryFacetOnPropertyInvertedByOptionalAnnotationFactory; import org.apache.isis.core.metamodel.facets.properties.mandatory.dflt.MandatoryFacetOnProperyDefaultFactory; @@ -401,8 +401,8 @@ public final class ProgrammingModelFacetsJava5 extends ProgrammingModelAbstract addFactory(MultiLineFacetOnParameterAnnotationFactory.class); // must come after MultiLine - addFactory(LabelAtFacetOnPropertyFactory.class); - addFactory(LabelAtFacetOnParameterAnnotationFactory.class); + addFactory(PropParamLayoutFacetForPropertyLayoutAnnotationFactory.class); + addFactory(PropParamLayoutFacetForParameterLayoutAnnotationFactory.class); addFactory(ActionLayoutFacetFactory.class); http://git-wip-us.apache.org/repos/asf/isis/blob/3969f34c/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 index 3af9fe1..4982c10 100644 --- 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 @@ -33,11 +33,11 @@ public class ActionLayoutAnnotationFacetFactoryTest extends AbstractFacetFactory class Customer { @SuppressWarnings("unused") @ActionLayout(position = ActionLayout.Position.PANEL) - public String foo() { + public String foz() { return null; } } - final Method method = findMethod(Customer.class, "foo"); + final Method method = findMethod(Customer.class, "foz"); facetFactory.process(new ProcessMethodContext(Customer.class, null, null, method, methodRemover, facetedMethod)); http://git-wip-us.apache.org/repos/asf/isis/blob/3969f34c/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/param/layout/annotation/PropParamLayoutFacetForParameterLayoutAnnotationFactoryTest.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/param/layout/annotation/PropParamLayoutFacetForParameterLayoutAnnotationFactoryTest.java b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/param/layout/annotation/PropParamLayoutFacetForParameterLayoutAnnotationFactoryTest.java new file mode 100644 index 0000000..7924a16 --- /dev/null +++ b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/param/layout/annotation/PropParamLayoutFacetForParameterLayoutAnnotationFactoryTest.java @@ -0,0 +1,50 @@ +/* + * 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.param.layout.annotation; + +import java.lang.reflect.Method; +import org.apache.isis.applib.annotation.LabelPosition; +import org.apache.isis.applib.annotation.ParameterLayout; +import org.apache.isis.core.metamodel.facetapi.Facet; +import org.apache.isis.core.metamodel.facets.AbstractFacetFactoryTest; +import org.apache.isis.core.metamodel.facets.FacetFactory; +import org.apache.isis.core.metamodel.facets.propparam.layout.PropParamLayoutFacet; + +public class PropParamLayoutFacetForParameterLayoutAnnotationFactoryTest extends AbstractFacetFactoryTest { + + public void testParameterLayoutAnnotationPickedUp() { + final PropParamLayoutFacetForParameterLayoutAnnotationFactory facetFactory = new PropParamLayoutFacetForParameterLayoutAnnotationFactory(); + + class Customer { + @SuppressWarnings("unused") + public void someAction(@ParameterLayout(labelPosition = LabelPosition.LEFT) final String foo) { + } + } + final Method method = findMethod(Customer.class, "someAction", new Class[] { String.class }); + + facetFactory.processParams(new FacetFactory.ProcessParameterContext(method, 0, facetedMethodParameter)); + + final Facet facet = facetedMethodParameter.getFacet(PropParamLayoutFacet.class); + assertNotNull(facet); + assertTrue(facet instanceof PropParamLayoutFacetForParameterLayoutAnnotation); + final PropParamLayoutFacetForParameterLayoutAnnotation layoutAnnotation = (PropParamLayoutFacetForParameterLayoutAnnotation) facet; + assertEquals(LabelPosition.LEFT, layoutAnnotation.label()); + } +} http://git-wip-us.apache.org/repos/asf/isis/blob/3969f34c/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/properties/layout/annotation/PropParamLayoutFacetForPropertyLayoutAnnotationFactoryTest.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/properties/layout/annotation/PropParamLayoutFacetForPropertyLayoutAnnotationFactoryTest.java b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/properties/layout/annotation/PropParamLayoutFacetForPropertyLayoutAnnotationFactoryTest.java new file mode 100644 index 0000000..e970bd7 --- /dev/null +++ b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/properties/layout/annotation/PropParamLayoutFacetForPropertyLayoutAnnotationFactoryTest.java @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.isis.core.metamodel.facets.properties.layout.annotation; + +import java.lang.reflect.Method; +import org.apache.isis.applib.annotation.LabelPosition; +import org.apache.isis.applib.annotation.PropertyLayout; +import org.apache.isis.core.metamodel.facetapi.Facet; +import org.apache.isis.core.metamodel.facets.AbstractFacetFactoryTest; +import org.apache.isis.core.metamodel.facets.FacetFactory.ProcessMethodContext; +import org.apache.isis.core.metamodel.facets.propparam.layout.PropParamLayoutFacet; + +public class PropParamLayoutFacetForPropertyLayoutAnnotationFactoryTest extends AbstractFacetFactoryTest { + + public void testPropertyLayoutAnnotationPickedUp() { + final PropParamLayoutFacetForPropertyLayoutAnnotationFactory facetFactory = new PropParamLayoutFacetForPropertyLayoutAnnotationFactory(); + + class Customer { + @SuppressWarnings("unused") + @PropertyLayout(labelPosition = LabelPosition.LEFT) + public String getFirstName() { + return null; + } + } + final Method method = findMethod(Customer.class, "getFirstName"); + + facetFactory.process(new ProcessMethodContext(Customer.class, null, null, method, methodRemover, facetedMethod)); + + final Facet facet = facetedMethod.getFacet(PropParamLayoutFacet.class); + assertNotNull(facet); + assertTrue(facet instanceof PropParamLayoutFacetForPropertyLayoutAnnotation); + final PropParamLayoutFacetForPropertyLayoutAnnotation layoutAnnotation = (PropParamLayoutFacetForPropertyLayoutAnnotation) facet; + assertEquals(LabelPosition.LEFT, layoutAnnotation.label()); + } + +}
