Search in sources :

Example 1 with TreeSelectableBean

use of com.evolveum.midpoint.web.component.util.TreeSelectableBean in project midpoint by Evolveum.

the class OrgTreeProvider method getRoots.

@Override
public Iterator<TreeSelectableBean<OrgType>> getRoots() {
    OperationResult result = null;
    if (root == null) {
        Task task = getPageBase().createSimpleTask(LOAD_ORG_UNIT);
        result = task.getResult();
        LOGGER.debug("Getting roots for: " + rootOid.getObject());
        PrismObject<OrgType> object = WebModelServiceUtils.loadObject(OrgType.class, rootOid.getObject(), WebModelServiceUtils.createOptionsForParentOrgRefs(getPageBase().getOperationOptionsBuilder()), getPageBase(), task, result);
        result.computeStatus();
        root = createObjectWrapper(null, object);
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("\n{}", result.debugDump());
            LOGGER.debug("Finished roots loading.");
        }
    }
    if (WebComponentUtil.showResultInPage(result)) {
        getPageBase().showResult(result);
    }
    List<TreeSelectableBean<OrgType>> list = new ArrayList<>();
    if (root != null) {
        list.add(root);
        if (!getAvailableData().containsKey(root.getValue().getOid())) {
            getAvailableData().put(root.getValue().getOid(), root);
        }
    }
    return list.iterator();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) TreeSelectableBean(com.evolveum.midpoint.web.component.util.TreeSelectableBean)

Example 2 with TreeSelectableBean

use of com.evolveum.midpoint.web.component.util.TreeSelectableBean in project midpoint by Evolveum.

the class TreeTablePanel method initLayout.

protected void initLayout(ModelServiceLocator serviceLocator) {
    OrgTreePanel treePanel = new OrgTreePanel(ID_TREE_PANEL, getModel(), false, serviceLocator) {

        private static final long serialVersionUID = 1L;

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

        protected List<InlineMenuItem> createTreeMenu() {
            return TreeTablePanel.this.createTreeMenu();
        }

        @Override
        protected List<InlineMenuItem> createTreeChildrenMenu(TreeSelectableBean<OrgType> org) {
            return TreeTablePanel.this.createTreeChildrenMenu(org);
        }
    };
    treePanel.setOutputMarkupId(true);
    add(treePanel);
    add(createMemberPanel(treePanel.getSelected().getValue()));
    // 
    add(createManagerPanel());
    setOutputMarkupId(true);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) OrgTreePanel(com.evolveum.midpoint.web.page.admin.orgs.OrgTreePanel) TreeSelectableBean(com.evolveum.midpoint.web.component.util.TreeSelectableBean) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)

Example 3 with TreeSelectableBean

use of com.evolveum.midpoint.web.component.util.TreeSelectableBean in project midpoint by Evolveum.

the class AbstractTreeTablePanel method getRootFromProvider.

protected TreeSelectableBean<OrgType> getRootFromProvider() {
    MidpointNestedTree tree = getTree();
    ITreeProvider<TreeSelectableBean<OrgType>> provider = tree.getProvider();
    Iterator<? extends TreeSelectableBean<OrgType>> iterator = provider.getRoots();
    return iterator.hasNext() ? iterator.next() : null;
}
Also used : OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) TreeSelectableBean(com.evolveum.midpoint.web.component.util.TreeSelectableBean) MidpointNestedTree(com.evolveum.midpoint.web.page.admin.orgs.MidpointNestedTree)

Example 4 with TreeSelectableBean

use of com.evolveum.midpoint.web.component.util.TreeSelectableBean 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 5 with TreeSelectableBean

use of com.evolveum.midpoint.web.component.util.TreeSelectableBean in project midpoint by Evolveum.

the class OrgTreeAssignablePanel method initLayout.

private void initLayout() {
    if (getPreselectedOrgsList() != null) {
        allTabsSelectedOrgs.addAll(getPreselectedOrgsList());
    }
    AbstractOrgTabPanel tabbedPanel = new AbstractOrgTabPanel(ID_ORG_TABS, getPageBase()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected Panel createTreePanel(String id, Model<String> model, PageBase pageBase) {
            OrgTreePanel panel = new OrgTreePanel(id, model, selectable, pageBase, "", allTabsSelectedOrgs) {

                private static final long serialVersionUID = 1L;

                private final OrgStructurePanelStorage storage = new OrgStructurePanelStorage();

                @Override
                protected IModel<Boolean> getCheckBoxValueModel(IModel<TreeSelectableBean<OrgType>> rowModel) {
                    return new LoadableModel<>(true) {

                        @Override
                        public Boolean load() {
                            for (OrgType org : allTabsSelectedOrgs) {
                                if (rowModel.getObject().getValue().getOid().equals(org.getOid())) {
                                    return true;
                                }
                            }
                            return false;
                        }
                    };
                }

                @Override
                protected void onOrgTreeCheckBoxSelectionPerformed(AjaxRequestTarget target, IModel<TreeSelectableBean<OrgType>> rowModel) {
                    if (rowModel != null && rowModel.getObject() != null) {
                        boolean isAlreadyInList = false;
                        Iterator<OrgType> it = allTabsSelectedOrgs.iterator();
                        while (it.hasNext()) {
                            OrgType org = it.next();
                            if (org.getOid().equals(rowModel.getObject().getValue().getOid())) {
                                isAlreadyInList = true;
                                it.remove();
                            }
                        }
                        if (!isAlreadyInList) {
                            allTabsSelectedOrgs.add(rowModel.getObject().getValue());
                        }
                    }
                    OrgTreeAssignablePanel.this.onOrgTreeCheckBoxSelectionPerformed(target, rowModel);
                }

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

                @Override
                public OrgTreeStateStorage getOrgTreeStateStorage() {
                    return storage;
                }

                @Override
                protected ObjectFilter getCustomFilter() {
                    return OrgTreeAssignablePanel.this.getCustomFilter();
                }
            };
            panel.setOutputMarkupId(true);
            panel.setOutputMarkupPlaceholderTag(true);
            return panel;
        }

        @Override
        protected boolean isWarnMessageVisible() {
            return false;
        }

        @Override
        protected ObjectFilter getAssignableItemsFilter() {
            return OrgTreeAssignablePanel.this.getCustomFilter();
        }

        @Override
        protected OrgStructurePanelStorage getOrgStructurePanelStorage() {
            return null;
        }
    };
    tabbedPanel.setOutputMarkupId(true);
    tabbedPanel.setOutputMarkupPlaceholderTag(true);
    add(tabbedPanel);
    AjaxButton assignButton = new AjaxButton(ID_ASSIGN, getPageBase().createStringResource("userBrowserDialog.button.addButton")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            assignSelectedOrgPerformed(getAllTabPanelsSelectedOrgs(), target);
        }
    };
    assignButton.setOutputMarkupId(true);
    assignButton.setOutputMarkupPlaceholderTag(true);
    assignButton.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isAssignButtonVisible();
        }
    });
    add(assignButton);
}
Also used : IModel(org.apache.wicket.model.IModel) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) StringResourceModel(org.apache.wicket.model.StringResourceModel) Model(org.apache.wicket.model.Model) IModel(org.apache.wicket.model.IModel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) OrgStructurePanelStorage(com.evolveum.midpoint.web.session.OrgStructurePanelStorage) TreeSelectableBean(com.evolveum.midpoint.web.component.util.TreeSelectableBean) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Aggregations

TreeSelectableBean (com.evolveum.midpoint.web.component.util.TreeSelectableBean)8 OrgType (com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType)6 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)4 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)3 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)3 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 Task (com.evolveum.midpoint.task.api.Task)2 OrgTreePanel (com.evolveum.midpoint.web.page.admin.orgs.OrgTreePanel)2 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)2 IModel (org.apache.wicket.model.IModel)2 DropdownButtonDto (com.evolveum.midpoint.gui.api.component.button.DropdownButtonDto)1 DropdownButtonPanel (com.evolveum.midpoint.gui.api.component.button.DropdownButtonPanel)1 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)1 ReadOnlyModel (com.evolveum.midpoint.gui.api.model.ReadOnlyModel)1 PageBase (com.evolveum.midpoint.gui.api.page.PageBase)1 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 CommonException (com.evolveum.midpoint.util.exception.CommonException)1 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)1 MidpointNestedTree (com.evolveum.midpoint.web.page.admin.orgs.MidpointNestedTree)1 OrgTreeProvider (com.evolveum.midpoint.web.page.admin.users.component.OrgTreeProvider)1