public void save() { String frequency = month.getSelectedIndex() + ""; String stat = statusButton.getValue() + ""; String url = /*Window.Location.getUrl();*/ Window.Location.getHref().split("#", 2)[0]; String day = DateTimeFormat.getFormat("yyyy-MM-dd").format(date.getValue()) + " " + DateTimeFormat.getFormat("HH:mm:ss").format(time.getValue()); // Window.alert(frequency + " " + stat + " " + url + " " + day); mailingService.setMailing( stat, frequency, day, url, new AsyncCallback<Boolean>() { @Override public void onFailure(Throwable caught) { com.google.gwt.user.client.Window.alert("Error :" + caught.getMessage()); save.setIcon(null); save.setEnabled(true); } @Override public void onSuccess(Boolean result) { com.google.gwt.user.client.Window.alert(result ? "Success!" : "Error!"); save.setIcon(null); save.setEnabled(true); } }); }
public Widget getWidget() { form2 = new FramedPanel(); form2.setHeadingText(""); form2.setWidth("100%"); FieldSet fieldSet = new FieldSet(); fieldSet.setHeadingText("Emailing Setting"); fieldSet.setCollapsible(true); fieldSet.setHeight(155); form2.add(fieldSet); VerticalLayoutContainer p = new VerticalLayoutContainer(); fieldSet.add(p); HorizontalPanel hp = new HorizontalPanel(); // statusButton.setValue(true); // final TextButton refreshButton = new TextButton(); // refreshButton.setIcon(ressources.loading()); // statusButton.setWidth("60px"); hp.add(statusButton); // hp.add(refreshButton); p.add(new FieldLabel(hp, "System status")); month.setTriggerAction(TriggerAction.ALL); month.setEditable(false); month.setWidth(100); month.add(lFrequency); month.addSelectionHandler( new SelectionHandler<String>() { @Override public void onSelection(SelectionEvent<String> event) {} }); p.add(new FieldLabel(month, "Frequency"), new VerticalLayoutData(1, -1)); date.addParseErrorHandler( new ParseErrorHandler() { @Override public void onParseError(ParseErrorEvent event) { Info.display("Parse Error", event.getErrorValue() + " could not be parsed as a date"); } }); date.addValueChangeHandler( new ValueChangeHandler<Date>() { @Override public void onValueChange(ValueChangeEvent<Date> event) { String v = event.getValue() == null ? "nothing" : DateTimeFormat.getFormat(PredefinedFormat.DATE_MEDIUM) .format(event.getValue()); } }); // date.addValidator(new MinDateValidator(new Date())); p.add(new FieldLabel(date, "Starting date"), new VerticalLayoutData(1, -1)); time.addParseErrorHandler( new ParseErrorHandler() { @Override public void onParseError(ParseErrorEvent event) {} }); time.setMinValue(new DateWrapper().clearTime().addHours(8).asDate()); time.setMaxValue(new DateWrapper().clearTime().addHours(18).addSeconds(1).asDate()); p.add(new FieldLabel(time, "Starting time"), new VerticalLayoutData(1, -1)); statusButton.addValueChangeHandler( new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { statusButton.setText(statusButton.getValue() ? "On" : "Off"); } }); load(); form2.addButton(refresh); form2.addButton(save); refresh.addSelectHandler( new SelectHandler() { @Override public void onSelect(SelectEvent event) { refresh.setIcon(ressources.loading()); refresh.setEnabled(false); load(); } }); save.addSelectHandler( new SelectHandler() { @Override public void onSelect(SelectEvent event) { save.setIcon(ressources.loading()); save.setEnabled(false); save(); } }); return form2; }