mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-187518 Support italic in completion lookup element item text
This commit is contained in:
@@ -238,6 +238,16 @@ public final class LookupElementBuilder extends LookupElement {
|
||||
return new LookupElementBuilder(myLookupString, myObject, myInsertHandler, null, presentation, myPsiElement, myAllLookupStrings, myCaseSensitive);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2018.2
|
||||
*/
|
||||
@Contract(pure=true)
|
||||
public LookupElementBuilder withItemTextItalic(boolean italic) {
|
||||
final LookupElementPresentation presentation = copyPresentation();
|
||||
presentation.setItemTextItalic(italic);
|
||||
return new LookupElementBuilder(myLookupString, myObject, myInsertHandler, null, presentation, myPsiElement, myAllLookupStrings, myCaseSensitive);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #withTypeText(String)}
|
||||
*/
|
||||
|
||||
@@ -40,6 +40,7 @@ public class LookupElementPresentation {
|
||||
private Color myItemTextForeground = JBColor.foreground();
|
||||
private boolean myItemTextBold;
|
||||
private boolean myItemTextUnderlined;
|
||||
private boolean myItemTextItalic;
|
||||
private boolean myTypeGrayed;
|
||||
@Nullable private List<TextFragment> myTail;
|
||||
|
||||
@@ -59,6 +60,10 @@ public class LookupElementPresentation {
|
||||
myItemTextBold = bold;
|
||||
}
|
||||
|
||||
public void setItemTextItalic(boolean itemTextItalic) {
|
||||
myItemTextItalic = itemTextItalic;
|
||||
}
|
||||
|
||||
public void setTailText(@Nullable String text) {
|
||||
setTailText(text, false);
|
||||
}
|
||||
@@ -165,6 +170,10 @@ public class LookupElementPresentation {
|
||||
return myItemTextBold;
|
||||
}
|
||||
|
||||
public boolean isItemTextItalic() {
|
||||
return myItemTextItalic;
|
||||
}
|
||||
|
||||
public boolean isItemTextUnderlined() {
|
||||
return myItemTextUnderlined;
|
||||
}
|
||||
@@ -192,6 +201,7 @@ public class LookupElementPresentation {
|
||||
myTypeText = presentation.myTypeText;
|
||||
myStrikeout = presentation.myStrikeout;
|
||||
myItemTextBold = presentation.myItemTextBold;
|
||||
myItemTextItalic = presentation.myItemTextItalic;
|
||||
myTypeGrayed = presentation.myTypeGrayed;
|
||||
myTypeIconRightAligned = presentation.myTypeIconRightAligned;
|
||||
myItemTextUnderlined = presentation.myItemTextUnderlined;
|
||||
|
||||
@@ -261,7 +261,7 @@ public class LookupCellRenderer implements ListCellRenderer {
|
||||
Color foreground,
|
||||
int allowedWidth,
|
||||
boolean nonFocusedSelection, FontMetrics fontMetrics) {
|
||||
int style = getStyle(false, presentation.isStrikeout(), false);
|
||||
int style = getStyle(false, presentation.isStrikeout(), false, false);
|
||||
|
||||
for (LookupElementPresentation.TextFragment fragment : presentation.getTailFragments()) {
|
||||
if (allowedWidth < 0) {
|
||||
@@ -341,7 +341,7 @@ public class LookupCellRenderer implements ListCellRenderer {
|
||||
|
||||
Font customItemFont = myLookup.getCustomFont(item, bold);
|
||||
myNameComponent.setFont(customItemFont != null ? customItemFont : bold ? myBoldFont : myNormalFont);
|
||||
int style = getStyle(bold, presentation.isStrikeout(), presentation.isItemTextUnderlined());
|
||||
int style = getStyle(bold, presentation.isStrikeout(), presentation.isItemTextUnderlined(), presentation.isItemTextItalic());
|
||||
|
||||
final FontMetrics metrics = getRealFontMetrics(item, bold);
|
||||
final String name = trimLabelText(presentation.getItemText(), allowedWidth, metrics);
|
||||
@@ -361,7 +361,7 @@ public class LookupCellRenderer implements ListCellRenderer {
|
||||
}
|
||||
|
||||
@SimpleTextAttributes.StyleAttributeConstant
|
||||
private static int getStyle(boolean bold, boolean strikeout, boolean underlined) {
|
||||
private static int getStyle(boolean bold, boolean strikeout, boolean underlined, boolean italic) {
|
||||
int style = bold ? SimpleTextAttributes.STYLE_BOLD : SimpleTextAttributes.STYLE_PLAIN;
|
||||
if (strikeout) {
|
||||
style |= SimpleTextAttributes.STYLE_STRIKEOUT;
|
||||
@@ -369,6 +369,9 @@ public class LookupCellRenderer implements ListCellRenderer {
|
||||
if (underlined) {
|
||||
style |= SimpleTextAttributes.STYLE_UNDERLINE;
|
||||
}
|
||||
if (italic) {
|
||||
style |= SimpleTextAttributes.STYLE_ITALIC;
|
||||
}
|
||||
return style;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user