Package org.apache.isis.viewer.dnd.view

Examples of org.apache.isis.viewer.dnd.view.ViewSpecification


        return new Bounds(location, size);
    }

    private ViewSpecification loadSpecification(final String name, final Class<?> cls) {
        final String factoryName = IsisContext.getConfiguration().getString(SPECIFICATION_BASE + name);
        ViewSpecification spec;
        if (factoryName != null) {
            spec = InstanceUtil.createInstance(factoryName, ViewSpecification.class);
        } else {
            spec = InstanceUtil.createInstance(cls.getName(), ViewSpecification.class);
        }
View Full Code Here


    private View createFieldView(final View view, final Axes axes, final ObjectAdapter object, final ObjectAssociation field, final ObjectAdapter value) {
        if (field == null) {
            throw new NullPointerException();
        }
        final GlobalViewFactory factory = Toolkit.getViewFactory();
        ViewSpecification cellSpec;
        Content content;
        if (field instanceof OneToManyAssociation) {
            throw new UnexpectedCallException("no collections allowed");
        } else if (field instanceof OneToOneAssociation) {

            final ObjectSpecification fieldSpecification = field.getSpecification();
            if (fieldSpecification.isParseable()) {
                content = new TextParseableFieldImpl(object, value, (OneToOneAssociation) field);
                // REVIEW how do we deal with IMAGES?
                if (content.getAdapter() instanceof ImageValueFacet) {
                    return new BlankView(content);
                }

                if (!field.isVisible(IsisContext.getAuthenticationSession(), object, where).isAllowed()) {
                    return new BlankView(content);
                }
                if (((TextParseableContent) content).getNoLines() > 0) {
                    /*
                     * TODO remove this after introducing constraints into view
                     * specs that allow the parent view to specify what kind of
                     * subviews it can deal
                     */

                    if (fieldSpecification.containsFacet(BooleanValueFacet.class)) {
                        cellSpec = new CheckboxField.Specification();
                    } else {
                        cellSpec = new UnlinedTextFieldSpecification();
                    }
                } else {
                    return factory.createView(new ViewRequirement(content, ViewRequirement.CLOSED));
                }
            } else {
                content = new OneToOneFieldImpl(object, value, (OneToOneAssociation) field);
               
                if (!field.isVisible(IsisContext.getAuthenticationSession(), object, where).isAllowed()) {
                    return new BlankView(content);
                }
                return factory.createView(new ViewRequirement(content, ViewRequirement.CLOSED | ViewRequirement.SUBVIEW));

            }

        } else {
            throw new UnknownTypeException(field);
        }

        return cellSpec.createView(content, axes, -1);
    }
View Full Code Here

    protected static class ElementFactory implements ViewFactory {
        @Override
        public View createView(final Content content, final Axes axes, final int sequence) {
            final GlobalViewFactory factory = Toolkit.getViewFactory();

            final ViewSpecification elementSpecification = axes.getAxis(ConfigurationAxis.class).getElementSpecification();
            if (elementSpecification == null) {
                final int defaultRequirement = ViewRequirement.CLOSED | ViewRequirement.SUBVIEW;
                final ViewRequirement viewRequirement = new ViewRequirement(content, defaultRequirement);
                return factory.createView(viewRequirement);
            } else {
                return elementSpecification.createView(content, axes, sequence);
            }
        }
View Full Code Here

        @Override
        public void execute(final Workspace workspace, final View view, final Location at) {
            save(view);
            // by recreating the view the transient border is removed
            final ViewSpecification spec = view.getSpecification();
            final View newView = spec.createView(view.getContent(), view.getViewAxes(), -1);
            workspace.replaceView(view, newView);
        }
View Full Code Here

    @Override
    public void loadOptions(final Options viewOptions) {
        super.loadOptions(viewOptions);
        final String elementsClass = viewOptions.getString("elements");
        if (elementsClass != null) {
            ViewSpecification specification;
            if (elementsClass.startsWith("user:")) {
                final String name = elementsClass.substring("user:".length());
                final String wrappedSpecificationClass = Properties.getUserViewSpecificationOptions(name).getString("wrapped-specification");
                final ViewSpecification wrappedSpectification = (ViewSpecification) InstanceUtil.createInstance(wrappedSpecificationClass);
                specification = new UserViewSpecification(wrappedSpectification, name);
            } else {
                specification = (ViewSpecification) InstanceUtil.createInstance(elementsClass);
            }
            if (specification != null) {
View Full Code Here

    // TODO copied from AbstractView
    protected void replaceOptions(final Enumeration possibleViews, final UserActionSet options) {
        if (possibleViews.hasMoreElements()) {
            final UserActionSet suboptions = options.addNewActionSet("Replace with");
            while (possibleViews.hasMoreElements()) {
                final ViewSpecification specification = (ViewSpecification) possibleViews.nextElement();

                if (specification != getSpecification()) {
                    final UserAction viewAs = new ReplaceViewOption(specification) {
                        @Override
                        protected void replace(final View view, final View withReplacement) {
View Full Code Here

        }
    }

    public void addView(final Content content, final Position position) {
        final ViewRequirement requirement = new ViewRequirement(content, ViewRequirement.OPEN | ViewRequirement.SUBVIEW);
        final ViewSpecification viewSpecification = Toolkit.getViewFactory().availableViews(requirement).nextElement();
        addView(content, viewSpecification, position);
    }
View Full Code Here

        b.appendln("Location", getAbsoluteLocation());
        final View views[] = getSubviews();
        b.indent();
        for (final View subview : views) {
            b.appendln();
            final ViewSpecification spec = subview.getSpecification();
            b.appendln(spec == null ? "none" : spec.getName().toUpperCase());
            b.appendln("View", subview);
            subview.debugStructure(b);
        }
        b.unindent();
    }
View Full Code Here

    public void addSpecification(final ViewSpecification specification) {
        viewSpecifications.add(specification);
    }

    public void addSpecification(final String specClassName) {
        ViewSpecification spec;
        spec = (ViewSpecification) InstanceUtil.createInstance(specClassName);
        LOG.info("adding view specification: " + spec);
        addSpecification(spec);
    }
View Full Code Here

        final ViewRequirement requirements = new ViewRequirement(content, ViewRequirement.OPEN | ViewRequirement.EXPANDABLE);
        final Enumeration possibleViews = Toolkit.getViewFactory().availableViews(requirements);
        if (possibleViews.hasMoreElements()) {
            final UserActionSet submenu = options.addNewActionSet("Open as");
            while (possibleViews.hasMoreElements()) {
                final ViewSpecification specification = (ViewSpecification) possibleViews.nextElement();
                final UserActionAbstract viewAs = new OpenViewOption(specification);
                submenu.add(viewAs);
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.isis.viewer.dnd.view.ViewSpecification

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.