TreeSet<TimeUnit> timeUnits = new TreeSet<TimeUnit>();
timeUnits.add(TimeUnit.SECONDS);
timeUnits.add(TimeUnit.MINUTES);
timeUnits.add(TimeUnit.HOURS);
timeUnits.add(TimeUnit.DAYS);
final DurationItem startDelay = new DurationItem("duration", "", timeUnits, false, false);
delayForm.setFields(startDelay);
DynamicForm scheduleForm = new DynamicForm();
final DateTimeItem schedule = new DateTimeItem("schedule");
schedule.setEnforceDate(true);
schedule.setCenturyThreshold(99);
schedule.setShowTitle(false);
schedule.setStartDate(new Date());
schedule.setUseMask(true);
schedule.setShowHint(true);
scheduleForm.setFields(schedule);
LinkedHashMap<String, Canvas> items = new LinkedHashMap<String, Canvas>();
items.put(MSG.view_admin_plugins_update_on_agents_now(), nowCanvas);
items.put(MSG.view_admin_plugins_update_on_agents_delayed(), delayForm);
items.put(MSG.view_admin_plugins_update_on_agents_scheduled(), scheduleForm);
DynamicForm form = new DynamicForm();
form.setWidth(300);
final RadioGroupWithComponentsItem scheduling = new RadioGroupWithComponentsItem("scheduling", "", items, form);
form.setFields(scheduling);
layout.addMember(form);
ButtonItem ok = new ButtonItem("ok", MSG.common_button_ok());
ok.setEndRow(false);
ok.setAlign(Alignment.RIGHT);
ButtonItem cancel = new ButtonItem("cancel", MSG.common_button_cancel());
cancel.setStartRow(false);
cancel.setAlign(Alignment.LEFT);
DynamicForm buttons = new DynamicForm();
buttons.setNumCols(2);
buttons.setFields(ok, cancel);
layout.addMember(buttons);
ok.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() {
@Override
public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent clickEvent) {
long delay;
if (MSG.view_admin_plugins_update_on_agents_now().equals(scheduling.getSelected())) {
delay = 0;
} else if (MSG.view_admin_plugins_update_on_agents_delayed().equals(scheduling.getSelected())) {
Integer value = (Integer) startDelay.getValue();
TimeUnit u = startDelay.getValueUnit();
if (value == null) {
CoreGUI.getErrorHandler()
.handleError(MSG.view_admin_plugins_update_on_agents_no_time_specified());
w.hide();