Browse Source
* commit '65f3870e85aee0ba92b35688eea5bf0235b13e5b': 按照最新设计,处理连续弹窗问题 修改老图表部分面板问题 按照最新设计,处理连续弹窗问题 修改9.0新图表bug REPORT-2897 9.0设计器修改 缩放条在不同的sheet切换不应该继承 PMD REPORT-4361 单元格元素 数据列 数据设置 分组 高级 自定义按钮问题 REPORT-4308 单元格属性-样式,修改文本自定义样式无法实时生效 REPORT-4363 表单工具栏图表和控件的扩展按钮,点击后,扩展的部分位置错乱 代码质量 REPORT-2897 9.0设计器修改 缩放条在不同的sheet切换不应该继承 rollback UIToggleButton rollback UIToggleButton REPORT-2897 9.0设计器修改 缩放条在不同的sheet切换不应该继承 去掉表单缩放条 rollback 提交master
kerry
7 years ago
29 changed files with 418 additions and 96 deletions
@ -0,0 +1,126 @@
|
||||
package com.fr.design.gui.icombobox; |
||||
|
||||
|
||||
import com.fr.design.gui.icombobox.filter.Filter; |
||||
import com.fr.design.gui.icombobox.filter.StartsWithFilter; |
||||
import com.fr.design.gui.itextfield.UITextField; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import javax.swing.*; |
||||
import javax.swing.event.DocumentEvent; |
||||
import javax.swing.event.DocumentListener; |
||||
import java.awt.*; |
||||
import java.awt.event.ActionListener; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* Created by MoMeak on 2017/9/5. |
||||
*/ |
||||
public class TextFontComboBox<T> extends ExtendedComboBox { |
||||
private Filter filter; |
||||
|
||||
public TextFontComboBox() { |
||||
this(new ArrayList<T>()); |
||||
this.setEditable(true); |
||||
} |
||||
|
||||
public TextFontComboBox(List<T> itemList) { |
||||
this(new StartsWithFilter(), itemList); |
||||
} |
||||
|
||||
public TextFontComboBox(Filter filter, List<T> itemList) { |
||||
this.filter = filter; |
||||
|
||||
setModel(new FilterableComboBoxModel(itemList)); |
||||
setEditor(new TextFontComboBox.FilterComboBoxEditor()); |
||||
setEditable(true); |
||||
} |
||||
|
||||
public void setItemArray(T[] objectArray) { |
||||
List<T> itemList = new ArrayList<T>(); |
||||
if (objectArray != null) { |
||||
for (int i = 0; i < objectArray.length; i++) { |
||||
itemList.add(objectArray[i]); |
||||
} |
||||
} |
||||
|
||||
this.setItemList(itemList); |
||||
} |
||||
|
||||
public void setItemList(List<T> itemList) { |
||||
((FilterableComboBoxModel) this.getModel()).setPrefix(StringUtils.EMPTY); |
||||
((FilterableComboBoxModel) this.getModel()).setItemList(itemList); |
||||
} |
||||
|
||||
class FilterComboBoxEditor implements ComboBoxEditor, DocumentListener { |
||||
private Object item; |
||||
|
||||
public UITextField textField; |
||||
private volatile boolean filtering = false; |
||||
private volatile boolean setting = false; |
||||
|
||||
public FilterComboBoxEditor() { |
||||
textField = new UITextField(15); |
||||
textField.getDocument().addDocumentListener(this); |
||||
} |
||||
|
||||
public Component getEditorComponent() { |
||||
return textField; |
||||
} |
||||
|
||||
public void setItem(Object item) { |
||||
if (filtering) { |
||||
return; |
||||
} |
||||
this.item = item; |
||||
|
||||
this.setting = true; |
||||
String newText = (item == null) ? StringUtils.EMPTY : item.toString(); |
||||
textField.setText(newText); |
||||
this.setting = false; |
||||
} |
||||
|
||||
public Object getItem() { |
||||
return this.item; |
||||
} |
||||
|
||||
public void selectAll() { |
||||
textField.selectAll(); |
||||
} |
||||
|
||||
public void addActionListener(ActionListener l) { |
||||
textField.addActionListener(l); |
||||
} |
||||
|
||||
public void removeActionListener(ActionListener l) { |
||||
textField.removeActionListener(l); |
||||
} |
||||
|
||||
public void insertUpdate(DocumentEvent e) { |
||||
handleChange(); |
||||
} |
||||
|
||||
public void removeUpdate(DocumentEvent e) { |
||||
handleChange(); |
||||
} |
||||
|
||||
public void changedUpdate(DocumentEvent e) { |
||||
handleChange(); |
||||
} |
||||
|
||||
protected void handleChange() { |
||||
if (setting) { |
||||
return; |
||||
} |
||||
|
||||
filtering = true; |
||||
|
||||
((FilterableComboBoxModel) getModel()).setSelectedItem(textField.getText()); |
||||
this.item = textField.getText(); |
||||
|
||||
setPopupVisible(true); |
||||
filtering = false; |
||||
} |
||||
} |
||||
} |
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue