use of com.intellij.navigation.ItemPresentation in project intellij-community by JetBrains.
the class GotoImplementationHandler method getChooserTitle.
@Override
@NotNull
protected String getChooserTitle(@NotNull PsiElement sourceElement, String name, int length, boolean finished) {
ItemPresentation presentation = ((NavigationItem) sourceElement).getPresentation();
String fullName;
if (presentation == null) {
fullName = name;
} else {
PsiElement container = getContainer(sourceElement);
ItemPresentation containerPresentation = container == null || container instanceof PsiFile ? null : ((NavigationItem) container).getPresentation();
String containerText = containerPresentation == null ? null : containerPresentation.getPresentableText();
fullName = (containerText == null ? "" : containerText + ".") + presentation.getPresentableText();
}
return CodeInsightBundle.message("goto.implementation.chooserTitle", fullName, length, finished ? "" : " so far");
}
use of com.intellij.navigation.ItemPresentation in project intellij-community by JetBrains.
the class JavaModulePresentationProvider method getPresentation.
@Override
public ItemPresentation getPresentation(@NotNull final PsiJavaModule item) {
return new ItemPresentation() {
@Override
public String getPresentableText() {
return item.getName();
}
@Nullable
@Override
public String getLocationString() {
VirtualFile file = PsiImplUtil.getModuleVirtualFile(item);
FileIndexFacade index = FileIndexFacade.getInstance(item.getProject());
if (index.isInLibraryClasses(file)) {
Matcher matcher = JAR_NAME.matcher(file.getPath());
if (matcher.find()) {
return matcher.group(1);
}
} else if (index.isInSource(file)) {
Module module = index.getModuleForFile(file);
if (module != null) {
return '[' + module.getName() + ']';
}
}
return null;
}
@Nullable
@Override
public Icon getIcon(boolean unused) {
return AllIcons.Nodes.JavaModule;
}
};
}
use of com.intellij.navigation.ItemPresentation in project intellij-community by JetBrains.
the class AbstractMvcPsiNodeDescriptor method updateImpl.
@Override
protected void updateImpl(final PresentationData data) {
final PsiElement psiElement = extractPsiFromValue();
if (psiElement instanceof NavigationItem) {
final ItemPresentation presentation = ((NavigationItem) psiElement).getPresentation();
assert presentation != null;
data.setPresentableText(presentation.getPresentableText());
}
}
use of com.intellij.navigation.ItemPresentation in project intellij-community by JetBrains.
the class XPathEvalAction method showUsageView.
public static void showUsageView(@NotNull final Project project, MyUsageTarget usageTarget, Factory<UsageSearcher> searcherFactory, final EditExpressionAction editAction) {
final UsageViewPresentation presentation = new UsageViewPresentation();
presentation.setTargetsNodeText("XPath Expression");
presentation.setCodeUsages(false);
presentation.setCodeUsagesString("Found Matches");
presentation.setNonCodeUsagesString("Result");
presentation.setUsagesString("XPath Result");
presentation.setUsagesWord("match");
final ItemPresentation targetPresentation = usageTarget.getPresentation();
if (targetPresentation != null) {
presentation.setTabText(StringUtil.shortenTextWithEllipsis("XPath '" + targetPresentation.getPresentableText() + '\'', 60, 0, true));
} else {
presentation.setTabText("XPath");
}
presentation.setScopeText("XML Files");
presentation.setOpenInNewTab(FindSettings.getInstance().isShowResultsInSeparateView());
final FindUsagesProcessPresentation processPresentation = new FindUsagesProcessPresentation(presentation);
processPresentation.setProgressIndicatorFactory(() -> new FindProgressIndicator(project, "XML Document(s)"));
processPresentation.setShowPanelIfOnlyOneUsage(true);
processPresentation.setShowNotFoundMessage(true);
final UsageTarget[] usageTargets = { usageTarget };
UsageViewManager.getInstance(project).searchAndShowUsages(usageTargets, searcherFactory, processPresentation, presentation, new UsageViewManager.UsageViewStateListener() {
@Override
public void usageViewCreated(@NotNull UsageView usageView) {
usageView.addButtonToLowerPane(editAction, "&Edit Expression");
}
@Override
public void findingUsagesFinished(UsageView usageView) {
}
});
}
use of com.intellij.navigation.ItemPresentation in project intellij-community by JetBrains.
the class UsageViewTreeCellRenderer method getPlainTextForNode.
// computes the node text regardless of the node visibility
@NotNull
String getPlainTextForNode(Object value) {
boolean showAsReadOnly = false;
StringBuilder result = new StringBuilder();
if (value instanceof Node) {
Node node = (Node) value;
if (!node.isValid()) {
result.append(UsageViewBundle.message("node.invalid")).append(" ");
}
if (myPresentation.isShowReadOnlyStatusAsRed() && node.isReadOnly()) {
showAsReadOnly = true;
}
}
if (value instanceof DefaultMutableTreeNode) {
DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) value;
Object userObject = treeNode.getUserObject();
if (userObject instanceof UsageTarget) {
UsageTarget usageTarget = (UsageTarget) userObject;
if (usageTarget.isValid()) {
final ItemPresentation presentation = usageTarget.getPresentation();
LOG.assertTrue(presentation != null);
if (showAsReadOnly) {
result.append(UsageViewBundle.message("node.readonly")).append(" ");
}
final String text = presentation.getPresentableText();
result.append(text == null ? "" : text);
} else {
result.append(UsageViewBundle.message("node.invalid"));
}
} else if (treeNode instanceof GroupNode) {
GroupNode node = (GroupNode) treeNode;
if (node.isRoot()) {
result.append(StringUtil.capitalize(myPresentation.getUsagesWord()));
} else {
result.append(node.getGroup().getText(myView));
}
int count = node.getRecursiveUsageCount();
result.append(" (").append(StringUtil.pluralize(count + " " + myPresentation.getUsagesWord(), count)).append(")");
} else if (treeNode instanceof UsageNode) {
UsageNode node = (UsageNode) treeNode;
if (showAsReadOnly) {
result.append(UsageViewBundle.message("node.readonly")).append(" ");
}
if (node.isValid()) {
TextChunk[] text = node.getUsage().getPresentation().getText();
for (TextChunk textChunk : text) {
result.append(textChunk.getText());
}
}
} else if (userObject instanceof String) {
result.append((String) userObject);
} else {
result.append(userObject == null ? "" : userObject.toString());
}
} else {
result.append(value);
}
return result.toString();
}
Aggregations