operationSelectItem.setEndRow(true);
operationSelectItem.setWrapTitle(false);
operationSelectItem.setRedrawOnChange(true);
operationSelectItem.setVisible(false);
operationSelectItem.setDefaultToFirstOption(true);
operationSelectItem.addChangedHandler(new ChangedHandler() {
@Override
public void onChanged(ChangedEvent event) {
int operationId = Integer.valueOf(event.getValue().toString());
selectOperation(operationId);
}
});
// for SPECIFIC mode
singleResourceTextItem = new StaticTextItem("singleResourceTextItem",
MSG.view_alert_definition_notification_operation_editor_specific_resource());
singleResourceTextItem.setStartRow(true);
singleResourceTextItem.setEndRow(false);
singleResourceTextItem.setValue("Pick a resource...");
singleResourceTextItem.setShowIfCondition(new ShowIfModeFunction(ResourceSelectionMode.SPECIFIC));
singleResourceTextItem.setAttribute(RESOURCE_ID_ATTRIBUTE, 0); // we hide the resource ID in this attribute
singleResourceTextItem.setValidators(new ResourceIdValidator(singleResourceTextItem));
ButtonItem singleResourceButtonItem = new ButtonItem("singleResourceButtonItem",
MSG.view_alert_definition_notification_operation_editor_specific_pick_button());
singleResourceButtonItem.setStartRow(false);
singleResourceButtonItem.setEndRow(true);
singleResourceButtonItem.setShowTitle(false);
singleResourceButtonItem.setShowIfCondition(new ShowIfModeFunction(ResourceSelectionMode.SPECIFIC));
singleResourceButtonItem.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
SingleResourcePicker singleResourcePicker;
singleResourcePicker = new SingleResourcePicker(new OkHandler() {
public boolean ok(Set<Integer> resourceIdSelection) {
final int resourceId = resourceIdSelection.iterator().next().intValue();
setSpecificResource(resourceId, null, null);
return true;
}
}, null);
singleResourcePicker.show();
}
});
// for RELATIVE mode
ancestorTypeSelectItem = new SortedSelectItem("ancestorTypeSelectItem",
MSG.view_alert_definition_notification_operation_editor_relative_ancestor());
ancestorTypeSelectItem.setStartRow(true);
ancestorTypeSelectItem.setEndRow(true);
ancestorTypeSelectItem.setWrapTitle(false);
ancestorTypeSelectItem.setRedrawOnChange(true);
ancestorTypeSelectItem.setDefaultToFirstOption(true);
ancestorTypeSelectItem.setHoverWidth(200);
ancestorTypeSelectItem.setTooltip(MSG
.view_alert_definition_notification_operation_editor_relative_ancestor_tooltip());
ancestorTypeSelectItem.setShowIfCondition(new ShowIfModeFunction(ResourceSelectionMode.RELATIVE));
ancestorTypeSelectItem.addChangedHandler(new ChangedHandler() {
@Override
public void onChanged(ChangedEvent event) {
populateRelativeDescendantsDropDownMenu(null, null, null);
}
});
descendantTypeSelectItem = new SortedSelectItem("descendantTypeSelectItem",
MSG.view_alert_definition_notification_operation_editor_relative_descendant());
descendantTypeSelectItem.setStartRow(true);
descendantTypeSelectItem.setEndRow(false);
descendantTypeSelectItem.setWrapTitle(false);
descendantTypeSelectItem.setRedrawOnChange(true);
descendantTypeSelectItem.setDefaultToFirstOption(true);
descendantTypeSelectItem.setHoverWidth(200);
descendantTypeSelectItem.setTooltip(MSG
.view_alert_definition_notification_operation_editor_relative_descendant_tooltip());
descendantTypeSelectItem.setShowIfCondition(new ShowIfModeFunction(ResourceSelectionMode.RELATIVE));
descendantTypeSelectItem.addChangedHandler(new ChangedHandler() {
@Override
public void onChanged(ChangedEvent event) {
setOperationDropDownMenuValues(Integer.valueOf(event.getItem().getValue().toString()), null, null);
}
});
descendantNameTextItem = new TextItem("descendantNameTextItem");
descendantNameTextItem.setStartRow(false);
descendantNameTextItem.setEndRow(true);
descendantNameTextItem.setShowTitle(false);
descendantNameTextItem.setRequired(false);
descendantNameTextItem.setTooltip(MSG
.view_alert_definition_notification_operation_editor_relative_descendant_filter_tooltip());
descendantNameTextItem.setHoverWidth(200);
descendantNameTextItem.setShowIfCondition(new ShowIfModeFunction(ResourceSelectionMode.RELATIVE));
// the mode selector menu
modeSelectItem = new SortedSelectItem("modeSelectItem",
MSG.view_alert_definition_notification_operation_editor_mode_title());
modeSelectItem.setStartRow(true);
modeSelectItem.setEndRow(true);
modeSelectItem.setWrapTitle(false);
modeSelectItem.setRedrawOnChange(true);
LinkedHashMap<String, String> modes = new LinkedHashMap<String, String>(3);
modes.put(ResourceSelectionMode.SELF.name(), ResourceSelectionMode.SELF.getDisplayString());
modes.put(ResourceSelectionMode.SPECIFIC.name(), ResourceSelectionMode.SPECIFIC.getDisplayString());
modes.put(ResourceSelectionMode.RELATIVE.name(), ResourceSelectionMode.RELATIVE.getDisplayString());
modeSelectItem.setValueMap(modes);
modeSelectItem.addChangedHandler(new ChangedHandler() {
@Override
public void onChanged(ChangedEvent event) {
ResourceSelectionMode mode = ResourceSelectionMode.valueOf(event.getValue().toString());
switch (mode) {
case SELF: {