Lines 25-56
Link Here
|
25 |
public static final String PREF_USE_MAP_MODE = "use_map_mode"; //$NON-NLS-1$ |
25 |
public static final String PREF_USE_MAP_MODE = "use_map_mode"; //$NON-NLS-1$ |
26 |
public static final String PREF_USE_RUNTIME_FIGURES = "use_runtime_figures"; //$NON-NLS-1$ |
26 |
public static final String PREF_USE_RUNTIME_FIGURES = "use_runtime_figures"; //$NON-NLS-1$ |
27 |
|
27 |
|
|
|
28 |
private static String[] PROP_NAMES = new String[] { |
29 |
PREF_GENERATE_RCP, |
30 |
PREF_USE_MAP_MODE, |
31 |
PREF_USE_RUNTIME_FIGURES |
32 |
}; |
33 |
|
28 |
private Preferences myPreferences; |
34 |
private Preferences myPreferences; |
29 |
|
35 |
|
30 |
public TransformOptions() { |
36 |
public TransformOptions() { |
31 |
myPreferences = new Preferences(); |
|
|
32 |
reset(); |
37 |
reset(); |
33 |
} |
38 |
} |
34 |
|
39 |
|
35 |
private Preferences getPreferences() { |
40 |
private Preferences getPreferences() { |
|
|
41 |
if (myPreferences == null) { |
42 |
myPreferences = new Preferences(); |
43 |
} |
36 |
return myPreferences; |
44 |
return myPreferences; |
37 |
} |
45 |
} |
38 |
|
46 |
|
39 |
public void reset() { |
47 |
public void reset() { |
40 |
Preferences pluginPrefs = Plugin.getDefault().getPluginPreferences(); |
48 |
Preferences pluginPrefs = Plugin.getDefault().getPluginPreferences(); |
41 |
copyPreferences(pluginPrefs, myPreferences); |
49 |
copyPreferences(pluginPrefs, getPreferences()); |
42 |
} |
50 |
} |
43 |
|
51 |
|
44 |
public void flush() { |
52 |
public void flush() { |
45 |
Preferences pluginPrefs = Plugin.getDefault().getPluginPreferences(); |
53 |
Preferences pluginPrefs = Plugin.getDefault().getPluginPreferences(); |
46 |
copyPreferences(myPreferences, pluginPrefs); |
54 |
copyPreferences(getPreferences(), pluginPrefs); |
47 |
Plugin.getDefault().savePluginPreferences(); |
55 |
Plugin.getDefault().savePluginPreferences(); |
48 |
} |
56 |
} |
49 |
|
57 |
|
50 |
private void copyPreferences(Preferences source, Preferences target) { |
58 |
private void copyPreferences(Preferences source, Preferences target) { |
51 |
String[] propNames = source.propertyNames(); |
59 |
for (int i = 0; i < PROP_NAMES.length; i++) { |
52 |
for (int i = 0; i < propNames.length; i++) { |
60 |
String name = PROP_NAMES[i]; |
53 |
String name = propNames[i]; |
|
|
54 |
String value = source.getString(name); |
61 |
String value = source.getString(name); |
55 |
target.setValue(name, value); |
62 |
target.setValue(name, value); |
56 |
} |
63 |
} |