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();
}
};
}
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;
}
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);
}
}));
}
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;
}
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;
}
Aggregations