Java Code Examples for com.intellij.BundleBase

The following examples show how to use com.intellij.BundleBase. These examples are extracted from open source projects. 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 Project: consulo   Source File: ProblemsHolder.java    License: Apache License 2.0 6 votes vote down vote up
@Nonnull
public static String unresolvedReferenceMessage(@Nonnull PsiReference reference) {
  String message;
  if (reference instanceof EmptyResolveMessageProvider) {
    String pattern = ((EmptyResolveMessageProvider)reference).getUnresolvedMessagePattern();
    try {
      message = BundleBase.format(pattern, reference.getCanonicalText()); // avoid double formatting
    }
    catch (IllegalArgumentException ex) {
      // unresolvedMessage provided by third-party reference contains wrong format string (e.g. {}), tolerate it
      message = pattern;
      LOG.info(pattern);
    }
  }
  else {
    message = CodeInsightBundle.message("error.cannot.resolve.default.message", reference.getCanonicalText());
  }
  return message;
}
 
Example 2
@Nonnull
@Override
@RequiredReadAction
public String getText()
{
	String arguments = buildArgumentTypeRefs();
	if(arguments == null)
	{
		return "invalid";
	}
	return BundleBase.format("Create method ''{0}({1})''", myReferenceName, arguments);
}
 
Example 3
Source Project: consulo-csharp   Source File: CastNArgumentToTypeRefFix.java    License: Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
@Nonnull
@Override
public String getText()
{
	DotNetExpression element = myExpressionPointer.getElement();
	if(element == null)
	{
		return "invalid";
	}
	return BundleBase.format("Cast ''{0}'' argument to ''{1}''", myParameterName, CSharpTypeRefPresentationUtil.buildTextWithKeyword
			(myExpectedTypeRef, element));
}
 
Example 4
@Nonnull
@Override
@RequiredUIAccess
public String getText()
{
	String arguments = buildArgumentTypeRefs();
	if(arguments == null)
	{
		return "invalid";
	}
	return BundleBase.format(getTemplateText(), myReferenceName, arguments);
}
 
Example 5
Source Project: consulo-csharp   Source File: ChangeVariableToTypeRefFix.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public String getText()
{
	DotNetVariable element = myVariablePointer.getElement();
	if(element == null)
	{
		return "invalid";
	}
	return BundleBase.format("Change ''{0}'' type to ''{1}''", element.getName(), CSharpTypeRefPresentationUtil.buildTextWithKeyword
			(myToTypeRef, element));
}
 
Example 6
Source Project: consulo-csharp   Source File: ChangeReturnToTypeRefFix.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public String getText()
{
	DotNetLikeMethodDeclaration element = myMethodPointer.getElement();
	if(element == null)
	{
		return "invalid";
	}
	return BundleBase.format("Make ''{0}'' return to ''{1}''", element.getName(), CSharpTypeRefPresentationUtil.buildTextWithKeyword
			(myToTypeRef, element));
}
 
Example 7
Source Project: consulo-csharp   Source File: CastExpressionToTypeRef.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
@RequiredUIAccess
public String getText()
{
	DotNetExpression element = myExpressionPointer.getElement();
	if(element == null)
	{
		return "invalid";
	}
	return BundleBase.format("Cast to ''{0}''", CSharpTypeRefPresentationUtil.buildTextWithKeyword(myExpectedTypeRef, element));
}
 
Example 8
Source Project: consulo   Source File: ConsuloBuildInLoggerAdapter.java    License: Apache License 2.0 5 votes vote down vote up
private String buildMessage(String format, Object... args) {
  try {
    return BundleBase.format(format, args);
  }
  catch (Exception e) {
    return "Fail to build '" + format + "' args: " + Arrays.asList(args);
  }
}
 
Example 9
Source Project: consulo   Source File: SearchWebAction.java    License: Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
@Override
public void actionPerformed(@Nonnull AnActionEvent e) {
  DataContext dataContext = e.getDataContext();
  CopyProvider provider = dataContext.getData(PlatformDataKeys.COPY_PROVIDER);
  if (provider == null) {
    return;
  }
  provider.performCopy(dataContext);
  String content = CopyPasteManager.getInstance().getContents(DataFlavor.stringFlavor);
  if (StringUtil.isNotEmpty(content)) {
    WebSearchEngine engine = myWebSearchOptions.getEngine();
    BrowserUtil.browse(BundleBase.format(engine.getUrlTemplate(), URLUtil.encodeURIComponent(content)));
  }
}
 
Example 10
Source Project: consulo   Source File: SearchWebAction.java    License: Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
@Override
public void update(@Nonnull AnActionEvent e) {
  Presentation presentation = e.getPresentation();
  DataContext dataContext = e.getDataContext();
  CopyProvider provider = e.getData(PlatformDataKeys.COPY_PROVIDER);
  boolean available = provider != null && provider.isCopyEnabled(dataContext) && provider.isCopyVisible(dataContext);
  presentation.setEnabled(available);
  presentation.setVisible(available);

  WebSearchEngine engine = myWebSearchOptions.getEngine();

  presentation.setText(BundleBase.format(ActionsBundle.message("action.$SearchWeb.0.text", engine.getPresentableName())));
  presentation.setDescription(BundleBase.format(ActionsBundle.message("action.$SearchWeb.0.description", engine.getPresentableName())));
}
 
Example 11
Source Project: consulo   Source File: GotoActionModel.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull
private static String calcHit(@Nonnull OptionDescription value) {
  //if (value instanceof RegistryTextOptionDescriptor) {
  //  return value.getHit() + " = " + value.getValue();
  //}
  String hit = StringUtil.defaultIfEmpty(value.getHit(), value.getOption());
  return StringUtil.unescapeXmlEntities(StringUtil.notNullize(hit)).replace(BundleBase.MNEMONIC_STRING, "").replace("  ", " "); // avoid extra spaces from mnemonics and xml conversion
}
 
Example 12
Source Project: consulo-csharp   Source File: CreateUnresolvedEventFix.java    License: Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public String getText()
{
	return BundleBase.format("Create event ''{0}''", myReferenceName);
}
 
Example 13
Source Project: consulo-csharp   Source File: CreateUnresolvedFieldFix.java    License: Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public String getText()
{
	return BundleBase.format("Create field ''{0}''", myReferenceName);
}
 
Example 14
@Nonnull
@Override
public String getText()
{
	return BundleBase.format("Create property ''{0}''", myReferenceName);
}
 
Example 15
Source Project: consulo   Source File: UsageType.java    License: Apache License 2.0 4 votes vote down vote up
@Nonnull
public String toString(@Nonnull UsageViewPresentation presentation) {
  String word = presentation.getUsagesWord();
  String usageWord = StringUtil.startsWithChar(myName, '{') ? StringUtil.capitalize(word) : word;
  return BundleBase.format(myName, usageWord);
}
 
Example 16
Source Project: consulo   Source File: Executor.java    License: Apache License 2.0 4 votes vote down vote up
@Nonnull
public String getActionText(@javax.annotation.Nullable String configurationName) {
  return BundleBase.format(getStartActionText(StringUtil.isEmpty(configurationName)), escapeMnemonicsInConfigurationName(configurationName));
}
 
Example 17
Source Project: consulo   Source File: UIUtil.java    License: Apache License 2.0 4 votes vote down vote up
public static String replaceMnemonicAmpersand(final String value) {
  return BundleBase.replaceMnemonicAmpersand(value);
}
 
Example 18
/**
 * @param key
 * @param params
 * @return
 */
public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) {
    return BundleBase.message(getBundle(), key, params);
}