@Override public void propertyChange (final @Nonnull PropertyChangeEvent event) { set((T)event.getNewValue()); } });
/******************************************************************************************************************* * ******************************************************************************************************************/ @Test(dependsOnMethods = "must_properly_initialize_resources") public void must_properly_set_value_to_bound_property() throws NotFoundException, IOException { // given final BoundProperty<String> boundProperty = new BoundProperty<>(); // when underTest.bind(PROPERTY_2, boundProperty, callback); // then assertThat(boundProperty.get(), is(ORIGINAL_PROPERTY_2_VALUE)); verifyZeroInteractions(callback); }
/******************************************************************************************************************* * ******************************************************************************************************************/ @Test(dependsOnMethods = "must_properly_initialize_resources") public void must_be_notified_with_updated_ResourceProperties_when_bound_property_updated() throws NotFoundException, IOException { // given final BoundProperty<String> boundProperty = new BoundProperty<>(); underTest.bind(PROPERTY_2, boundProperty, callback); // when boundProperty.set("New title"); // then verify(callback).notify(argThat(resourcePropertiesWith(map().put(PROPERTY_1, ORIGINAL_PROPERTY_1_VALUE) .put(PROPERTY_2, "New title")))); verifyNoMoreInteractions(callback); }
private void askForOpeningSite() throws IOException { presentation.notifyInvitationToSelectAFolder(notificationWithFeedback() .withCaption("Select the site to open") .withFeedback(feedback() .withOnConfirm(() -> messageBus.publish(OpenSiteEvent.of(bindings.folderToOpen.get()))))); }
/******************************************************************************************************************* * * * ******************************************************************************************************************/ public void bind (final @Nonnull ChangingSource<T> source) { source.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange (final @Nonnull PropertyChangeEvent event) { set((T)event.getNewValue()); } }); if (source instanceof Changeable) { final Changeable<T> changeable = (Changeable<T>)source; changeable.set(value); this.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange (final @Nonnull PropertyChangeEvent event) { changeable.set((T)event.getNewValue()); } }); } }
/******************************************************************************************************************* * * 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")))); }
@Override public void onConfirm() { // TODO: warn for overwriting data, ask for confirmation // FIXME: this gets executed in JavaFX thread try { presentation.lock(); final IBizImporter accounting = importerBuilderFactory.newBuilder() .withPath(iBizFolder.get()) .create(); accounting.importAll(); accounting.as(Saveable).save(); messageBus.publish(new AccountingOpenRequest()); // TODO: use a progress bar during the import process } catch (Exception e) { log.error("", e); presentation.notifyError(); } finally { presentation.unlock(); } } }));
/******************************************************************************************************************* * * * ******************************************************************************************************************/ public void bind (final @Nonnull ChangingSource<T> source) { source.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange (final @Nonnull PropertyChangeEvent event) { set((T)event.getNewValue()); } }); if (source instanceof Changeable) { final Changeable<T> changeable = (Changeable<T>)source; changeable.set(value); this.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange (final @Nonnull PropertyChangeEvent event) { changeable.set((T)event.getNewValue()); } }); } }
/******************************************************************************************************************* * * 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")))); }
@Override public void propertyChange (final @Nonnull PropertyChangeEvent event) { set((T)event.getNewValue()); } });
/******************************************************************************************************************* * ******************************************************************************************************************/ private void onButtonPressed() { presentation.notify("Button pressed"); status++; bindings.textProperty.set(Integer.toString(status)); }
iBizFolder.set(Paths.get(System.getProperty("user.home") + "/Settings/iBiz")); presentation.chooseFolder(notificationWithFeedback().withFeedback(new Feedback()