All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nakedobjects.plugins.htmlviewer.object.FieldCollectionView Maven / Gradle / Ivy

The newest version!
package org.nakedobjects.plugins.htmlviewer.object;

import org.nakedobjects.metamodel.adapter.NakedObject;
import org.nakedobjects.metamodel.spec.NakedObjectSpecification;
import org.nakedobjects.metamodel.spec.feature.OneToManyAssociation;
import org.nakedobjects.plugins.htmlviewer.component.Table;
import org.nakedobjects.plugins.htmlviewer.component.ViewPane;
import org.nakedobjects.plugins.htmlviewer.request.Context;
import org.nakedobjects.plugins.htmlviewer.request.TableBuilder;
import org.nakedobjects.runtime.context.NakedObjectsContext;
import org.nakedobjects.plugins.htmlviewer.request.Request;
import org.nakedobjects.plugins.htmlviewer.request.Task;



public class FieldCollectionView extends AbstractObjectView {
    @Override
    protected void doExecute(final Context context, final ViewPane content, final NakedObject object, final String field) {
        final String id = context.mapObject(object);
        final NakedObjectSpecification specification = object.getSpecification();

        final OneToManyAssociation collection = (OneToManyAssociation) specification.getAssociation(field);
        NakedObjectsContext.getPersistenceSession().resolveField(object, collection);
        context.addCollectionFieldCrumb(collection.getName());
        content.add(context.getComponentFactory().createHeading(collection.getName()));
        final Table table = TableBuilder.createTable(context, id, object, collection);
        content.add(table);
        if (collection.isUsable(NakedObjectsContext.getAuthenticationSession(), object).isAllowed()) {
            content.add(context.getComponentFactory().createAddOption(id, collection.getId()));
        }
    }

    public String name() {
        return Request.FIELD_COLLECTION_COMMAND;
    }

}

// Copyright (c) Naked Objects Group Ltd.




© 2015 - 2025 Weber Informatics LLC | Privacy Policy