[#1715] Add button in preferences for clearing cached preferences
This commit is contained in:
parent
304289350a
commit
7557b67dbb
@ -276,6 +276,10 @@ pref.dlg.tab.Simulation = Simulation
|
|||||||
pref.dlg.tab.Launch = Launch
|
pref.dlg.tab.Launch = Launch
|
||||||
pref.dlg.tab.Miscellaneousoptions = Miscellaneous options
|
pref.dlg.tab.Miscellaneousoptions = Miscellaneous options
|
||||||
pref.dlg.lbl.RockSimWarning = Show warning when saving in RockSim format
|
pref.dlg.lbl.RockSimWarning = Show warning when saving in RockSim format
|
||||||
|
pref.dlg.but.clearCachedPreferences = Clear cached preferences
|
||||||
|
pref.dlg.but.clearCachedPreferences.ttip = Clear cached preferences (UI settings, recent files, etc.)
|
||||||
|
pref.dlg.clearCachedPreferences.title = Clear cached preferences?
|
||||||
|
pref.dlg.clearCachedPreferences.message = Are you sure you want to clear cached preferences?
|
||||||
|
|
||||||
pref.dlg.tab.Graphics = Graphics
|
pref.dlg.tab.Graphics = Graphics
|
||||||
pref.dlg.lbl.DecalEditor = Graphics Editor
|
pref.dlg.lbl.DecalEditor = Graphics Editor
|
||||||
|
@ -246,7 +246,21 @@ public class GeneralPreferencesPanel extends PreferencesPanel {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.add(rocksimWarningDialogBox,"spanx, wrap");
|
this.add(rocksimWarningDialogBox,"spanx, wrap");
|
||||||
|
|
||||||
|
//// Clear cached preferences
|
||||||
|
final JButton clearCachedPreferences = new SelectColorButton(trans.get("pref.dlg.but.clearCachedPreferences"));
|
||||||
|
clearCachedPreferences.setToolTipText(trans.get("pref.dlg.but.clearCachedPreferences.ttip"));
|
||||||
|
clearCachedPreferences.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
int resultYesNo = JOptionPane.showConfirmDialog(parent, trans.get("pref.dlg.clearCachedPreferences.message"),
|
||||||
|
trans.get("pref.dlg.clearCachedPreferences.title"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
|
||||||
|
if (resultYesNo == JOptionPane.YES_OPTION) {
|
||||||
|
preferences.clearPreferences();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.add(clearCachedPreferences, "spanx, pushy, bottom, wrap");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ public class SwingPreferences extends net.sf.openrocket.startup.Preferences {
|
|||||||
*/
|
*/
|
||||||
private static final String NODENAME = (DEBUG ? "OpenRocket-debug" : "OpenRocket");
|
private static final String NODENAME = (DEBUG ? "OpenRocket-debug" : "OpenRocket");
|
||||||
|
|
||||||
private final Preferences PREFNODE;
|
private Preferences PREFNODE;
|
||||||
|
|
||||||
|
|
||||||
public SwingPreferences() {
|
public SwingPreferences() {
|
||||||
@ -93,7 +93,18 @@ public class SwingPreferences extends net.sf.openrocket.startup.Preferences {
|
|||||||
|
|
||||||
//////////////////////
|
//////////////////////
|
||||||
|
|
||||||
|
public void clearPreferences() {
|
||||||
|
try {
|
||||||
|
Preferences root = Preferences.userRoot();
|
||||||
|
if (root.nodeExists(NODENAME)) {
|
||||||
|
root.node(NODENAME).removeNode();
|
||||||
|
}
|
||||||
|
PREFNODE = root.node(NODENAME);
|
||||||
|
log.info("Cleared preferences");
|
||||||
|
} catch (BackingStoreException e) {
|
||||||
|
throw new BugException("Unable to clear preference node", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store the current OpenRocket version into the preferences to allow for preferences migration.
|
* Store the current OpenRocket version into the preferences to allow for preferences migration.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user