view.confirmToDeleteMedia(notificationWithFeedback().withCaption(_, "confirmDeletionTitle") .withText(_, "confirmDeletionMessage") .withFeedback(new Feedback()
view.notifyExportCompleted(notificationWithFeedback().withCaption(_, "export") .withText(_, "exportCompleted", path)); view.notifyExportFailed(notificationWithFeedback().withCaption(_, "export") .withText(_, "exportFailed")); throw new RuntimeException(t);
view.notifyFatalError(notificationWithFeedback().withCaption("Fatal error") .withText("Out of memory") .withFeedback(new Feedback() 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(); } } }
@VisibleForTesting void onProjectHourlyReportRequest (final @Nonnull @ListensTo ProjectHourlyReportRequest request) { final HourlyReport report = request.getProject().as(HourlyReportGenerator).createReport(); presentation.bind(); presentation.showUp(notificationWithFeedback().withCaption("Project Hourly Report")); presentation.populate(new DefaultPresentationModel(null, (PlainTextRenderableSupport8) (args) -> report.asString())); } }
view.notifyExportFailed(notificationWithFeedback().withCaption(_, "share") .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")); } })); }
/******************************************************************************************************************* * ******************************************************************************************************************/ private void onButtonDialogOkPressed() { presentation.notify(notificationWithFeedback() .withCaption("Notification") .withText("Now press the button") .withFeedback(feedback().withOnConfirm(() -> presentation.notify("Pressed ok")))); }
/******************************************************************************************************************* * * 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 askForOpeningSite() throws IOException { presentation.notifyInvitationToSelectAFolder(notificationWithFeedback() .withCaption("Select the site to open") .withFeedback(feedback() .withOnConfirm(() -> messageBus.publish(OpenSiteEvent.of(bindings.folderToOpen.get()))))); }
/******************************************************************************************************************* * ******************************************************************************************************************/ 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")))); }
/******************************************************************************************************************* * * This method demonstrates how to pick a directory name by using the proper UI dialog. * ******************************************************************************************************************/ private void onButtonPickDirectoryPressed() { final BoundProperty<Path> selectedFolder = new BoundProperty<>(USER_HOME); presentation.pickDirectory(selectedFolder, notificationWithFeedback() .withCaption("Pick a directory") .withFeedback(feedback().withOnConfirm(() -> presentation.notify("Selected folder: " + selectedFolder.get())) .withOnCancel(() -> presentation.notify("Selection cancelled")))); }
/******************************************************************************************************************* * * This method demonstrates how to pick a file name by using the proper UI dialog. * ******************************************************************************************************************/ private void onButtonPickFilePressed() { final BoundProperty<Path> selectedFile = new BoundProperty<>(USER_HOME); presentation.pickFile(selectedFile, notificationWithFeedback() .withCaption("Pick a file") .withFeedback(feedback().withOnConfirm(() -> presentation.notify("Selected file: " + selectedFile.get())) .withOnCancel(() -> presentation.notify("Selection cancelled")))); }