Search in sources :

Example 61 with InlineMenuItem

use of com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem in project midpoint by Evolveum.

the class OrgTreePanel method initLayout.

private void initLayout(ModelServiceLocator serviceLocator) {
    WebMarkupContainer treeHeader = new WebMarkupContainer(ID_TREE_HEADER);
    treeHeader.setOutputMarkupId(true);
    add(treeHeader);
    String title = StringUtils.isEmpty(treeTitleKey) ? "TreeTablePanel.hierarchy" : treeTitleKey;
    Label treeTitle = new Label(ID_TREE_TITLE, createStringResource(title));
    treeHeader.add(treeTitle);
    List<InlineMenuItem> actions = createTreeMenu();
    DropdownButtonDto model = new DropdownButtonDto(null, "fa fa-cog", null, actions);
    DropdownButtonPanel treeMenu = new DropdownButtonPanel(ID_TREE_MENU, model) {

        private static final long serialVersionUID = 1L;

        @Override
        protected String getSpecialButtonClass() {
            return "btn-default";
        }

        @Override
        protected boolean visibleCaret() {
            return false;
        }
    };
    treeMenu.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !actions.isEmpty();
        }
    });
    treeMenu.setOutputMarkupId(true);
    treeMenu.setOutputMarkupPlaceholderTag(true);
    treeHeader.add(treeMenu);
    ISortableTreeProvider provider = new OrgTreeProvider(this, getModel(), preselecteOrgsList) {

        @Override
        protected ObjectFilter getCustomFilter() {
            return OrgTreePanel.this.getCustomFilter();
        }
    };
    WebMarkupContainer treeContainer = new WebMarkupContainer(ID_TREE_CONTAINER) {

        private static final long serialVersionUID = 1L;

        @Override
        public void renderHead(IHeaderResponse response) {
            super.renderHead(response);
            // method computes height based on document.innerHeight() -
            // screen height;
            Component form = OrgTreePanel.this.getParent().get("memberPanel");
            if (form != null) {
            // TODO fix
            // response.render(OnDomReadyHeaderItem.forScript(
            // "updateHeight('" + getMarkupId() + "', ['#" + form.getMarkupId() + "'], ['#"
            // + OrgTreePanel.this.get(ID_TREE_HEADER).getMarkupId() + "'])"));
            }
        }
    };
    add(treeContainer);
    TreeStateModel treeStateMode = new TreeStateModel(this, provider, getOrgTreeStateStorage()) {

        private static final long serialVersionUID = 1L;

        @Override
        public Set<TreeSelectableBean<OrgType>> getExpandedItems() {
            return OrgTreePanel.this.getExpandedItems(getOrgTreeStateStorage());
        }

        @Override
        public Set<TreeSelectableBean<OrgType>> getCollapsedItems() {
            return OrgTreePanel.this.getCollapsedItems(getOrgTreeStateStorage());
        }

        @Override
        public void setCollapsedItems(TreeStateSet items) {
            OrgTreePanel.this.setCollapsedItems(null, getOrgTreeStateStorage());
        }
    };
    contentPannels = new ArrayList<OrgTreeFolderContent>();
    MidpointNestedTree tree = new MidpointNestedTree(ID_TREE, provider, treeStateMode) {

        @Override
        protected Component newContentComponent(String id, IModel<TreeSelectableBean<OrgType>> model) {
            OrgTreeFolderContent contentPannel = new OrgTreeFolderContent(id, model, selectable, selected, this, getOrgTreeStateStorage()) {

                @Override
                protected void selectTreeItemPerformed(TreeSelectableBean<OrgType> selected, AjaxRequestTarget target) {
                    OrgTreePanel.this.selectTreeItemPerformed(selected, target);
                }

                @Override
                protected IModel<Boolean> getCheckboxModel(IModel<TreeSelectableBean<OrgType>> org) {
                    return OrgTreePanel.this.getCheckBoxValueModel(org);
                }

                @Override
                protected void onUpdateCheckbox(AjaxRequestTarget target) {
                    selected = getModel();
                    onOrgTreeCheckBoxSelectionPerformed(target, selected);
                }

                @Override
                protected IModel<List<InlineMenuItem>> createInlineMenuItemsModel() {
                    return new ReadOnlyModel<>(() -> createTreeChildrenMenuInternal(model.getObject(), serviceLocator.getCompiledGuiProfile()));
                }
            };
            contentPannels.add(contentPannel);
            return contentPannel;
        }

        @Override
        public void collapse(TreeSelectableBean<OrgType> collapsedItem) {
            super.collapse(collapsedItem);
            Set<TreeSelectableBean<OrgType>> items = OrgTreePanel.this.getExpandedItems(getOrgTreeStateStorage());
            if (items != null && items.contains(collapsedItem)) {
                items.remove(collapsedItem);
            }
            OrgTreePanel.this.setExpandedItems((TreeStateSet) items, getOrgTreeStateStorage());
            OrgTreePanel.this.addCollapsedItem(collapsedItem, getOrgTreeStateStorage());
        }

        @Override
        public void expand(TreeSelectableBean<OrgType> expandedItem) {
            super.expand(expandedItem);
            Set<TreeSelectableBean<OrgType>> items = OrgTreePanel.this.getCollapsedItems(getOrgTreeStateStorage());
            if (items != null && items.contains(expandedItem)) {
                items.remove(expandedItem);
            }
            OrgTreePanel.this.setCollapsedItems((TreeStateSet) items, getOrgTreeStateStorage());
            OrgTreePanel.this.addExpandedItem(expandedItem, getOrgTreeStateStorage());
        }
    };
    tree.setItemReuseStrategy(new ReuseIfModelsEqualStrategy());
    tree.setOutputMarkupId(true);
    tree.add(new WindowsTheme());
    treeContainer.add(tree);
}
Also used : Label(org.apache.wicket.markup.html.basic.Label) WindowsTheme(org.apache.wicket.extensions.markup.html.repeater.tree.theme.WindowsTheme) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ReuseIfModelsEqualStrategy(org.apache.wicket.markup.repeater.ReuseIfModelsEqualStrategy) ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel) OrgTreeProvider(com.evolveum.midpoint.web.page.admin.users.component.OrgTreeProvider) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) IHeaderResponse(org.apache.wicket.markup.head.IHeaderResponse) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) Component(org.apache.wicket.Component) IModel(org.apache.wicket.model.IModel) DropdownButtonDto(com.evolveum.midpoint.gui.api.component.button.DropdownButtonDto) TreeStateSet(com.evolveum.midpoint.web.page.admin.users.dto.TreeStateSet) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ISortableTreeProvider(org.apache.wicket.extensions.markup.html.repeater.tree.ISortableTreeProvider) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) TreeSelectableBean(com.evolveum.midpoint.web.component.util.TreeSelectableBean) DropdownButtonPanel(com.evolveum.midpoint.gui.api.component.button.DropdownButtonPanel)

Example 62 with InlineMenuItem

use of com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem in project midpoint by Evolveum.

the class PageObjectCollections method initLayout.

private void initLayout() {
    Form mainForm = new MidpointForm(ID_MAIN_FORM);
    add(mainForm);
    MainObjectListPanel<ObjectCollectionType> table = new MainObjectListPanel<ObjectCollectionType>(ID_TABLE, ObjectCollectionType.class) {

        @Override
        protected UserProfileStorage.TableId getTableId() {
            return UserProfileStorage.TableId.TABLE_OBJECTS_COLLECTION;
        }

        @Override
        protected List<InlineMenuItem> createInlineMenu() {
            List<InlineMenuItem> menu = new ArrayList<>();
            menu.add(createDeleteInlineMenu());
            return menu;
        }

        @Override
        protected List<IColumn<SelectableBean<ObjectCollectionType>, String>> createDefaultColumns() {
            return ColumnUtils.getDefaultObjectColumns();
        }

        @Override
        protected String getNothingSelectedMessage() {
            return getString("pageObjectCollections.message.nothingSelected");
        }

        @Override
        protected String getConfirmMessageKeyForSingleObject() {
            return "pageObjectCollections.message.confirmationMessageForMultipleObject";
        }

        @Override
        protected String getConfirmMessageKeyForMultiObject() {
            return "pageObjectCollections.message.confirmationMessageForSingleObject";
        }
    };
    table.setOutputMarkupId(true);
    mainForm.add(table);
}
Also used : UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) MainObjectListPanel(com.evolveum.midpoint.gui.api.component.MainObjectListPanel) Form(org.apache.wicket.markup.html.form.Form) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) ArrayList(java.util.ArrayList) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ObjectCollectionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectCollectionType)

Example 63 with InlineMenuItem

use of com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem in project midpoint by Evolveum.

the class InlineMenuButtonColumn method createMenuModel.

private IModel<List<InlineMenuItem>> createMenuModel(final IModel<T> rowModel, List<InlineMenuItem> menuItems) {
    return new LoadableModel<List<InlineMenuItem>>(false) {

        @Override
        public List<InlineMenuItem> load() {
            if (rowModel == null) {
                return menuItems;
            }
            if (rowModel.getObject() == null || !(rowModel.getObject() instanceof InlineMenuable)) {
                return new ArrayList<InlineMenuItem>();
            }
            for (InlineMenuItem item : ((InlineMenuable) rowModel.getObject()).getMenuItems()) {
                if (!(item.getAction() instanceof ColumnMenuAction)) {
                    continue;
                }
                ColumnMenuAction action = (ColumnMenuAction) item.getAction();
                action.setRowModel(rowModel);
            }
            return ((InlineMenuable) rowModel.getObject()).getMenuItems();
        }
    };
}
Also used : LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) ArrayList(java.util.ArrayList) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)

Example 64 with InlineMenuItem

use of com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem in project midpoint by Evolveum.

the class InlineMenuColumn method createMenuModel.

private IModel<List<InlineMenuItem>> createMenuModel(final IModel<T> rowModel) {
    return new LoadableModel<List<InlineMenuItem>>(false) {

        @Override
        public List<InlineMenuItem> load() {
            if (!(rowModel.getObject() instanceof InlineMenuable)) {
                return new ArrayList<InlineMenuItem>();
            }
            T row = rowModel.getObject();
            if (row.getMenuItems() == null) {
                return new ArrayList<InlineMenuItem>();
            }
            for (InlineMenuItem item : row.getMenuItems()) {
                if (!(item.getAction() instanceof ColumnMenuAction)) {
                    continue;
                }
                ColumnMenuAction action = (ColumnMenuAction) item.getAction();
                action.setRowModel(rowModel);
            }
            return row.getMenuItems();
        }
    };
}
Also used : LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) ArrayList(java.util.ArrayList) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)

Example 65 with InlineMenuItem

use of com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem in project midpoint by Evolveum.

the class PageCertCampaigns method createInlineMenuForItem.

private void createInlineMenuForItem(final CertCampaignListItemDto dto) {
    dto.getMenuItems().clear();
    dto.getMenuItems().add(new InlineMenuItem(createStringResource("PageCertCampaigns.menu.close"), new ColumnMenuAction<CertCampaignListItemDto>() {

        @Override
        public void onClick(AjaxRequestTarget target) {
            closeCampaignConfirmation(target, dto);
        }
    }) {

        @Override
        public IModel<Boolean> getEnabled() {
            return new AbstractReadOnlyModel<Boolean>() {

                @Override
                public Boolean getObject() {
                    return dto.getState() != AccessCertificationCampaignStateType.CLOSED;
                }
            };
        }
    });
    dto.getMenuItems().add(new InlineMenuItem(createStringResource("PageCertCampaigns.menu.delete"), new ColumnMenuAction<CertCampaignListItemDto>() {

        @Override
        public void onClick(AjaxRequestTarget target) {
            deleteCampaignConfirmation(target, dto);
        }
    }));
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IModel(org.apache.wicket.model.IModel) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ColumnMenuAction(com.evolveum.midpoint.web.component.data.column.ColumnMenuAction)

Aggregations

InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)114 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)82 ArrayList (java.util.ArrayList)68 ButtonInlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)47 InlineMenuItemAction (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction)43 IModel (org.apache.wicket.model.IModel)41 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)35 UserProfileStorage (com.evolveum.midpoint.web.session.UserProfileStorage)30 CompositedIconBuilder (com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder)26 MainObjectListPanel (com.evolveum.midpoint.gui.api.component.MainObjectListPanel)25 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)24 ColumnMenuAction (com.evolveum.midpoint.web.component.data.column.ColumnMenuAction)19 Label (org.apache.wicket.markup.html.basic.Label)18 MidpointForm (com.evolveum.midpoint.web.component.form.MidpointForm)17 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)15 Form (org.apache.wicket.markup.html.form.Form)15 SelectableBeanImpl (com.evolveum.midpoint.web.component.util.SelectableBeanImpl)13 HeaderMenuAction (com.evolveum.midpoint.web.page.admin.configuration.component.HeaderMenuAction)13 ListItem (org.apache.wicket.markup.html.list.ListItem)12 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)11