Package org.apache.isis.applib.annotation.MemberGroupLayout

Examples of org.apache.isis.applib.annotation.MemberGroupLayout.ColumnSpans


    public String asJson(ObjectSpecification objectSpec) {
        final LayoutMetadata metadata = new LayoutMetadata();
        metadata.setColumns(Lists.<ColumnRepr>newArrayList());
       
        final MemberGroupLayoutFacet mglf = objectSpec.getFacet(MemberGroupLayoutFacet.class);
        final ColumnSpans columnSpans = mglf.getColumnSpans();
       
        Set<String> actionIdsForAssociations = Sets.newTreeSet();
       
        ColumnRepr columnRepr;
       
        columnRepr = addColumnWithSpan(metadata, columnSpans.getLeft());
        updateColumnMemberGroups(objectSpec, MemberGroupLayoutHint.LEFT, columnRepr, actionIdsForAssociations);
       
        columnRepr = addColumnWithSpan(metadata, columnSpans.getMiddle());
        updateColumnMemberGroups(objectSpec, MemberGroupLayoutHint.MIDDLE, columnRepr, actionIdsForAssociations);
       
        columnRepr = addColumnWithSpan(metadata, columnSpans.getRight());
        updateColumnMemberGroups(objectSpec, MemberGroupLayoutHint.RIGHT, columnRepr, actionIdsForAssociations);
       
        columnRepr = addColumnWithSpan(metadata, columnSpans.getCollections());
        updateCollectionColumnRepr(objectSpec, columnRepr, actionIdsForAssociations);

        addActions(objectSpec, metadata, actionIdsForAssociations);
       
        final Gson gson = new GsonBuilder().setPrettyPrinting().create();
View Full Code Here


                list.add(i);
            }
            return asSpans(list);
        }
        private static ColumnSpans asSpans(List<Integer> list) {
            return new ColumnSpans(list);
        }
View Full Code Here

                return true;
            if (obj == null)
                return false;
            if (getClass() != obj.getClass())
                return false;
            ColumnSpans other = (ColumnSpans) obj;
            if (collections != other.collections)
                return false;
            if (left != other.left)
                return false;
            if (middle != other.middle)
View Full Code Here

        assertTrue(facet instanceof MemberGroupLayoutFacetAnnotation);
        final MemberGroupLayoutFacetAnnotation memberGroupsFacet = (MemberGroupLayoutFacetAnnotation) facet;
        final List<String> leftNames = memberGroupsFacet.getLeft();
        final List<String> middleNames = memberGroupsFacet.getMiddle();
        final List<String> rightNames = memberGroupsFacet.getRight();
        final ColumnSpans columnSpans = memberGroupsFacet.getColumnSpans();
        assertEquals(Arrays.asList("General", "Foo", "Bar"), leftNames);
        assertEquals(Arrays.asList("Baz", "Boz"), middleNames);
        assertEquals(Arrays.asList("Flip", "Flop"), rightNames);
        assertEquals(ColumnSpans.asSpans(2,4,6,0), columnSpans);
View Full Code Here

public class MemberGroupLayoutColumnSpansTest {

    @Test
    public void asSpans() {
        final ColumnSpans spans = MemberGroupLayout.ColumnSpans.asSpans(2,3,0,7);
       
        assertThat(spans.getLeft(), is(2));
        assertThat(spans.getMiddle(), is(3));
        assertThat(spans.getRight(), is(0));
        assertThat(spans.getCollections(), is(7));
    }
View Full Code Here

        return new MetaModelValidatorVisiting.Visitor() {

            @Override
            public boolean visit(ObjectSpecification objectSpec, ValidationFailures validationFailures) {
                MemberGroupLayoutFacet facet = objectSpec.getFacet(MemberGroupLayoutFacet.class);
                ColumnSpans columnSpans = facet.getColumnSpans();
                final List<String> middle = facet.getMiddle();
                final List<String> right = facet.getRight();
                final int numCollections = numCollectionsOf(objectSpec);

                if(columnSpans.getMiddle() == 0 && !middle.isEmpty()) {
                    validationFailures.add("%s MemberGroupLayout: middle (property) column is 0 for ColumnSpans (%s), but groups have been listed (%s).  NB: ColumnSpans may have been defaulted if could not be parsed.", objectSpec.getIdentifier().getClassName(), columnSpans.name(), middle);
                }
                if(columnSpans.getMiddle() > 0 && middle.isEmpty()) {
                    // ignore; may want a gap, or there may just not be any properties to put in this column.
                    // validationFailures.add("%s MemberGroupLayout: middle (property) column is non-zero for ColumnSpans (%s), but no groups have been listed", objectSpec.getIdentifier().getClassName(), columnSpans.name());
                }
               
                if(columnSpans.getRight() == 0 && !right.isEmpty()) {
                    validationFailures.add("%s MemberGroupLayout: right (property) column is 0 for ColumnSpans (%s), but groups have been listed (%s).  NB: ColumnSpans may have been defaulted if could not be parsed.", objectSpec.getIdentifier().getClassName(), columnSpans.name(), right);
                }
                if(columnSpans.getRight() > 0 && right.isEmpty()) {
                    // ignore; may want a gap, or there may just not be any properties to put in this column.
                    // validationFailures.add("%s MemberGroupLayout: right (property) column is non-zero for ColumnSpans (%s), but no groups have been listed", objectSpec.getIdentifier().getClassName(), columnSpans.name());
                }
               
                if(columnSpans.getCollections() == 0 && numCollections>0) {
                    validationFailures.add("%s MemberGroupLayout: collections column is 0 for ColumnSpans (%s), but there are (up to) %d visible collections", objectSpec.getIdentifier().getClassName(), columnSpans.name(), numCollections);
                }
                return true;
            }

            @SuppressWarnings("unchecked")
View Full Code Here

    public String asJson(ObjectSpecification objectSpec) {
        final LayoutMetadata metadata = new LayoutMetadata();
        metadata.setColumns(Lists.<ColumnRepr>newArrayList());
       
        final MemberGroupLayoutFacet mglf = objectSpec.getFacet(MemberGroupLayoutFacet.class);
        final ColumnSpans columnSpans = mglf.getColumnSpans();
       
        Set<String> actionIdsForAssociations = Sets.newTreeSet();
       
        ColumnRepr columnRepr;
       
        columnRepr = addColumnWithSpan(metadata, columnSpans.getLeft());
        updateColumnMemberGroups(objectSpec, MemberGroupLayoutHint.LEFT, columnRepr, actionIdsForAssociations);
       
        columnRepr = addColumnWithSpan(metadata, columnSpans.getMiddle());
        updateColumnMemberGroups(objectSpec, MemberGroupLayoutHint.MIDDLE, columnRepr, actionIdsForAssociations);
       
        columnRepr = addColumnWithSpan(metadata, columnSpans.getRight());
        updateColumnMemberGroups(objectSpec, MemberGroupLayoutHint.RIGHT, columnRepr, actionIdsForAssociations);
       
        columnRepr = addColumnWithSpan(metadata, columnSpans.getCollections());
        updateCollectionColumnRepr(objectSpec, columnRepr, actionIdsForAssociations);

        addActions(objectSpec, metadata, actionIdsForAssociations);
       
        final Gson gson = new GsonBuilder().setPrettyPrinting().create();
View Full Code Here

        return new MetaModelValidatorVisiting.Visitor() {

            @Override
            public boolean visit(ObjectSpecification objectSpec, ValidationFailures validationFailures) {
                MemberGroupLayoutFacet facet = objectSpec.getFacet(MemberGroupLayoutFacet.class);
                ColumnSpans columnSpans = facet.getColumnSpans();
                final List<String> middle = facet.getMiddle();
                final List<String> right = facet.getRight();
                final int numCollections = numCollectionsOf(objectSpec);

                if(columnSpans.getMiddle() == 0 && !middle.isEmpty()) {
                    validationFailures.add("%s MemberGroupLayout: middle (property) column is 0 for ColumnSpans (%s), but groups have been listed (%s).  NB: ColumnSpans may have been defaulted if could not be parsed.", objectSpec.getIdentifier().getClassName(), columnSpans.name(), middle);
                }
                if(columnSpans.getMiddle() > 0 && middle.isEmpty()) {
                    // ignore; may want a gap, or there may just not be any properties to put in this column.
                    // validationFailures.add("%s MemberGroupLayout: middle (property) column is non-zero for ColumnSpans (%s), but no groups have been listed", objectSpec.getIdentifier().getClassName(), columnSpans.name());
                }
               
                if(columnSpans.getRight() == 0 && !right.isEmpty()) {
                    validationFailures.add("%s MemberGroupLayout: right (property) column is 0 for ColumnSpans (%s), but groups have been listed (%s).  NB: ColumnSpans may have been defaulted if could not be parsed.", objectSpec.getIdentifier().getClassName(), columnSpans.name(), right);
                }
                if(columnSpans.getRight() > 0 && right.isEmpty()) {
                    // ignore; may want a gap, or there may just not be any properties to put in this column.
                    // validationFailures.add("%s MemberGroupLayout: right (property) column is non-zero for ColumnSpans (%s), but no groups have been listed", objectSpec.getIdentifier().getClassName(), columnSpans.name());
                }
               
                if(columnSpans.getCollections() == 0 && numCollections>0) {
                    validationFailures.add("%s MemberGroupLayout: collections column is 0 for ColumnSpans (%s), but there are (up to) %d visible collections", objectSpec.getIdentifier().getClassName(), columnSpans.name(), numCollections);
                }
                return true;
            }

            @SuppressWarnings("unchecked")
View Full Code Here

        assertTrue(facet instanceof MemberGroupLayoutFacetAnnotation);
        final MemberGroupLayoutFacetAnnotation memberGroupsFacet = (MemberGroupLayoutFacetAnnotation) facet;
        final List<String> leftNames = memberGroupsFacet.getLeft();
        final List<String> middleNames = memberGroupsFacet.getMiddle();
        final List<String> rightNames = memberGroupsFacet.getRight();
        final ColumnSpans columnSpans = memberGroupsFacet.getColumnSpans();
        assertEquals(Arrays.asList("General", "Foo", "Bar"), leftNames);
        assertEquals(Arrays.asList("Baz", "Boz"), middleNames);
        assertEquals(Arrays.asList("Flip", "Flop"), rightNames);
        assertEquals(ColumnSpans.asSpans(2,4,6,0), columnSpans);
View Full Code Here

    }

    private void buildGui() {

        final EntityModel entityModel = (EntityModel) getModel();
        final ColumnSpans columnSpans = entityModel.getObject().getSpecification().getFacet(MemberGroupLayoutFacet.class).getColumnSpans();

        renderedFirstField = false;
       
        // left column
        MarkupContainer leftColumn = new WebMarkupContainer(ID_LEFT_COLUMN);
        add(leftColumn);
       
        boolean addedProperties;
        if(columnSpans.getLeft() > 0) {
            addedProperties = addPropertiesInColumn(leftColumn, MemberGroupLayoutHint.LEFT, columnSpans);
            addButtons(leftColumn);
            addFeedbackGui(leftColumn);
        } else {
            Components.permanentlyHide(this, ID_LEFT_COLUMN);
            addedProperties = false;
        }
        if(!addedProperties) {
            // a bit hacky...
            Components.permanentlyHide(this,
                    ID_EDIT_BUTTON, ID_OK_BUTTON, ID_CANCEL_BUTTON,
                    ID_FEEDBACK);
        }
       
        // middle column
        if(columnSpans.getMiddle() > 0) {
            MarkupContainer middleColumn = new WebMarkupContainer(ID_MIDDLE_COLUMN);
            add(middleColumn);
            addPropertiesInColumn(middleColumn, MemberGroupLayoutHint.MIDDLE, columnSpans);
        } else {
            Components.permanentlyHide(this, ID_MIDDLE_COLUMN);
        }

        // right column
        if(columnSpans.getRight() > 0) {
            MarkupContainer rightColumn = new WebMarkupContainer(ID_RIGHT_COLUMN);
            add(rightColumn);
            addPropertiesInColumn(rightColumn, MemberGroupLayoutHint.RIGHT, columnSpans);
        } else {
            Components.permanentlyHide(this, ID_RIGHT_COLUMN);
        }

        // collections
        if(columnSpans.getCollections() > 0) {
            final String idCollectionsToShow;
            final String idCollectionsToHide;
            int collectionSpan;
            if (columnSpans.exceedsRow())  {
                idCollectionsToShow = ID_ENTITY_COLLECTIONS_OVERFLOW;
                idCollectionsToHide = ID_ENTITY_COLLECTIONS;
                collectionSpan = 12;
            } else {
                idCollectionsToShow = ID_ENTITY_COLLECTIONS;
                idCollectionsToHide = ID_ENTITY_COLLECTIONS_OVERFLOW;
                collectionSpan = columnSpans.getCollections();
            }

            final Component collectionsColumn = getComponentFactoryRegistry().addOrReplaceComponent(this, idCollectionsToShow, ComponentType.ENTITY_COLLECTIONS, entityModel);
            addClassForSpan(collectionsColumn, collectionSpan);
           
View Full Code Here

TOP

Related Classes of org.apache.isis.applib.annotation.MemberGroupLayout.ColumnSpans

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.