use of com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem 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.menu.cog.InlineMenuItem in project midpoint by Evolveum.
the class PageObjectCollections method initLayout.
private void initLayout() {
Form mainForm = new MidpointForm(ID_MAIN_FORM);
add(mainForm);
MainObjectListPanel<ObjectCollectionType> table = new MainObjectListPanel<ObjectCollectionType>(ID_TABLE, ObjectCollectionType.class) {
@Override
protected UserProfileStorage.TableId getTableId() {
return UserProfileStorage.TableId.TABLE_OBJECTS_COLLECTION;
}
@Override
protected List<InlineMenuItem> createInlineMenu() {
List<InlineMenuItem> menu = new ArrayList<>();
menu.add(createDeleteInlineMenu());
return menu;
}
@Override
protected List<IColumn<SelectableBean<ObjectCollectionType>, String>> createDefaultColumns() {
return ColumnUtils.getDefaultObjectColumns();
}
@Override
protected String getNothingSelectedMessage() {
return getString("pageObjectCollections.message.nothingSelected");
}
@Override
protected String getConfirmMessageKeyForSingleObject() {
return "pageObjectCollections.message.confirmationMessageForMultipleObject";
}
@Override
protected String getConfirmMessageKeyForMultiObject() {
return "pageObjectCollections.message.confirmationMessageForSingleObject";
}
};
table.setOutputMarkupId(true);
mainForm.add(table);
}
use of com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem in project midpoint by Evolveum.
the class InlineMenuButtonColumn method createMenuModel.
private IModel<List<InlineMenuItem>> createMenuModel(final IModel<T> rowModel, List<InlineMenuItem> menuItems) {
return new LoadableModel<List<InlineMenuItem>>(false) {
@Override
public List<InlineMenuItem> load() {
if (rowModel == null) {
return menuItems;
}
if (rowModel.getObject() == null || !(rowModel.getObject() instanceof InlineMenuable)) {
return new ArrayList<InlineMenuItem>();
}
for (InlineMenuItem item : ((InlineMenuable) rowModel.getObject()).getMenuItems()) {
if (!(item.getAction() instanceof ColumnMenuAction)) {
continue;
}
ColumnMenuAction action = (ColumnMenuAction) item.getAction();
action.setRowModel(rowModel);
}
return ((InlineMenuable) rowModel.getObject()).getMenuItems();
}
};
}
use of com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem in project midpoint by Evolveum.
the class InlineMenuColumn method createMenuModel.
private IModel<List<InlineMenuItem>> createMenuModel(final IModel<T> rowModel) {
return new LoadableModel<List<InlineMenuItem>>(false) {
@Override
public List<InlineMenuItem> load() {
if (!(rowModel.getObject() instanceof InlineMenuable)) {
return new ArrayList<InlineMenuItem>();
}
T row = rowModel.getObject();
if (row.getMenuItems() == null) {
return new ArrayList<InlineMenuItem>();
}
for (InlineMenuItem item : row.getMenuItems()) {
if (!(item.getAction() instanceof ColumnMenuAction)) {
continue;
}
ColumnMenuAction action = (ColumnMenuAction) item.getAction();
action.setRowModel(rowModel);
}
return row.getMenuItems();
}
};
}
use of com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem in project midpoint by Evolveum.
the class PageCertCampaigns method createInlineMenuForItem.
private void createInlineMenuForItem(final CertCampaignListItemDto dto) {
dto.getMenuItems().clear();
dto.getMenuItems().add(new InlineMenuItem(createStringResource("PageCertCampaigns.menu.close"), new ColumnMenuAction<CertCampaignListItemDto>() {
@Override
public void onClick(AjaxRequestTarget target) {
closeCampaignConfirmation(target, dto);
}
}) {
@Override
public IModel<Boolean> getEnabled() {
return new AbstractReadOnlyModel<Boolean>() {
@Override
public Boolean getObject() {
return dto.getState() != AccessCertificationCampaignStateType.CLOSED;
}
};
}
});
dto.getMenuItems().add(new InlineMenuItem(createStringResource("PageCertCampaigns.menu.delete"), new ColumnMenuAction<CertCampaignListItemDto>() {
@Override
public void onClick(AjaxRequestTarget target) {
deleteCampaignConfirmation(target, dto);
}
}));
}
Aggregations