mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
options bundle
GitOrigin-RevId: 5565b78f63a9040b2fa8f7d373a5ef7eeee8e026
This commit is contained in:
committed by
intellij-monorepo-bot
parent
57c36c4b38
commit
31f1e3d3ee
@@ -269,7 +269,7 @@ private fun getComponentPresentableName(state: State, aClass: Class<*>, pluginDe
|
||||
resourceBundleName = pluginDescriptor.resourceBundleBaseName
|
||||
if (resourceBundleName == null) {
|
||||
if (pluginDescriptor.vendor == "JetBrains") {
|
||||
resourceBundleName = OptionsBundle.PATH_TO_BUNDLE
|
||||
resourceBundleName = OptionsBundle.BUNDLE
|
||||
}
|
||||
else {
|
||||
return trimDefaultName()
|
||||
@@ -277,7 +277,7 @@ private fun getComponentPresentableName(state: State, aClass: Class<*>, pluginDe
|
||||
}
|
||||
}
|
||||
else {
|
||||
resourceBundleName = OptionsBundle.PATH_TO_BUNDLE
|
||||
resourceBundleName = OptionsBundle.BUNDLE
|
||||
}
|
||||
|
||||
val classLoader = pluginDescriptor?.pluginClassLoader ?: aClass.classLoader
|
||||
|
||||
+5
-2
@@ -10,7 +10,10 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class GeneralCodeStylePropertyMapper extends AbstractCodeStylePropertyMapper {
|
||||
private static final Logger LOG = Logger.getInstance(AbstractCodeStylePropertyMapper.class);
|
||||
@@ -116,7 +119,7 @@ public class GeneralCodeStylePropertyMapper extends AbstractCodeStylePropertyMap
|
||||
@Nullable
|
||||
public String getPropertyDescription(@NotNull String externalName) {
|
||||
String key = "codestyle.property.description." + externalName;
|
||||
return OptionsBundle.getBundle().containsKey(key) ? OptionsBundle.message("codestyle.property.description." + externalName) : null;
|
||||
return OptionsBundle.INSTANCE.containsKey(key) ? OptionsBundle.message("codestyle.property.description." + externalName) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -140,6 +140,6 @@ public final class LanguageCodeStylePropertyMapper extends AbstractCodeStyleProp
|
||||
@Override
|
||||
public String getPropertyDescription(@NotNull String externalName) {
|
||||
String key = "codestyle.property.description." + externalName;
|
||||
return OptionsBundle.getBundle().containsKey(key) ? OptionsBundle.message(key) : null;
|
||||
return OptionsBundle.INSTANCE.containsKey(key) ? OptionsBundle.message(key) : null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,36 +15,19 @@
|
||||
*/
|
||||
package com.intellij.openapi.options;
|
||||
|
||||
import com.intellij.CommonBundle;
|
||||
import com.intellij.DynamicBundle;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.PropertyKey;
|
||||
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.util.ResourceBundle;
|
||||
public class OptionsBundle extends DynamicBundle {
|
||||
@NonNls public static final String BUNDLE = "messages.OptionsBundle";
|
||||
public static final OptionsBundle INSTANCE = new OptionsBundle();
|
||||
|
||||
/**
|
||||
* @author lesya
|
||||
*/
|
||||
public class OptionsBundle {
|
||||
private OptionsBundle() { super(BUNDLE); }
|
||||
|
||||
public static String message(@NotNull @PropertyKey(resourceBundle = PATH_TO_BUNDLE) String key, @NotNull Object... params) {
|
||||
return CommonBundle.message(getBundle(), key, params);
|
||||
@NotNull
|
||||
public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) {
|
||||
return INSTANCE.getMessage(key, params);
|
||||
}
|
||||
|
||||
private static Reference<ResourceBundle> ourBundle;
|
||||
@NonNls public static final String PATH_TO_BUNDLE = "messages.OptionsBundle";
|
||||
|
||||
private OptionsBundle() {
|
||||
}
|
||||
|
||||
public static ResourceBundle getBundle() {
|
||||
ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle);
|
||||
if (bundle == null) {
|
||||
bundle = ResourceBundle.getBundle(PATH_TO_BUNDLE);
|
||||
ourBundle = new SoftReference<>(bundle);
|
||||
}
|
||||
return bundle;
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -211,7 +211,7 @@ public class ConfigurableExtensionPointUtil {
|
||||
String id = "configurable.group." + groupId;
|
||||
ResourceBundle bundle = getBundle(id + ".settings.display.name", configurables, alternative);
|
||||
if (bundle == null) {
|
||||
bundle = OptionsBundle.getBundle();
|
||||
bundle = OptionsBundle.INSTANCE.getResourceBundle();
|
||||
if ("root".equals(groupId)) {
|
||||
try {
|
||||
String value = bundle.getString("configurable.group.root.settings.display.name");
|
||||
@@ -404,7 +404,7 @@ public class ConfigurableExtensionPointUtil {
|
||||
public static ResourceBundle getBundle(@NotNull String resource,
|
||||
@Nullable Iterable<? extends Configurable> configurables,
|
||||
@Nullable ResourceBundle alternative) {
|
||||
ResourceBundle bundle = OptionsBundle.getBundle();
|
||||
ResourceBundle bundle = OptionsBundle.INSTANCE.getResourceBundle();
|
||||
if (getString(bundle, resource) != null) {
|
||||
return bundle;
|
||||
}
|
||||
|
||||
@@ -42,21 +42,25 @@ public abstract class AbstractBundle {
|
||||
|
||||
@NotNull
|
||||
public String getMessage(@NotNull String key, @NotNull Object... params) {
|
||||
return CommonBundle.message(getBundle(), key, params);
|
||||
return CommonBundle.message(getResourceBundle(), key, params);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String messageOfNull(@NotNull String key, @NotNull Object... params) {
|
||||
return CommonBundle.messageOfNull(getBundle(), key, params);
|
||||
return CommonBundle.messageOfNull(getResourceBundle(), key, params);
|
||||
}
|
||||
|
||||
public String messageOrDefault(@NotNull String key,
|
||||
@Nullable String defaultValue,
|
||||
@NotNull Object... params) {
|
||||
return CommonBundle.messageOrDefault(getBundle(), key, defaultValue, params);
|
||||
return CommonBundle.messageOrDefault(getResourceBundle(), key, defaultValue, params);
|
||||
}
|
||||
|
||||
public boolean containsKey(@NotNull String key) {
|
||||
return getResourceBundle().containsKey(key);
|
||||
}
|
||||
|
||||
private ResourceBundle getBundle() {
|
||||
public ResourceBundle getResourceBundle() {
|
||||
ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(myBundle);
|
||||
if (bundle == null) {
|
||||
bundle = getResourceBundle(myPathToBundle, getClass().getClassLoader());
|
||||
|
||||
Reference in New Issue
Block a user