Search in sources :

Example 1 with AjaxCompositedIconButton

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);
                }
            }
        }
    };
}
Also used : AjaxCompositedIconButton(com.evolveum.midpoint.gui.impl.component.AjaxCompositedIconButton) IModel(org.apache.wicket.model.IModel) MenuMultiButtonPanel(com.evolveum.midpoint.web.component.data.MenuMultiButtonPanel) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) CompositedIconBuilder(com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem) EnableBehaviour(com.evolveum.midpoint.web.component.util.EnableBehaviour)

Example 2 with AjaxCompositedIconButton

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;
}
Also used : AjaxCompositedIconButton(com.evolveum.midpoint.gui.impl.component.AjaxCompositedIconButton) WebPage(org.apache.wicket.markup.html.WebPage) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView) AssignmentObjectRelation(com.evolveum.midpoint.model.api.AssignmentObjectRelation) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) CompositedIconBuilder(com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder)

Example 3 with AjaxCompositedIconButton

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);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxCompositedIconButton(com.evolveum.midpoint.gui.impl.component.AjaxCompositedIconButton) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) CompositedIconBuilder(com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder) RunReportPopupPanel(com.evolveum.midpoint.web.page.admin.reports.component.RunReportPopupPanel)

Example 4 with AjaxCompositedIconButton

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);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxCompositedIconButton(com.evolveum.midpoint.gui.impl.component.AjaxCompositedIconButton) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) ConfirmationPanel(com.evolveum.midpoint.web.component.dialog.ConfirmationPanel) SchemaException(com.evolveum.midpoint.util.exception.SchemaException)

Example 5 with AjaxCompositedIconButton

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);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxCompositedIconButton(com.evolveum.midpoint.gui.impl.component.AjaxCompositedIconButton) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) ConfirmationPanel(com.evolveum.midpoint.web.component.dialog.ConfirmationPanel) SchemaException(com.evolveum.midpoint.util.exception.SchemaException)

Aggregations

AjaxCompositedIconButton (com.evolveum.midpoint.gui.impl.component.AjaxCompositedIconButton)10 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)10 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)8 CompositedIconBuilder (com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder)4 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)4 ConfirmationPanel (com.evolveum.midpoint.web.component.dialog.ConfirmationPanel)4 AssignmentObjectRelation (com.evolveum.midpoint.model.api.AssignmentObjectRelation)2 CompiledObjectCollectionView (com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView)2 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)2 WebPage (org.apache.wicket.markup.html.WebPage)2 IModel (org.apache.wicket.model.IModel)2 CsvDownloadButtonPanel (com.evolveum.midpoint.gui.api.component.button.CsvDownloadButtonPanel)1 ContainerableListPanel (com.evolveum.midpoint.gui.impl.component.ContainerableListPanel)1 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)1 ObjectOrdering (com.evolveum.midpoint.prism.query.ObjectOrdering)1 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)1 OrderDirection (com.evolveum.midpoint.prism.query.OrderDirection)1 GetOperationOptions (com.evolveum.midpoint.schema.GetOperationOptions)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 Task (com.evolveum.midpoint.task.api.Task)1