use of com.intellij.navigation.ItemPresentation in project android by JetBrains.
the class LazyValueResourceElementWrapper method getPresentation.
@Override
public ItemPresentation getPresentation() {
return new ItemPresentation() {
@Override
@Nullable
public String getPresentableText() {
final String name = myResourceInfo.getName();
final VirtualFile file = myResourceInfo.getContainingFile();
final VirtualFile dir = file.getParent();
if (dir == null) {
return name;
}
return name + " (..." + File.separatorChar + dir.getName() + File.separatorChar + file.getName() + ')';
}
@Override
public String getLocationString() {
return null;
}
@Override
public Icon getIcon(boolean open) {
return null;
}
};
}
use of com.intellij.navigation.ItemPresentation in project intellij-plugins by JetBrains.
the class GrStepDefinitionPresentationProvider method getPresentation.
@Nullable
@Override
public ItemPresentation getPresentation(@NotNull final GrMethodCall item) {
if (!GrCucumberUtil.isStepDefinition(item))
return null;
return new ItemPresentation() {
@Nullable
@Override
public String getPresentableText() {
final String stepRef = GrCucumberUtil.getCucumberStepRef(item).getText();
final String pattern = GrCucumberUtil.getStepDefinitionPattern(item).getText();
return CucumberBundle.message("step.definition.0.1", stepRef, pattern);
}
@Nullable
@Override
public String getLocationString() {
final PsiFile file = item.getContainingFile();
final ItemPresentation presentation = ItemPresentationProviders.getItemPresentation(file);
LOG.assertTrue(presentation != null, file.getClass().getName());
return presentation.getPresentableText();
}
@Nullable
@Override
public Icon getIcon(boolean unused) {
return null;
}
};
}
use of com.intellij.navigation.ItemPresentation in project intellij-plugins by JetBrains.
the class DartHierarchyNodeDescriptor method update.
@Override
public boolean update() {
boolean changes = super.update();
final CompositeAppearance oldText = myHighlightedText;
myHighlightedText = new CompositeAppearance();
NavigatablePsiElement element = (NavigatablePsiElement) getPsiElement();
if (element == null) {
return invalidElement();
}
final ItemPresentation presentation = element.getPresentation();
if (presentation != null) {
if (element instanceof DartMethodDeclaration) {
if (DartComponentType.typeOf(element) != DartComponentType.CONSTRUCTOR) {
// Do not print constructors as Class.Class.Class(args) Class
final DartClass cls = PsiTreeUtil.getParentOfType(element, DartClass.class);
if (cls != null) {
myHighlightedText.getEnding().addText(cls.getName() + ".");
}
}
}
myHighlightedText.getEnding().addText(presentation.getPresentableText());
PsiFile file = element.getContainingFile();
if (file != null) {
myHighlightedText.getEnding().addText(" (" + file.getName() + ")", HierarchyNodeDescriptor.getPackageNameAttributes());
}
}
myName = myHighlightedText.getText();
if (!Comparing.equal(myHighlightedText, oldText)) {
changes = true;
}
return changes;
}
use of com.intellij.navigation.ItemPresentation in project intellij-plugins by JetBrains.
the class DartMethodHierarchyNodeDescriptor method update.
public final boolean update() {
boolean changes = super.update();
final CompositeAppearance oldText = myHighlightedText;
myHighlightedText = new CompositeAppearance();
DartClass dartClass = getType();
if (dartClass == null) {
if (!myHighlightedText.getText().startsWith(INVALID_PREFIX)) {
myHighlightedText.getBeginning().addText(INVALID_PREFIX, HierarchyNodeDescriptor.getInvalidPrefixAttributes());
}
return true;
}
final ItemPresentation presentation = dartClass.getPresentation();
Icon baseIcon = null;
Icon stateIcon = null;
if (presentation != null) {
myHighlightedText.getEnding().addText(presentation.getPresentableText());
PsiFile file = dartClass.getContainingFile();
if (file != null) {
myHighlightedText.getEnding().addText(" (" + file.getName() + ")", HierarchyNodeDescriptor.getPackageNameAttributes());
}
baseIcon = presentation.getIcon(false);
stateIcon = calculateStateIcon(dartClass);
}
if (changes || baseIcon != myRawIcon || stateIcon != myStateIcon) {
changes = true;
Icon newIcon = myRawIcon = baseIcon;
myStateIcon = stateIcon;
if (myIsBase) {
final LayeredIcon icon = new LayeredIcon(2);
icon.setIcon(newIcon, 0);
newIcon = icon;
icon.setIcon(AllIcons.Hierarchy.Base, 1, -AllIcons.Hierarchy.Base.getIconWidth() / 2, 0);
}
if (myStateIcon != null) {
newIcon = new RowIcon(myStateIcon, newIcon);
}
setIcon(newIcon);
}
myName = myHighlightedText.getText();
if (!Comparing.equal(myHighlightedText, oldText)) {
changes = true;
}
return changes;
}
use of com.intellij.navigation.ItemPresentation in project intellij-plugins by JetBrains.
the class DartNamedElementNode method buildPresentationText.
@Nullable
private static String buildPresentationText(DartComponent dartComponent) {
final ItemPresentation presentation = dartComponent.getPresentation();
if (presentation == null) {
return dartComponent.getName();
}
final StringBuilder result = new StringBuilder();
if (dartComponent instanceof DartClass) {
result.append(dartComponent.getName());
final String location = presentation.getLocationString();
if (location != null && !location.isEmpty()) {
result.append(" ").append(location);
}
} else {
result.append(presentation.getPresentableText());
}
return result.toString();
}
Aggregations