You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2026/05/02 23:56:50 UTC
(cayenne) 05/05: CAY-2929 Prefrences management UI
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cayenne.git
commit 91992ae9f23994ef50a850e79d8f17a4fbb6cb57
Author: Andrus Adamchik <an...@objectstyle.com>
AuthorDate: Sat May 2 19:30:43 2026 -0400
CAY-2929 Prefrences management UI
---
.../preferences/all/AllPreferencesController.java | 30 ++++++++++++++++++----
1 file changed, 25 insertions(+), 5 deletions(-)
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/preferences/all/AllPreferencesController.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/preferences/all/AllPreferencesController.java
index f725fe688..8868b021e 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/preferences/all/AllPreferencesController.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ui/preferences/all/AllPreferencesController.java
@@ -19,8 +19,10 @@
package org.apache.cayenne.modeler.ui.preferences.all;
+import org.apache.cayenne.modeler.Application;
import org.apache.cayenne.modeler.mvc.ChildController;
import org.apache.cayenne.modeler.pref.PreferencesRepository;
+import org.apache.cayenne.modeler.ui.action.ProjectAction;
import org.apache.cayenne.modeler.ui.preferences.PreferenceDialogController;
import javax.swing.*;
@@ -58,7 +60,7 @@ public class AllPreferencesController extends ChildController<PreferenceDialogCo
private void deleteAll() {
int answer = JOptionPane.showConfirmDialog(
view,
- "This will erase all Modeler preferences. Continue?",
+ "Erasing all preferences requires closing and restarting CayenneModeler. Continue?",
"Delete All Preferences",
JOptionPane.YES_NO_OPTION,
JOptionPane.WARNING_MESSAGE);
@@ -66,11 +68,29 @@ public class AllPreferencesController extends ChildController<PreferenceDialogCo
return;
}
- getApplication().getPreferencesRepository().deleteAll();
+ // Close the open project first (with the standard unsaved-changes
+ // prompt). closeProject is a no-op when no project is open. If the user
+ // cancels the save prompt, abort the wipe entirely.
+ ProjectAction projectAction = getApplication().getActionManager().getAction(ProjectAction.class);
+ if (!projectAction.closeProject(true)) {
+ return;
+ }
+
+ Application application = getApplication();
- Window dialog = SwingUtilities.getWindowAncestor(view);
- if (dialog != null) {
- dialog.dispose();
+ // Tear down the visible UI: the preferences dialog and the main frame.
+ // The frame holds the docked log console, so disposing it cleans up
+ // both. Subsequent startup() will rebuild everything.
+ Window prefsDialog = SwingUtilities.getWindowAncestor(view);
+ if (prefsDialog != null) {
+ prefsDialog.dispose();
}
+ application.getFrameController().getView().dispose();
+
+ application.getPreferencesRepository().deleteAll();
+
+ // Defer the rebuild to a later EDT tick so the in-flight action handler
+ // (and any pending dispose events) drain first.
+ SwingUtilities.invokeLater(() -> application.startup(null));
}
}