/** * Invoked from the super class, * * @see org.usemon.gui.client.dimquery.wizard.WizardPanel#updateData() */ protected void updateData(Widget widget) { if (widget instanceof RadioButton) { periodFromDate = null; periodToDate = null; fromDateTextBox.setText(null); toDateTextBox.setText(null); } else if (widget instanceof RadioButtonTimeFrame) { periodFromDate = null; periodToDate = null; fromDateTextBox.setText(null); toDateTextBox.setText(null); numberOfMilliSeconds = ((RadioButtonTimeFrame) widget).getTotalMillis(); } else { DateTimeFormat formatter = DateTimeFormat.getFormat("dd.MM.yyyy"); String fromDate = fromDateTextBox.getText(); if (fromDate != null && fromDate.length() > 0) { periodFromDate = formatter.parse(fromDate); noValue.setChecked(true); } else { periodFromDate = null; } String toDate = toDateTextBox.getText(); if (toDate != null && toDate.length() > 0) { periodToDate = formatter.parse(toDate); noValue.setChecked(true); } else { periodToDate = null; } } }
/** * invoked from super class to validate the contents of this panel * * @see org.usemon.gui.client.dimquery.wizard.WizardPanel#validate() */ public boolean validate() { boolean result = false; result = result || hourRadio.isChecked() || dayRadio.isChecked() || weekRadio.isChecked() || monthRadio.isChecked(); result = result || (periodFromDate != null && periodToDate != null); return result; }
// Invoked by the constructor of the super class protected void initPanel() { if (!initialized) { this.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); hourRadio = new RadioButtonTimeFrame( RADIO_TIME_FRAME_GROUP, "Last ¤ hours", DateTimeUtils.getMillisPerHour(), 1); dayRadio = new RadioButtonTimeFrame( RADIO_TIME_FRAME_GROUP, "Last ¤ days", DateTimeUtils.getMillisPerDay(), 1); weekRadio = new RadioButtonTimeFrame( RADIO_TIME_FRAME_GROUP, "Last ¤ weeks", DateTimeUtils.getMillisPerWeek(), 1); monthRadio = new RadioButtonTimeFrame( RADIO_TIME_FRAME_GROUP, "Last ¤ months", DateTimeUtils.getMillisPerMonth(), 1); noValue = new RadioButtonTimeFrame(RADIO_TIME_FRAME_GROUP, "noValue"); noValue.setChecked(true); noValue.setVisible(false); fromDateTextBox = new TextBox(); toDateTextBox = new TextBox(); fromDateLabel = new Label("Fra dato: "); toDateLabel = new Label("Til dato: "); HorizontalPanel fromToPanel = new HorizontalPanel(); fromToPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); fromToPanel.add(fromDateLabel); fromToPanel.add(fromDateTextBox); fromToPanel.add(toDateLabel); fromToPanel.add(toDateTextBox); // Adding these input widgets, will also // attach a click listener or change listener, since // this method is overridden in the parent class. this.add(hourRadio); this.add(dayRadio); this.add(weekRadio); this.add(monthRadio); this.add(noValue); this.add(fromToPanel); initialized = true; } }