.withText(_, "confirmDeletionMessage") .withFeedback(new Feedback()
log.error("", e); view.notifyFatalError(notificationWithFeedback().withCaption("Fatal error") .withText("Out of memory") .withFeedback(new Feedback() log.error("", t); view.notifyFatalError(notificationWithFeedback().withCaption("Fatal error") .withText("Internal error") .withFeedback(new Feedback()
/******************************************************************************************************************* * * ******************************************************************************************************************/ protected void downloadMediaWithConfirmation (final @Nonnull Runnable runnable) { if (networkingPreferences.get().isNetworkConnectionAllowed()) { doDownloadMedia(runnable); } else { view.confirmToDownloadMedia(notificationWithFeedback().withCaption(_, "confirmDownloadTitle") .withText(_, "confirmDownloadMessage") .withFeedback(new Feedback() { @Override public void onConfirm() { doDownloadMedia(runnable); } })); } }
/******************************************************************************************************************* * * {@inheritDoc} * ******************************************************************************************************************/ public void deleteAllObservations() { ThreadAssertions.assertThread(UI); log.info("deleteAllObservations()"); view.confirmToDeleteAllObservations(notificationWithFeedback().withCaption(_, "confirm") .withText(_, "confirmEraseAllObservations") .withFeedback(new UserNotificationWithFeedback.Feedback() { @Override public void onConfirm() { observationSet.clear(); view.notifyAllObservationsDeleted(notification().withText(_, "allObservationsErased")); } })); }
/******************************************************************************************************************* * * ******************************************************************************************************************/ protected void doDownloadMedia (final @Nonnull Runnable runnable) { final FileSystem externalFileSystem = masterFileSystem.get().getExternalFileSystem(); if (!externalFileSystem.isWritable()) { view.notifySdCardNotReady(notificationWithFeedback().withCaption(_, "downloadFailed") .withText(_, "diskNotMountedMessage")); } else if (externalFileSystem.getFreeSpace() < MIN_FREE_SPACE) { view.notifySdCardNotReady(notificationWithFeedback().withCaption(_, "downloadFailed") .withText(_, "diskFullMessage", MIN_FREE_SPACE / MEGA)); } else { media.as(Downloadable).addPropertyChangeListener(downloadablePropertyChangeListener); runnable.run(); } } }
.withText(_, "shareFailed")); throw new RuntimeException(t);
/******************************************************************************************************************* * * {@inheritDoc} * ******************************************************************************************************************/ public void deleteObservationItem (final @Nonnull ObservationItem observationItem) { ThreadAssertions.assertThread(UI); log.info("deleteObservationItem({})", observationItem); final Taxon taxon = observationItem.getObservable().as(Taxon); view.confirmToDeleteAnObservationItem(notificationWithFeedback().withCaption(_, "confirm") .withText(_, "confirmDeleteObservationItem", taxon.as(PlainTextRenderable).render()) .withFeedback(new UserNotificationWithFeedback.Feedback() { @Override public void onConfirm() { observationItem.getObservation().change().without(observationItem).apply(); view.notifyObservationItemDeleted(notification().withText(_, "itemDeleted")); } })); }
/******************************************************************************************************************* * * 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(); } })); } } }
/******************************************************************************************************************* * ******************************************************************************************************************/ private void onButtonDialogOkPressed() { presentation.notify(notificationWithFeedback() .withCaption("Notification") .withText("Now press the button") .withFeedback(feedback().withOnConfirm(() -> presentation.notify("Pressed ok")))); }
/******************************************************************************************************************* * ******************************************************************************************************************/ private void onButtonDialogOkCancelPressed() { presentation.notify(notificationWithFeedback() .withCaption("Notification") .withText("Now press the button") .withFeedback(feedback().withOnConfirm(() -> presentation.notify("Pressed ok")) .withOnCancel(() -> presentation.notify("Pressed cancel")))); }