Search in sources :

Example 6 with InlineMenuItem

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

the class SearchPanel method initLayout.

private void initLayout() {
    moreDialogModel = new LoadableModel<MoreDialogDto>(false) {

        @Override
        protected MoreDialogDto load() {
            MoreDialogDto dto = new MoreDialogDto();
            dto.setProperties(createPropertiesList());
            return dto;
        }
    };
    Form form = new Form(ID_FORM);
    add(form);
    ListView items = new ListView<SearchItem>(ID_ITEMS, new PropertyModel<List<SearchItem>>(getModel(), Search.F_ITEMS)) {

        @Override
        protected void populateItem(ListItem<SearchItem> item) {
            SearchItemPanel searchItem = new SearchItemPanel(ID_ITEM, item.getModel());
            item.add(searchItem);
        }
    };
    items.add(createVisibleBehaviour(SearchBoxModeType.BASIC));
    form.add(items);
    WebMarkupContainer moreGroup = new WebMarkupContainer(ID_MORE_GROUP);
    moreGroup.add(createVisibleBehaviour(SearchBoxModeType.BASIC));
    form.add(moreGroup);
    AjaxLink more = new AjaxLink(ID_MORE) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            Component button = SearchPanel.this.get(createComponentPath(ID_FORM, ID_MORE_GROUP, ID_MORE));
            Component popover = SearchPanel.this.get(createComponentPath(ID_POPOVER));
            togglePopover(target, button, popover, 14);
        }
    };
    more.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            Search search = getModelObject();
            return !search.getAvailableDefinitions().isEmpty();
        }
    });
    more.setOutputMarkupId(true);
    moreGroup.add(more);
    WebMarkupContainer searchContainer = new WebMarkupContainer(ID_SEARCH_CONTAINER);
    searchContainer.setOutputMarkupId(true);
    form.add(searchContainer);
    AjaxSubmitButton searchSimple = new AjaxSubmitButton(ID_SEARCH_SIMPLE) {

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(form);
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            searchPerformed(target);
        }
    };
    searchSimple.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            if (SearchBoxModeType.BASIC.equals(getModelObject().getSearchType()) || SearchBoxModeType.FULLTEXT.equals(getModelObject().getSearchType())) {
                return true;
            }
            return false;
        }

        @Override
        public boolean isVisible() {
            return SearchBoxModeType.BASIC.equals(getModelObject().getSearchType()) || SearchBoxModeType.FULLTEXT.equals(getModelObject().getSearchType());
        }
    });
    searchSimple.setOutputMarkupId(true);
    searchContainer.add(searchSimple);
    WebMarkupContainer searchDropdown = new WebMarkupContainer(ID_SEARCH_DROPDOWN);
    searchDropdown.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return SearchBoxModeType.ADVANCED.equals(getModelObject().getSearchType()) && queryPlagroundAccessible;
        }
    });
    searchContainer.add(searchDropdown);
    AjaxSubmitButton searchButtonBeforeDropdown = new AjaxSubmitButton(ID_SEARCH_BUTTON_BEFORE_DROPDOWN) {

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(form);
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            searchPerformed(target);
        }
    };
    searchButtonBeforeDropdown.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            if (SearchBoxModeType.BASIC.equals(getModelObject().getSearchType()) || SearchBoxModeType.FULLTEXT.equals(getModelObject().getSearchType())) {
                return true;
            }
            Search search = getModelObject();
            PrismContext ctx = getPageBase().getPrismContext();
            return search.isAdvancedQueryValid(ctx);
        }
    });
    searchDropdown.add(searchButtonBeforeDropdown);
    List<InlineMenuItem> searchItems = new ArrayList<>();
    InlineMenuItem searchItem = new InlineMenuItem(createStringResource("SearchPanel.search"), new InlineMenuItemAction() {

        @Override
        public void onClick(AjaxRequestTarget target) {
            PrismContext ctx = getPageBase().getPrismContext();
            if (getModelObject().isAdvancedQueryValid(ctx)) {
                searchPerformed(target);
            }
        }
    });
    searchItems.add(searchItem);
    searchItem = new InlineMenuItem(createStringResource("SearchPanel.debug"), new InlineMenuItemAction() {

        @Override
        public void onClick(AjaxRequestTarget target) {
            debugPerformed();
        }
    });
    searchItems.add(searchItem);
    ListView<InlineMenuItem> li = new ListView<InlineMenuItem>(ID_MENU_ITEM, Model.ofList(searchItems)) {

        @Override
        protected void populateItem(ListItem<InlineMenuItem> item) {
            WebMarkupContainer menuItemBody = new MenuLinkPanel(ID_MENU_ITEM_BODY, item.getModel());
            menuItemBody.setRenderBodyOnly(true);
            item.add(menuItemBody);
        }
    };
    searchDropdown.add(li);
    WebMarkupContainer linksContainer = new WebMarkupContainer(ID_LINKS_CONTAINER);
    linksContainer.setOutputMarkupId(true);
    form.add(linksContainer);
    AjaxButton advanced = new AjaxButton(ID_ADVANCED, createStringResource("SearchPanel.advanced")) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            searchTypeUpdated(target, SearchBoxModeType.ADVANCED);
        }
    };
    advanced.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !SearchBoxModeType.ADVANCED.equals(getModelObject().getSearchType());
        }
    });
    linksContainer.add(advanced);
    AjaxButton fullTextButton = new AjaxButton(ID_FULL_TEXT, createStringResource("SearchPanel.fullText")) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            searchTypeUpdated(target, SearchBoxModeType.FULLTEXT);
        }
    };
    fullTextButton.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return isFullTextSearchEnabled() && !SearchBoxModeType.FULLTEXT.equals(getModelObject().getSearchType());
        }
    });
    linksContainer.add(fullTextButton);
    AjaxButton basicSearchButton = new AjaxButton(ID_BASIC_SEARCH, createStringResource("SearchPanel.basic")) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            searchTypeUpdated(target, SearchBoxModeType.BASIC);
        }
    };
    basicSearchButton.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !SearchBoxModeType.BASIC.equals(getModelObject().getSearchType());
        }
    });
    linksContainer.add(basicSearchButton);
    advanced.add(new AttributeAppender("style", new LoadableModel<String>() {

        @Override
        public String load() {
            return basicSearchButton.isVisible() ? "margin-top: -20px;" : "display: table-cell; vertical-align: top;";
        }
    }));
    initPopover();
    WebMarkupContainer fullTextContainer = new WebMarkupContainer(ID_FULL_TEXT_CONTAINER);
    fullTextContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isFullTextSearchEnabled() && getModelObject().getSearchType().equals(SearchBoxModeType.FULLTEXT);
        }
    });
    fullTextContainer.setOutputMarkupId(true);
    form.add(fullTextContainer);
    TextField fullTextInput = new TextField(ID_FULL_TEXT_FIELD, new PropertyModel<String>(getModel(), Search.F_FULL_TEXT));
    fullTextInput.add(new AjaxFormComponentUpdatingBehavior("blur") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    });
    fullTextInput.add(new Behavior() {

        @Override
        public void bind(Component component) {
            super.bind(component);
            component.add(AttributeModifier.replace("onkeydown", Model.of("if(event.keyCode == 13) {$('[about=\"searchSimple\"]').click();}")));
        }
    });
    fullTextInput.setOutputMarkupId(true);
    fullTextInput.add(new AttributeAppender("placeholder", createStringResource("SearchPanel.fullTextSearch")));
    fullTextInput.add(createVisibleBehaviour(SearchBoxModeType.FULLTEXT));
    fullTextContainer.add(fullTextInput);
    WebMarkupContainer advancedGroup = new WebMarkupContainer(ID_ADVANCED_GROUP);
    advancedGroup.add(createVisibleBehaviour(SearchBoxModeType.ADVANCED));
    advancedGroup.add(AttributeAppender.append("class", createAdvancedGroupStyle()));
    advancedGroup.setOutputMarkupId(true);
    form.add(advancedGroup);
    Label advancedCheck = new Label(ID_ADVANCED_CHECK);
    advancedCheck.add(AttributeAppender.append("class", createAdvancedGroupLabelStyle()));
    advancedGroup.add(advancedCheck);
    final TextArea advancedArea = new TextArea(ID_ADVANCED_AREA, new PropertyModel(getModel(), Search.F_ADVANCED_QUERY));
    advancedArea.add(new AjaxFormComponentUpdatingBehavior("keyup") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            updateAdvancedArea(advancedArea, target);
        }

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);
            attributes.setThrottlingSettings(new ThrottlingSettings(ID_ADVANCED_AREA, Duration.milliseconds(500), true));
        }
    });
    advancedGroup.add(advancedArea);
    Label advancedError = new Label(ID_ADVANCED_ERROR, new PropertyModel<String>(getModel(), Search.F_ADVANCED_ERROR));
    advancedError.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            Search search = getModelObject();
            if (!search.isShowAdvanced()) {
                return false;
            }
            return StringUtils.isNotEmpty(search.getAdvancedError());
        }
    });
    advancedGroup.add(advancedError);
}
Also used : ThrottlingSettings(org.apache.wicket.ajax.attributes.ThrottlingSettings) Form(org.apache.wicket.markup.html.form.Form) TextArea(org.apache.wicket.markup.html.form.TextArea) PrismContext(com.evolveum.midpoint.prism.PrismContext) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) ListView(org.apache.wicket.markup.html.list.ListView) TextField(org.apache.wicket.markup.html.form.TextField) ArrayList(java.util.ArrayList) List(java.util.List) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) Behavior(org.apache.wicket.behavior.Behavior) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) Component(org.apache.wicket.Component) AttributeAppender(org.apache.wicket.behavior.AttributeAppender) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) PropertyModel(org.apache.wicket.model.PropertyModel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxRequestAttributes(org.apache.wicket.ajax.attributes.AjaxRequestAttributes) MenuLinkPanel(com.evolveum.midpoint.web.component.menu.cog.MenuLinkPanel) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 7 with InlineMenuItem

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

the class FocusListInlineMenuHelper method createRowActions.

public List<InlineMenuItem> createRowActions(boolean isHeader) {
    List<InlineMenuItem> menu = new ArrayList<>();
    menu.add(new InlineMenuItem(parentPage.createStringResource("FocusListInlineMenuHelper.menu.enable"), new Model<Boolean>(false), new Model<Boolean>(false), false, new ColumnMenuAction<SelectableBean<F>>() {

        @Override
        public void onClick(AjaxRequestTarget target) {
            if (getRowModel() == null) {
                updateActivationPerformed(target, true, null);
            } else {
                SelectableBean<F> rowDto = getRowModel().getObject();
                updateActivationPerformed(target, true, rowDto.getValue());
            }
        }
    }, isHeader ? InlineMenuItem.FOCUS_LIST_INLINE_MENU_ITEM_ID.HEADER_ENABLE.getMenuItemId() : InlineMenuItem.FOCUS_LIST_INLINE_MENU_ITEM_ID.ENABLE.getMenuItemId(), GuiStyleConstants.CLASS_OBJECT_USER_ICON, DoubleButtonColumn.BUTTON_COLOR_CLASS.SUCCESS.toString()) {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isShowConfirmationDialog() {
            return FocusListInlineMenuHelper.this.isShowConfirmationDialog((ColumnMenuAction) getAction());
        }

        @Override
        public IModel<String> getConfirmationMessageModel() {
            String actionName = parentPage.createStringResource("pageUsers.message.enableAction").getString();
            return FocusListInlineMenuHelper.this.getConfirmationMessageModel((ColumnMenuAction) getAction(), actionName);
        }
    });
    menu.add(new InlineMenuItem(parentPage.createStringResource("FocusListInlineMenuHelper.menu.disable"), isHeader ? new Model<Boolean>(true) : new Model<Boolean>(false), isHeader ? new Model<Boolean>(true) : new Model<Boolean>(false), false, new ColumnMenuAction<SelectableBean<F>>() {

        @Override
        public void onClick(AjaxRequestTarget target) {
            if (getRowModel() == null) {
                updateActivationPerformed(target, false, null);
            } else {
                SelectableBean<F> rowDto = getRowModel().getObject();
                updateActivationPerformed(target, false, rowDto.getValue());
            }
        }
    }, isHeader ? InlineMenuItem.FOCUS_LIST_INLINE_MENU_ITEM_ID.HEADER_DISABLE.getMenuItemId() : InlineMenuItem.FOCUS_LIST_INLINE_MENU_ITEM_ID.DISABLE.getMenuItemId(), GuiStyleConstants.CLASS_OBJECT_USER_ICON, DoubleButtonColumn.BUTTON_COLOR_CLASS.DANGER.toString()) {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isShowConfirmationDialog() {
            return FocusListInlineMenuHelper.this.isShowConfirmationDialog((ColumnMenuAction) getAction());
        }

        @Override
        public IModel<String> getConfirmationMessageModel() {
            String actionName = parentPage.createStringResource("pageUsers.message.disableAction").getString();
            return FocusListInlineMenuHelper.this.getConfirmationMessageModel((ColumnMenuAction) getAction(), actionName);
        }
    });
    menu.add(new InlineMenuItem(parentPage.createStringResource("FocusListInlineMenuHelper.menu.reconcile"), new Model<Boolean>(false), new Model<Boolean>(false), false, new ColumnMenuAction<SelectableBean<F>>() {

        @Override
        public void onClick(AjaxRequestTarget target) {
            if (getRowModel() == null) {
                reconcilePerformed(target, null);
            } else {
                SelectableBean<F> rowDto = getRowModel().getObject();
                reconcilePerformed(target, rowDto.getValue());
            }
        }
    }, isHeader ? InlineMenuItem.FOCUS_LIST_INLINE_MENU_ITEM_ID.HEADER_RECONCILE.getMenuItemId() : InlineMenuItem.FOCUS_LIST_INLINE_MENU_ITEM_ID.RECONCILE.getMenuItemId(), GuiStyleConstants.CLASS_RECONCILE_MENU_ITEM, DoubleButtonColumn.BUTTON_COLOR_CLASS.INFO.toString()) {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isShowConfirmationDialog() {
            return FocusListInlineMenuHelper.this.isShowConfirmationDialog((ColumnMenuAction) getAction());
        }

        @Override
        public IModel<String> getConfirmationMessageModel() {
            String actionName = parentPage.createStringResource("pageUsers.message.reconcileAction").getString();
            return FocusListInlineMenuHelper.this.getConfirmationMessageModel((ColumnMenuAction) getAction(), actionName);
        }
    });
    menu.add(new InlineMenuItem(parentPage.createStringResource("FocusListInlineMenuHelper.menu.delete"), new ColumnMenuAction<SelectableBean<F>>() {

        @Override
        public void onClick(AjaxRequestTarget target) {
            if (getRowModel() == null) {
                deleteConfirmedPerformed(target, null);
            } else {
                SelectableBean<F> rowDto = getRowModel().getObject();
                deleteConfirmedPerformed(target, rowDto.getValue());
            }
        }
    }) {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isShowConfirmationDialog() {
            return FocusListInlineMenuHelper.this.isShowConfirmationDialog((ColumnMenuAction) getAction());
        }

        @Override
        public IModel<String> getConfirmationMessageModel() {
            String actionName = parentPage.createStringResource("pageUsers.message.deleteAction").getString();
            return FocusListInlineMenuHelper.this.getConfirmationMessageModel((ColumnMenuAction) getAction(), actionName);
        }
    });
    return menu;
}
Also used : IModel(org.apache.wicket.model.IModel) ArrayList(java.util.ArrayList) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IModel(org.apache.wicket.model.IModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ColumnMenuAction(com.evolveum.midpoint.web.component.data.column.ColumnMenuAction)

Example 8 with InlineMenuItem

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

the class PageTasks method createNodesInlineMenu.

private List<InlineMenuItem> createNodesInlineMenu(boolean isHeader) {
    List<InlineMenuItem> items = new ArrayList<>();
    items.add(new InlineMenuItem(createStringResource("pageTasks.button.stopScheduler"), new Model<Boolean>(false), new Model<Boolean>(false), false, new ColumnMenuAction<NodeDto>() {

        @Override
        public void onClick(AjaxRequestTarget target) {
            if (getRowModel() == null) {
                stopSchedulersPerformed(target);
            } else {
                NodeDto rowDto = getRowModel().getObject();
                stopSchedulersPerformed(target, rowDto);
            }
        }
    }, InlineMenuItem.TASKS_INLINE_MENU_ITEM_ID.NODE_STOP_SCHEDULER.getMenuItemId(), GuiStyleConstants.CLASS_STOP_MENU_ITEM, DoubleButtonColumn.BUTTON_COLOR_CLASS.INFO.toString()) {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isShowConfirmationDialog() {
            return PageTasks.this.isNodeShowConfirmationDialog((ColumnMenuAction) getAction());
        }

        @Override
        public IModel<String> getConfirmationMessageModel() {
            String actionName = createStringResource("pageTasks.message.stopSchedulerAction").getString();
            return PageTasks.this.getNodeConfirmationMessageModel((ColumnMenuAction) getAction(), actionName);
        }
    });
    items.add(new InlineMenuItem(createStringResource("pageTasks.button.stopSchedulerAndTasks"), false, new ColumnMenuAction<NodeDto>() {

        @Override
        public void onClick(AjaxRequestTarget target) {
            stopSchedulersAndTasksPerformed(target, getRowModel() != null ? getRowModel().getObject() : null);
        }
    }) {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isShowConfirmationDialog() {
            return PageTasks.this.isNodeShowConfirmationDialog((ColumnMenuAction) getAction());
        }

        @Override
        public IModel<String> getConfirmationMessageModel() {
            String actionName = createStringResource("pageTasks.message.stopSchedulerTasksAction").getString();
            return PageTasks.this.getNodeConfirmationMessageModel((ColumnMenuAction) getAction(), actionName);
        }
    });
    items.add(new InlineMenuItem(createStringResource("pageTasks.button.startScheduler"), new Model<Boolean>(false), new Model<Boolean>(false), false, new ColumnMenuAction<NodeDto>() {

        @Override
        public void onClick(AjaxRequestTarget target) {
            if (getRowModel() == null) {
                startSchedulersPerformed(target);
            } else {
                NodeDto rowDto = getRowModel().getObject();
                startSchedulersPerformed(target, rowDto);
            }
        }
    }, InlineMenuItem.TASKS_INLINE_MENU_ITEM_ID.NODE_START.getMenuItemId(), GuiStyleConstants.CLASS_START_MENU_ITEM, DoubleButtonColumn.BUTTON_COLOR_CLASS.INFO.toString()) {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isShowConfirmationDialog() {
            return PageTasks.this.isNodeShowConfirmationDialog((ColumnMenuAction) getAction());
        }

        @Override
        public IModel<String> getConfirmationMessageModel() {
            String actionName = createStringResource("pageTasks.message.startSchedulerAction").getString();
            return PageTasks.this.getNodeConfirmationMessageModel((ColumnMenuAction) getAction(), actionName);
        }
    });
    items.add(new InlineMenuItem(createStringResource("pageTasks.button.deleteNode"), false, new ColumnMenuAction<NodeDto>() {

        @Override
        public void onClick(AjaxRequestTarget target) {
            if (getRowModel() == null) {
                deleteNodesPerformed(target);
            } else {
                NodeDto rowDto = getRowModel().getObject();
                deleteNodesPerformed(target, rowDto);
            }
        }
    }) {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isShowConfirmationDialog() {
            return PageTasks.this.isNodeShowConfirmationDialog((ColumnMenuAction) getAction());
        }

        @Override
        public IModel<String> getConfirmationMessageModel() {
            String actionName = createStringResource("pageTasks.message.deleteAction").getString();
            return PageTasks.this.getNodeConfirmationMessageModel((ColumnMenuAction) getAction(), actionName);
        }
    });
    return items;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IModel(org.apache.wicket.model.IModel) IModel(org.apache.wicket.model.IModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model) PropertyModel(org.apache.wicket.model.PropertyModel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)

Example 9 with InlineMenuItem

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

the class InlineMenuButtonColumn method getButtonCssClass.

protected String getButtonCssClass(int id, List<InlineMenuItem> menuItems) {
    StringBuilder sb = new StringBuilder();
    sb.append(DoubleButtonColumn.BUTTON_BASE_CLASS).append(" ");
    sb.append(getButtonColorCssClass(id, menuItems)).append(" ");
    sb.append(getButtonSizeCssClass(id)).append(" ");
    for (InlineMenuItem menuItem : menuItems) {
        if (menuItem.getId() == id) {
            sb.append(menuItem.getButtonIconCssClass()).append(" ");
        }
    }
    return sb.toString();
}
Also used : InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)

Example 10 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() {
    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);
    InlineMenu treeMenu = new InlineMenu(ID_TREE_MENU, new Model<>((Serializable) createTreeMenuInternal()));
    treeHeader.add(treeMenu);
    ISortableTreeProvider provider = new OrgTreeProvider(this, getModel()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected List<InlineMenuItem> createInlineMenuItems(OrgType org) {
            return createTreeChildrenMenu(org);
        }
    };
    List<IColumn<SelectableBean<OrgType>, String>> columns = new ArrayList<>();
    if (selectable) {
        columns.add(new CheckBoxHeaderColumn<SelectableBean<OrgType>>());
    }
    columns.add(new TreeColumn<SelectableBean<OrgType>, String>(createStringResource("TreeTablePanel.hierarchy")));
    columns.add(new InlineMenuHeaderColumn(createTreeChildrenMenu(null)));
    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) {
                response.render(OnDomReadyHeaderItem.forScript("updateHeight('" + getMarkupId() + "', ['#" + form.getMarkupId() + "'], ['#" + OrgTreePanel.this.get(ID_TREE_HEADER).getMarkupId() + "'])"));
            }
        }
    };
    add(treeContainer);
    TreeStateModel treeStateMode = new TreeStateModel(this, provider) {

        private static final long serialVersionUID = 1L;

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

        @Override
        public SelectableBean<OrgType> getCollapsedItem() {
            return OrgTreePanel.this.getCollapsedItem(getOrgTreeStateStorage());
        }

        @Override
        public void setCollapsedItem(SelectableBean<OrgType> item) {
            OrgTreePanel.this.setCollapsedItem(null, getOrgTreeStateStorage());
        }
    };
    TableTree<SelectableBean<OrgType>, String> tree = new TableTree<SelectableBean<OrgType>, String>(ID_TREE, columns, provider, Integer.MAX_VALUE, treeStateMode) {

        private static final long serialVersionUID = 1L;

        @Override
        protected Component newContentComponent(String id, IModel<SelectableBean<OrgType>> model) {
            return new SelectableFolderContent(id, this, model, selected) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onClick(AjaxRequestTarget target) {
                    super.onClick(target);
                    OrgTreePanel.this.setSelectedItem(selected.getObject(), getOrgTreeStateStorage());
                    selectTreeItemPerformed(selected.getObject(), target);
                }
            };
        }

        @Override
        protected Item<SelectableBean<OrgType>> newRowItem(String id, int index, final IModel<SelectableBean<OrgType>> model) {
            Item<SelectableBean<OrgType>> item = super.newRowItem(id, index, model);
            item.add(AttributeModifier.append("class", new AbstractReadOnlyModel<String>() {

                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    SelectableBean<OrgType> itemObject = model.getObject();
                    if (itemObject != null && itemObject.equals(selected.getObject())) {
                        return "success";
                    }
                    return null;
                }
            }));
            return item;
        }

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

        @Override
        protected void onModelChanged() {
            super.onModelChanged();
            TreeStateSet<SelectableBean<OrgType>> items = (TreeStateSet) getModelObject();
            if (!items.isInverse()) {
                OrgTreePanel.this.setExpandedItems(items, getOrgTreeStateStorage());
            }
        }
    };
    tree.setItemReuseStrategy(new ReuseIfModelsEqualStrategy());
    tree.getTable().add(AttributeModifier.replace("class", "table table-striped table-condensed"));
    tree.add(new WindowsTheme());
    // tree.add(AttributeModifier.replace("class", "tree-midpoint"));
    treeContainer.add(tree);
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Serializable(java.io.Serializable) InlineMenuHeaderColumn(com.evolveum.midpoint.web.component.data.column.InlineMenuHeaderColumn) TableTree(org.apache.wicket.extensions.markup.html.repeater.tree.TableTree) 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) InlineMenu(com.evolveum.midpoint.web.component.menu.cog.InlineMenu) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) 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) Component(org.apache.wicket.Component) IModel(org.apache.wicket.model.IModel) SelectableFolderContent(com.evolveum.midpoint.web.page.admin.users.component.SelectableFolderContent) TreeStateSet(com.evolveum.midpoint.web.page.admin.users.dto.TreeStateSet) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) ISortableTreeProvider(org.apache.wicket.extensions.markup.html.repeater.tree.ISortableTreeProvider) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType)

Aggregations

InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)45 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)36 ArrayList (java.util.ArrayList)24 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)11 HeaderMenuAction (com.evolveum.midpoint.web.page.admin.configuration.component.HeaderMenuAction)11 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)10 IModel (org.apache.wicket.model.IModel)10 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)9 Form (org.apache.wicket.markup.html.form.Form)9 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)8 MainObjectListPanel (com.evolveum.midpoint.gui.api.component.MainObjectListPanel)7 InlineMenuItemAction (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction)7 Label (org.apache.wicket.markup.html.basic.Label)7 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)7 Model (org.apache.wicket.model.Model)7 ColumnMenuAction (com.evolveum.midpoint.web.component.data.column.ColumnMenuAction)5 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)4 ObjectBrowserPanel (com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel)3 PrismObject (com.evolveum.midpoint.prism.PrismObject)3 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)3