diff --git a/java/remote-servers/impl/src/com/intellij/remoteServer/impl/module/CloudModuleBuilderSourceContribution.java b/java/remote-servers/impl/src/com/intellij/remoteServer/impl/module/CloudModuleBuilderSourceContribution.java index 0c23b4980180..3fd7fad5a071 100644 --- a/java/remote-servers/impl/src/com/intellij/remoteServer/impl/module/CloudModuleBuilderSourceContribution.java +++ b/java/remote-servers/impl/src/com/intellij/remoteServer/impl/module/CloudModuleBuilderSourceContribution.java @@ -73,7 +73,7 @@ public abstract class CloudModuleBuilderSourceContribution< final ServerType cloudType = account.getType(); final Project project = module.getProject(); new CloudConnectionTask(project, - CloudBundle.getText("cloud.support", cloudType.getPresentableName()), + CloudBundle.message("cloud.support", cloudType.getPresentableName()), account) { boolean myFirstAttempt = true; @@ -144,7 +144,7 @@ public abstract class CloudModuleBuilderSourceContribution< }); ProgressManager.getInstance() - .run(new Task.Backgroundable(project, CloudBundle.getText("detect.module.structure", getCloudType().getPresentableName()), false) { + .run(new Task.Backgroundable(project, CloudBundle.message("detect.module.structure", getCloudType().getPresentableName()), false) { @Override public void run(@NotNull ProgressIndicator indicator) { @@ -173,7 +173,7 @@ public abstract class CloudModuleBuilderSourceContribution< return; } moduleBuilder.commit(project); - getNotifier().showMessage(CloudBundle.getText("cloud.support.added", getCloudType().getPresentableName()), MessageType.INFO); + getNotifier().showMessage(CloudBundle.message("cloud.support.added", getCloudType().getPresentableName()), MessageType.INFO); } }); } diff --git a/json/src/com/intellij/json/JsonBundle.java b/json/src/com/intellij/json/JsonBundle.java index 9f006b8ea4fe..32e19f2eb803 100644 --- a/json/src/com/intellij/json/JsonBundle.java +++ b/json/src/com/intellij/json/JsonBundle.java @@ -1,37 +1,20 @@ package com.intellij.json; -import com.intellij.CommonBundle; -import com.intellij.reference.SoftReference; +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.util.ResourceBundle; - -/** - * @author Mikhail Golubev - */ -public class JsonBundle { - - private static Reference ourBundle; +public class JsonBundle extends DynamicBundle { @NonNls public static final String BUNDLE = "com.intellij.json.JsonBundle"; + private static final JsonBundle INSTANCE = new JsonBundle(); private JsonBundle() { - // empty + super(BUNDLE); } @NotNull public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { - return CommonBundle.message(getBundle(), key, params); + return INSTANCE.getMessage(key, params); } - - private static ResourceBundle getBundle() { - ResourceBundle bundle = SoftReference.dereference(ourBundle); - if (bundle == null) { - bundle = ResourceBundle.getBundle(BUNDLE); - ourBundle = new SoftReference<>(bundle); - } - return bundle; - } -} +} \ No newline at end of file diff --git a/json/src/com/intellij/json/formatter/JsonCodeStyleSettings.java b/json/src/com/intellij/json/formatter/JsonCodeStyleSettings.java index 79f091ad5087..4f7f4f029206 100644 --- a/json/src/com/intellij/json/formatter/JsonCodeStyleSettings.java +++ b/json/src/com/intellij/json/formatter/JsonCodeStyleSettings.java @@ -14,9 +14,9 @@ import org.jetbrains.annotations.PropertyKey; */ public class JsonCodeStyleSettings extends CustomCodeStyleSettings { - public static int DO_NOT_ALIGN_PROPERTY = PropertyAlignment.DO_NOT_ALIGN.getId(); - public static int ALIGN_PROPERTY_ON_VALUE = PropertyAlignment.ALIGN_ON_VALUE.getId(); - public static int ALIGN_PROPERTY_ON_COLON = PropertyAlignment.ALIGN_ON_COLON.getId(); + public static final int DO_NOT_ALIGN_PROPERTY = PropertyAlignment.DO_NOT_ALIGN.getId(); + public static final int ALIGN_PROPERTY_ON_VALUE = PropertyAlignment.ALIGN_ON_VALUE.getId(); + public static final int ALIGN_PROPERTY_ON_COLON = PropertyAlignment.ALIGN_ON_COLON.getId(); public boolean SPACE_AFTER_COLON = true; public boolean SPACE_BEFORE_COLON = false; @@ -24,7 +24,7 @@ public class JsonCodeStyleSettings extends CustomCodeStyleSettings { // TODO: check whether it's possible to migrate CustomCodeStyleSettings to newer com.intellij.util.xmlb.XmlSerializer /** - * Contains value of {@link com.intellij.json.formatter.JsonCodeStyleSettings.PropertyAlignment#getId()} + * Contains value of {@link JsonCodeStyleSettings.PropertyAlignment#getId()} * * @see #DO_NOT_ALIGN_PROPERTY * @see #ALIGN_PROPERTY_ON_VALUE diff --git a/platform/analysis-impl/src/com/intellij/find/FindBundle.java b/platform/analysis-impl/src/com/intellij/find/FindBundle.java index c688790eef91..efc743819d52 100644 --- a/platform/analysis-impl/src/com/intellij/find/FindBundle.java +++ b/platform/analysis-impl/src/com/intellij/find/FindBundle.java @@ -16,36 +16,21 @@ package com.intellij.find; -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; - -/** - * @author yole - */ -public class FindBundle { - - public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { - return CommonBundle.message(getBundle(), key, params); - } - - private static Reference ourBundle; +public class FindBundle extends DynamicBundle { @NonNls private static final String BUNDLE = "messages.FindBundle"; + private static final FindBundle INSTANCE = new FindBundle(); private FindBundle() { + super(BUNDLE); } - private static ResourceBundle getBundle() { - ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle); - if (bundle == null) { - bundle = ResourceBundle.getBundle(BUNDLE); - ourBundle = new SoftReference<>(bundle); - } - return bundle; + @NotNull + public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { + return INSTANCE.getMessage(key, params); } -} +} \ No newline at end of file diff --git a/platform/core-impl/src/com/intellij/lang/LangBundle.java b/platform/core-impl/src/com/intellij/lang/LangBundle.java index b88a47995bd7..d5a63d1eaf6d 100644 --- a/platform/core-impl/src/com/intellij/lang/LangBundle.java +++ b/platform/core-impl/src/com/intellij/lang/LangBundle.java @@ -16,36 +16,21 @@ package com.intellij.lang; -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; - -/** - * @author yole - */ -public class LangBundle { - - public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { - return CommonBundle.message(getBundle(), key, params); - } - - private static Reference ourBundle; +public class LangBundle extends DynamicBundle { @NonNls private static final String BUNDLE = "messages.LangBundle"; + private static final LangBundle INSTANCE = new LangBundle(); private LangBundle() { + super(BUNDLE); } - private static ResourceBundle getBundle() { - ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle); - if (bundle == null) { - bundle = ResourceBundle.getBundle(BUNDLE); - ourBundle = new SoftReference<>(bundle); - } - return bundle; + @NotNull + public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { + return INSTANCE.getMessage(key, params); } -} +} \ No newline at end of file diff --git a/platform/core-impl/src/com/intellij/openapi/fileTypes/FileTypesBundle.java b/platform/core-impl/src/com/intellij/openapi/fileTypes/FileTypesBundle.java index c5184b541bcc..a83278b4eca8 100644 --- a/platform/core-impl/src/com/intellij/openapi/fileTypes/FileTypesBundle.java +++ b/platform/core-impl/src/com/intellij/openapi/fileTypes/FileTypesBundle.java @@ -15,36 +15,22 @@ */ package com.intellij.openapi.fileTypes; -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; - -/** - * @author yole - */ -public class FileTypesBundle { - - public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { - return CommonBundle.message(getBundle(), key, params); - } - - private static Reference ourBundle; +public class FileTypesBundle extends DynamicBundle { @NonNls private static final String BUNDLE = "messages.FileTypesBundle"; + private static final FileTypesBundle INSTANCE = new FileTypesBundle(); + private FileTypesBundle() { + super(BUNDLE); } - private static ResourceBundle getBundle() { - ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle); - if (bundle == null) { - bundle = ResourceBundle.getBundle(BUNDLE); - ourBundle = new SoftReference<>(bundle); - } - return bundle; + @NotNull + public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { + return INSTANCE.getMessage(key, params); } -} +} \ No newline at end of file diff --git a/platform/duplicates-analysis/src/com/intellij/dupLocator/DupLocatorBundle.java b/platform/duplicates-analysis/src/com/intellij/dupLocator/DupLocatorBundle.java index 125c73445ee1..c79c2279a89c 100644 --- a/platform/duplicates-analysis/src/com/intellij/dupLocator/DupLocatorBundle.java +++ b/platform/duplicates-analysis/src/com/intellij/dupLocator/DupLocatorBundle.java @@ -1,32 +1,21 @@ package com.intellij.dupLocator; -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 DupLocatorBundle { - - public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { - return CommonBundle.message(getBundle(), key, params); - } - - private static Reference ourBundle; +public class DupLocatorBundle extends DynamicBundle { @NonNls private static final String BUNDLE = "messages.DupLocatorBundle"; + private static final DupLocatorBundle INSTANCE = new DupLocatorBundle(); + private DupLocatorBundle() { + super(BUNDLE); } - private static ResourceBundle getBundle() { - ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle); - if (bundle == null) { - bundle = ResourceBundle.getBundle(BUNDLE); - ourBundle = new SoftReference<>(bundle); - } - return bundle; + @NotNull + public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { + return INSTANCE.getMessage(key, params); } -} +} \ No newline at end of file diff --git a/platform/lang-impl/src/com/intellij/codeEditor/printing/CodeEditorBundle.java b/platform/lang-impl/src/com/intellij/codeEditor/printing/CodeEditorBundle.java index 689b3d3b89d9..3ed1eef5cbe7 100644 --- a/platform/lang-impl/src/com/intellij/codeEditor/printing/CodeEditorBundle.java +++ b/platform/lang-impl/src/com/intellij/codeEditor/printing/CodeEditorBundle.java @@ -16,36 +16,19 @@ package com.intellij.codeEditor.printing; -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; - -/** - * @author yole - */ -public class CodeEditorBundle { - - public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { - return CommonBundle.message(getBundle(), key, params); - } - - private static Reference ourBundle; +public class CodeEditorBundle extends DynamicBundle { @NonNls private static final String BUNDLE = "messages.CodeEditorBundle"; + private static final CodeEditorBundle INSTANCE = new CodeEditorBundle(); - private CodeEditorBundle() { - } + private CodeEditorBundle() { super(BUNDLE); } - private static ResourceBundle getBundle() { - ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle); - if (bundle == null) { - bundle = ResourceBundle.getBundle(BUNDLE); - ourBundle = new SoftReference<>(bundle); - } - return bundle; + @NotNull + public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { + return INSTANCE.getMessage(key, params); } } diff --git a/platform/lang-impl/src/com/intellij/tools/ToolsBundle.java b/platform/lang-impl/src/com/intellij/tools/ToolsBundle.java index 3dbf9df65f5f..04ff9d4b3007 100644 --- a/platform/lang-impl/src/com/intellij/tools/ToolsBundle.java +++ b/platform/lang-impl/src/com/intellij/tools/ToolsBundle.java @@ -16,36 +16,21 @@ package com.intellij.tools; -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; - -/** - * @author yole - */ -public class ToolsBundle { - - public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { - return CommonBundle.message(getBundle(), key, params); - } - - private static Reference ourBundle; +public class ToolsBundle extends DynamicBundle { @NonNls private static final String BUNDLE = "messages.ToolsBundle"; + private static final ToolsBundle INSTANCE = new ToolsBundle(); private ToolsBundle() { + super(BUNDLE); } - private static ResourceBundle getBundle() { - ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle); - if (bundle == null) { - bundle = ResourceBundle.getBundle(BUNDLE); - ourBundle = new SoftReference<>(bundle); - } - return bundle; + @NotNull + public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { + return INSTANCE.getMessage(key, params); } -} +} \ No newline at end of file diff --git a/platform/platform-impl/src/com/intellij/diagnostic/DiagnosticBundle.java b/platform/platform-impl/src/com/intellij/diagnostic/DiagnosticBundle.java index b163555dfe81..bae704202548 100644 --- a/platform/platform-impl/src/com/intellij/diagnostic/DiagnosticBundle.java +++ b/platform/platform-impl/src/com/intellij/diagnostic/DiagnosticBundle.java @@ -15,36 +15,19 @@ */ package com.intellij.diagnostic; -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; - -/** - * @author yole - */ -public class DiagnosticBundle { - - public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { - return CommonBundle.message(getBundle(), key, params); - } - - private static Reference ourBundle; +public class DiagnosticBundle extends DynamicBundle { @NonNls private static final String BUNDLE = "messages.DiagnosticBundle"; + private static final DiagnosticBundle INSTANCE = new DiagnosticBundle(); - private DiagnosticBundle() { - } + private DiagnosticBundle() { super(BUNDLE); } - private static ResourceBundle getBundle() { - ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle); - if (bundle == null) { - bundle = ResourceBundle.getBundle(BUNDLE); - ourBundle = new SoftReference<>(bundle); - } - return bundle; + @NotNull + public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { + return INSTANCE.getMessage(key, params); } -} +} \ No newline at end of file diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/configuration/RemoteServerListConfigurable.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/configuration/RemoteServerListConfigurable.java index 7cc6a796fd99..040405f97b90 100644 --- a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/configuration/RemoteServerListConfigurable.java +++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/configuration/RemoteServerListConfigurable.java @@ -82,7 +82,7 @@ public class RemoteServerListConfigurable extends MasterDetailsComponent impleme type -> type.getPresentableName(), ", "); if (typeNames.length() > 0) { - return CloudBundle.getText("clouds.configure.empty.selection.string", typeNames); + return CloudBundle.message("clouds.configure.empty.selection.string", typeNames); } return null; } diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/configuration/deployment/DeployToServerSettingsEditor.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/configuration/deployment/DeployToServerSettingsEditor.java index 3df8a2956ad1..553bef73e730 100644 --- a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/configuration/deployment/DeployToServerSettingsEditor.java +++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/configuration/deployment/DeployToServerSettingsEditor.java @@ -266,7 +266,7 @@ public abstract class DeployToServerSettingsEditor createAndEditNewServer()*/); + CloudBundle.message("remote.server.combo.message.test.connection.failed")/*, () -> createAndEditNewServer()*/); } }; @@ -300,7 +300,7 @@ public abstract class DeployToServerSettingsEditor extends ComboboxWi @Override public void render(@NotNull SimpleColoredComponent ui) { ui.setIcon(EmptyIcon.create(myServerType.getIcon())); - ui.append(CloudBundle.getText("remote.server.combo.create.new.server"), SimpleTextAttributes.REGULAR_ATTRIBUTES); + ui.append(CloudBundle.message("remote.server.combo.create.new.server"), SimpleTextAttributes.REGULAR_ATTRIBUTES); } @Override @@ -339,7 +339,7 @@ public class RemoteServerCombo extends ComboboxWi @Override public void render(@NotNull SimpleColoredComponent ui) { ui.setIcon(null); - ui.append(CloudBundle.getText("remote.server.combo.no.servers"), SimpleTextAttributes.ERROR_ATTRIBUTES); + ui.append(CloudBundle.message("remote.server.combo.no.servers"), SimpleTextAttributes.ERROR_ATTRIBUTES); } } } diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/RemoteServersServiceViewContributor.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/RemoteServersServiceViewContributor.java index c87b3c4131bf..1cb0fdc9f90d 100644 --- a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/RemoteServersServiceViewContributor.java +++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/RemoteServersServiceViewContributor.java @@ -127,7 +127,7 @@ public abstract class RemoteServersServiceViewContributor RemoteServersManager remoteServersManager = RemoteServersManager.getInstance(); RemoteServer server = remoteServersManager.createServer(serverType, name); SingleRemoteServerConfigurable configurable = new SingleRemoteServerConfigurable(server, null, true); - configurable.setDisplayName(CloudBundle.getText("new.cloud.connection.configurable.title", serverType.getPresentableName())); + configurable.setDisplayName(CloudBundle.message("new.cloud.connection.configurable.title", serverType.getPresentableName())); Runnable advancedInitialization = () -> { configurable.setDisplayName(name); configurable.updateName(); diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/ServersTreeStructure.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/ServersTreeStructure.java index 7406db8815f1..7455f76cfe97 100644 --- a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/ServersTreeStructure.java +++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/ServersTreeStructure.java @@ -170,9 +170,9 @@ public class ServersTreeStructure { } if (runConfigOrSourceType instanceof SingletonDeploymentSourceType) { String displayName = ((SingletonDeploymentSourceType)runConfigOrSourceType).getPresentableName(); - return CloudBundle.getText("create.new.deployment.configuration.for.singleton.type", displayName); + return CloudBundle.message("create.new.deployment.configuration.for.singleton.type", displayName); } - return CloudBundle.getText("create.new.deployment.configuration.generic"); + return CloudBundle.message("create.new.deployment.configuration.generic"); } @Override diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/AddCloudConnectionActionGroup.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/AddCloudConnectionActionGroup.java index a0edc964c40e..33e906c97dcf 100644 --- a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/AddCloudConnectionActionGroup.java +++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/AddCloudConnectionActionGroup.java @@ -43,8 +43,7 @@ public class AddCloudConnectionActionGroup extends ActionGroup { @Override public void update(@NotNull AnActionEvent e) { if (e.getPlace().equals(ActionPlaces.ACTION_SEARCH)) { - e.getPresentation().setText(CloudBundle.getText("new.cloud.connection.configurable.title", - myServerType.getPresentableName())); + e.getPresentation().setText(CloudBundle.message("new.cloud.connection.configurable.title", myServerType.getPresentableName())); } else { e.getPresentation().setText(myServerType.getPresentableName()); diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudBundle.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudBundle.java index 0ee8319ff203..8c03b4394a98 100644 --- a/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudBundle.java +++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudBundle.java @@ -15,37 +15,19 @@ */ package com.intellij.remoteServer.util; -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; - -/** - * @author michael.golubev - */ -public class CloudBundle { - - private static Reference ourBundle; - +public class CloudBundle extends DynamicBundle { @NonNls private static final String BUNDLE = "resources.cloud"; + private static final CloudBundle INSTANCE = new CloudBundle(); - private CloudBundle() { + private CloudBundle() { super(BUNDLE); } - } - - public static String getText(@PropertyKey(resourceBundle = BUNDLE) String key, Object... params) { - return CommonBundle.message(getBundle(), key, params); - } - - private static ResourceBundle getBundle() { - ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle); - if (bundle == null) { - bundle = ResourceBundle.getBundle(BUNDLE); - ourBundle = new SoftReference<>(bundle); - } - return bundle; + @NotNull + public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { + return INSTANCE.getMessage(key, params); } } diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudGitApplicationRuntime.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudGitApplicationRuntime.java index 40399c133b96..6b441cc882f9 100644 --- a/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudGitApplicationRuntime.java +++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudGitApplicationRuntime.java @@ -90,9 +90,9 @@ public class CloudGitApplicationRuntime extends CloudApplicationRuntime { private boolean confirmUndeploy() { final Ref confirmed = new Ref<>(false); ApplicationManager.getApplication().invokeAndWait(() -> { - String title = CloudBundle.getText("cloud.undeploy.confirm.title"); + String title = CloudBundle.message("cloud.undeploy.confirm.title"); while (true) { - String password = Messages.showPasswordDialog(CloudBundle.getText("cloud.undeploy.confirm.message", getApplicationName()), title); + String password = Messages.showPasswordDialog(CloudBundle.message("cloud.undeploy.confirm.message", getApplicationName()), title); if (password == null) { return; } @@ -100,7 +100,7 @@ public class CloudGitApplicationRuntime extends CloudApplicationRuntime { confirmed.set(true); return; } - Messages.showErrorDialog(CloudBundle.getText("cloud.undeploy.confirm.password.incorrect"), title); + Messages.showErrorDialog(CloudBundle.message("cloud.undeploy.confirm.password.incorrect"), title); } }); return confirmed.get(); diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudRunConfigurationUtil.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudRunConfigurationUtil.java index bc5906bb708e..b2dce11ff25a 100644 --- a/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudRunConfigurationUtil.java +++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudRunConfigurationUtil.java @@ -52,6 +52,6 @@ public class CloudRunConfigurationUtil { private static String generateRunConfigurationName(@NotNull RemoteServer account, Module module) { String accountName = account.getName(); String moduleName = module.getName(); - return CloudBundle.getText("run.configuration.name", accountName, moduleName); + return CloudBundle.message("run.configuration.name", accountName, moduleName); } } diff --git a/plugins/git4idea/remote-servers-git-java/src/com/intellij/remoteServer/util/importProject/CloudGitRemoteDetector.java b/plugins/git4idea/remote-servers-git-java/src/com/intellij/remoteServer/util/importProject/CloudGitRemoteDetector.java index d3bccb5910e5..a882daacd090 100644 --- a/plugins/git4idea/remote-servers-git-java/src/com/intellij/remoteServer/util/importProject/CloudGitRemoteDetector.java +++ b/plugins/git4idea/remote-servers-git-java/src/com/intellij/remoteServer/util/importProject/CloudGitRemoteDetector.java @@ -192,7 +192,7 @@ public class CloudGitRemoteDetector implements GitRepositoryChangeListener, Proj myRepositoryRoot = repository.getRoot(); myCloudName = deploymentDetector.getCloudType().getPresentableName(); String path = FileUtil.toSystemDependentName(myRepositoryRoot.getPath()); - myNotification = myNotifier.showMessage(CloudBundle.getText("git.cloud.app.detected", myCloudName, path), + myNotification = myNotifier.showMessage(CloudBundle.message("git.cloud.app.detected", myCloudName, path), MessageType.INFO, new NotificationListener() { @@ -231,7 +231,7 @@ public class CloudGitRemoteDetector implements GitRepositoryChangeListener, Proj } else { final Ref chooseAccountStepRef = new Ref<>(); - if (!new AbstractProjectWizard(CloudBundle.getText("choose.account.wizzard.title", myCloudName), myProject, (String)null) { + if (!new AbstractProjectWizard(CloudBundle.message("choose.account.wizzard.title", myCloudName), myProject, (String)null) { final StepSequence myStepSequence; diff --git a/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudGitDeploymentRuntime.java b/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudGitDeploymentRuntime.java index dd2e64705b4a..8ec0b4085a11 100644 --- a/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudGitDeploymentRuntime.java +++ b/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudGitDeploymentRuntime.java @@ -316,11 +316,11 @@ public class CloudGitDeploymentRuntime extends CloudDeploymentRuntime { } protected void addGitRemote(CloudGitApplication application) throws ServerRuntimeException { - doGitRemote(getRemoteName(), application, "add", CloudBundle.getText("failed.add.remote", getRemoteName())); + doGitRemote(getRemoteName(), application, "add", CloudBundle.message("failed.add.remote", getRemoteName())); } protected void resetGitRemote(CloudGitApplication application) throws ServerRuntimeException { - doGitRemote(getRemoteName(), application, "set-url", CloudBundle.getText("failed.reset.remote", getRemoteName())); + doGitRemote(getRemoteName(), application, "set-url", CloudBundle.message("failed.reset.remote", getRemoteName())); } protected void doGitRemote(String remoteName, @@ -386,7 +386,7 @@ public class CloudGitDeploymentRuntime extends CloudDeploymentRuntime { fetchHandler.setSilent(false); fetchHandler.addParameters(getRemoteName()); fetchHandler.addLineListener(createGitLineHandlerListener()); - performRemoteGitTask(fetchHandler, CloudBundle.getText("fetching.application", getCloudName())); + performRemoteGitTask(fetchHandler, CloudBundle.message("fetching.application", getCloudName())); repository.update(); } @@ -530,7 +530,7 @@ public class CloudGitDeploymentRuntime extends CloudDeploymentRuntime { handler.addParameters("-o"); handler.addParameters(getRemoteName()); handler.addLineListener(createGitLineHandlerListener()); - performRemoteGitTask(handler, CloudBundle.getText("cloning.existing.application", getCloudName())); + performRemoteGitTask(handler, CloudBundle.message("cloning.existing.application", getCloudName())); } } } diff --git a/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/importProject/CloudGitChooseAccountStepBase.java b/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/importProject/CloudGitChooseAccountStepBase.java index 39fe721c17d4..c5f277439143 100644 --- a/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/importProject/CloudGitChooseAccountStepBase.java +++ b/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/importProject/CloudGitChooseAccountStepBase.java @@ -46,7 +46,7 @@ public class CloudGitChooseAccountStepBase extends ModuleWizardStep { myDeploymentDetector = deploymentDetector; myContext = context; ServerType cloudType = deploymentDetector.getCloudType(); - myTitleLabel.setText(CloudBundle.getText("choose.account.title", cloudType.getPresentableName())); + myTitleLabel.setText(CloudBundle.message("choose.account.title", cloudType.getPresentableName())); myEditor = new CloudAccountSelectionEditor(Collections.singletonList(cloudType)); myAccountSelectionPanelPlaceHolder.add(myEditor.getMainPanel()); }