Skip to content

Commit

Permalink
fix: default theme cannot be set in plugin customization file #713
Browse files Browse the repository at this point in the history
  • Loading branch information
sebthom committed Feb 16, 2024
1 parent 0434b35 commit 64c2fa1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public class TMUIPlugin extends AbstractUIPlugin {
@Nullable
private static volatile TMUIPlugin plugin;

public static @Nullable String getPreference(final String key, final @Nullable String defaultValue) {
return Platform.getPreferencesService().getString(PLUGIN_ID, key, defaultValue, null /* = search in all available scopes */);
}

public static void log(final IStatus status) {
final var p = plugin;
if (p != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ public static String toJsonThemeAssociations(final Collection<IThemeAssociation>
}

public static Set<MarkerConfig> loadMarkerConfigs() {
final var prefs = InstanceScope.INSTANCE.getNode(TMUIPlugin.PLUGIN_ID);
final var json = prefs.get(PreferenceConstants.TASK_TAGS, null);
final var json = TMUIPlugin.getPreference(PreferenceConstants.TASK_TAGS, null);
Set<MarkerConfig> result = null;
try {
result = loadMarkerConfigs(json);
} catch (final JsonSyntaxException ex) {
TMUIPlugin.logError(ex);
}
if (json != null)
try {
result = loadMarkerConfigs(json);
} catch (final JsonSyntaxException ex) {
TMUIPlugin.logError(ex);
}
return result == null ? MarkerConfig.getDefaults() : result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,8 @@ private void loadThemesFromExtensionPoints() {
* Load TextMate Themes from preferences.
*/
private void loadThemesFromPreferences() {
// Load Theme definitions from the
// "${workspace_loc}/metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.tm4e.ui.prefs"
final var prefs = InstanceScope.INSTANCE.getNode(TMUIPlugin.PLUGIN_ID);
String json = prefs.get(PreferenceConstants.THEMES, null);
// Load Theme definitions from preferences
String json = TMUIPlugin.getPreference(PreferenceConstants.THEMES, null);
if (json != null) {
for (final var jsonElem : new Gson().fromJson(json, JsonObject[].class)) {
final String name = jsonElem.get("id").getAsString();
Expand All @@ -134,16 +132,16 @@ private void loadThemesFromPreferences() {
}
}

json = prefs.get(PreferenceConstants.THEME_ASSOCIATIONS, null);
json = TMUIPlugin.getPreference(PreferenceConstants.THEME_ASSOCIATIONS, null);
if (json != null) {
final var themeAssociations = PreferenceHelper.loadThemeAssociations(json);
for (final IThemeAssociation association : themeAssociations) {
super.registerThemeAssociation(association);
}
}

defaultDarkThemeId = prefs.get(PreferenceConstants.DEFAULT_DARK_THEME, null);
defaultLightThemeId = prefs.get(PreferenceConstants.DEFAULT_LIGHT_THEME, null);
defaultDarkThemeId = TMUIPlugin.getPreference(PreferenceConstants.DEFAULT_DARK_THEME, null);
defaultLightThemeId = TMUIPlugin.getPreference(PreferenceConstants.DEFAULT_LIGHT_THEME, null);
}

void save() throws BackingStoreException {
Expand Down

0 comments on commit 64c2fa1

Please sign in to comment.