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

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


    private void createOpenAsSubmenu(final UserActionSet options, final Content content) {
        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


    private void createCreateViewSubmenu(final UserActionSet options, final Content content) {
        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);
                    }
                };

                submenu.add(viewAs);
            }
        }
    }
View Full Code Here

    }

    @Override
    public void viewMenuOptions(final UserActionSet options) {
        final UserActionSet sortOptions = options.addNewActionSet("Sort");

        sortOptions.add(new UserActionAbstract("Clear") {
            @Override
            public Consent disabled(final View component) {
                return ConsentAbstract.allowIf(order != null);
            }

            @Override
            public void execute(final Workspace workspace, final View view, final Location at) {
                order = null;
                view.invalidateContent();
            }
        });

        if (reverse) {
            sortOptions.add(new UserActionAbstract("Normal sort order") {
                @Override
                public Consent disabled(final View component) {
                    return ConsentAbstract.allowIf(order != null);
                }

                @Override
                public void execute(final Workspace workspace, final View view, final Location at) {
                    reverse = false;
                    view.invalidateContent();
                }
            });
        } else {
            sortOptions.add(new UserActionAbstract("Reverse sort order") {
                @Override
                public Consent disabled(final View component) {
                    return ConsentAbstract.allowIf(order != null);
                }

                @Override
                public void execute(final Workspace workspace, final View view, final Location at) {
                    reverse = true;
                    view.invalidateContent();
                }
            });
        }

        sortOptions.add(new UserActionAbstract("Sort by title") {
            @Override
            public Consent disabled(final View component) {
                return ConsentAbstract.allowIf(order != TITLE_COMPARATOR);
            }

            @Override
            public void execute(final Workspace workspace, final View view, final Location at) {
                order = TITLE_COMPARATOR;
                view.invalidateContent();
            }
        });

        sortOptions.add(new UserActionAbstract("Sort by type") {
            @Override
            public Consent disabled(final View component) {
                return ConsentAbstract.allowIf(order != TYPE_COMPARATOR);
            }

            @Override
            public void execute(final Workspace workspace, final View view, final Location at) {
                order = TYPE_COMPARATOR;
                view.invalidateContent();
            }
        });

        final List<ObjectAssociation> fields = getElementSpecification().getAssociations();
        for (int i = 0; i < fields.size(); i++) {
            final ObjectAssociation field = fields.get(i);

            sortOptions.add(new UserActionAbstract("Sort by " + field.getName()) {
                @Override
                public void execute(final Workspace workspace, final View view, final Location at) {
                    order = new FieldComparator(field);
                    view.invalidateContent();
                }
View Full Code Here

        final GridLayout layout = getViewAxes().getAxis(GridLayout.class);

        final boolean columnOrientation = layout.getOrientation() == GridLayout.COLUMNS;

        final UserActionSet submenu = menuOptions.addNewActionSet("Grid");

        submenu.add(new UserActionAbstract("Add " + (columnOrientation ? "Column" : "Row")) {
            @Override
            public void execute(final Workspace workspace, final View view, final Location at) {
                layout.setSize(layout.getSize() + 1);
                invalidateLayout();
            }
        });

        if (layout.getSize() > 1) {
            submenu.add(new UserActionAbstract("Remove " + (columnOrientation ? "Column" : "Row")) {
                @Override
                public void execute(final Workspace workspace, final View view, final Location at) {
                    layout.setSize(layout.getSize() - 1);
                    invalidateLayout();
                }
            });
        }

        submenu.add(new UserActionAbstract(columnOrientation ? "In Rows" : "In Columns") {
            @Override
            public void execute(final Workspace workspace, final View view, final Location at) {
                layout.setOrientation(columnOrientation ? GridLayout.ROWS : GridLayout.COLUMNS);
                invalidateLayout();
            }
View Full Code Here

        menuOptions.add(CLOSE_OTHER_VIEWS_FOR_OBJECT);

        super.viewMenuOptions(menuOptions);

        final Content content = getContent();
        final UserActionSet suboptions = menuOptions.addNewActionSet("Replace with");
        replaceOptions(Toolkit.getViewFactory().availableViews(new ViewRequirement(content, ViewRequirement.OPEN)),
            suboptions);
        replaceOptions(Toolkit.getViewFactory().availableViews(new ViewRequirement(content, ViewRequirement.CLOSED)),
            suboptions);
    }
View Full Code Here

TOP

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

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.