mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
This commit is contained in:
@@ -54,12 +54,10 @@ public class ComboBox<E> extends ComboBoxWithWidePopup<E> implements AWTEventLis
|
||||
protected boolean myPaintingNow;
|
||||
|
||||
public ComboBox() {
|
||||
super();
|
||||
init(-1);
|
||||
}
|
||||
|
||||
public ComboBox(int width) {
|
||||
super();
|
||||
init(width);
|
||||
}
|
||||
|
||||
@@ -262,11 +260,6 @@ public class ComboBox<E> extends ComboBoxWithWidePopup<E> implements AWTEventLis
|
||||
return new Dimension(width, UIUtil.fixComboBoxHeight(preferredSize.height));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Dimension getOriginalPreferredSize() {
|
||||
return super.getPreferredSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
try {
|
||||
|
||||
@@ -27,7 +27,6 @@ public class ComboBoxWithWidePopup<E> extends JComboBox<E> {
|
||||
private int myMinLength = 20;
|
||||
|
||||
public ComboBoxWithWidePopup() {
|
||||
super();
|
||||
init();
|
||||
}
|
||||
|
||||
@@ -96,29 +95,28 @@ public class ComboBoxWithWidePopup<E> extends JComboBox<E> {
|
||||
private final ListCellRenderer<? super E> myOldRenderer;
|
||||
private final ComboBoxWithWidePopup myComboBox;
|
||||
|
||||
public AdjustingListCellRenderer(ComboBoxWithWidePopup<E> comboBox, ListCellRenderer<? super E> oldRenderer) {
|
||||
AdjustingListCellRenderer(ComboBoxWithWidePopup<E> comboBox, ListCellRenderer<? super E> oldRenderer) {
|
||||
myComboBox = comboBox;
|
||||
myOldRenderer = oldRenderer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<? extends E> list, E value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
E _value = value;
|
||||
if (index == -1 && _value instanceof String && !myComboBox.isValid()) {
|
||||
if (index == -1 && value instanceof String && !myComboBox.isValid()) {
|
||||
int minLength = getMinLength();
|
||||
|
||||
Dimension size = myComboBox._getSuperSize();
|
||||
String stringValue = (String)_value;
|
||||
String stringValue = (String)value;
|
||||
|
||||
if (size.width == 0) {
|
||||
if (stringValue.length() > minLength) {
|
||||
@SuppressWarnings("unchecked") E e = (E)stringValue.substring(0, minLength);
|
||||
_value = e;
|
||||
value = e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return myOldRenderer.getListCellRendererComponent(list, _value, index, isSelected, cellHasFocus);
|
||||
return myOldRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,12 +35,6 @@ public class TextFieldWithHistory extends ComboBox {
|
||||
setEditable(true);
|
||||
}
|
||||
|
||||
// API compatibility with 7.0.1
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public TextFieldWithHistory(boolean cropList) {
|
||||
this();
|
||||
}
|
||||
|
||||
public void addDocumentListener(DocumentListener listener) {
|
||||
getTextEditor().getDocument().addDocumentListener(listener);
|
||||
}
|
||||
@@ -81,6 +75,7 @@ public class TextFieldWithHistory extends ComboBox {
|
||||
return getTextEditor().getText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeNotify() {
|
||||
super.removeNotify();
|
||||
hidePopup();
|
||||
@@ -121,10 +116,12 @@ public class TextFieldWithHistory extends ComboBox {
|
||||
|
||||
private Object mySelectedItem;
|
||||
|
||||
@Override
|
||||
public Object getElementAt(int index) {
|
||||
return myFullList.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return Math.min(myHistorySize == -1 ? Integer.MAX_VALUE : myHistorySize, myFullList.size());
|
||||
}
|
||||
@@ -132,7 +129,7 @@ public class TextFieldWithHistory extends ComboBox {
|
||||
public void addElement(Object obj) {
|
||||
String newItem = ((String)obj).trim();
|
||||
|
||||
if (0 == newItem.length()) {
|
||||
if (newItem.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -149,10 +146,12 @@ public class TextFieldWithHistory extends ComboBox {
|
||||
fireIntervalAdded(this, index, index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getSelectedItem() {
|
||||
return mySelectedItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelectedItem(Object anItem) {
|
||||
mySelectedItem = anItem;
|
||||
fireContentsChanged();
|
||||
@@ -173,6 +172,7 @@ public class TextFieldWithHistory extends ComboBox {
|
||||
}
|
||||
|
||||
protected static class TextFieldWithProcessing extends JTextField {
|
||||
@Override
|
||||
public void processKeyEvent(KeyEvent e) {
|
||||
super.processKeyEvent(e);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ public class TextFieldWithStoredHistory extends TextFieldWithHistory {
|
||||
private final String myPropertyName;
|
||||
|
||||
// API compatibility with 7.0.1
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public TextFieldWithStoredHistory(@NonNls final String propertyName, boolean cropList) {
|
||||
this(propertyName);
|
||||
}
|
||||
@@ -35,6 +34,7 @@ public class TextFieldWithStoredHistory extends TextFieldWithHistory {
|
||||
reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCurrentTextToHistory() {
|
||||
super.addCurrentTextToHistory();
|
||||
PropertiesComponent.getInstance().setValue(myPropertyName, StringUtil.join(getHistory(), "\n"));
|
||||
@@ -47,7 +47,7 @@ public class TextFieldWithStoredHistory extends TextFieldWithHistory {
|
||||
final String[] items = history.split("\n");
|
||||
ArrayList<String> result = new ArrayList<>();
|
||||
for (String item : items) {
|
||||
if (item != null && item.length() > 0) {
|
||||
if (item != null && !item.isEmpty()) {
|
||||
result.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -341,9 +341,9 @@ public class FileTypesTest extends PlatformTestCase {
|
||||
myFileTypeManager.drainReDetectQueue();
|
||||
log("T: ensureRedetected: drain. re-detect queue: "+myFileTypeManager.dumpReDetectQueue());
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
log("T: ensureRedetected: dispatch");
|
||||
log("T: ensureRedetected: dispatch. re-detect queue: "+myFileTypeManager.dumpReDetectQueue());
|
||||
FileType type = vFile.getFileType();
|
||||
log("T: ensureRedetected: getFileType ("+type.getName()+")");
|
||||
log("T: ensureRedetected: getFileType ("+type.getName()+") re-detect queue: "+myFileTypeManager.dumpReDetectQueue());
|
||||
assertTrue(detectorCalled.contains(vFile));
|
||||
detectorCalled.clear();
|
||||
log("T: ensureRedetected: clear");
|
||||
|
||||
@@ -51,7 +51,7 @@ public class ObjectUtils {
|
||||
|
||||
@Contract("null,null->null")
|
||||
public static <T> T coalesce(@Nullable T t1, @Nullable T t2) {
|
||||
return t1 != null ? t1 : t2;
|
||||
return chooseNotNull(t1, t2);
|
||||
}
|
||||
|
||||
@Contract("null,null,null->null")
|
||||
|
||||
Reference in New Issue
Block a user