Search in sources :

Example 26 with InlineMenuItem

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();
        }
    };
}
Also used : LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) ArrayList(java.util.ArrayList) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)

Example 27 with InlineMenuItem

use of com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem in project midpoint by Evolveum.

the class PageCertCampaigns method createInlineMenu.

private List<InlineMenuItem> createInlineMenu() {
    List<InlineMenuItem> items = new ArrayList<>();
    items.add(new InlineMenuItem(createStringResource("PageCertCampaigns.menu.startSelected"), false, new HeaderMenuAction(this) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            startSelectedCampaignsPerformed(target);
        }
    }));
    items.add(new InlineMenuItem(createStringResource("PageCertCampaigns.menu.closeSelected"), false, new HeaderMenuAction(this) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            closeSelectedCampaignsConfirmation(target);
        }
    }));
    items.add(new InlineMenuItem(createStringResource("PageCertCampaigns.menu.deleteSelected"), false, new HeaderMenuAction(this) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            deleteSelectedCampaignsConfirmation(target);
        }
    }));
    return items;
}
Also used : HeaderMenuAction(com.evolveum.midpoint.web.page.admin.configuration.component.HeaderMenuAction) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ArrayList(java.util.ArrayList) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)

Example 28 with InlineMenuItem

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);
        }
    }));
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IModel(org.apache.wicket.model.IModel) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ColumnMenuAction(com.evolveum.midpoint.web.component.data.column.ColumnMenuAction)

Example 29 with InlineMenuItem

use of com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem in project midpoint by Evolveum.

the class PageTasks method initTaskColumns.

private List<IColumn<TaskDto, String>> initTaskColumns() {
    List<IColumn<TaskDto, String>> columns = new ArrayList<IColumn<TaskDto, String>>();
    IColumn column = new CheckBoxHeaderColumn<>();
    columns.add(column);
    column = createTaskNameColumn(this, "pageTasks.task.name");
    columns.add(column);
    columns.add(createTaskCategoryColumn(this, "pageTasks.task.category"));
    columns.add(new IconColumn<TaskDto>(createStringResource("")) {

        @Override
        protected IModel<String> createIconModel(IModel<TaskDto> rowModel) {
            ObjectReferenceType ref = rowModel.getObject().getObjectRef();
            if (ref == null || ref.getType() == null) {
                return Model.of("");
            }
            ObjectTypeGuiDescriptor guiDescriptor = getObjectTypeDescriptor(ref.getType());
            String icon = guiDescriptor != null ? guiDescriptor.getBlackIcon() : ObjectTypeGuiDescriptor.ERROR_ICON;
            return new Model<>(icon);
        }

        private ObjectTypeGuiDescriptor getObjectTypeDescriptor(QName type) {
            return ObjectTypeGuiDescriptor.getDescriptor(ObjectTypes.getObjectTypeFromTypeQName(type));
        }

        @Override
        public void populateItem(Item<ICellPopulator<TaskDto>> item, String componentId, IModel<TaskDto> rowModel) {
            super.populateItem(item, componentId, rowModel);
            ObjectReferenceType ref = rowModel.getObject().getObjectRef();
            if (ref != null && ref.getType() != null) {
                ObjectTypeGuiDescriptor guiDescriptor = getObjectTypeDescriptor(ref.getType());
                if (guiDescriptor != null) {
                    item.add(AttributeModifier.replace("title", createStringResource(guiDescriptor.getLocalizationKey())));
                    item.add(new TooltipBehavior());
                }
            }
        }
    });
    columns.add(new AbstractExportableColumn<TaskDto, String>(createStringResource("pageTasks.task.objectRef")) {

        @Override
        public void populateItem(Item<ICellPopulator<TaskDto>> item, String componentId, final IModel<TaskDto> rowModel) {
            item.add(new Label(componentId, new AbstractReadOnlyModel<Object>() {

                @Override
                public Object getObject() {
                    return createObjectRef(rowModel);
                }
            }));
        }

        @Override
        public IModel<String> getDataModel(IModel<TaskDto> rowModel) {
            return Model.of(createObjectRef(rowModel));
        }
    });
    columns.add(createTaskExecutionStatusColumn(this, "pageTasks.task.execution"));
    columns.add(new PropertyColumn<TaskDto, String>(createStringResource("pageTasks.task.executingAt"), "executingAt"));
    columns.add(new AbstractExportableColumn<TaskDto, String>(createStringResource("pageTasks.task.progress")) {

        @Override
        public void populateItem(Item<ICellPopulator<TaskDto>> cellItem, String componentId, final IModel<TaskDto> rowModel) {
            cellItem.add(new Label(componentId, new AbstractReadOnlyModel<Object>() {

                @Override
                public Object getObject() {
                    return createProgress(rowModel);
                }
            }));
        }

        @Override
        public IModel<String> getDataModel(IModel<TaskDto> rowModel) {
            return Model.of(createProgress(rowModel));
        }
    });
    columns.add(new AbstractExportableColumn<TaskDto, String>(createStringResource("pageTasks.task.currentRunTime")) {

        @Override
        public void populateItem(final Item<ICellPopulator<TaskDto>> item, final String componentId, final IModel<TaskDto> rowModel) {
            DateLabelComponent dateLabel = new DateLabelComponent(componentId, new AbstractReadOnlyModel<Date>() {

                @Override
                public Date getObject() {
                    Date date = createCurrentRuntime(rowModel);
                    TaskDto task = rowModel.getObject();
                    if (task.getRawExecutionStatus() == TaskExecutionStatus.CLOSED) {
                        ((DateLabelComponent) item.get(componentId)).setBefore("closed at ");
                    } else if (date != null) {
                        ((DateLabelComponent) item.get(componentId)).setBefore(DurationFormatUtils.formatDurationWords(date.getTime(), true, true));
                    }
                    return date;
                }
            }, DateLabelComponent.MEDIUM_MEDIUM_STYLE);
            item.add(dateLabel);
        }

        @Override
        public IModel<String> getDataModel(IModel<TaskDto> rowModel) {
            TaskDto task = rowModel.getObject();
            Date date = createCurrentRuntime(rowModel);
            String displayValue = "";
            if (date != null) {
                if (task.getRawExecutionStatus() == TaskExecutionStatus.CLOSED) {
                    displayValue = "closed at " + WebComponentUtil.getLocalizedDate(date, DateLabelComponent.LONG_MEDIUM_STYLE);
                } else {
                    displayValue = DurationFormatUtils.formatDurationWords(date.getTime(), true, true);
                }
            }
            return Model.of(displayValue);
        }
    });
    columns.add(new AbstractExportableColumn<TaskDto, String>(createStringResource("pageTasks.task.scheduledToRunAgain")) {

        @Override
        public void populateItem(Item<ICellPopulator<TaskDto>> item, String componentId, final IModel<TaskDto> rowModel) {
            item.add(new Label(componentId, new AbstractReadOnlyModel<Object>() {

                @Override
                public Object getObject() {
                    return createScheduledToRunAgain(rowModel);
                }
            }));
        }

        @Override
        public IModel<String> getDataModel(IModel<TaskDto> rowModel) {
            return Model.of(createScheduledToRunAgain(rowModel));
        }
    });
    columns.add(new IconColumn<TaskDto>(createStringResource("pageTasks.task.status")) {

        @Override
        protected IModel<String> createTitleModel(final IModel<TaskDto> rowModel) {
            return new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    TaskDto dto = rowModel.getObject();
                    if (dto != null && dto.getStatus() != null) {
                        return createStringResourceStatic(PageTasks.this, dto.getStatus()).getString();
                    } else {
                        return createStringResourceStatic(PageTasks.this, OperationResultStatus.UNKNOWN).getString();
                    }
                }
            };
        }

        @Override
        protected IModel<String> createIconModel(final IModel<TaskDto> rowModel) {
            return new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    if (rowModel != null && rowModel.getObject() != null && rowModel.getObject().getStatus() != null) {
                        return OperationResultStatusPresentationProperties.parseOperationalResultStatus(rowModel.getObject().getStatus().createStatusType()).getIcon() + " fa-lg";
                    } else
                        return OperationResultStatusPresentationProperties.UNKNOWN.getIcon() + " fa-lg";
                }
            };
        }
    });
    IColumn<TaskDto, String> menuColumn = new InlineMenuButtonColumn<TaskDto>(createTasksInlineMenu(false), 2, PageTasks.this) {

        @Override
        protected int getHeaderNumberOfButtons() {
            return 2;
        }

        @Override
        protected List<InlineMenuItem> getHeaderMenuItems() {
            return createTasksInlineMenu(true);
        }
    };
    columns.add(menuColumn);
    return columns;
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Label(org.apache.wicket.markup.html.basic.Label) TooltipBehavior(com.evolveum.midpoint.web.util.TooltipBehavior) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) IModel(org.apache.wicket.model.IModel) QName(javax.xml.namespace.QName) DateLabelComponent(com.evolveum.midpoint.web.component.DateLabelComponent) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) ObjectTypeGuiDescriptor(com.evolveum.midpoint.web.util.ObjectTypeGuiDescriptor) PrismObject(com.evolveum.midpoint.prism.PrismObject)

Example 30 with InlineMenuItem

use of com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem in project midpoint by Evolveum.

the class PageTasks method createTasksInlineMenu.

private List<InlineMenuItem> createTasksInlineMenu(boolean isHeader) {
    List<InlineMenuItem> items = new ArrayList<>();
    items.add(new InlineMenuItem(createStringResource("pageTasks.button.suspendTask"), new Model<Boolean>(false), new Model<Boolean>(false), false, new ColumnMenuAction<TaskDto>() {

        @Override
        public void onClick(AjaxRequestTarget target) {
            if (getRowModel() == null) {
                suspendTasksPerformed(target);
            } else {
                TaskDto rowDto = getRowModel().getObject();
                suspendTaskPerformed(target, rowDto);
            }
        }
    }, InlineMenuItem.TASKS_INLINE_MENU_ITEM_ID.SUSPEND.getMenuItemId(), GuiStyleConstants.CLASS_SUSPEND_MENU_ITEM, DoubleButtonColumn.BUTTON_COLOR_CLASS.INFO.toString()) {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isShowConfirmationDialog() {
            return PageTasks.this.isTaskShowConfirmationDialog((ColumnMenuAction) getAction());
        }

        @Override
        public IModel<String> getConfirmationMessageModel() {
            String actionName = createStringResource("pageTasks.message.suspendAction").getString();
            return PageTasks.this.getTaskConfirmationMessageModel((ColumnMenuAction) getAction(), actionName);
        }
    });
    items.add(new InlineMenuItem(createStringResource("pageTasks.button.resumeTask"), new Model<Boolean>(false), new Model<Boolean>(false), false, new ColumnMenuAction<TaskDto>() {

        @Override
        public void onClick(AjaxRequestTarget target) {
            if (getRowModel() == null) {
                resumeTasksPerformed(target);
            } else {
                TaskDto rowDto = getRowModel().getObject();
                resumeTaskPerformed(target, rowDto);
            }
        }
    }, InlineMenuItem.TASKS_INLINE_MENU_ITEM_ID.RESUME.getMenuItemId(), GuiStyleConstants.CLASS_RESUME_MENU_ITEM, DoubleButtonColumn.BUTTON_COLOR_CLASS.INFO.toString()) {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isShowConfirmationDialog() {
            return PageTasks.this.isTaskShowConfirmationDialog((ColumnMenuAction) getAction());
        }

        @Override
        public IModel<String> getConfirmationMessageModel() {
            String actionName = createStringResource("pageTasks.message.resumeAction").getString();
            return PageTasks.this.getTaskConfirmationMessageModel((ColumnMenuAction) getAction(), actionName);
        }
    });
    items.add(new InlineMenuItem(createStringResource("pageTasks.button.scheduleTask"), false, new ColumnMenuAction<TaskDto>() {

        @Override
        public void onClick(AjaxRequestTarget target) {
            if (getRowModel() == null) {
                scheduleTasksPerformed(target);
            } else {
                TaskDto rowDto = getRowModel().getObject();
                scheduleTaskPerformed(target, rowDto);
            }
        }
    }) {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isShowConfirmationDialog() {
            return PageTasks.this.isTaskShowConfirmationDialog((ColumnMenuAction) getAction());
        }

        @Override
        public IModel<String> getConfirmationMessageModel() {
            String actionName = createStringResource("pageTasks.message.runNowAction").getString();
            return PageTasks.this.getTaskConfirmationMessageModel((ColumnMenuAction) getAction(), actionName);
        }
    });
    items.add(new InlineMenuItem(createStringResource("pageTasks.button.deleteTask"), false, new ColumnMenuAction<TaskDto>() {

        @Override
        public void onClick(AjaxRequestTarget target) {
            if (getRowModel() == null) {
                deleteTaskConfirmedPerformed(target, null);
            } else {
                TaskDto rowDto = getRowModel().getObject();
                deleteTaskConfirmedPerformed(target, rowDto);
            }
        }
    }) {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isShowConfirmationDialog() {
            return PageTasks.this.isTaskShowConfirmationDialog((ColumnMenuAction) getAction());
        }

        @Override
        public IModel<String> getConfirmationMessageModel() {
            String actionName = createStringResource("pageTasks.message.deleteAction").getString();
            return PageTasks.this.getTaskConfirmationMessageModel((ColumnMenuAction) getAction(), actionName);
        }
    });
    if (isHeader) {
        items.add(new InlineMenuItem(createStringResource("pageTasks.button.deleteAllClosedTasks"), false, new ColumnMenuAction<TaskDto>() {

            @Override
            public void onClick(AjaxRequestTarget target) {
                deleteAllClosedTasksConfirmedPerformed(target);
            }
        }) {

            private static final long serialVersionUID = 1L;

            @Override
            public boolean isShowConfirmationDialog() {
                return true;
            }

            @Override
            public IModel<String> getConfirmationMessageModel() {
                return createStringResource("pageTasks.message.deleteAllClosedTasksConfirm");
            }
        });
    }
    return items;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IModel(org.apache.wicket.model.IModel) IModel(org.apache.wicket.model.IModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model) PropertyModel(org.apache.wicket.model.PropertyModel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)

Aggregations

InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)45 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)36 ArrayList (java.util.ArrayList)24 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)11 HeaderMenuAction (com.evolveum.midpoint.web.page.admin.configuration.component.HeaderMenuAction)11 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)10 IModel (org.apache.wicket.model.IModel)10 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)9 Form (org.apache.wicket.markup.html.form.Form)9 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)8 MainObjectListPanel (com.evolveum.midpoint.gui.api.component.MainObjectListPanel)7 InlineMenuItemAction (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction)7 Label (org.apache.wicket.markup.html.basic.Label)7 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)7 Model (org.apache.wicket.model.Model)7 ColumnMenuAction (com.evolveum.midpoint.web.component.data.column.ColumnMenuAction)5 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)4 ObjectBrowserPanel (com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel)3 PrismObject (com.evolveum.midpoint.prism.PrismObject)3 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)3