+ this.specimenSearchComposite.addListener(SWT.Selection, this);
+ specimenSearchComposite.getBtnShowDate().addListener(SWT.Selection, this);
+ specimenSearchComposite.getBtnShowDate().setSelection(false);
+ specimenSearchComposite.getDateFrom().setEnabled(false);
+ specimenSearchComposite.getDateTo().setEnabled(false);
+
+ loadLastState();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
+ */
+ @Override
+ public void handleEvent(Event event) {
+ Button btnShowDate = specimenSearchComposite.getBtnShowDate();
+ if(event.widget==btnShowDate){
+ specimenSearchComposite.getDateFrom().setEnabled(btnShowDate.getSelection());
+ specimenSearchComposite.getDateTo().setEnabled(btnShowDate.getSelection());
+ }
+ }
+
+
+ private void loadLastState(){
+ if(lastQuery!=null){
+ specimenSearchComposite.getTextAccessionNumber().setText(lastQuery.accessionNumber);
+ specimenSearchComposite.getTextCollector().setText(lastQuery.collector);
+ specimenSearchComposite.getTextCollectorNumber().setText(lastQuery.collectorsNumber);
+ specimenSearchComposite.getTextCountry().setText(lastQuery.country);
+ specimenSearchComposite.getTextHerbarium().setText(lastQuery.herbarium);
+ specimenSearchComposite.getTextLocality().setText(lastQuery.locality);
+ specimenSearchComposite.getTextTaxonName().setText(lastQuery.taxonName);
+ if(lastQuery.dateFrom!=null){
+ specimenSearchComposite.getDateFrom().setDate(lastQuery.dateFrom.get(Calendar.YEAR), lastQuery.dateFrom.get(Calendar.MONTH), lastQuery.dateFrom.get(Calendar.DAY_OF_MONTH));
+ }
+ if(lastQuery.dateTo!=null){
+ specimenSearchComposite.getDateTo().setDate(lastQuery.dateTo.get(Calendar.YEAR), lastQuery.dateTo.get(Calendar.MONTH), lastQuery.dateTo.get(Calendar.DAY_OF_MONTH));
+ }
+ }
+ }
+
+ public void saveLastSate() {
+ lastQuery = new OccurenceQuery(getTaxonName(), getCollector(), getCollectorNumber(), getAccessionNumber(), getHerbarium(), getCountry(), getLocality(), getDateFrom(), getDateTo());