Search in sources :

Example 66 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 67 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)

Example 68 with InlineMenuItem

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

the class PageTasks method initNodeColumns.

private List<IColumn<NodeDto, String>> initNodeColumns() {
    List<IColumn<NodeDto, String>> columns = new ArrayList<>();
    IColumn column = new CheckBoxHeaderColumn<>();
    columns.add(column);
    column = new PropertyColumn<>(createStringResource("pageTasks.node.name"), "name", "name");
    columns.add(column);
    columns.add(new EnumPropertyColumn<NodeDto>(createStringResource("pageTasks.node.executionStatus"), "executionStatus") {

        @Override
        protected String translate(Enum en) {
            return createStringResource(en).getString();
        }
    });
    columns.add(new PropertyColumn(createStringResource("pageTasks.node.managementPort"), "managementPort"));
    columns.add(new AbstractColumn<NodeDto, String>(createStringResource("pageTasks.node.lastCheckInTime")) {

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

                @Override
                public Object getObject() {
                    return createLastCheckInTime(rowModel);
                }
            }));
        }
    });
    CheckBoxColumn check = new CheckBoxColumn(createStringResource("pageTasks.node.clustered"), "clustered");
    check.setEnabled(false);
    columns.add(check);
    columns.add(new PropertyColumn(createStringResource("pageTasks.node.statusMessage"), "statusMessage"));
    IColumn<NodeDto, String> menuColumn = new InlineMenuButtonColumn<NodeDto>(createNodesInlineMenu(false), 2, PageTasks.this) {

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

        @Override
        protected List<InlineMenuItem> getHeaderMenuItems() {
            return createNodesInlineMenu(true);
        }
    };
    columns.add(menuColumn);
    return columns;
}
Also used : PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) Label(org.apache.wicket.markup.html.basic.Label) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) PrismObject(com.evolveum.midpoint.prism.PrismObject) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)

Example 69 with InlineMenuItem

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

the class RoleGovernanceRelationsPanel method createNewMemberInlineMenuItems.

@Override
protected List<InlineMenuItem> createNewMemberInlineMenuItems() {
    List<InlineMenuItem> newMemberMenuItems = new ArrayList<>();
    newMemberMenuItems.add(new InlineMenuItem(createStringResource("roleMemberPanel.menu.createApprover"), false, new HeaderMenuAction(this) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            createFocusMemberPerformed(RelationTypes.APPROVER.getRelation(), target);
        }
    }));
    newMemberMenuItems.add(new InlineMenuItem(createStringResource("roleMemberPanel.menu.assignApprovers"), false, new HeaderMenuAction(this) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            addMembers(RelationTypes.APPROVER.getRelation(), target);
        }
    }));
    newMemberMenuItems.add(new InlineMenuItem(createStringResource("roleMemberPanel.menu.createOwner"), false, new HeaderMenuAction(this) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            createFocusMemberPerformed(RelationTypes.OWNER.getRelation(), target);
        }
    }));
    newMemberMenuItems.add(new InlineMenuItem(createStringResource("roleMemberPanel.menu.assignOwners"), false, new HeaderMenuAction(this) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            addMembers(RelationTypes.OWNER.getRelation(), target);
        }
    }));
    newMemberMenuItems.add(new InlineMenuItem(createStringResource("TreeTablePanel.menu.createManager"), false, new HeaderMenuAction(this) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            createFocusMemberPerformed(RelationTypes.MANAGER.getRelation(), target);
        }
    }));
    newMemberMenuItems.add(new InlineMenuItem(createStringResource("TreeTablePanel.menu.addManagers"), false, new HeaderMenuAction(this) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            addMembers(RelationTypes.MANAGER.getRelation(), target);
        }
    }));
    return newMemberMenuItems;
}
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 70 with InlineMenuItem

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

the class OrgTreePanel method createTreeMenuInternal.

private List<InlineMenuItem> createTreeMenuInternal() {
    List<InlineMenuItem> items = new ArrayList<>();
    InlineMenuItem item = new InlineMenuItem(createStringResource("TreeTablePanel.collapseAll"), new InlineMenuItemAction() {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            collapseAllPerformed(target);
        }
    });
    items.add(item);
    item = new InlineMenuItem(createStringResource("TreeTablePanel.expandAll"), new InlineMenuItemAction() {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            expandAllPerformed(target);
        }
    });
    items.add(item);
    List<InlineMenuItem> additionalActions = createTreeMenu();
    if (additionalActions != null) {
        items.addAll(additionalActions);
    }
    return items;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)

Aggregations

InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)114 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)82 ArrayList (java.util.ArrayList)68 ButtonInlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)47 InlineMenuItemAction (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction)43 IModel (org.apache.wicket.model.IModel)41 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)35 UserProfileStorage (com.evolveum.midpoint.web.session.UserProfileStorage)30 CompositedIconBuilder (com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder)26 MainObjectListPanel (com.evolveum.midpoint.gui.api.component.MainObjectListPanel)25 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)24 ColumnMenuAction (com.evolveum.midpoint.web.component.data.column.ColumnMenuAction)19 Label (org.apache.wicket.markup.html.basic.Label)18 MidpointForm (com.evolveum.midpoint.web.component.form.MidpointForm)17 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)15 Form (org.apache.wicket.markup.html.form.Form)15 SelectableBeanImpl (com.evolveum.midpoint.web.component.util.SelectableBeanImpl)13 HeaderMenuAction (com.evolveum.midpoint.web.page.admin.configuration.component.HeaderMenuAction)13 ListItem (org.apache.wicket.markup.html.list.ListItem)12 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)11