/*
 * Copyright 2000-2013 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.intellij.idea;

import com.intellij.CommonBundle;
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 Eugene Zhuravlev
 */
public class ActionsBundle {

  public static String message(@NotNull @PropertyKey(resourceBundle = IDEA_ACTIONS_BUNDLE) String key, @NotNull Object... params) {
    return CommonBundle.message(getBundle(), key, params);
  }

  private static Reference<ResourceBundle> ourBundle;
  @NonNls private static final String IDEA_ACTIONS_BUNDLE = "messages.ActionsBundle";

  @SuppressWarnings({"UnresolvedPropertyKey"})
  public static String actionText(@NonNls String actionId) {
    return message("action." + actionId + ".text");
  }

  @SuppressWarnings({"UnresolvedPropertyKey"})
  public static String groupText(@NonNls String actionId) {
    return message("group." + actionId + ".text");
  }

  @SuppressWarnings({"UnresolvedPropertyKey"})
  public static String actionDescription(@NonNls String actionId) {
    return message("action." + actionId + ".description");
  }

  private static ResourceBundle getBundle() {
    ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle);
    if (bundle == null) {
      bundle = ResourceBundle.getBundle(IDEA_ACTIONS_BUNDLE);
      ourBundle = new SoftReference<>(bundle);
    }
    return bundle;
  }
}

@@ -642,22 +642,23 @@
 ntellij.
-Common
+Dynamic
 Bundle;%0A
@@ -791,158 +791,228 @@
 y;%0A%0A
-import java.lang.ref.Reference;%0Aimport java.lang.ref.SoftReference;%0Aimport java.util.ResourceBundle;%0A%0A/**%0A * @author Eugene Zhuravlev%0A */%0Apublic class
+public class ActionsBundle extends DynamicBundle %7B%0A  @NonNls private static final String IDEA_ACTIONS_BUNDLE = %22messages.ActionsBundle%22;%0A%0A  private static final ActionsBundle ourInstance = new ActionsBundle();%0A%0A  private
  Act
@@ -1021,18 +1021,56 @@
 nsBundle
+()
  %7B
+%0A    super(IDEA_ACTIONS_BUNDLE);%0A  %7D
 %0A%0A  publ
@@ -1210,248 +1210,49 @@
 urn 
-CommonBundle.message(getBundle(), key, params);%0A  %7D%0A%0A  private static Reference%3CResourceBundle%3E ourBundle;%0A  @NonNls private static final String IDEA_ACTIONS_BUNDLE = %22messages.ActionsBundle%22;%0A%0A  @SuppressWarnings(%7B%22UnresolvedPropertyKey%22%7D)
+ourInstance.getMessage(key, params);%0A  %7D%0A
 %0A  p
@@ -1370,55 +1370,8 @@
  %7D%0A%0A
-  @SuppressWarnings(%7B%22UnresolvedPropertyKey%22%7D)%0A
   pu
@@ -1486,55 +1486,8 @@
  %7D%0A%0A
-  @SuppressWarnings(%7B%22UnresolvedPropertyKey%22%7D)%0A
   pu
@@ -1616,307 +1616,7 @@
 %0A  %7D
-%0A%0A  private static ResourceBundle getBundle() %7B%0A    ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle);%0A    if (bundle == null) %7B%0A      bundle = ResourceBundle.getBundle(IDEA_ACTIONS_BUNDLE);%0A      ourBundle = new SoftReference%3C%3E(bundle);%0A    %7D%0A    return bundle;%0A  %7D
 %0A%7D%0A

make actions bundle dynamic