Java Code Examples for com.intellij.usageView.UsageViewBundle#message()

The following examples show how to use com.intellij.usageView.UsageViewBundle#message() . 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: UsageLimitUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
public static Result showTooManyUsagesWarning(@Nonnull final Project project,
                                              @Nonnull final String message,
                                              @Nonnull final UsageViewPresentation usageViewPresentation) {
  final String[] buttons = {UsageViewBundle.message("button.text.continue"), UsageViewBundle.message("button.text.abort")};
  int result = runOrInvokeAndWait(new Computable<Integer>() {
    @Override
    public Integer compute() {
      String title = UsageViewBundle.message("find.excessive.usages.title", StringUtil.capitalize(StringUtil.pluralize(usageViewPresentation.getUsagesWord())));
      return Messages.showOkCancelDialog(project, message,
                                         title, buttons[0], buttons[1],
                                         Messages.getWarningIcon());
    }
  });
  return result == Messages.OK ? Result.CONTINUE : Result.ABORT;
}
 
Example 2
Source File: UsagePreviewPanel.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
private String cannotPreviewMessage(@Nullable List<? extends UsageInfo> infos) {
  if (infos == null || infos.isEmpty()) {
    return UsageViewBundle.message("select.the.usage.to.preview", myPresentation.getUsagesWord());
  }
  PsiFile psiFile = null;
  for (UsageInfo info : infos) {
    PsiElement element = info.getElement();
    if (element == null) continue;
    PsiFile file = element.getContainingFile();
    if (psiFile == null) {
      psiFile = file;
    }
    else {
      if (psiFile != file) {
        return UsageViewBundle.message("several.occurrences.selected");
      }
    }
  }
  return null;
}
 
Example 3
Source File: UsageInfo2UsageAdapter.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
private TextChunk[] initChunks() {
  PsiFile psiFile = getPsiFile();
  Document document = psiFile == null ? null : PsiDocumentManager.getInstance(getProject()).getDocument(psiFile);
  TextChunk[] chunks;
  if (document == null) {
    // element over light virtual file
    PsiElement element = getElement();
    if (element == null) {
      chunks = new TextChunk[]{new TextChunk(SimpleTextAttributes.ERROR_ATTRIBUTES.toTextAttributes(), UsageViewBundle.message("node.invalid"))};
    }
    else {
      chunks = new TextChunk[]{new TextChunk(new TextAttributes(), element.getText())};
    }
  }
  else {
    chunks = ChunkExtractor.extractChunks(psiFile, this);
  }

  myTextChunks = new SoftReference<>(chunks);
  return chunks;
}
 
Example 4
Source File: ShowUsagesAction.java    From dagger-intellij-plugin with Apache License 2.0 5 votes vote down vote up
@NotNull
private static String getFullTitle(@NotNull List<Usage> usages, @NotNull String title,
    boolean hadMoreSeparator, int visibleNodesCount, boolean findUsagesInProgress) {
  String s;
  if (hadMoreSeparator) {
    s = "<b>Some</b> " + title + " " + "<b>(Only " + visibleNodesCount + " usages shown" + (
        findUsagesInProgress ? " so far" : "") + ")</b>";
  } else {
    s = title + " (" + UsageViewBundle.message("usages.n", usages.size()) + (findUsagesInProgress
        ? " so far" : "") + ")";
  }
  return "<html><nobr>" + s + "</nobr></html>";
}
 
Example 5
Source File: UsageViewImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private MyPanel(@Nonnull JTree tree) {
  mySupport = new OccurenceNavigatorSupport(tree) {
    @Override
    protected Navigatable createDescriptorForNode(@Nonnull DefaultMutableTreeNode node) {
      if (node.getChildCount() > 0) return null;
      if (node instanceof Node && ((Node)node).isExcluded()) return null;
      return getNavigatableForNode(node, !myPresentation.isReplaceMode());
    }

    @Nonnull
    @Override
    public String getNextOccurenceActionName() {
      return UsageViewBundle.message("action.next.occurrence");
    }

    @Nonnull
    @Override
    public String getPreviousOccurenceActionName() {
      return UsageViewBundle.message("action.previous.occurrence");
    }
  };
  myCopyProvider = new TextCopyProvider() {
    @Nullable
    @Override
    public Collection<String> getTextLinesToCopy() {
      final Node[] selectedNodes = getSelectedNodes();
      if (selectedNodes != null && selectedNodes.length > 0) {
        ArrayList<String> lines = new ArrayList<>();
        for (Node node : selectedNodes) {
          lines.add(node.getText(UsageViewImpl.this));
        }
        return lines;
      }
      return null;
    }
  };
}
 
Example 6
Source File: SearchForUsagesRunnable.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void notifyByFindBalloon(@javax.annotation.Nullable final HyperlinkListener listener,
                                        @Nonnull final MessageType info,
                                        @Nonnull FindUsagesProcessPresentation processPresentation,
                                        @Nonnull final Project project,
                                        @Nonnull final List<String> lines) {
  com.intellij.usageView.UsageViewManager.getInstance(project); // in case tool window not registered

  final Collection<VirtualFile> largeFiles = processPresentation.getLargeFiles();
  List<String> resultLines = new ArrayList<>(lines);
  HyperlinkListener resultListener = listener;
  if (!largeFiles.isEmpty()) {
    String shortMessage = "(<a href='" + LARGE_FILES_HREF_TARGET + "'>" + UsageViewBundle.message("large.files.were.ignored", largeFiles.size()) + "</a>)";

    resultLines.add(shortMessage);
    resultListener = addHrefHandling(resultListener, LARGE_FILES_HREF_TARGET, () -> {
      String detailedMessage = detailedLargeFilesMessage(largeFiles);
      List<String> strings = new ArrayList<>(lines);
      strings.add(detailedMessage);
      //noinspection SSBasedInspection
      ToolWindowManager.getInstance(project).notifyByBalloon(ToolWindowId.FIND, info, wrapInHtml(strings), AllIcons.Actions.Find, listener);
    });
  }

  Runnable searchIncludingProjectFileUsages = processPresentation.searchIncludingProjectFileUsages();
  if (searchIncludingProjectFileUsages != null) {
    resultLines
            .add("Occurrences in project configuration files are skipped. " + "<a href='" + SHOW_PROJECT_FILE_OCCURRENCES_HREF_TARGET + "'>Include them</a>");
    resultListener = addHrefHandling(resultListener, SHOW_PROJECT_FILE_OCCURRENCES_HREF_TARGET, searchIncludingProjectFileUsages);
  }

  //noinspection SSBasedInspection
  ToolWindowManager.getInstance(project).notifyByBalloon(ToolWindowId.FIND, info, wrapInHtml(resultLines), AllIcons.Actions.Find, resultListener);
}
 
Example 7
Source File: PsiElement2UsageTargetAdapter.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public String getLongDescriptiveName() {
  SearchScope searchScope = myOptions.searchScope;
  String scopeString = searchScope.getDisplayName();
  PsiElement psiElement = getElement();

  return psiElement == null
         ? UsageViewBundle.message("node.invalid")
         : FindBundle.message("recent.find.usages.action.popup", StringUtil.capitalize(UsageViewUtil.getType(psiElement)), DescriptiveNameUtil.getDescriptiveName(psiElement), scopeString);
}
 
Example 8
Source File: UsageContextCallHierarchyPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void updateLayoutLater(@Nullable final List<? extends UsageInfo> infos) {
  PsiElement element = infos == null ? null : getElementToSliceOn(infos);
  if (myBrowser instanceof Disposable) {
    Disposer.dispose((Disposable)myBrowser);
    myBrowser = null;
  }
  if (element != null) {
    myBrowser = createCallHierarchyPanel(element);
    if (myBrowser == null) {
      element = null;
    }
  }

  removeAll();
  if (element == null) {
    JComponent titleComp = new JLabel(UsageViewBundle.message("select.the.usage.to.preview", myPresentation.getUsagesWord()), SwingConstants.CENTER);
    add(titleComp, BorderLayout.CENTER);
  }
  else {
    if (myBrowser instanceof Disposable) {
      Disposer.register(this, (Disposable)myBrowser);
    }
    JComponent panel = myBrowser.getComponent();
    add(panel, BorderLayout.CENTER);
  }
  revalidate();
}
 
Example 9
Source File: UsageGroupingRuleProviderImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
private GroupByFileStructureAction(UsageViewImpl view) {
  super(view, UsageViewBundle.message("action.group.by.file.structure"), AllIcons.Actions.GroupByMethod);
}
 
Example 10
Source File: UsageGroupingRuleProviderImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
private GroupByPackageAction(UsageViewImpl view) {
  super(view, UsageViewBundle.message("action.group.by.package"), AllIcons.Actions.GroupByPackage);
}
 
Example 11
Source File: UsageGroupingRuleProviderImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
private GroupByModuleTypeAction(UsageViewImpl view) {
  super(view, UsageViewBundle.message("action.group.by.module"), AllIcons.Actions.GroupByModule);
}
 
Example 12
Source File: UsageGroupingRuleProviderImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
private GroupByUsageTypeAction(UsageViewImpl view) {
  super(view, UsageViewBundle.message("action.group.by.usage.type"), AllIcons.General.Filter); //TODO: special icon
}
 
Example 13
Source File: PreviewUsageAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
PreviewUsageAction(@Nonnull UsageView usageView) {
  super(usageView, UsageViewBundle.message("preview.usages.action.text"), AllIcons.Actions.PreviewDetails);
}
 
Example 14
Source File: NonCodeUsageGroupingRule.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
@Nonnull
public String getText(UsageView view) {
  return view == null ? UsageViewBundle.message("node.group.code.usages") : view.getPresentation().getNonCodeUsagesString();
}
 
Example 15
Source File: NonCodeUsageGroupingRule.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
@Nonnull
public String getText(UsageView view) {
  return view == null ? UsageViewBundle.message("node.group.code.usages") : view.getPresentation().getCodeUsagesString();
}
 
Example 16
Source File: SortMembersAlphabeticallyAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
SortMembersAlphabeticallyAction(UsageViewImpl usageView) {
  super(usageView, UsageViewBundle.message("sort.alphabetically.action.text"), AllIcons.ObjectBrowser.Sorted);
}
 
Example 17
Source File: UsageViewImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
private MergeDupLines() {
  super(UsageViewImpl.this, UsageViewBundle.message("action.merge.same.line"), AllIcons.Toolbar.Filterdups);
  setShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_F, InputEvent.CTRL_DOWN_MASK)));
}
 
Example 18
Source File: ImportUsageFilteringRuleProvider.java    From consulo with Apache License 2.0 4 votes vote down vote up
private ShowImportsAction(UsageView view) {
  super(view, UsageViewBundle.message("action.show.import.statements"), AllIcons.Actions.ShowImportStatements);
}
 
Example 19
Source File: UsageFilteringRuleProviderImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
private ShowWriteAccessUsagesAction() {
  super(UsageViewBundle.message("action.show.write.access"), null, AllIcons.Actions.ShowWriteAccess);
}
 
Example 20
Source File: UsageFilteringRuleProviderImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
private ShowReadAccessUsagesAction() {
  super(UsageViewBundle.message("action.show.read.access"), null, AllIcons.Actions.ShowReadAccess);
}