use of com.evolveum.midpoint.gui.impl.component.AjaxCompositedIconButton 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.gui.impl.component.AjaxCompositedIconButton in project midpoint by Evolveum.
the class MainObjectListPanel method createNewObjectButton.
private Component createNewObjectButton(String buttonId) {
DisplayType newObjectButtonDisplayType = getNewObjectButtonStandardDisplayType();
CompositedIconBuilder builder = new CompositedIconBuilder();
builder.setBasicIcon(WebComponentUtil.getIconCssClass(newObjectButtonDisplayType), IconCssStyle.IN_ROW_STYLE).appendColorHtmlValue(WebComponentUtil.getIconColor(newObjectButtonDisplayType));
CompiledObjectCollectionView view = getObjectCollectionView();
if (ObjectCollectionViewUtil.isArchetypedCollectionView(view)) {
IconType plusIcon = new IconType();
plusIcon.setCssClass(GuiStyleConstants.CLASS_ADD_NEW_OBJECT);
plusIcon.setColor("green");
builder.appendLayerIcon(plusIcon, LayeredIconCssStyle.BOTTOM_RIGHT_STYLE);
}
String iconTitle = WebComponentUtil.getDisplayTypeTitle(newObjectButtonDisplayType);
AjaxCompositedIconButton createNewObjectButton = new AjaxCompositedIconButton(buttonId, builder.build(), createStringResource(StringUtils.isEmpty(iconTitle) ? "MainObjectListPanel.newObject" : iconTitle)) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
if (isCollectionViewPanelForCompiledView()) {
CompiledObjectCollectionView collectionView = getObjectCollectionView();
// HACK TODO clenup and think about generic mechanism for this
if (isCollectionViewWithoutMorePossibleNewType(collectionView)) {
newObjectPerformed(target, null, collectionView);
return;
}
}
if (!showNewObjectCreationPopup()) {
newObjectPerformed(target, null, getObjectCollectionView());
return;
}
NewObjectCreationPopup buttonsPanel = new NewObjectCreationPopup(getPageBase().getMainPopupBodyId(), new PropertyModel<>(loadButtonDescriptions(), MultiFunctinalButtonDto.F_ADDITIONAL_BUTTONS)) {
private static final long serialVersionUID = 1L;
@Override
protected void buttonClickPerformed(AjaxRequestTarget target, AssignmentObjectRelation relationSpec, CompiledObjectCollectionView collectionViews, Class<? extends WebPage> page) {
getPageBase().hideMainPopup(target);
MainObjectListPanel.this.newObjectPerformed(target, relationSpec, collectionViews);
}
};
getPageBase().showMainPopup(buttonsPanel, target);
}
};
createNewObjectButton.add(new VisibleBehaviour(this::isCreateNewObjectEnabled));
createNewObjectButton.add(AttributeAppender.append("class", "btn btn-default btn-sm"));
return createNewObjectButton;
}
use of com.evolveum.midpoint.gui.impl.component.AjaxCompositedIconButton in project midpoint by Evolveum.
the class ReportOperationalButtonsPanel method initOperationalButtons.
private void initOperationalButtons(RepeatingView repeatingView) {
String refreshId = repeatingView.newChildId();
String showPreviewId = repeatingView.newChildId();
String showPreviewInPopupId = repeatingView.newChildId();
IconType iconType = new IconType();
iconType.setCssClass("fa fa-address-card-o");
CompositedIconBuilder iconBuilder = new CompositedIconBuilder().setBasicIcon("fa fa-refresh", IconCssStyle.IN_ROW_STYLE).appendLayerIcon(iconType, IconCssStyle.BOTTOM_RIGHT_STYLE);
AjaxCompositedIconButton refresh = new AjaxCompositedIconButton(refreshId, iconBuilder.build(), createStringResource("pageCreateCollectionReport.button.refresh")) {
@Override
public void onClick(AjaxRequestTarget target) {
ReportObjectsListPanel<?> table = getReportTable();
table.getPageStorage().setSearch(null);
table.resetSearchModel();
table.resetTable(target);
table.refreshTable(target);
table.checkView();
target.add(table);
target.add(getTableBox());
target.add(getTableContainer());
target.add(getPageBase().getFeedbackPanel());
}
};
refresh.add(new VisibleBehaviour(isShowingPreview::getObject));
refresh.add(AttributeAppender.append("class", "btn-default btn-sm"));
refresh.setOutputMarkupId(true);
repeatingView.add(refresh);
iconBuilder = new CompositedIconBuilder().setBasicIcon("fa fa-address-card-o", IconCssStyle.IN_ROW_STYLE);
AjaxCompositedIconButton showPreview = new AjaxCompositedIconButton(showPreviewId, iconBuilder.build(), createStringResource("pageCreateCollectionReport.button.showPreview.${}", isShowingPreview)) {
@Override
public void onClick(AjaxRequestTarget target) {
isShowingPreview.setObject(!isShowingPreview.getObject());
ReportObjectsListPanel<?> table = getReportTable();
if (isShowingPreview.getObject()) {
table.getPageStorage().setSearch(null);
table.resetSearchModel();
table.resetTable(target);
table.refreshTable(target);
table.checkView();
}
target.add(getTableBox());
if (isShowingPreview.getObject() && table.hasView()) {
info(createStringResource("PageReport.message.shownedReportPreview").getString());
}
target.add(getTableContainer());
target.add(this);
target.add(repeatingView.get(showPreviewInPopupId));
target.add(repeatingView.get(refreshId));
target.add(ReportOperationalButtonsPanel.this);
target.add(getPageBase().getFeedbackPanel());
}
};
showPreview.titleAsLabel(true);
showPreview.add(new VisibleBehaviour(this::isCollectionReport));
showPreview.add(AttributeAppender.append("class", "btn-default btn-sm"));
showPreview.setOutputMarkupId(true);
repeatingView.add(showPreview);
iconType = new IconType();
iconType.setCssClass("fa fa-window-maximize");
iconBuilder = new CompositedIconBuilder().setBasicIcon("fa fa-address-card-o", IconCssStyle.IN_ROW_STYLE);
// .appendLayerIcon(iconType, IconCssStyle.BOTTOM_RIGHT_STYLE);
AjaxCompositedIconButton showPreviewInPopup = new AjaxCompositedIconButton(showPreviewInPopupId, iconBuilder.build(), createStringResource("pageCreateCollectionReport.button.showPreviewInPopup")) {
@Override
public void onClick(AjaxRequestTarget target) {
RunReportPopupPanel reportPopup = new RunReportPopupPanel(getPageBase().getMainPopupBodyId(), getReport(), false) {
@Override
public StringResourceModel getTitle() {
return createStringResource("PageReport.reportPreview");
}
};
getPageBase().showMainPopup(reportPopup, target);
target.add(ReportOperationalButtonsPanel.this);
}
};
showPreviewInPopup.titleAsLabel(true);
showPreviewInPopup.add(new VisibleBehaviour(() -> isCollectionReport() && !isShowingPreview.getObject()));
showPreviewInPopup.add(AttributeAppender.append("class", "btn-default btn-sm"));
showPreviewInPopup.setOutputMarkupId(true);
repeatingView.add(showPreviewInPopup);
iconBuilder = new CompositedIconBuilder().setBasicIcon(GuiStyleConstants.CLASS_START_MENU_ITEM, IconCssStyle.IN_ROW_STYLE);
AjaxCompositedIconButton runReport = new AjaxCompositedIconButton(repeatingView.newChildId(), iconBuilder.build(), createStringResource("pageCreateCollectionReport.button.runOriginalReport")) {
@Override
public void onClick(AjaxRequestTarget target) {
runReportPerformed(target, getOriginalReport(), getPageBase());
}
};
runReport.titleAsLabel(true);
runReport.add(new VisibleBehaviour(() -> isEditObject() && !WebComponentUtil.isImportReport(getOriginalReport().asObjectable())));
runReport.add(AttributeAppender.append("class", "btn-default btn-sm"));
runReport.setOutputMarkupId(true);
repeatingView.add(runReport);
iconBuilder = new CompositedIconBuilder().setBasicIcon(GuiStyleConstants.CLASS_UPLOAD, IconCssStyle.IN_ROW_STYLE);
AjaxCompositedIconButton importReport = new AjaxCompositedIconButton(repeatingView.newChildId(), iconBuilder.build(), createStringResource("pageCreateCollectionReport.button.importOriginalReport")) {
@Override
public void onClick(AjaxRequestTarget target) {
importReportPerformed(target, getOriginalReport(), getPageBase());
}
};
importReport.add(new VisibleBehaviour(() -> isEditObject() && WebComponentUtil.isImportReport(getOriginalReport().asObjectable())));
importReport.add(AttributeAppender.append("class", "btn-default btn-sm"));
importReport.setOutputMarkupId(true);
repeatingView.add(importReport);
}
use of com.evolveum.midpoint.gui.impl.component.AjaxCompositedIconButton in project midpoint by Evolveum.
the class PageTask method createCleanupPerformanceButton.
private void createCleanupPerformanceButton(RepeatingView repeatingView) {
AjaxCompositedIconButton cleanupPerformance = new AjaxCompositedIconButton(repeatingView.newChildId(), getTaskCleanupCompositedIcon(GuiStyleConstants.CLASS_ICON_PERFORMANCE), createStringResource("operationalButtonsPanel.cleanupEnvironmentalPerformance")) {
@Override
public void onClick(AjaxRequestTarget target) {
ConfirmationPanel dialog = new ConfirmationPanel(getMainPopupBodyId(), createStringResource("operationalButtonsPanel.cleanupEnvironmentalPerformance.confirmation")) {
private static final long serialVersionUID = 1L;
@Override
public void yesPerformed(AjaxRequestTarget target) {
try {
deleteStatistics(target);
} catch (Exception e) {
LOGGER.error("Cannot delete task operation statistics, {}", e.getMessage(), e);
getSession().error(PageTask.this.getString("PageTask.cleanup.operationStatistics.failed"));
}
}
};
showMainPopup(dialog, target);
}
};
cleanupPerformance.add(AttributeAppender.append("class", "btn btn-default btn-margin-left btn-sm"));
cleanupPerformance.add(new VisibleBehaviour(this::isNotRunning));
repeatingView.add(cleanupPerformance);
}
use of com.evolveum.midpoint.gui.impl.component.AjaxCompositedIconButton in project midpoint by Evolveum.
the class PageTask method createCleanupResultsButton.
private void createCleanupResultsButton(RepeatingView repeatingView) {
AjaxCompositedIconButton cleanupResults = new AjaxCompositedIconButton(repeatingView.newChildId(), getTaskCleanupCompositedIcon(GuiStyleConstants.CLASS_ICON_TASK_RESULTS), createStringResource("operationalButtonsPanel.cleanupResults")) {
@Override
public void onClick(AjaxRequestTarget target) {
ConfirmationPanel dialog = new ConfirmationPanel(getMainPopupBodyId(), createStringResource("operationalButtonsPanel.cleanupResults.confirmation")) {
private static final long serialVersionUID = 1L;
@Override
public void yesPerformed(AjaxRequestTarget target) {
try {
deleteItem(target, TaskType.F_RESULT, TaskType.F_RESULT_STATUS);
} catch (Exception e) {
LOGGER.error("Cannot clear task results: {}", e.getMessage());
getSession().error(PageTask.this.getString("PageTask.cleanup.result.failed"));
}
}
};
showMainPopup(dialog, target);
}
};
cleanupResults.add(new VisibleBehaviour(this::isNotRunning));
cleanupResults.add(AttributeAppender.append("class", "btn btn-default btn-margin-left btn-sm"));
repeatingView.add(cleanupResults);
}
Aggregations