File tree Expand file tree Collapse file tree 4 files changed +40
-1
lines changed
tmc-plugin/src/fi/helsinki/cs/tmc Expand file tree Collapse file tree 4 files changed +40
-1
lines changed Original file line number Diff line number Diff line change 1+ package fi .helsinki .cs .tmc .actions ;
2+
3+ import fi .helsinki .cs .tmc .core .configuration .TmcSettings ;
4+ import fi .helsinki .cs .tmc .coreimpl .TmcCoreSettingsImpl ;
5+ import fi .helsinki .cs .tmc .model .PersistableSettings ;
6+
7+ import java .util .logging .Logger ;
8+ import java .util .prefs .BackingStoreException ;
9+
10+ public class MigrateSettings {
11+
12+ private static Logger logger = Logger .getLogger (MigrateSettings .class .getName ());
13+
14+ public static void run () {
15+ PersistableSettings rightSettings = PersistableSettings .forModule (TmcCoreSettingsImpl .class );
16+ PersistableSettings wrongSettings = PersistableSettings .forModule (TmcSettings .class );
17+ try {
18+ final String [] keys = wrongSettings .getPreferences ().keys ();
19+ for (String key : keys ) {
20+ String wrongValue = wrongSettings .get (key , null );
21+ if (wrongValue == null ) {
22+ continue ;
23+ }
24+ rightSettings .put (key , wrongValue );
25+ wrongSettings .remove (key );
26+ }
27+ wrongSettings .saveAll ();
28+ rightSettings .saveAll ();
29+ } catch (BackingStoreException ex ) {
30+ logger .fine ("Could not migrate wrong settings." );
31+ }
32+ }
33+ }
Original file line number Diff line number Diff line change @@ -43,6 +43,8 @@ public void restored() {
4343 WindowManager .getDefault ().invokeWhenUIReady (new Runnable () {
4444 @ Override
4545 public void run () {
46+ MigrateSettings .run ();
47+
4648 CheckForOutdatedNetbeans .run ();
4749
4850 TmcCore .setInstance (new TmcCore ());
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ public class TmcCoreSettingsImpl implements TmcSettings {
3737 private static final String PREF_RESOLVE_DEPENDENCIES = "resolveDependencies" ;
3838 private static final String PREF_SEND_DIAGNOSTICS = "sendDiagnostics" ;
3939
40- private static PersistableSettings settings = PersistableSettings .forModule (TmcSettings .class );
40+ private static PersistableSettings settings = PersistableSettings .forModule (TmcCoreSettingsImpl .class );
4141
4242 private Tailoring tailoring = SelectedTailoring .get ();
4343 private TmcEventBus eventBus = TmcEventBus .getDefault ();
Original file line number Diff line number Diff line change @@ -83,6 +83,10 @@ public void cancel() {
8383 transients .clear ();
8484 }
8585
86+ public Preferences getPreferences () {
87+ return prefs ;
88+ }
89+
8690 private void flushPrefsOrThrow () {
8791 try {
8892 prefs .flush ();
You can’t perform that action at this time.
0 commit comments