/******************************************************************************************************************* * * {@inheritDoc} * ******************************************************************************************************************/ public void startNewObservationSequence() { ThreadAssertions.assertThread(UI); log.info("startNewObservationSequence()"); observationClipboard.clear(); final Builder builder = observationClipboard.getBuilder(); observationClipboard.setBuilder(builder.at(Calendar.getInstance().getTime())); locationFinder.start(); // search needs time, and we pre-start it }
/******************************************************************************************************************* * * Adds the picked location to the {@link Observation} being built in the {@link ObservationClipboard}. * ******************************************************************************************************************/ private void commitLocation() { final List<Object> capabilities = new ArrayList<Object>(); capabilities.add(new DefaultDisplayable(etPlace.getText().toString(), "SimpleLocation")); try { capabilities.add(locationFinder.getRange()); } catch (NotFoundException e) { } final Location location = new SimpleLocation(capabilities.toArray()); // FIXME: use observationSet.findOrCreate() final ObservationClipboard observationClipboard = Locator.find(ObservationClipboard.class); final Observation.Builder builder = observationClipboard.getBuilder(); observationClipboard.setBuilder(builder.at(location)); controlFlow.toNextStep(); }
/******************************************************************************************************************* * * {@inheritDoc} * ******************************************************************************************************************/ public void commitNewObservation() { ThreadAssertions.assertThread(UI); log.info("commitNewObservation()"); final Observation.Builder builder = observationClipboard.getBuilder(); if (builder.getItemCount() > 0) { builder.build(); view.highlightLatestObservation(); view.notifyNewObservationCommitted(notification().withText(_, "addedNewObservation")); } observationClipboard.clear(); }
/******************************************************************************************************************* * * {@inheritDoc} * ******************************************************************************************************************/ public void initialize (final @Nonnull Taxon taxon) { log.info("initialize({})", taxon); this.taxon = taxon; builder = observationClipboard.get().getBuilder(); view.bindModel(model); view.renderTaxon(taxon); }
/******************************************************************************************************************* * * ******************************************************************************************************************/ @Nonnull public Taxonomy reloadTaxonomy() { log.info("reloadTaxonomy()"); taxonomy = null; observationClipboard.get().clear(); taxonHistory.get().clearTaxonHistory(); observationManager.get().findOrCreateObservationSetById(null).clear(); return getTaxonomy(); }
observationClipboard.get().setBuilder(builder.of(observable, getCardinality(model))); taxonHistory.get().addToTaxonHistory(taxon);
/******************************************************************************************************************* * * Checks whether the taxonomy can be changed right now. A taxonomy cannot be changed if there are stored * observations or a new observation is being inserted. When it's unfeasible to change the taxonomy, this method * will terminate the UI. * ******************************************************************************************************************/ private void checkWhetherTheTaxonomyCanBeChanged() { final ObservationSet observationSet = observationManager.get().findOrCreateObservationSetById(null); final boolean observationsInserted = observationSet.find(Observation.class).count() > 0; final boolean insertInProgress = observationClipboard.get().getBuilder().getItemCount() > 0; if (observationsInserted || insertInProgress) { view.notifyThatTheTaxonomyCannotBeChanged(notificationWithFeedback().withCaption(_, "cantChangeChecklist_title") .withText(_, "cantChangeChecklist_message") .withFeedback(new Feedback() { @Override public void onConfirm() { flowController.finish(); } })); } } }