in client/idrepo/console/src/main/java/org/apache/syncope/client/console/events/EventCategoryPanel.java [120:284]
public EventCategoryPanel(
final String id,
final List<EventCategory> eventCategories,
final IModel<List<String>> model) {
super(id);
this.model = model;
selectedEventsPanel = new SelectedEventsPanel("selectedEventsPanel", model);
add(selectedEventsPanel);
this.eventCategories = eventCategories;
categoryContainer = new WebMarkupContainer("categoryContainer");
categoryContainer.setOutputMarkupId(true);
add(categoryContainer);
eventsContainer = new WebMarkupContainer("eventsContainer");
eventsContainer.setOutputMarkupId(true);
add(eventsContainer);
authorizeList();
authorizeChanges();
type = new AjaxDropDownChoicePanel<>(
"type",
"type",
new PropertyModel<>(eventCategory, "type"),
false);
type.setChoices(eventCategories.stream().
map(EventCategory::getType).distinct().
sorted(Comparator.comparing(OpEvent.CategoryType::name)).
collect(Collectors.toList()));
type.setChoiceRenderer(new IChoiceRenderer<>() {
private static final long serialVersionUID = 2317134950949778735L;
@Override
public String getDisplayValue(final OpEvent.CategoryType eventCategoryType) {
return eventCategoryType.name();
}
@Override
public String getIdValue(final OpEvent.CategoryType eventCategoryType, final int i) {
return eventCategoryType.name();
}
@Override
public OpEvent.CategoryType getObject(
final String id,
final IModel<? extends List<? extends OpEvent.CategoryType>> choices) {
return choices.getObject().stream().filter(object -> object.name().equals(id)).findAny().orElse(null);
}
});
categoryContainer.add(type);
type.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
private static final long serialVersionUID = -1107858522700306810L;
@Override
protected void onUpdate(final AjaxRequestTarget target) {
send(EventCategoryPanel.this, Broadcast.EXACT, new ChangeCategoryEvent(target, type));
}
});
category = new AjaxDropDownChoicePanel<>(
"category",
"category",
new PropertyModel<>(eventCategory, "category"),
false);
category.setChoices(filter(eventCategories, type.getModelObject()));
categoryContainer.add(category);
category.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
private static final long serialVersionUID = -1107858522700306811L;
@Override
protected void onUpdate(final AjaxRequestTarget target) {
send(EventCategoryPanel.this, Broadcast.EXACT, new ChangeCategoryEvent(target, category));
}
});
subcategory = new AjaxDropDownChoicePanel<>(
"subcategory",
"subcategory",
new PropertyModel<>(eventCategory, "subcategory"),
false);
subcategory.setChoices(filter(eventCategories, type.getModelObject(), category.getModelObject()));
categoryContainer.add(subcategory);
subcategory.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
private static final long serialVersionUID = -1107858522700306812L;
@Override
protected void onUpdate(final AjaxRequestTarget target) {
send(EventCategoryPanel.this, Broadcast.EXACT, new ChangeCategoryEvent(target, subcategory));
}
});
categoryContainer.add(new Label("customLabel", new ResourceModel("custom", "custom")).setVisible(false));
custom = new AjaxTextFieldPanel("custom", "custom", new Model<>(null));
custom.setVisible(false);
custom.setEnabled(false);
categoryContainer.add(custom.hideLabel());
actionsPanel = new ActionsPanel<>("customActions", null);
actionsPanel.add(new ActionLink<>() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
public void onClick(final AjaxRequestTarget target, final EventCategory ignore) {
if (StringUtils.isNotBlank(custom.getModelObject())) {
OpEvent opEvent = OpEvent.fromString(custom.getModelObject());
custom.setModelObject(StringUtils.EMPTY);
send(EventCategoryPanel.this.getPage(), Broadcast.BREADTH, new EventSelectionChanged(
target,
Set.of(opEvent),
Set.of()));
target.add(categoryContainer);
}
}
}, ActionLink.ActionType.CREATE, StringUtils.EMPTY).hideLabel();
actionsPanel.add(new ActionLink<>() {
private static final long serialVersionUID = -3722207913631435521L;
@Override
public void onClick(final AjaxRequestTarget target, final EventCategory ignore) {
if (StringUtils.isNotBlank(custom.getModelObject())) {
OpEvent opEvent = OpEvent.fromString(custom.getModelObject());
custom.setModelObject(StringUtils.EMPTY);
send(EventCategoryPanel.this.getPage(), Broadcast.BREADTH, new EventSelectionChanged(
target,
Set.of(),
Set.of(opEvent)));
target.add(categoryContainer);
}
}
}, ActionLink.ActionType.DELETE, StringUtils.EMPTY, true).hideLabel();
categoryContainer.add(actionsPanel);
actionsPanel.setVisible(false);
actionsPanel.setEnabled(false);
actionsPanel.setMarkupId("inline-actions");
eventsContainer.add(new EventSelectionPanel("eventsPanel", eventCategory, model) {
private static final long serialVersionUID = 3513194801190026082L;
@Override
protected void onEventAction(final IEvent<?> event) {
EventCategoryPanel.this.onEventAction(event);
}
});
}