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();
}
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);
}
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;
}
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);
}
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);
}
Aggregations