mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
+setToString()
This commit is contained in:
+8
-1
@@ -16,9 +16,11 @@
|
||||
package com.intellij.ui.components.editors;
|
||||
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.ui.components.JBLabel;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.Icons;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
|
||||
@@ -40,13 +42,14 @@ public class JBComboBoxTableCellEditorComponent extends JBLabel {
|
||||
private final JBList myList = new JBList();
|
||||
private Object[] myOptions = {};
|
||||
private Object myValue;
|
||||
private Function<Object, String> myToString = StringUtil.createToStringFunction(Object.class);
|
||||
|
||||
private ListCellRenderer myRenderer = new DefaultListCellRenderer() {
|
||||
public Icon myEmptyIcon;
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
final JLabel label = (JLabel)super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
final JLabel label = (JLabel)super.getListCellRendererComponent(list, myToString.fun(value), index, isSelected, cellHasFocus);
|
||||
if (value == myValue) {
|
||||
label.setIcon(getIcon(isSelected));
|
||||
} else {
|
||||
@@ -135,4 +138,8 @@ public class JBComboBoxTableCellEditorComponent extends JBLabel {
|
||||
public void setDefaultValue(Object value) {
|
||||
myValue = value;
|
||||
}
|
||||
|
||||
public void setToString(Function<Object, String> toString) {
|
||||
myToString = toString;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user