Search in sources :

Example 6 with DropdownButtonPanel

use of com.evolveum.midpoint.gui.api.component.button.DropdownButtonPanel 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 7 with DropdownButtonPanel

use of com.evolveum.midpoint.gui.api.component.button.DropdownButtonPanel in project midpoint by Evolveum.

the class ResourceContentPanel method initButton.

private void initButton(String id, String label, String icon, String archetypeOid) {
    ObjectQuery existingTasksQuery = getExistingTasksQuery(archetypeOid);
    OperationResult result = new OperationResult(OPERATION_SEARCH_TASKS_FOR_RESOURCE);
    List<PrismObject<TaskType>> tasksList = WebModelServiceUtils.searchObjects(TaskType.class, existingTasksQuery, result, getPageBase());
    List<InlineMenuItem> items = new ArrayList<>();
    InlineMenuItem item = new InlineMenuItem(getPageBase().createStringResource("ResourceContentResourcePanel.showExisting")) {

        private static final long serialVersionUID = 1L;

        @Override
        public InlineMenuItemAction initAction() {
            return new InlineMenuItemAction() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    List<TaskType> filteredByKindIntentTasks = getTasksForKind(tasksList);
                    redirectToTasksListPage(createInTaskOidQuery(filteredByKindIntentTasks), archetypeOid);
                }
            };
        }
    };
    items.add(item);
    item = new InlineMenuItem(getPageBase().createStringResource("ResourceContentResourcePanel.newTask")) {

        private static final long serialVersionUID = 1L;

        @Override
        public InlineMenuItemAction initAction() {
            return new InlineMenuItemAction() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    newTaskPerformed(archetypeOid);
                }
            };
        }
    };
    items.add(item);
    DropdownButtonPanel button = new DropdownButtonPanel(id, new DropdownButtonDto(String.valueOf(tasksList.size()), icon, label, items)) {

        @Override
        protected String getSpecialDropdownMenuClass() {
            return "pull-left";
        }
    };
    add(button);
}
Also used : DropdownButtonDto(com.evolveum.midpoint.gui.api.component.button.DropdownButtonDto) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) PrismObject(com.evolveum.midpoint.prism.PrismObject) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) DropdownButtonPanel(com.evolveum.midpoint.gui.api.component.button.DropdownButtonPanel)

Example 8 with DropdownButtonPanel

use of com.evolveum.midpoint.gui.api.component.button.DropdownButtonPanel in project midpoint by Evolveum.

the class ExecuteChangeOptionsPanel method createOptionsDropdownButton.

private void createOptionsDropdownButton(List<InlineMenuItem> items) {
    DropdownButtonDto model = new DropdownButtonDto(null, GuiStyleConstants.CLASS_OPTIONS_BUTTON_ICON, getPageBase().createStringResource("ExecuteChangeOptionsPanel.options").getString(), items);
    DropdownButtonPanel dropdownButtonPanel = new DropdownButtonPanel(ID_OPTIONS, model) {

        @Override
        protected void populateMenuItem(String componentId, ListItem<InlineMenuItem> menuItem) {
            InlineMenuItem item = menuItem.getModelObject();
            if (!(item instanceof CheckboxMenuItem)) {
                super.populateMenuItem(componentId, menuItem);
                return;
            }
            CheckboxMenuItem checkboxMenuItem = (CheckboxMenuItem) item;
            CheckBoxPanel panel = new CheckBoxPanel(componentId, checkboxMenuItem.getCheckBoxModel(), checkboxMenuItem.getLabel(), null) {

                @Override
                public void onUpdate(AjaxRequestTarget target) {
                // checkboxMenuItem.getCheckBoxModel().setObject(!checkboxMenuItem.getCheckBoxModel().getObject());
                }
            };
            panel.setOutputMarkupId(true);
            menuItem.add(panel);
        }

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

        @Override
        protected String getSpecialDropdownMenuClass() {
            return "execute-options";
        }

        @Override
        protected String getSpecialLabelClass() {
            return "execute-options-label";
        }
    };
    add(dropdownButtonPanel);
    dropdownButtonPanel.setOutputMarkupId(true);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) DropdownButtonDto(com.evolveum.midpoint.gui.api.component.button.DropdownButtonDto) CheckboxMenuItem(com.evolveum.midpoint.web.component.menu.cog.CheckboxMenuItem) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ListItem(org.apache.wicket.markup.html.list.ListItem) DropdownButtonPanel(com.evolveum.midpoint.gui.api.component.button.DropdownButtonPanel) CheckBoxPanel(com.evolveum.midpoint.gui.api.component.form.CheckBoxPanel)

Example 9 with DropdownButtonPanel

use of com.evolveum.midpoint.gui.api.component.button.DropdownButtonPanel in project midpoint by Evolveum.

the class AssignmentTablePanel method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    final WebMarkupContainer assignments = new WebMarkupContainer(ID_ASSIGNMENTS);
    assignments.setOutputMarkupId(true);
    add(assignments);
    Label label = new Label(ID_HEADER, getLabel());
    assignments.add(label);
    DropdownButtonDto model = new DropdownButtonDto(null, null, null, createAssignmentMenu());
    DropdownButtonPanel assignmentMenu = new DropdownButtonPanel(ID_MENU, model) {

        private static final long serialVersionUID = 1L;

        @Override
        protected String getSpecialButtonClass() {
            return "btn-xs btn-default";
        }
    };
    assignmentMenu.setVisible(getAssignmentMenuVisibility());
    assignments.add(assignmentMenu);
    ListView<AssignmentEditorDto> list = new ListView<AssignmentEditorDto>(ID_LIST, getModel()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<AssignmentEditorDto> item) {
            AssignmentTablePanel.this.populateAssignmentDetailsPanel(item);
        }
    };
    list.setOutputMarkupId(true);
    assignments.add(list);
    AjaxCheckBox checkAll = new AjaxCheckBox(ID_CHECK_ALL, new Model()) {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            List<AssignmentEditorDto> assignmentsList = getAssignmentModel().getObject();
            for (AssignmentEditorDto dto : assignmentsList) {
                dto.setSelected(this.getModelObject());
            }
            target.add(assignments);
        }
    };
    checkAll.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            int count = 0;
            for (AssignmentEditorDto dto : getModelObject()) {
                if (dto.isSimpleView()) {
                    count++;
                }
            }
            return count != getModelObject().size();
        }
    });
    assignments.add(checkAll);
}
Also used : Label(org.apache.wicket.markup.html.basic.Label) DropdownButtonDto(com.evolveum.midpoint.gui.api.component.button.DropdownButtonDto) AjaxCheckBox(org.apache.wicket.ajax.markup.html.form.AjaxCheckBox) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ListView(org.apache.wicket.markup.html.list.ListView) IModel(org.apache.wicket.model.IModel) Model(org.apache.wicket.model.Model) ListItem(org.apache.wicket.markup.html.list.ListItem) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) DropdownButtonPanel(com.evolveum.midpoint.gui.api.component.button.DropdownButtonPanel)

Aggregations

DropdownButtonDto (com.evolveum.midpoint.gui.api.component.button.DropdownButtonDto)9 DropdownButtonPanel (com.evolveum.midpoint.gui.api.component.button.DropdownButtonPanel)9 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)7 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)6 InlineMenuItemAction (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction)4 ListItem (org.apache.wicket.markup.html.list.ListItem)4 IModel (org.apache.wicket.model.IModel)4 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)3 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)3 Label (org.apache.wicket.markup.html.basic.Label)3 ButtonInlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)2 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)2 ArrayList (java.util.ArrayList)2 AjaxCheckBox (org.apache.wicket.ajax.markup.html.form.AjaxCheckBox)2 ListView (org.apache.wicket.markup.html.list.ListView)2 Model (org.apache.wicket.model.Model)2 CheckBoxPanel (com.evolveum.midpoint.gui.api.component.form.CheckBoxPanel)1 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)1 ReadOnlyModel (com.evolveum.midpoint.gui.api.model.ReadOnlyModel)1 UserDetailsModel (com.evolveum.midpoint.gui.impl.page.admin.user.UserDetailsModel)1