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

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


        final ViewRequirement requirements = new ViewRequirement(content, ViewRequirement.OPEN);
        final Enumeration possibleViews = Toolkit.getViewFactory().availableDesigns(requirements);
        if (possibleViews.hasMoreElements()) {
            final UserActionSet submenu = options.addNewActionSet("Create view from");
            while (possibleViews.hasMoreElements()) {
                final ViewSpecification specification = (ViewSpecification) possibleViews.nextElement();
                final UserActionAbstract viewAs = new UserActionAbstract(specification.getName(), ActionType.USER) {
                    @Override
                    public void execute(final Workspace workspace, final View view, final Location at) {
                        ViewSpecification newSpec;
                        try {
                            newSpec = specification.getClass().newInstance();
                        } catch (final InstantiationException e) {
                            throw new ViewerException(e);
                        } catch (final IllegalAccessException e) {
                            throw new ViewerException(e);
                        }

                        Content content = view.getContent();
                        if (!(content instanceof FieldContent)) {
                            content = Toolkit.getContentFactory().createRootContent(content.getAdapter());
                        }
                        final View newView = newSpec.createView(content, view.getViewAxes(), -1);
                        LOG.debug("open view " + newView);
                        workspace.addWindow(newView, new Placement(view));
                        workspace.markDamaged();

                        Options viewOptions = Properties.getViewConfigurationOptions(newSpec);
                        newView.saveOptions(viewOptions);
                        viewOptions = Properties.getUserViewSpecificationOptions(newSpec.getName());
                        viewOptions.addOption("design", specification.getClass().getName());

                        Toolkit.getViewFactory().addSpecification(newSpec);
                    }
                };
View Full Code Here


    public View createDialog(final Content content) {
        return createView(dialogSpec, content);
    }

    private View createView(final ViewSpecification specification, final Content content) {
        ViewSpecification spec;
        if (specification == null) {
            LOG.warn("no suitable view for " + content + " using fallback view");
            spec = new FallbackView.Specification();
        } else {
            spec = specification;
        }
        // TODO this should be passed in so that factory created views can be
        // related to the views that ask
        // for them
        final Axes axes = new Axes();
        View createView = spec.createView(content, axes, -1);

        /*
         * ObjectSpecification contentSpecification =
         * content.getSpecification(); if (contentSpecification != null) {
         * Options viewOptions = Properties.getViewConfigurationOptions(spec);
View Full Code Here

    @Override
    public void debugData(final DebugBuilder sb) {
        sb.append("RootsViews\n");
        Enumeration fields = rootViews.elements();
        while (fields.hasMoreElements()) {
            final ViewSpecification spec = (ViewSpecification) fields.nextElement();
            sb.append("  ");
            sb.append(spec);
            sb.append("\n");
        }
        sb.append("\n\n");

        sb.append("Subviews\n");
        fields = subviews.elements();
        while (fields.hasMoreElements()) {
            final ViewSpecification spec = (ViewSpecification) fields.nextElement();
            sb.append("  ");
            sb.append(spec);
            sb.append("\n");
        }
        sb.append("\n\n");
View Full Code Here

        return new MinimizedView(view);
    }

    @Override
    public View createView(final ViewRequirement requirement) {
        final ViewSpecification objectFieldSpecification = getSpecificationForRequirement(requirement);
        return createView(objectFieldSpecification, requirement.getContent());
    }
View Full Code Here

                    } else if (content instanceof ObjectContent && requirement.isObject() && requirement.isOpen()) {
                        spec = Properties.getDefaultObjectViewOptions();
                    }
                }
                if (spec != null) {
                    final ViewSpecification lookSpec = lookupSpecByName(spec);
                    if (lookSpec != null && lookSpec.canDisplay(requirement)) {
                        return lookSpec;
                    }
                }
            }
            for (final ViewSpecification viewSpecification : viewSpecifications) {
View Full Code Here

        view.layout();
    }

    @Override
    protected void buildView() {
        ViewSpecification internalSpecification;
        if (fieldContent.isCollection()) {
            internalSpecification = new SimpleListSpecification();
        } else {
            internalSpecification = new InternalFormSpecification();
        }
        addView(internalSpecification.createView(fieldContent, new Axes(), 0));
    }
View Full Code Here

    }

    protected void replaceOptions(final Enumeration possibleViews, final UserActionSet options) {
        if (possibleViews.hasMoreElements()) {
            while (possibleViews.hasMoreElements()) {
                final ViewSpecification specification = (ViewSpecification) possibleViews.nextElement();
                if (specification != getSpecification()) {
                    options.add(new ReplaceViewOption(specification));
                }
            }
        }
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

        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

        final ViewRequirement requirements = new ViewRequirement(content, ViewRequirement.OPEN);
        final Enumeration possibleViews = Toolkit.getViewFactory().availableDesigns(requirements);
        if (possibleViews.hasMoreElements()) {
            final UserActionSet submenu = options.addNewActionSet("Create view from");
            while (possibleViews.hasMoreElements()) {
                final ViewSpecification specification = (ViewSpecification) possibleViews.nextElement();
                final UserActionAbstract viewAs = new UserActionAbstract(specification.getName(), ActionType.USER) {
                    @Override
                    public void execute(final Workspace workspace, final View view, final Location at) {
                        ViewSpecification newSpec;
                        try {
                            newSpec = specification.getClass().newInstance();
                        } catch (final InstantiationException e) {
                            throw new ViewerException(e);
                        } catch (final IllegalAccessException e) {
                            throw new ViewerException(e);
                        }

                        Content content = view.getContent();
                        if (!(content instanceof FieldContent)) {
                            content = Toolkit.getContentFactory().createRootContent(content.getAdapter());
                        }
                        final View newView = newSpec.createView(content, view.getViewAxes(), -1);
                        LOG.debug("open view " + newView);
                        workspace.addWindow(newView, new Placement(view));
                        workspace.markDamaged();

                        Options viewOptions = Properties.getViewConfigurationOptions(newSpec);
                        newView.saveOptions(viewOptions);
                        viewOptions = Properties.getUserViewSpecificationOptions(newSpec.getName());
                        viewOptions.addOption("design", specification.getClass().getName());

                        Toolkit.getViewFactory().addSpecification(newSpec);
                    }
                };
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.