com.intellij.AbstractBundle Java Examples

The following examples show how to use com.intellij.AbstractBundle. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IntentionActionBean.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
public String[] getCategories() {
  if (categoryKey != null) {
    final String baseName = bundleName != null ? bundleName : myPluginDescriptor.getResourceBundleBaseName();
    if (baseName == null) {
      LOG.error("No resource bundle specified for "+myPluginDescriptor);
    }
    final ResourceBundle bundle = AbstractBundle.getResourceBundle(baseName, myPluginDescriptor.getPluginClassLoader());

    final String[] keys = categoryKey.split("/");
    if (keys.length > 1) {
      return ContainerUtil.map2Array(keys, String.class, new Function<String, String>() {
        @Override
        public String fun(final String s) {
          return CommonBundle.message(bundle, s);
        }
      });
    }

    category = CommonBundle.message(bundle, categoryKey);
  }
  if (category == null) return null;
  return category.split("/");
}
 
Example #2
Source File: TypeNameEP.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected String compute() {
  if (name != null) {
    return name;
  }
  if (resourceKey != null) {
    String bundleName = resourceBundle;
    if (bundleName == null && myPluginDescriptor != null) {
      bundleName = myPluginDescriptor.getResourceBundleBaseName();
    }
    if (bundleName != null) {
      ResourceBundle bundle = AbstractBundle.getResourceBundle(bundleName, getLoaderForClass());
      return bundle.getString(resourceKey);
    }
  }
  return null;
}
 
Example #3
Source File: InspectionEP.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
private String getLocalizedString(String bundleName, String key) {
  final String baseName = bundleName != null ? bundleName : bundle == null ? myPluginDescriptor.getResourceBundleBaseName() : bundle;
  if (baseName == null || key == null) {
    if (bundleName != null) {
      LOG.warn(implementationClass);
    }
    return null;
  }
  final ResourceBundle resourceBundle = AbstractBundle.getResourceBundle(baseName, myPluginDescriptor.getPluginClassLoader());
  return CommonBundle.message(resourceBundle, key);
}
 
Example #4
Source File: LocalizeHelper.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public String getText(String key) {
  if (myResourceBundle == null) {
    myResourceBundle = AbstractBundle.getResourceBundle(myResourceBundleBaseName, myPluginClassLoader);
  }

  return CommonBundle.message(myResourceBundle, key);
}
 
Example #5
Source File: ExportSettingsAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private static String getComponentPresentableName(@Nonnull State state, @Nonnull Class<?> aClass) {
  String defaultName = state.name();
  String resourceBundleName;

  PluginDescriptor pluginDescriptor = null;
  ClassLoader classLoader = aClass.getClassLoader();

  if(classLoader instanceof PluginClassLoader) {
    pluginDescriptor = PluginManager.getPlugin(((PluginClassLoader)classLoader).getPluginId());
  }

  if (pluginDescriptor != null && !PluginManagerCore.CORE_PLUGIN.equals(pluginDescriptor.getPluginId())) {
    resourceBundleName = pluginDescriptor.getResourceBundleBaseName();
  }
  else {
    resourceBundleName = OptionsBundle.PATH_TO_BUNDLE;
  }

  if (resourceBundleName == null) {
    return defaultName;
  }

  if (classLoader != null) {
    ResourceBundle bundle = AbstractBundle.getResourceBundle(resourceBundleName, classLoader);
    if (bundle != null) {
      return CommonBundle.messageOrDefault(bundle, "exportable." + defaultName + ".presentable.name", defaultName);
    }
  }
  return defaultName;
}
 
Example #6
Source File: KeyPromoterBundle.java    From IntelliJ-Key-Promoter-X with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public static String message(@NotNull @PropertyKey(resourceBundle = "de.halirutan.keypromoterx.messages.KeyPromoterBundle") String key, @NotNull Object... params) {
  return AbstractBundle.message(getBundle(), key, params);
}
 
Example #7
Source File: PantsBundle.java    From intellij-pants-plugin with Apache License 2.0 4 votes vote down vote up
public static String message(@PropertyKey(resourceBundle = BUNDLE) String key, Object... params) {
  return AbstractBundle.message(getBundle(), key, params);
}
 
Example #8
Source File: LombokBundle.java    From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public static String message(@PropertyKey(resourceBundle = BUNDLE_NAME) String key, Object... params) {
  return AbstractBundle.message(BUNDLE, key, params);
}
 
Example #9
Source File: CrucibleBundle.java    From Crucible4IDEA with MIT License 4 votes vote down vote up
public static String message(@PropertyKey(resourceBundle = BUNDLE)String key, Object... params) {
    return AbstractBundle.message(getBundle(), key, params);
}
 
Example #10
Source File: ConfigurableEP.java    From consulo with Apache License 2.0 4 votes vote down vote up
public String getDisplayName() {
  if (displayName != null) return displayName;
  LOG.assertTrue(bundle != null, "Bundle missed for " + instanceClass);
  final ResourceBundle resourceBundle = AbstractBundle.getResourceBundle(bundle, myPluginDescriptor.getPluginClassLoader());
  return displayName = CommonBundle.message(resourceBundle, key);
}
 
Example #11
Source File: TemplateSettings.java    From consulo with Apache License 2.0 4 votes vote down vote up
private TemplateImpl readTemplateFromElement(final boolean isDefault,
                                             final String groupName,
                                             final Element element,
                                             ClassLoader classLoader) throws InvalidDataException {
  String name = element.getAttributeValue(NAME);
  String value = element.getAttributeValue(VALUE);
  String description;
  String resourceBundle = element.getAttributeValue(RESOURCE_BUNDLE);
  String key = element.getAttributeValue(KEY);
  String id = element.getAttributeValue(ID);
  if (resourceBundle != null && key != null) {
    if (classLoader == null) {
      classLoader = getClass().getClassLoader();
    }
    ResourceBundle bundle = AbstractBundle.getResourceBundle(resourceBundle, classLoader);
    description = bundle.getString(key);
  }
  else {
    description = element.getAttributeValue(DESCRIPTION);
  }
  String shortcut = element.getAttributeValue(SHORTCUT);
  TemplateImpl template = addTemplate(name, value, groupName, description, shortcut, isDefault, id);

  template.setToReformat(Boolean.parseBoolean(element.getAttributeValue(TO_REFORMAT)));
  template.setToShortenLongNames(Boolean.parseBoolean(element.getAttributeValue(TO_SHORTEN_FQ_NAMES)));
  template.setDeactivated(Boolean.parseBoolean(element.getAttributeValue(DEACTIVATED)));

  String useStaticImport = element.getAttributeValue(USE_STATIC_IMPORT);
  if (useStaticImport != null) {
    template.setValue(TemplateImpl.Property.USE_STATIC_IMPORT_IF_POSSIBLE, Boolean.parseBoolean(useStaticImport));
  }

  for (final Object o : element.getChildren(VARIABLE)) {
    Element e = (Element)o;
    String variableName = e.getAttributeValue(NAME);
    String expression = e.getAttributeValue(EXPRESSION);
    String defaultValue = e.getAttributeValue(DEFAULT_VALUE);
    boolean isAlwaysStopAt = Boolean.parseBoolean(e.getAttributeValue(ALWAYS_STOP_AT));
    template.addVariable(variableName, expression, defaultValue, isAlwaysStopAt);
  }

  Element context = element.getChild(CONTEXT);
  if (context != null) {
    template.getTemplateContext().readTemplateContext(context);
  }

  return template;
}