use of com.evolveum.midpoint.web.component.data.MenuMultiButtonPanel in project midpoint by Evolveum.
the class InlineMenuButtonColumn method getPanel.
private Component getPanel(String componentId, IModel<T> rowModel, int numberOfButtons, boolean isHeaderPanel) {
List<InlineMenuItem> filteredMenuItems = new ArrayList<>();
for (InlineMenuItem menuItem : menuItems) {
if (isHeaderPanel && !menuItem.isHeaderMenuItem()) {
continue;
}
if (rowModel != null && menuItem.getAction() != null && menuItem.getAction() instanceof ColumnMenuAction) {
((ColumnMenuAction) menuItem.getAction()).setRowModel(rowModel);
}
if (menuItem.getVisibilityChecker() != null && !menuItem.getVisibilityChecker().isVisible(rowModel, isHeaderPanel)) {
continue;
}
filteredMenuItems.add(menuItem);
}
List<ButtonInlineMenuItem> buttonMenuItems = new ArrayList<>();
menuItems.forEach(menuItem -> {
if (menuItem instanceof ButtonInlineMenuItem) {
if (isHeaderPanel && !menuItem.isHeaderMenuItem() || !menuItem.getVisible().getObject()) {
return;
}
if (menuItem.getVisibilityChecker() != null && !menuItem.getVisibilityChecker().isVisible(rowModel, isHeaderPanel)) {
return;
}
buttonMenuItems.add((ButtonInlineMenuItem) menuItem);
}
});
if (filteredMenuItems.isEmpty()) {
// this is hack, TODO: cleanup and refactor soif there aren't any inline (row) actions, nothing is displayed
return new Label(componentId);
}
return new MenuMultiButtonPanel<T>(componentId, rowModel, buttonMenuItems.size(), Model.ofList(filteredMenuItems)) {
private static final long serialVersionUID = 1L;
@Override
protected Component createButton(int index, String componentId, IModel<T> model) {
CompositedIconBuilder builder = getIconCompositedBuilder(index, buttonMenuItems);
AjaxCompositedIconButton btn = new AjaxCompositedIconButton(componentId, builder.build(), Model.of(getButtonTitle(index, buttonMenuItems))) {
@Override
public void onClick(AjaxRequestTarget target) {
setRowModelToButtonAction(rowModel, buttonMenuItems);
buttonMenuItemClickPerformed(index, buttonMenuItems, target);
}
};
btn.add(AttributeAppender.append("class", " btn btn-default btn-xs"));
btn.add(new EnableBehaviour(() -> isButtonMenuItemEnabled(model)));
return btn;
}
@Override
protected void onBeforeClickMenuItem(AjaxRequestTarget target, InlineMenuItemAction action, IModel<InlineMenuItem> item) {
if (action instanceof ColumnMenuAction) {
if (!isHeaderPanel) {
((ColumnMenuAction) action).setRowModel(rowModel);
} else {
((ColumnMenuAction) action).setRowModel(null);
}
}
}
};
}
use of com.evolveum.midpoint.web.component.data.MenuMultiButtonPanel in project midpoint by Evolveum.
the class OrgTreeFolderContent method initLayout.
private void initLayout() {
SelectableFolderContent folder = new SelectableFolderContent(ID_FOLDER, tree, getModel(), selected) {
private static final long serialVersionUID = 1L;
@Override
protected void onClick(Optional<AjaxRequestTarget> target) {
super.onClick(target);
OrgTreeFolderContent.this.setSelectedItem(selected.getObject(), orgTreeStorage);
selectTreeItemPerformed(selected.getObject(), target.get());
Component component = get("table");
if (component != null) {
target.get().add(component);
}
}
};
folder.setOutputMarkupId(true);
addOrReplace(folder);
if (selected.getObject().equals(getModelObject())) {
getParent().add(AttributeAppender.append("class", "success"));
} else {
getParent().add(new AttributeAppender("class", "success", " ") {
@Override
protected Serializable newValue(String currentValue, String removeValue) {
currentValue = getSeparator() + currentValue + getSeparator();
removeValue = getSeparator() + removeValue + getSeparator();
return currentValue.replace(removeValue, getSeparator());
}
});
}
MenuMultiButtonPanel<OrgType> menuButtons = new MenuMultiButtonPanel<>(ID_MENU, new PropertyModel<>(getModel(), TreeSelectableBean.F_VALUE), 2, createInlineMenuItemsModel());
menuButtons.setOutputMarkupId(true);
addOrReplace(menuButtons);
CheckBoxPanel checkBoxPanel = new CheckBoxPanel(ID_CHECK, getCheckboxModel(getModel())) {
@Override
public void onUpdate(AjaxRequestTarget target) {
getModelObject().setSelected(!getModelObject().isSelected());
OrgTreeFolderContent.this.onUpdateCheckbox(target);
}
};
checkBoxPanel.add(new VisibleBehaviour(() -> selectable));
addOrReplace(checkBoxPanel);
}
Aggregations