use of com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction in project midpoint by Evolveum.
the class ResourceContentPanel method initButton.
private void initButton(String id, String label, String icon, final String category, final List<TaskType> tasks) {
List<InlineMenuItem> items = new ArrayList<>();
InlineMenuItem item = new InlineMenuItem(getPageBase().createStringResource("ResourceContentResourcePanel.showExisting"), new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
runTask(tasks, target);
}
});
items.add(item);
item = new InlineMenuItem(getPageBase().createStringResource("ResourceContentResourcePanel.newTask"), new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
newTaskPerformed(category, target);
}
});
items.add(item);
DropdownButtonPanel button = new DropdownButtonPanel(id, new DropdownButtonDto(String.valueOf(tasks.size()), icon, label, items));
add(button);
}
use of com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction in project midpoint by Evolveum.
the class MultivalueContainerListPanel method getDefaultMenuActions.
public List<InlineMenuItem> getDefaultMenuActions() {
List<InlineMenuItem> menuItems = new ArrayList<>();
menuItems.add(new ButtonInlineMenuItem(createStringResource("pageAdminFocus.button.delete")) {
private static final long serialVersionUID = 1L;
public CompositedIconBuilder getIconCompositedBuilder() {
return getDefaultCompositedIconBuilder(GuiStyleConstants.CLASS_DELETE_MENU_ITEM);
}
@Override
public InlineMenuItemAction initAction() {
return createDeleteColumnAction();
}
});
menuItems.add(new ButtonInlineMenuItem(createStringResource("PageBase.button.edit")) {
private static final long serialVersionUID = 1L;
@Override
public CompositedIconBuilder getIconCompositedBuilder() {
return getDefaultCompositedIconBuilder(GuiStyleConstants.CLASS_EDIT_MENU_ITEM);
}
@Override
public InlineMenuItemAction initAction() {
return createEditColumnAction();
}
});
return menuItems;
}
use of com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction 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.menu.cog.InlineMenuItemAction in project midpoint by Evolveum.
the class PageCertCampaigns method createInlineMenuForItem.
private List<InlineMenuItem> createInlineMenuForItem() {
List<InlineMenuItem> menuItems = new ArrayList<>();
InlineMenuItem item = new InlineMenuItem(createStringResource("PageCertCampaigns.menu.close")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new ColumnMenuAction<CertCampaignListItemDto>() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
closeCampaignConfirmation(target, getRowModel().getObject());
}
};
}
@Override
public boolean isHeaderMenuItem() {
return false;
}
};
item.setVisibilityChecker((rowModel, header) -> isNotClosed(rowModel));
menuItems.add(item);
item = new InlineMenuItem(createStringResource("PageCertCampaigns.menu.reiterate")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new ColumnMenuAction<CertCampaignListItemDto>() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
reiterateCampaignConfirmation(target, getRowModel().getObject());
}
};
}
@Override
public boolean isHeaderMenuItem() {
return false;
}
};
item.setVisibilityChecker((rowModel, header) -> isReiterable(rowModel));
menuItems.add(item);
menuItems.add(new InlineMenuItem(createStringResource("PageCertCampaigns.menu.delete")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new ColumnMenuAction<CertCampaignListItemDto>() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
deleteCampaignConfirmation(target, getRowModel().getObject());
}
};
}
@Override
public boolean isHeaderMenuItem() {
return false;
}
});
return menuItems;
}
use of com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction in project midpoint by Evolveum.
the class PageCertDefinitions method createInlineMenu.
private List<InlineMenuItem> createInlineMenu() {
List<InlineMenuItem> menu = new ArrayList<>();
menu.add(new ButtonInlineMenuItem(createStringResource("PageCertDefinitions.button.createCampaign")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new ColumnMenuAction<SelectableBean<AccessCertificationDefinitionType>>() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
AccessCertificationDefinitionType campaign = getRowModel().getObject().getValue();
createCampaignPerformed(target, campaign);
}
};
}
@Override
public CompositedIconBuilder getIconCompositedBuilder() {
return getDefaultCompositedIconBuilder(GuiStyleConstants.CLASS_START_MENU_ITEM);
}
@Override
public boolean isHeaderMenuItem() {
return false;
}
});
menu.add(new ButtonInlineMenuItem(createStringResource("PageCertDefinitions.button.showCampaigns")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new ColumnMenuAction<SelectableBeanImpl<AccessCertificationDefinitionType>>() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
AccessCertificationDefinitionType campaign = getRowModel().getObject().getValue();
showCampaignsPerformed(target, campaign);
}
};
}
@Override
public CompositedIconBuilder getIconCompositedBuilder() {
return getDefaultCompositedIconBuilder("fa fa-files-o");
}
@Override
public boolean isHeaderMenuItem() {
return false;
}
});
menu.add(new ButtonInlineMenuItem(createStringResource("PageCertDefinitions.button.deleteDefinition")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new ColumnMenuAction<SelectableBeanImpl<AccessCertificationDefinitionType>>() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
AccessCertificationDefinitionType campaign = getRowModel().getObject().getValue();
deleteConfirmation(target, campaign);
}
};
}
@Override
public CompositedIconBuilder getIconCompositedBuilder() {
return getDefaultCompositedIconBuilder(GuiStyleConstants.CLASS_DELETE_MENU_ITEM);
}
@Override
public boolean isHeaderMenuItem() {
return false;
}
});
return menu;
}
Aggregations