fix popup caption to not expand popup for wild titles + fix ClassPresentationUtil to return correct presentation for anonymous classes

This commit is contained in:
Alexey Pegov
2011-05-25 15:01:55 +04:00
parent d81c9d429a
commit cf74c0b849
2 changed files with 15 additions and 2 deletions
@@ -79,8 +79,8 @@ public class ClassPresentationUtil {
}
}
@NotNull
public static ItemPresentation getPresentation(@NotNull final PsiClass psiClass) {
if (psiClass instanceof PsiAnonymousClass) return null;
return new ItemPresentation() {
public String getPresentableText() {
return getNameForClass(psiClass, false);
@@ -64,10 +64,23 @@ public class TitlePanel extends CaptionPanel {
myLabel.setText(titleText);
}
@Override
public Dimension getMinimumSize() {
return new Dimension(10, getPreferredSize().height);
}
public Dimension getPreferredSize() {
final String text = myLabel.getText();
return text != null && text.trim().length() > 0 ? super.getPreferredSize() : new Dimension(0, 0);
if (text == null || text.trim().length() == 0) {
return new Dimension(0, 0);
}
final Dimension preferredSize = super.getPreferredSize();
if (preferredSize.width > 100) { // do not allow caption to extend parent container
return new Dimension(100, preferredSize.height);
}
return preferredSize;
}
}