File tree 4 files changed +40
-1
lines changed
tmc-plugin/src/fi/helsinki/cs/tmc
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() {
43
43
WindowManager .getDefault ().invokeWhenUIReady (new Runnable () {
44
44
@ Override
45
45
public void run () {
46
+ MigrateSettings .run ();
47
+
46
48
CheckForOutdatedNetbeans .run ();
47
49
48
50
TmcCore .setInstance (new TmcCore ());
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ public class TmcCoreSettingsImpl implements TmcSettings {
37
37
private static final String PREF_RESOLVE_DEPENDENCIES = "resolveDependencies" ;
38
38
private static final String PREF_SEND_DIAGNOSTICS = "sendDiagnostics" ;
39
39
40
- private static PersistableSettings settings = PersistableSettings .forModule (TmcSettings .class );
40
+ private static PersistableSettings settings = PersistableSettings .forModule (TmcCoreSettingsImpl .class );
41
41
42
42
private Tailoring tailoring = SelectedTailoring .get ();
43
43
private TmcEventBus eventBus = TmcEventBus .getDefault ();
Original file line number Diff line number Diff line change @@ -83,6 +83,10 @@ public void cancel() {
83
83
transients .clear ();
84
84
}
85
85
86
+ public Preferences getPreferences () {
87
+ return prefs ;
88
+ }
89
+
86
90
private void flushPrefsOrThrow () {
87
91
try {
88
92
prefs .flush ();
You can’t perform that action at this time.
0 commit comments