use of com.evolveum.midpoint.web.session.OrgStructurePanelStorage in project midpoint by Evolveum.
the class AbstractOrgTabPanel method initLayout.
private void initLayout() {
final IModel<List<ITab>> tabModel = new LoadableModel<>(true) {
private static final long serialVersionUID = 1L;
@Override
protected List<ITab> load() {
LOGGER.debug("Loading org. roots for tabs for tabbed panel.");
roots = loadOrgRoots();
final List<ITab> tabs = new ArrayList<>();
for (PrismObject<OrgType> root : roots) {
final String oid = root.getOid();
tabs.add(new AbstractTab(createTabTitle(root)) {
private static final long serialVersionUID = 1L;
private final int tabId = tabs.size();
@Override
public WebMarkupContainer getPanel(String panelId) {
add(new AjaxEventBehavior("load") {
private static final long serialVersionUID = 1L;
protected void onEvent(final AjaxRequestTarget target) {
OrgStructurePanelStorage usersStorage = getOrgStructurePanelStorage();
if (usersStorage != null) {
usersStorage.setSelectedTabId(tabId);
}
}
});
Panel panel = createTreePanel(panelId, new Model<>(oid), getPageBase());
panel.setOutputMarkupId(true);
return panel;
}
});
}
LOGGER.debug("Tab count is {}", tabs.size());
return tabs;
}
};
List<ITab> tabsList = tabModel.getObject();
OrgStructurePanelStorage orgStructurePanelStorage = getOrgStructurePanelStorage();
int selectedTab = 0;
if (orgStructurePanelStorage != null) {
selectedTab = orgStructurePanelStorage.getSelectedTabId() == -1 ? 0 : orgStructurePanelStorage.getSelectedTabId();
if (tabsList == null || (selectedTab > tabsList.size() - 1)) {
orgStructurePanelStorage.setSelectedTabId(0);
}
}
AjaxTabbedPanel<ITab> tabbedPanel = new AjaxTabbedPanel<>(ID_TABS, tabModel.getObject(), new Model<>(selectedTab), null) {
private static final long serialVersionUID = 1L;
@Override
public TabbedPanel<ITab> setSelectedTab(int index) {
changeTabPerformed(index);
return super.setSelectedTab(index);
}
};
tabbedPanel.setOutputMarkupId(true);
if (tabsList == null || tabsList.size() == 0) {
tabbedPanel.setVisible(false);
}
add(tabbedPanel);
}
use of com.evolveum.midpoint.web.session.OrgStructurePanelStorage 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