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

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


            }
        });
    }

    private void menuForChangingLook(final UserActionSet options) {
        final UserActionSet set = options.addNewActionSet("Change Look", ActionType.USER);
        for (final Look look : LookFactory.getAvailableLooks()) {
            menuOptionForChangingLook(set, look, look.getName());
        }
    }
View Full Code Here


        // exploration mode
        if (getAuthenticationSession() instanceof MultiUserExplorationSession) {
            final MultiUserExplorationSession session = (MultiUserExplorationSession) getAuthenticationSession();

            final Set<String> users = session.getUserNames();
            final UserActionSet set = options.addNewActionSet("Change user", ActionType.EXPLORATION);
            for (final String user : users) {
                menuOptionForChangingUser(set, user, session.getUserName());
            }
        }
    }
View Full Code Here

    public void show(final boolean forView, final boolean includeDebug, final boolean includeExploration, final boolean includePrototype) {
        final boolean withExploration = getViewManager().isRunningAsExploration() && includeExploration;
        final boolean withPrototype = getViewManager().isRunningAsPrototype() && includePrototype;

        final UserActionSet optionSet = new UserActionSetImpl(withExploration, withPrototype, includeDebug, ActionType.USER);
        if (forView) {
            target.viewMenuOptions(optionSet);
        } else {
            target.contentMenuOptions(optionSet);
        }
        optionSet.add(DEBUG_OPTION);
        final Enumeration e = options.elements();
        while (e.hasMoreElements()) {
            final MenuOptions element = (MenuOptions) e.nextElement();
            element.menuOptions(optionSet);
        }

        menu = new PopupMenu(this);

        backgroundColor = optionSet.getColor();
        menu.show(target, optionSet.getUserActions(), backgroundColor);
        getViewManager().setOverlayView(this);

        if (target != null) {
            final String status = changeStatus(target, forView, withExploration, includeDebug);
            getFeedbackManager().setViewDetail(status);
View Full Code Here

    }

    @Override
    public void viewMenuOptions(final UserActionSet menuOptions) {
        super.viewMenuOptions(menuOptions);
        final UserActionSet subOptions = menuOptions.addNewActionSet("Elements as");
        final View firstSubview = getSubviews()[0];
        final int status = ViewRequirement.OPEN | ViewRequirement.CLOSED | ViewRequirement.SUBVIEW | ViewRequirement.FIXED;
        final ViewRequirement viewRequirement = new ViewRequirement(firstSubview.getContent(), status);
        final Enumeration<ViewSpecification> possibleViews = Toolkit.getViewFactory().availableViews(viewRequirement);
        while (possibleViews.hasMoreElements()) {
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) {
                            final View parent = wrappedView.getParent();
                            wrappedView = LabelBorder.createFieldLabelBorder(view.getParent().getViewAxes().getAxis(LabelAxis.class), withReplacement);
                            wrappedView.setParent(parent);
                            wrappedView.setView(ConfigurableFieldBorder.this);
                            invalidateLayout();
                        }
                    };
                    suboptions.add(viewAs);
                }
            }
        }
    }
View Full Code Here

    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

        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

    }

    @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(Contributed.EXCLUDED);
        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

        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.