//vertical layout
VStack column = new VStack();
//horizontal layout
EnhancedHLayout sheduledOperationsLayout = new EnhancedHLayout();
final CheckboxItem enableScheduledOperationsGrouping = new CheckboxItem();
enableScheduledOperationsGrouping.setName(OPERATIONS_RANGE_SCHEDULED_ENABLED);
enableScheduledOperationsGrouping.setTitle(" " + MSG.view_portlet_operations_config_show_next() + " ");
enableScheduledOperationsGrouping.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
String selectedItem = "" + event.getValue();
//stuff into the master form for retrieval
form.setValue(OPERATIONS_RANGE_SCHEDULED_ENABLED, selectedItem);
}
});
//wrap field item in dynamicform for addition
DynamicForm fieldWrapper = new DynamicForm();
fieldWrapper.setFields(enableScheduledOperationsGrouping);
sheduledOperationsLayout.addMember(fieldWrapper);
//retrieve previous value otherwise initialize to true(live unlimited list)
PropertySimple property = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED_ENABLED);
if (property != null) {
enableScheduledOperationsGrouping.setValue(property.getBooleanValue());
} else {
enableScheduledOperationsGrouping.setValue(true);
}
//------------- Build second combobox for timeframe for problem resources search.
final SelectItem maximumScheduledOperationsComboBox = new SelectItem(OPERATIONS_RANGE_SCHEDULED);
maximumScheduledOperationsComboBox.setTitle("");
maximumScheduledOperationsComboBox.setHint("<nobr><b> " + MSG.common_label_scheduled_operations()
+ ".</b></nobr>");
maximumScheduledOperationsComboBox.setType("selection");
//define acceptable values for display amount
String[] acceptableDisplayValues = { "1", "5", "10", "15", unlimitedString };
maximumScheduledOperationsComboBox.setValueMap(acceptableDisplayValues);
maximumScheduledOperationsComboBox.setWidth(100);
maximumScheduledOperationsComboBox.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
String selectedItem = "" + event.getValue();
//stuff into the master form for retrieval
form.setValue(OPERATIONS_RANGE_SCHEDULED, selectedItem);
}
});
String retrieved = defaultValue;
if ((property = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED)) != null) {
retrieved = property.getStringValue();
// protect against legacy issue with non-numeric values
try {
Integer.parseInt(retrieved);
} catch (NumberFormatException e) {
retrieved = unlimited;
}
}
//prepopulate the combobox with the previously stored selection
String selectedValue = retrieved.equals(unlimited) ? unlimitedString : retrieved;
//prepopulate the combobox with the previously stored selection
maximumScheduledOperationsComboBox.setDefaultValue(selectedValue);
DynamicForm fieldWrapper2 = new DynamicForm();
fieldWrapper2.setFields(maximumScheduledOperationsComboBox);
sheduledOperationsLayout.addMember(fieldWrapper2);
column.addMember(sheduledOperationsLayout);
form.addChild(column);
//submit handler
form.addSubmitValuesHandler(new SubmitValuesHandler() {