diff --git a/user-interface/src/main/bundles/dev.bundle b/user-interface/src/main/bundles/dev.bundle index bf4751e4e..9a6dd122a 100644 Binary files a/user-interface/src/main/bundles/dev.bundle and b/user-interface/src/main/bundles/dev.bundle differ diff --git a/user-interface/src/main/java/life/qbic/datamanager/views/account/PersonalAccessTokenMain.java b/user-interface/src/main/java/life/qbic/datamanager/views/account/PersonalAccessTokenMain.java index 9a835ad6f..4252d05d6 100644 --- a/user-interface/src/main/java/life/qbic/datamanager/views/account/PersonalAccessTokenMain.java +++ b/user-interface/src/main/java/life/qbic/datamanager/views/account/PersonalAccessTokenMain.java @@ -102,7 +102,7 @@ private void onAddTokenClicked(AddTokenEvent addTokenEvent) { event.personalAccessTokenDTO() .tokenDescription(), event.personalAccessTokenDTO().expirationDate()); personalAccessTokenComponent.showCreatedToken(createdToken); - event.getSource().closeIgnoringListeners(); + event.getSource().close(); Toast toast = messageSourceToastFactory.create("personal-access-token.created.success", new Object[]{event.personalAccessTokenDTO().tokenDescription()}, getLocale()); toast.open(); diff --git a/user-interface/src/main/java/life/qbic/datamanager/views/account/UserProfileComponent.java b/user-interface/src/main/java/life/qbic/datamanager/views/account/UserProfileComponent.java index 2ded9571a..07a3f62b2 100644 --- a/user-interface/src/main/java/life/qbic/datamanager/views/account/UserProfileComponent.java +++ b/user-interface/src/main/java/life/qbic/datamanager/views/account/UserProfileComponent.java @@ -227,7 +227,7 @@ private void openChangeUserDialog() { private void onChangeUserDetailsDialogConfirmed(ConfirmEvent event) { var response = identityService.requestUserNameChange(userInfo.id(), event.userName()); if (response.isSuccess()) { - event.getSource().closeIgnoringListeners(); + event.getSource().close(); // Trigger reload of UI reloading the username displayed in the datamanager menu // and within this component UI.getCurrent().getPage().reload(); diff --git a/user-interface/src/main/java/life/qbic/datamanager/views/general/QbicDialog.java b/user-interface/src/main/java/life/qbic/datamanager/views/general/QbicDialog.java index 0a5b6f8f7..c955bb0e8 100644 --- a/user-interface/src/main/java/life/qbic/datamanager/views/general/QbicDialog.java +++ b/user-interface/src/main/java/life/qbic/datamanager/views/general/QbicDialog.java @@ -1,152 +1,21 @@ package life.qbic.datamanager.views.general; -import com.vaadin.flow.component.ComponentEvent; import com.vaadin.flow.component.Key; import com.vaadin.flow.component.Shortcuts; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import life.qbic.datamanager.views.notifications.SupportsCloseConfirmation; -import life.qbic.datamanager.views.notifications.WithCloseListener.CloseEvent; /** * A {@link com.vaadin.flow.component.dialog.Dialog} with additional functionality. *

- * This class adds functionality to only close on user confirmation. For this simply call - * {@link #requireCloseConfirmation()}. * * @see com.vaadin.flow.component.dialog.Dialog * @since 1.4.0 */ -public class QbicDialog extends com.vaadin.flow.component.dialog.Dialog implements - SupportsCloseConfirmation> { - - private final List dialogCloseListeners = new ArrayList<>(); - private ListenerRegistration requireCloseConfirmationListener = null; - private boolean ignoresModificationForCloseConfirmation = SupportsCloseConfirmation.super.ignoresCloseCheckIfUnmodified(); - private boolean modified = false; +public class QbicDialog extends com.vaadin.flow.component.dialog.Dialog { public QbicDialog() { setCloseOnOutsideClick(false); setCloseOnEsc(false); - Shortcuts.addShortcutListener(this, this::close, Key.ESCAPE); - } - - @Override - public ListenerRegistration requireCloseConfirmation() { - if (requireCloseConfirmationListener != null) { - requireCloseConfirmationListener.listenerRemover().removeListener(); - } - requireCloseConfirmationListener = SupportsCloseConfirmation.super.requireCloseConfirmation(); - return requireCloseConfirmationListener; - } - - /** - * Remove required close confirmation. Can be used to revert {@link #requireCloseConfirmation()} - * - * @since 1.4.0 - */ - public void allowCloseWithoutConfirmation() { - if (Objects.nonNull(requireCloseConfirmationListener)) { - requireCloseConfirmationListener.listenerRemover().removeListener(); - } - } - - /** - * Add a listener that controls whether the dialog closes or not. The listener is informed when - * the dialog is requested to close. Then you can decide whether to close or to keep opened the - * dialog. It means that dialog won't closed unless you call the {@link #closeIgnoringListeners()} - * method explicitly in the listener implementation. - *

- * NOTE: - * Adding this listener changes behavior of the dialog. - *

- * If there are no close listeners present, the {@link #close()} method closes the dialog. - * Otherwise, the existing close listeners will prevent {@link #close()} from closing the dialog. - * The listeners should call the {@link #closeIgnoringListeners()} method to close the dialog - * instead. - * - * @param listener the listener to add - * @return the resulting - * {@link life.qbic.datamanager.views.notifications.WithCloseListener.ListenerRegistration} - */ - @Override - public ListenerRegistration addCloseListener( - DialogCloseListener> listener) { - com.vaadin.flow.shared.Registration registration = addListener(DialogCloseEvent.class, - listener::onClose); - - ListenerRegistration listenerRegistration = new ListenerRegistration(listener, - registration::remove); - dialogCloseListeners.add(listenerRegistration); - return listenerRegistration; - } - - @Override - public boolean ignoresCloseCheckIfUnmodified() { - return this.ignoresModificationForCloseConfirmation; - } - - /** - * Sets whether unmodified dialogs require close confirmation. - * - * @param ignore should missing modification ignore the close check? - * @param the class from which the method is called. - * @return the modified dialog - */ - public S setIgnoreCloseCheckIfUnmodified(boolean ignore) { - this.ignoresModificationForCloseConfirmation = ignore; - return (S) this; - } - - @Override - public boolean wasModified() { - return modified; - } - - @Override - public void setModified(boolean modified) { - this.modified = modified; - } - - /** - * @see #close() - */ - @Override - public void closeIgnoringListeners() { - super.close(); - } - - /** - * Closes the dialog if no close listeners are present. - *

- *

- * If there are close listeners, instead of closing the dialog, a {@link DialogCloseEvent} is - * fired. - */ - @Override - public void close() { - if (dialogCloseListeners.isEmpty()) { - closeIgnoringListeners(); - return; - } - fireEvent(new DialogCloseEvent(this, false)); - } - - public static class DialogCloseEvent extends ComponentEvent implements - CloseEvent { - - /** - * Creates a new event using the given source and indicator whether the event originated from - * the client side or the server side. - * - * @param source the source component - * @param fromClient true if the event originated from the client - * side, false otherwise - */ - public DialogCloseEvent(QbicDialog source, boolean fromClient) { - super(source, fromClient); - } - + Shortcuts.addShortcutListener(this, this::close, + Key.ESCAPE); //overwrite to point to close method instead } } diff --git a/user-interface/src/main/java/life/qbic/datamanager/views/general/WizardDialogWindow.java b/user-interface/src/main/java/life/qbic/datamanager/views/general/WizardDialogWindow.java index efe28959c..bc1a9e708 100644 --- a/user-interface/src/main/java/life/qbic/datamanager/views/general/WizardDialogWindow.java +++ b/user-interface/src/main/java/life/qbic/datamanager/views/general/WizardDialogWindow.java @@ -38,7 +38,7 @@ protected WizardDialogWindow() { * @since 1.0.0 */ protected void onFinishClicked(ClickEvent