com.intellij.usageView.UsageViewBundle Java Examples
The following examples show how to use
com.intellij.usageView.UsageViewBundle.
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: ShowUsagesAction.java From otto-intellij-plugin with Apache License 2.0 | 6 votes |
@NotNull private static List<UsageNode> collectData(@NotNull List<Usage> usages, @NotNull Collection<UsageNode> visibleNodes, @NotNull UsageViewImpl usageView, @NotNull UsageViewPresentation presentation) { @NotNull List<UsageNode> data = new ArrayList<UsageNode>(); int filtered = filtered(usages, usageView); if (filtered != 0) { data.add(createStringNode(UsageViewBundle.message("usages.were.filtered.out", filtered))); } data.addAll(visibleNodes); if (data.isEmpty()) { String progressText = UsageViewManagerImpl.getProgressTitle(presentation); data.add(createStringNode(progressText)); } Collections.sort(data, USAGE_NODE_COMPARATOR); return data; }
Example #2
Source File: UsagePreviewPanel.java From consulo with Apache License 2.0 | 6 votes |
@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 |
@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: UsageInfo2UsageAdapter.java From consulo with Apache License 2.0 | 6 votes |
@Override @Nonnull public String getPlainText() { int startOffset = getNavigationOffset(); final PsiElement element = getElement(); if (element != null && startOffset != -1) { final Document document = getDocument(); if (document != null) { int lineNumber = document.getLineNumber(startOffset); int lineStart = document.getLineStartOffset(lineNumber); int lineEnd = document.getLineEndOffset(lineNumber); String prefixSuffix = null; if (lineEnd - lineStart > ChunkExtractor.MAX_LINE_LENGTH_TO_SHOW) { prefixSuffix = "..."; lineStart = Math.max(startOffset - ChunkExtractor.OFFSET_BEFORE_TO_SHOW_WHEN_LONG_LINE, lineStart); lineEnd = Math.min(startOffset + ChunkExtractor.OFFSET_AFTER_TO_SHOW_WHEN_LONG_LINE, lineEnd); } String s = document.getCharsSequence().subSequence(lineStart, lineEnd).toString(); if (prefixSuffix != null) s = prefixSuffix + s + prefixSuffix; return s; } } return UsageViewBundle.message("node.invalid"); }
Example #5
Source File: ShowUsagesAction.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull private static String getFullTitle(@Nonnull List<Usage> usages, @Nonnull String title, boolean hadMoreSeparator, int visibleNodesCount, boolean findUsagesInProgress) { String s; String soFarSuffix = findUsagesInProgress ? " so far" : ""; if (hadMoreSeparator) { s = "<b>Some</b> " + title + " " + "<b>(Only " + visibleNodesCount + " usages shown" + soFarSuffix + ")</b>"; } else { s = title + " (" + UsageViewBundle.message("usages.n", usages.size()) + soFarSuffix + ")"; } return "<html><nobr>" + s + "</nobr></html>"; }
Example #6
Source File: ShowUsagesAction.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull private static List<UsageNode> collectData(@Nonnull List<Usage> usages, @Nonnull Collection<UsageNode> visibleNodes, @Nonnull UsageViewImpl usageView, @Nonnull UsageViewPresentation presentation) { @Nonnull List<UsageNode> data = new ArrayList<>(); int filtered = filtered(usages, usageView); if (filtered != 0) { data.add(createStringNode(UsageViewBundle.message("usages.were.filtered.out", filtered))); } data.addAll(visibleNodes); if (data.isEmpty()) { String progressText = StringUtil.escapeXml(UsageViewManagerImpl.getProgressTitle(presentation)); data.add(createStringNode(progressText)); } Collections.sort(data, USAGE_NODE_COMPARATOR); return data; }
Example #7
Source File: UsageViewManagerImpl.java From consulo with Apache License 2.0 | 6 votes |
public static void showTooManyUsagesWarningLater(@Nonnull final Project project, @Nonnull final TooManyUsagesStatus tooManyUsagesStatus, @Nonnull final ProgressIndicator indicator, @Nonnull final UsageViewPresentation presentation, final int usageCount, @Nullable final UsageViewImpl usageView) { UIUtil.invokeLaterIfNeeded(() -> { if (usageView != null && usageView.searchHasBeenCancelled() || indicator.isCanceled()) return; int shownUsageCount = usageView == null ? usageCount : usageView.getRoot().getRecursiveUsageCount(); String message = UsageViewBundle.message("find.excessive.usage.count.prompt", shownUsageCount, StringUtil.pluralize(presentation.getUsagesWord())); UsageLimitUtil.Result ret = UsageLimitUtil.showTooManyUsagesWarning(project, message, presentation); if (ret == UsageLimitUtil.Result.ABORT) { if (usageView != null) { usageView.cancelCurrentSearch(); } indicator.cancel(); } tooManyUsagesStatus.userResponded(); }); }
Example #8
Source File: FindPopupPanel.java From consulo with Apache License 2.0 | 6 votes |
@Override protected void customizeCellRenderer(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) { if (value instanceof UsageInfo2UsageAdapter) { if (!((UsageInfo2UsageAdapter)value).isValid()) { myUsageRenderer.append(" " + UsageViewBundle.message("node.invalid") + " ", SimpleTextAttributes.ERROR_ATTRIBUTES); } TextChunk[] text = ((UsageInfo2UsageAdapter)value).getPresentation().getText(); // skip line number / file info for (int i = 1; i < text.length; ++i) { TextChunk textChunk = text[i]; SimpleTextAttributes attributes = getAttributes(textChunk); myUsageRenderer.append(textChunk.getText(), attributes); } } setBorder(null); }
Example #9
Source File: DependenciesPanel.java From consulo with Apache License 2.0 | 6 votes |
@Override public void customizeCellRenderer( JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus ){ PackageDependenciesNode node = (PackageDependenciesNode)value; if (node.isValid()) { setIcon(node.getIcon()); } else { append(UsageViewBundle.message("node.invalid") + " ", SimpleTextAttributes.ERROR_ATTRIBUTES); } append(node.toString(), node.hasMarked() && !selected ? SimpleTextAttributes.ERROR_ATTRIBUTES : SimpleTextAttributes.REGULAR_ATTRIBUTES); append(node.getPresentableFilesCount(), SimpleTextAttributes.GRAYED_ATTRIBUTES); }
Example #10
Source File: ExporterToTextFile.java From consulo with Apache License 2.0 | 6 votes |
private void appendNodeText(StringBuilder buf, DefaultMutableTreeNode node, String lineSeparator) { if (node instanceof Node && ((Node)node).isExcluded()) { buf.append("(").append(UsageViewBundle.message("usage.excluded")).append(") "); } if (node instanceof UsageNode) { appendUsageNodeText(buf, (UsageNode)node); } else if (node instanceof GroupNode) { UsageGroup group = ((GroupNode)node).getGroup(); buf.append(group != null ? group.getText(myUsageView) : UsageViewBundle.message("usages.title")); buf.append(" "); int count = ((GroupNode)node).getRecursiveUsageCount(); buf.append(" (").append(UsageViewBundle.message("usages.n", count)).append(")"); } else if (node instanceof UsageTargetNode) { buf.append(((UsageTargetNode)node).getTarget().getPresentation().getPresentableText()); } else { buf.append(node.toString()); } buf.append(lineSeparator); }
Example #11
Source File: ShowUsagesAction.java From dagger-intellij-plugin with Apache License 2.0 | 6 votes |
@NotNull private static List<UsageNode> collectData(@NotNull List<Usage> usages, @NotNull Collection<UsageNode> visibleNodes, @NotNull UsageViewImpl usageView, @NotNull UsageViewPresentation presentation) { @NotNull List<UsageNode> data = new ArrayList<UsageNode>(); int filtered = filtered(usages, usageView); if (filtered != 0) { data.add(createStringNode(UsageViewBundle.message("usages.were.filtered.out", filtered))); } data.addAll(visibleNodes); if (data.isEmpty()) { String progressText = UsageViewManagerImpl.getProgressTitle(presentation); data.add(createStringNode(progressText)); } Collections.sort(data, USAGE_NODE_COMPARATOR); return data; }
Example #12
Source File: UsageLimitUtil.java From consulo with Apache License 2.0 | 6 votes |
@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 #13
Source File: UsageViewImpl.java From consulo with Apache License 2.0 | 5 votes |
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 #14
Source File: ShowUsagesAction.java From otto-intellij-plugin with Apache License 2.0 | 5 votes |
@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 #15
Source File: SearchForUsagesRunnable.java From consulo with Apache License 2.0 | 5 votes |
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 #16
Source File: UsageContextCallHierarchyPanel.java From consulo with Apache License 2.0 | 5 votes |
@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 #17
Source File: ShowUsagesAction.java From dagger-intellij-plugin with Apache License 2.0 | 5 votes |
@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 #18
Source File: PsiElement2UsageTargetAdapter.java From consulo with Apache License 2.0 | 5 votes |
@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 #19
Source File: UsageViewManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
private UsageView doSearchAndShow(@Nonnull final UsageTarget[] searchFor, @Nonnull final Factory<UsageSearcher> searcherFactory, @Nonnull final UsageViewPresentation presentation, @Nonnull final FindUsagesProcessPresentation processPresentation, @Nullable final UsageViewStateListener listener) { final SearchScope searchScopeToWarnOfFallingOutOf = getMaxSearchScopeToWarnOfFallingOutOf(searchFor); final AtomicReference<UsageViewImpl> usageViewRef = new AtomicReference<>(); long start = System.currentTimeMillis(); Task.Backgroundable task = new Task.Backgroundable(myProject, getProgressTitle(presentation), true, new SearchInBackgroundOption()) { @Override public void run(@Nonnull final ProgressIndicator indicator) { new SearchForUsagesRunnable(UsageViewManagerImpl.this, UsageViewManagerImpl.this.myProject, usageViewRef, presentation, searchFor, searcherFactory, processPresentation, searchScopeToWarnOfFallingOutOf, listener).run(); } @Nonnull @Override public NotificationInfo getNotificationInfo() { UsageViewImpl usageView = usageViewRef.get(); int count = usageView == null ? 0 : usageView.getUsagesCount(); String notification = StringUtil.capitalizeWords(UsageViewBundle.message("usages.n", count), true); LOG.debug(notification + " in " + (System.currentTimeMillis() - start) + "ms."); return new NotificationInfo("Find Usages", "Find Usages Finished", notification); } }; ProgressManager.getInstance().run(task); return usageViewRef.get(); }
Example #20
Source File: SafeDeleteUsageViewDescriptor.java From consulo with Apache License 2.0 | 4 votes |
@Override public String getCodeReferencesText(int usagesCount, int filesCount) { return RefactoringBundle.message("references.in.code", UsageViewBundle.getReferencesString(usagesCount, filesCount)); }
Example #21
Source File: UsageGroupingRuleProviderImpl.java From consulo with Apache License 2.0 | 4 votes |
private GroupByUsageTypeAction(UsageViewImpl view) { super(view, UsageViewBundle.message("action.group.by.usage.type"), AllIcons.General.Filter); //TODO: special icon }
Example #22
Source File: SafeDeleteUsageViewDescriptor.java From consulo with Apache License 2.0 | 4 votes |
@Override public String getCommentReferencesText(int usagesCount, int filesCount) { return RefactoringBundle.message("safe.delete.comment.occurences.header", UsageViewBundle.getOccurencesString(usagesCount, filesCount)); }
Example #23
Source File: MoveMultipleElementsViewDescriptor.java From consulo with Apache License 2.0 | 4 votes |
@Override public String getCodeReferencesText(int usagesCount, int filesCount) { return myCodeReferencesText + UsageViewBundle.getReferencesString(usagesCount, filesCount); }
Example #24
Source File: UsageViewDescriptorAdapter.java From consulo with Apache License 2.0 | 4 votes |
@Override public String getCodeReferencesText(int usagesCount, int filesCount) { return RefactoringBundle.message("references.to.be.changed", UsageViewBundle.getReferencesString(usagesCount, filesCount)); }
Example #25
Source File: RenameViewDescriptor.java From consulo with Apache License 2.0 | 4 votes |
@Override public String getCodeReferencesText(int usagesCount, int filesCount) { return myCodeReferencesText + UsageViewBundle.getReferencesString(usagesCount, filesCount); }
Example #26
Source File: RenameViewDescriptor.java From consulo with Apache License 2.0 | 4 votes |
@Override public String getCommentReferencesText(int usagesCount, int filesCount) { return RefactoringBundle.message("comments.elements.header", UsageViewBundle.getOccurencesString(usagesCount, filesCount)); }
Example #27
Source File: MoveFilesOrDirectoriesViewDescriptor.java From consulo with Apache License 2.0 | 4 votes |
@Override public String getCodeReferencesText(int usagesCount, int filesCount) { return myCodeReferencesText + UsageViewBundle.getReferencesString(usagesCount, filesCount); }
Example #28
Source File: MoveFilesOrDirectoriesViewDescriptor.java From consulo with Apache License 2.0 | 4 votes |
@Override public String getCommentReferencesText(int usagesCount, int filesCount) { return RefactoringBundle.message("comments.elements.header", UsageViewBundle.getOccurencesString(usagesCount, filesCount)); }
Example #29
Source File: MoveMultipleElementsViewDescriptor.java From consulo with Apache License 2.0 | 4 votes |
@Override public String getCommentReferencesText(int usagesCount, int filesCount) { return RefactoringBundle.message("comments.elements.header", UsageViewBundle.getOccurencesString(usagesCount, filesCount)); }
Example #30
Source File: MoveMemberViewDescriptor.java From consulo with Apache License 2.0 | 4 votes |
@Override public String getCodeReferencesText(int usagesCount, int filesCount) { return RefactoringBundle.message("references.to.be.changed", UsageViewBundle.getReferencesString(usagesCount, filesCount)); }