Browse Source
* commit 'cff86213b7bee3e2f1d83abae7102c2f068a28df': REPORT-6868 设计器数据列单元格切换频繁弹出sql参数对话框; 无任务,删除部分无用代码。 REPORT-3272 之前代码被冲突覆盖了. REPORT-6883 漏传了 REPORT-6883 (这边取的是fitlayout不是对应的button上的背景,兼容性不好处理) REPORT-6769 tab选中后背景变化 无JIRA任务 组件共享readme文件生成问题 REPORT-6769 tab添加一个选中背景 REPORT-6740 9.0切换工作目录和远程设计,卡 REPORT-6740 9.0切换工作目录和远程设计,卡 视觉修改 修复数据库表名带.引起的bug tab按钮添加渐变色设置 无 REPORT-6733 新tab布局vic验收问题以及一些代码质量 REPORT-6260 自适应布局下,选中body,无法粘贴组件了 REPORT-5856 插件管理新分类 平台插件分类过滤失效 代码修改 REPORT-6709 报表块、图表块的样式选了自定义,面板下方没有联动出内容 REPORT-6492 同步9.0 版本管理 验收问题修改
37 changed files with 1014 additions and 835 deletions
@ -1,211 +1,192 @@
|
||||
/* |
||||
* Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved. |
||||
*/ |
||||
package com.fr.design.gui.icombobox; |
||||
|
||||
import java.awt.Dimension; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
import javax.swing.*; |
||||
import javax.swing.event.DocumentEvent; |
||||
import javax.swing.event.DocumentListener; |
||||
import javax.swing.event.PopupMenuEvent; |
||||
import javax.swing.event.PopupMenuListener; |
||||
import javax.swing.plaf.basic.BasicComboPopup; |
||||
|
||||
import com.fr.general.Inter; |
||||
|
||||
/** |
||||
* @author richer |
||||
* @since 6.5.5 创建于2011-6-15 延迟加载的下拉框 |
||||
*/ |
||||
public abstract class LazyComboBox extends UIComboBox implements PopupMenuListener { |
||||
protected boolean loaded = false; |
||||
private List<EventListener> ls = new ArrayList<EventListener>(); |
||||
private Object initialSelected = null; |
||||
private static final int NUM=80; |
||||
|
||||
public static final Object PENDING = new Object() { |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return Inter.getLocText("Loading") + "..."; |
||||
} |
||||
}; |
||||
|
||||
public LazyComboBox() { |
||||
super(); |
||||
this.setEditor(new FilterComboBoxEditor()); |
||||
addPopupMenuListener(this); |
||||
// updateUI();
|
||||
} |
||||
|
||||
public void setLoaded(boolean loaded) { |
||||
this.loaded = loaded; |
||||
} |
||||
|
||||
public abstract Object[] load(); |
||||
|
||||
public void setSelectedItem(Object anObject) { |
||||
initialSelected = anObject; |
||||
if (loaded) { |
||||
super.setSelectedItem(anObject); |
||||
} else { |
||||
|
||||
setModel(new DefaultComboBoxModel(new Object[] { anObject })); |
||||
super.setSelectedItem(anObject); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 通过调用该方法,在点击下拉框按钮之前就加载好数据,不需要出现loading了 |
||||
*/ |
||||
public void loadInstant() { |
||||
setLoaded(true); |
||||
loadList(); |
||||
} |
||||
|
||||
@Override |
||||
public void popupMenuWillBecomeVisible(PopupMenuEvent e) { |
||||
if (loaded) { |
||||
return; |
||||
} |
||||
DefaultComboBoxModel loadingModel = new DefaultComboBoxModel(new String[]{"", Inter.getLocText("Loading") + "..."}); |
||||
LazyComboBox.this.setModel(loadingModel); |
||||
new SwingWorker<Void, Void>() { |
||||
|
||||
@Override |
||||
protected Void doInBackground() throws Exception { |
||||
final Object selectedObj = getSelectedItem(); |
||||
loadList(); |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public void done() { |
||||
LazyComboBox.this.updateUI(); |
||||
LazyComboBox.this.fireEvent(); |
||||
LazyComboBox.this.showPopup(); |
||||
} |
||||
|
||||
}.execute(); |
||||
|
||||
|
||||
} |
||||
|
||||
/** |
||||
* 计算加载下拉列表 |
||||
*/ |
||||
public void loadList() { |
||||
DefaultComboBoxModel model = new DefaultComboBoxModel(load()); |
||||
model.setSelectedItem(initialSelected); |
||||
LazyComboBox.this.setModel(model); |
||||
LazyComboBox.this.selectedItemReminder = initialSelected ; |
||||
loaded = true; |
||||
} |
||||
|
||||
@Override |
||||
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void popupMenuCanceled(PopupMenuEvent e) { |
||||
|
||||
} |
||||
|
||||
public void addClickListener(EventListener l) { |
||||
if (ls == null) { |
||||
ls = new ArrayList<LazyComboBox.EventListener>(); |
||||
} |
||||
ls.add(l); |
||||
} |
||||
|
||||
public void fireEvent() { |
||||
for (int i = 0, n = ls.size(); i < n; i++) { |
||||
ls.get(i).fireEvent(); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public Dimension getPreferredSize() { |
||||
Dimension dim = super.getPreferredSize(); |
||||
dim.width = NUM; |
||||
return dim; |
||||
} |
||||
|
||||
private static class LazyPopMenu extends BasicComboPopup { |
||||
|
||||
public LazyPopMenu(final JComboBox combo) { |
||||
super(combo); |
||||
LazyComboBox comboc = (LazyComboBox) combo; |
||||
comboc.addClickListener(new EventListener() { |
||||
|
||||
@Override |
||||
public void fireEvent() { |
||||
LazyPopMenu.this.show(); |
||||
combo.showPopup(); |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
|
||||
private interface EventListener { |
||||
void fireEvent(); |
||||
} |
||||
|
||||
class FilterComboBoxEditor extends UIComboBoxEditor implements DocumentListener { |
||||
private Object item; |
||||
private volatile boolean filtering = false; |
||||
private volatile boolean setting = false; |
||||
|
||||
public FilterComboBoxEditor() { |
||||
super(); |
||||
textField.getDocument().addDocumentListener(this); |
||||
} |
||||
|
||||
public void setItem(Object item) { |
||||
if (filtering) { |
||||
return; |
||||
} |
||||
this.item = item; |
||||
|
||||
this.setting = true; |
||||
textField.setSetting(true); |
||||
String newText = (item == null) ? "" : item.toString(); |
||||
textField.setText(newText); |
||||
textField.setSetting(false); |
||||
this.setting = false; |
||||
} |
||||
|
||||
public Object getItem() { |
||||
return this.item; |
||||
} |
||||
|
||||
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; |
||||
String xx = textField.getText(); |
||||
LazyComboBox.this.setSelectedItem(xx); |
||||
this.item = textField.getText(); |
||||
|
||||
setPopupVisible(true); |
||||
filtering = false; |
||||
} |
||||
} |
||||
/* |
||||
* Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved. |
||||
*/ |
||||
package com.fr.design.gui.icombobox; |
||||
|
||||
import com.fr.general.FRLogger; |
||||
import com.fr.general.Inter; |
||||
|
||||
import javax.swing.DefaultComboBoxModel; |
||||
import javax.swing.SwingWorker; |
||||
import javax.swing.event.DocumentEvent; |
||||
import javax.swing.event.DocumentListener; |
||||
import javax.swing.event.PopupMenuEvent; |
||||
import javax.swing.event.PopupMenuListener; |
||||
import java.awt.Dimension; |
||||
import java.util.concurrent.ExecutionException; |
||||
|
||||
/** |
||||
* @author richer |
||||
* @version 2018年2月6日14点43分 by @yaoh.wu |
||||
* @since 6.5.5 创建于2011-6-15 延迟加载的下拉框 |
||||
*/ |
||||
public abstract class LazyComboBox extends UIComboBox implements PopupMenuListener { |
||||
|
||||
private static final int NUM = 80; |
||||
private static final String[] PENDING_CONTENT = new String[]{"", Inter.getLocText("Loading") + "..."}; |
||||
|
||||
/** |
||||
* 是否加载完成 |
||||
*/ |
||||
protected boolean loaded = false; |
||||
|
||||
/** |
||||
* 初始化选项 |
||||
*/ |
||||
private Object initialSelected = null; |
||||
|
||||
|
||||
protected LazyComboBox() { |
||||
super(); |
||||
this.setEditor(new FilterComboBoxEditor()); |
||||
addPopupMenuListener(this); |
||||
} |
||||
|
||||
public void setLoaded(boolean loaded) { |
||||
this.loaded = loaded; |
||||
} |
||||
|
||||
/** |
||||
* 加载下拉框中的选项 |
||||
* |
||||
* @return 下拉框中的选项 |
||||
*/ |
||||
public abstract Object[] load(); |
||||
|
||||
@Override |
||||
public void setSelectedItem(Object anObject) { |
||||
initialSelected = anObject; |
||||
if (loaded) { |
||||
super.setSelectedItem(anObject); |
||||
} else { |
||||
this.setModel(new DefaultComboBoxModel<>(new Object[]{anObject})); |
||||
super.setSelectedItem(anObject); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void popupMenuWillBecomeVisible(PopupMenuEvent e) { |
||||
if (loaded) { |
||||
return; |
||||
} |
||||
DefaultComboBoxModel<String> loadingModel = new DefaultComboBoxModel<>(PENDING_CONTENT); |
||||
this.setModel(loadingModel); |
||||
new SwingWorker<Object[], Void>() { |
||||
|
||||
@Override |
||||
protected Object[] doInBackground() { |
||||
return load(); |
||||
} |
||||
|
||||
@Override |
||||
public void done() { |
||||
try { |
||||
LazyComboBox.this.loadList(get()); |
||||
} catch (InterruptedException | ExecutionException exception) { |
||||
FRLogger.getLogger().debug(exception.getMessage()); |
||||
} |
||||
LazyComboBox.this.showPopup(); |
||||
} |
||||
}.execute(); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 加载下拉列表 |
||||
*/ |
||||
public void loadList() { |
||||
DefaultComboBoxModel<Object> model = new DefaultComboBoxModel<>(load()); |
||||
model.setSelectedItem(initialSelected); |
||||
this.setModel(model); |
||||
this.selectedItemReminder = initialSelected; |
||||
loaded = true; |
||||
} |
||||
|
||||
/** |
||||
* 加载下拉列表 |
||||
* |
||||
* @param contents 下拉列表内容 |
||||
*/ |
||||
private void loadList(Object[] contents) { |
||||
DefaultComboBoxModel<Object> model = new DefaultComboBoxModel<>(contents); |
||||
model.setSelectedItem(initialSelected); |
||||
this.setModel(model); |
||||
this.selectedItemReminder = initialSelected; |
||||
loaded = true; |
||||
} |
||||
|
||||
@Override |
||||
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void popupMenuCanceled(PopupMenuEvent e) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public Dimension getPreferredSize() { |
||||
Dimension dim = super.getPreferredSize(); |
||||
dim.width = NUM; |
||||
return dim; |
||||
} |
||||
|
||||
class FilterComboBoxEditor extends UIComboBoxEditor implements DocumentListener { |
||||
private Object item; |
||||
private volatile boolean filtering = false; |
||||
private volatile boolean setting = false; |
||||
|
||||
public FilterComboBoxEditor() { |
||||
super(); |
||||
textField.getDocument().addDocumentListener(this); |
||||
} |
||||
|
||||
@Override |
||||
public void setItem(Object item) { |
||||
if (filtering) { |
||||
return; |
||||
} |
||||
this.item = item; |
||||
this.setting = true; |
||||
textField.setSetting(true); |
||||
String newText = (item == null) ? "" : item.toString(); |
||||
textField.setText(newText); |
||||
textField.setSetting(false); |
||||
this.setting = false; |
||||
} |
||||
|
||||
@Override |
||||
public Object getItem() { |
||||
return this.item; |
||||
} |
||||
|
||||
@Override |
||||
public void insertUpdate(DocumentEvent e) { |
||||
handleChange(); |
||||
} |
||||
|
||||
@Override |
||||
public void removeUpdate(DocumentEvent e) { |
||||
handleChange(); |
||||
} |
||||
|
||||
@Override |
||||
public void changedUpdate(DocumentEvent e) { |
||||
handleChange(); |
||||
} |
||||
|
||||
void handleChange() { |
||||
if (setting) { |
||||
return; |
||||
} |
||||
filtering = true; |
||||
String xx = textField.getText(); |
||||
LazyComboBox.this.setSelectedItem(xx); |
||||
this.item = textField.getText(); |
||||
|
||||
setPopupVisible(true); |
||||
filtering = false; |
||||
} |
||||
} |
||||
} |
@ -1,214 +1,198 @@
|
||||
package com.fr.design.gui.icombobox; |
||||
|
||||
import com.fr.design.event.GlobalNameListener; |
||||
import com.fr.design.event.GlobalNameObserver; |
||||
import com.fr.design.event.UIObserver; |
||||
import com.fr.design.event.UIObserverListener; |
||||
import com.fr.design.utils.gui.GUICoreUtils; |
||||
|
||||
import javax.swing.*; |
||||
import javax.swing.plaf.ComboBoxUI; |
||||
import javax.swing.plaf.basic.ComboPopup; |
||||
import java.awt.*; |
||||
import java.awt.event.FocusAdapter; |
||||
import java.awt.event.FocusEvent; |
||||
import java.awt.event.ItemEvent; |
||||
import java.awt.event.ItemListener; |
||||
import java.util.Vector; |
||||
|
||||
/** |
||||
* august:非常beautiful的ComboBox,不支持编辑状态. 内容过长时,鼠标移动过去会有ToolTips,不会有横向滚动条 |
||||
* 假如支持编辑,因为UIComboBox的TextField 的绘制 并不是靠Renderer来控制 , |
||||
* 它会通过paintCurrentValueBackground()来绘制背景, |
||||
* 然后通过paintCurrentValue(),去绘制UIComboBox里显示的值。所考虑情况比现在复杂多多多多多了,所以暂时不支持 |
||||
* 另外,项的内容最好不要有图标 |
||||
* |
||||
* @author zhou |
||||
* @since 2012-5-9下午3:18:58 |
||||
*/ |
||||
public class UIComboBox extends JComboBox implements UIObserver, GlobalNameObserver { |
||||
|
||||
/** |
||||
* |
||||
*/ |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
private static final int SIZE = 20; |
||||
|
||||
private static final int SIZE5 = 5; |
||||
|
||||
protected UIObserverListener uiObserverListener; |
||||
|
||||
private String comboBoxName = ""; |
||||
|
||||
private GlobalNameListener globalNameListener = null; |
||||
|
||||
public UIComboBox() { |
||||
super(); |
||||
init(); |
||||
} |
||||
|
||||
public UIComboBox(ComboBoxModel model) { |
||||
super(model); |
||||
init(); |
||||
} |
||||
|
||||
public UIComboBox(Object[] items) { |
||||
super(items); |
||||
init(); |
||||
} |
||||
|
||||
public UIComboBox(Vector<?> items) { |
||||
super(items); |
||||
init(); |
||||
} |
||||
|
||||
private void init() { |
||||
setOpaque(false); |
||||
setUI(getUIComboBoxUI()); |
||||
setRenderer(new UIComboBoxRenderer()); |
||||
setEditor(new UIComboBoxEditor()); |
||||
initListener(); |
||||
} |
||||
|
||||
protected void initListener() { |
||||
if (shouldResponseChangeListener()) { |
||||
this.addFocusListener(new FocusAdapter() { |
||||
@Override |
||||
public void focusGained(FocusEvent e) { |
||||
fireSetGlobalName(); |
||||
} |
||||
}); |
||||
this.addItemListener(new ItemListener() { |
||||
@Override |
||||
public void itemStateChanged(ItemEvent e) { |
||||
if (uiObserverListener == null) { |
||||
return; |
||||
} |
||||
fireSetGlobalName(); |
||||
if (e.getStateChange() == ItemEvent.SELECTED) { |
||||
uiObserverListener.doChange(); |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
|
||||
protected void fireSetGlobalName() { |
||||
if (globalNameListener != null && shouldResponseNameListener()) { |
||||
globalNameListener.setGlobalName(comboBoxName); |
||||
} |
||||
} |
||||
|
||||
|
||||
protected ComboBoxUI getUIComboBoxUI() { |
||||
return new UIComboBoxUI(); |
||||
} |
||||
|
||||
/** |
||||
* 只允许设置为UIComboBoxRenderer,所以要继承UIComboBoxRenderer |
||||
*/ |
||||
@Override |
||||
public void setRenderer(ListCellRenderer aRenderer) { |
||||
if (aRenderer instanceof UIComboBoxRenderer) { |
||||
super.setRenderer(aRenderer); |
||||
} else { |
||||
//throw new IllegalArgumentException("Must be UIComboBoxRenderer");
|
||||
} |
||||
} |
||||
|
||||
protected ComboPopup createPopup() { |
||||
return null; |
||||
} |
||||
|
||||
public void setGlobalName(String name) { |
||||
comboBoxName = name; |
||||
} |
||||
|
||||
@Override |
||||
public Dimension getPreferredSize() { |
||||
return new Dimension(super.getPreferredSize().width + SIZE5, SIZE);//加5的原因在于:render里,每一个项前面了空了一格,要多几像素
|
||||
} |
||||
|
||||
/** |
||||
* 鼠标进入事件 |
||||
*/ |
||||
public void mouseEnterEvent() { |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 鼠标离开事件 |
||||
*/ |
||||
public void mouseExitEvent() { |
||||
|
||||
} |
||||
|
||||
/** |
||||
* |
||||
*/ |
||||
public void updateUI() { |
||||
setUI(getUIComboBoxUI()); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* |
||||
* @param listener 观察者监听事件 |
||||
*/ |
||||
public void registerChangeListener(UIObserverListener listener) { |
||||
uiObserverListener = listener; |
||||
} |
||||
|
||||
public void removeChangeListener(){ |
||||
uiObserverListener = null; |
||||
} |
||||
|
||||
public UIObserverListener getUiObserverListener(){ |
||||
return uiObserverListener; |
||||
} |
||||
|
||||
/** |
||||
* @return |
||||
*/ |
||||
public boolean shouldResponseChangeListener() { |
||||
return true; |
||||
} |
||||
|
||||
/** |
||||
* |
||||
* @param listener 观察者监听事件 |
||||
*/ |
||||
public void registerNameListener(GlobalNameListener listener) { |
||||
globalNameListener = listener; |
||||
} |
||||
|
||||
/** |
||||
* |
||||
* @return |
||||
*/ |
||||
public boolean shouldResponseNameListener() { |
||||
return true; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* @param args |
||||
*/ |
||||
public static void main(String... args) { |
||||
LayoutManager layoutManager = null; |
||||
JFrame jf = new JFrame("test"); |
||||
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
||||
JPanel content = (JPanel) jf.getContentPane(); |
||||
content.setLayout(layoutManager); |
||||
UIComboBox bb = new UIComboBox(new String[]{"", "jerry", "kunsnat", "richer"}); |
||||
bb.setEditable(true); |
||||
bb.setBounds(20, 20, bb.getPreferredSize().width, bb.getPreferredSize().height); |
||||
content.add(bb); |
||||
GUICoreUtils.centerWindow(jf); |
||||
jf.setSize(400, 400); |
||||
jf.setVisible(true); |
||||
} |
||||
|
||||
|
||||
package com.fr.design.gui.icombobox; |
||||
|
||||
import com.fr.design.event.GlobalNameListener; |
||||
import com.fr.design.event.GlobalNameObserver; |
||||
import com.fr.design.event.UIObserver; |
||||
import com.fr.design.event.UIObserverListener; |
||||
|
||||
import javax.swing.ComboBoxModel; |
||||
import javax.swing.JComboBox; |
||||
import javax.swing.ListCellRenderer; |
||||
import javax.swing.plaf.ComboBoxUI; |
||||
import javax.swing.plaf.basic.ComboPopup; |
||||
import java.awt.Dimension; |
||||
import java.awt.event.FocusAdapter; |
||||
import java.awt.event.FocusEvent; |
||||
import java.awt.event.ItemEvent; |
||||
import java.awt.event.ItemListener; |
||||
import java.util.Vector; |
||||
|
||||
/** |
||||
* august:非常beautiful的ComboBox,不支持编辑状态. 内容过长时,鼠标移动过去会有ToolTips,不会有横向滚动条 |
||||
* 假如支持编辑,因为UIComboBox的TextField 的绘制 并不是靠Renderer来控制 , |
||||
* 它会通过paintCurrentValueBackground()来绘制背景, |
||||
* 然后通过paintCurrentValue(),去绘制UIComboBox里显示的值。所考虑情况比现在复杂多多多多多了,所以暂时不支持 |
||||
* 另外,项的内容最好不要有图标 |
||||
* |
||||
* @author zhou |
||||
* @since 2012-5-9下午3:18:58 |
||||
*/ |
||||
public class UIComboBox extends JComboBox implements UIObserver, GlobalNameObserver { |
||||
|
||||
/** |
||||
* |
||||
*/ |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
private static final int SIZE = 20; |
||||
|
||||
private static final int SIZE5 = 5; |
||||
|
||||
protected UIObserverListener uiObserverListener; |
||||
|
||||
private String comboBoxName = ""; |
||||
|
||||
private GlobalNameListener globalNameListener = null; |
||||
|
||||
public UIComboBox() { |
||||
super(); |
||||
init(); |
||||
} |
||||
|
||||
public UIComboBox(ComboBoxModel model) { |
||||
super(model); |
||||
init(); |
||||
} |
||||
|
||||
public UIComboBox(Object[] items) { |
||||
super(items); |
||||
init(); |
||||
} |
||||
|
||||
public UIComboBox(Vector<?> items) { |
||||
super(items); |
||||
init(); |
||||
} |
||||
|
||||
private void init() { |
||||
setOpaque(false); |
||||
setUI(getUIComboBoxUI()); |
||||
setRenderer(new UIComboBoxRenderer()); |
||||
setEditor(new UIComboBoxEditor()); |
||||
initListener(); |
||||
} |
||||
|
||||
protected void initListener() { |
||||
if (shouldResponseChangeListener()) { |
||||
this.addFocusListener(new FocusAdapter() { |
||||
@Override |
||||
public void focusGained(FocusEvent e) { |
||||
fireSetGlobalName(); |
||||
} |
||||
}); |
||||
this.addItemListener(new ItemListener() { |
||||
@Override |
||||
public void itemStateChanged(ItemEvent e) { |
||||
if (uiObserverListener == null) { |
||||
return; |
||||
} |
||||
fireSetGlobalName(); |
||||
if (e.getStateChange() == ItemEvent.SELECTED) { |
||||
uiObserverListener.doChange(); |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
|
||||
protected void fireSetGlobalName() { |
||||
if (globalNameListener != null && shouldResponseNameListener()) { |
||||
globalNameListener.setGlobalName(comboBoxName); |
||||
} |
||||
} |
||||
|
||||
|
||||
protected ComboBoxUI getUIComboBoxUI() { |
||||
return new UIComboBoxUI(); |
||||
} |
||||
|
||||
/** |
||||
* 只允许设置为UIComboBoxRenderer,所以要继承UIComboBoxRenderer |
||||
*/ |
||||
@Override |
||||
public void setRenderer(ListCellRenderer aRenderer) { |
||||
if (aRenderer instanceof UIComboBoxRenderer) { |
||||
super.setRenderer(aRenderer); |
||||
} |
||||
} |
||||
|
||||
protected ComboPopup createPopup() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public void setGlobalName(String name) { |
||||
comboBoxName = name; |
||||
} |
||||
|
||||
@Override |
||||
public Dimension getPreferredSize() { |
||||
//加5的原因在于:render里,每一个项前面了空了一格,要多几像素
|
||||
return new Dimension(super.getPreferredSize().width + SIZE5, SIZE); |
||||
} |
||||
|
||||
/** |
||||
* 鼠标进入事件 |
||||
*/ |
||||
public void mouseEnterEvent() { |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 鼠标离开事件 |
||||
*/ |
||||
public void mouseExitEvent() { |
||||
|
||||
} |
||||
|
||||
/** |
||||
* |
||||
*/ |
||||
@Override |
||||
public void updateUI() { |
||||
setUI(getUIComboBoxUI()); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* @param listener 观察者监听事件 |
||||
*/ |
||||
@Override |
||||
public void registerChangeListener(UIObserverListener listener) { |
||||
uiObserverListener = listener; |
||||
} |
||||
|
||||
public void removeChangeListener() { |
||||
uiObserverListener = null; |
||||
} |
||||
|
||||
public UIObserverListener getUiObserverListener() { |
||||
return uiObserverListener; |
||||
} |
||||
|
||||
/** |
||||
* @return 是否响应变更事件 |
||||
*/ |
||||
@Override |
||||
public boolean shouldResponseChangeListener() { |
||||
return true; |
||||
} |
||||
|
||||
/** |
||||
* @param listener 观察者监听事件 |
||||
*/ |
||||
@Override |
||||
public void registerNameListener(GlobalNameListener listener) { |
||||
globalNameListener = listener; |
||||
} |
||||
|
||||
/** |
||||
* @return 是否响应名称事件 |
||||
*/ |
||||
@Override |
||||
public boolean shouldResponseNameListener() { |
||||
return true; |
||||
} |
||||
|
||||
|
||||
} |
@ -1,40 +1,17 @@
|
||||
package com.fr.design.mainframe.widget.accessibles; |
||||
|
||||
import com.fr.base.background.ColorBackground; |
||||
import com.fr.design.dialog.BasicDialog; |
||||
import com.fr.design.dialog.DialogActionAdapter; |
||||
import com.fr.design.mainframe.widget.wrappers.BackgroundWrapper; |
||||
import com.fr.design.style.background.BackgroundTabPane; |
||||
import com.fr.general.Background; |
||||
|
||||
import javax.swing.SwingUtilities; |
||||
import java.awt.Dimension; |
||||
|
||||
import com.fr.design.style.background.BackgroundButtonPane; |
||||
import com.fr.design.style.background.BackgroundCardSwitchButtonPane; |
||||
/** |
||||
* @author kerry |
||||
* @date 2018/1/17 |
||||
* @date 2018/1/29 |
||||
*/ |
||||
public class AccessibleTabBackgroundEditor extends UneditableAccessibleEditor { |
||||
private BackgroundTabPane choosePane; |
||||
|
||||
public class AccessibleTabBackgroundEditor extends AccessibleImgBackgroundEditor { |
||||
public AccessibleTabBackgroundEditor() { |
||||
super(new BackgroundWrapper()); |
||||
super(); |
||||
} |
||||
|
||||
@Override |
||||
protected void showEditorPane() { |
||||
choosePane = new BackgroundTabPane(); |
||||
choosePane.setPreferredSize(new Dimension(600, 400)); |
||||
BasicDialog dlg = choosePane.showWindow(SwingUtilities.getWindowAncestor(this)); |
||||
dlg.addDialogActionListener(new DialogActionAdapter() { |
||||
|
||||
@Override |
||||
public void doOk() { |
||||
setValue(choosePane.update()); |
||||
fireStateChanged(); |
||||
} |
||||
}); |
||||
choosePane.populate(getValue() instanceof Background ? (Background) getValue() : new ColorBackground()); |
||||
dlg.setVisible(true); |
||||
protected BackgroundButtonPane initBackgroundPane(){ |
||||
return new BackgroundCardSwitchButtonPane(); |
||||
} |
||||
} |
||||
} |
||||
|
@ -0,0 +1,40 @@
|
||||
package com.fr.design.mainframe.widget.accessibles; |
||||
|
||||
import com.fr.base.background.ColorBackground; |
||||
import com.fr.design.dialog.BasicDialog; |
||||
import com.fr.design.dialog.DialogActionAdapter; |
||||
import com.fr.design.mainframe.widget.wrappers.BackgroundWrapper; |
||||
import com.fr.design.style.background.BackgroundTabPane; |
||||
import com.fr.general.Background; |
||||
|
||||
import javax.swing.SwingUtilities; |
||||
import java.awt.Dimension; |
||||
|
||||
/** |
||||
* @author kerry |
||||
* @date 2018/1/17 |
||||
*/ |
||||
public class AccessibleTabPaneBackgroundEditor extends UneditableAccessibleEditor { |
||||
private BackgroundTabPane choosePane; |
||||
|
||||
public AccessibleTabPaneBackgroundEditor() { |
||||
super(new BackgroundWrapper()); |
||||
} |
||||
|
||||
@Override |
||||
protected void showEditorPane() { |
||||
choosePane = new BackgroundTabPane(); |
||||
choosePane.setPreferredSize(new Dimension(600, 400)); |
||||
BasicDialog dlg = choosePane.showWindow(SwingUtilities.getWindowAncestor(this)); |
||||
dlg.addDialogActionListener(new DialogActionAdapter() { |
||||
|
||||
@Override |
||||
public void doOk() { |
||||
setValue(choosePane.update()); |
||||
fireStateChanged(); |
||||
} |
||||
}); |
||||
choosePane.populate(getValue() instanceof Background ? (Background) getValue() : new ColorBackground()); |
||||
dlg.setVisible(true); |
||||
} |
||||
} |
@ -0,0 +1,95 @@
|
||||
package com.fr.design.style.background; |
||||
|
||||
import com.fr.base.background.ColorBackground; |
||||
import com.fr.base.background.GradientBackground; |
||||
import com.fr.base.background.ImageBackground; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.style.background.gradient.GradientBackgroundPane; |
||||
import com.fr.design.style.background.impl.ColorBackgroundPane; |
||||
import com.fr.design.style.background.impl.ImageBackgroundPane; |
||||
import com.fr.design.style.background.impl.NullBackgroundPane; |
||||
import com.fr.general.Background; |
||||
import com.fr.general.Inter; |
||||
|
||||
import java.util.LinkedHashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author kerry |
||||
* @date 2018/1/29 |
||||
*/ |
||||
public class BackgroundCardSwitchButtonPane extends BackgroundButtonPane { |
||||
|
||||
private static Map<Class<? extends Background>, BackgroundUIWrapper> cardSwitchButton = new LinkedHashMap<>(); |
||||
|
||||
static { |
||||
registerCardSwitchBtnBackground(cardSwitchButton); |
||||
} |
||||
|
||||
|
||||
private static void registerCardSwitchBtnBackground(Map<Class<? extends Background>, BackgroundUIWrapper> map) { |
||||
map.put(ColorBackground.class, BackgroundUIWrapper.create() |
||||
.setType(ColorBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Color"))); |
||||
map.put(ImageBackground.class, BackgroundUIWrapper.create() |
||||
.setType(ImageBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Image"))); |
||||
map.put(GradientBackground.class, BackgroundUIWrapper.create() |
||||
.setType(GradientBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Gradient_Color"))); |
||||
|
||||
} |
||||
|
||||
public BackgroundCardSwitchButtonPane() { |
||||
super(); |
||||
} |
||||
|
||||
@Override |
||||
protected void initTabPane() { |
||||
int index = 0; |
||||
for (Class<? extends Background> key : cardSwitchButton.keySet()) { |
||||
BackgroundUIWrapper wrapper = cardSwitchButton.get(key); |
||||
wrapper.setIndex(index++); |
||||
tabbedPane.addTab(Inter.getLocText(wrapper.getTitle()), FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane()); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
protected BackgroundUIWrapper getBackgroundUIWrapper(Background background) { |
||||
return cardSwitchButton.get(background == null ? null : background.getClass()); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
protected BackgroundDetailPane getTabItemPane(Background background, int index) { |
||||
BackgroundDetailPane quickPane = cacheMap.get(index); |
||||
if (quickPane == null) { |
||||
BackgroundUIWrapper uiWrapper = getBackgroundUIWrapper(background); |
||||
quickPane = BackgroundFactory.createByWrapper(uiWrapper); |
||||
quickPane.addChangeListener(backgroundChangeListener); |
||||
cacheMap.put(index, quickPane); |
||||
} |
||||
tabbedPane.setComponentAt(index, quickPane); |
||||
tabbedPane.setSelectedIndex(index); |
||||
return quickPane; |
||||
} |
||||
|
||||
@Override |
||||
protected BackgroundDetailPane getTabItemPaneByIndex(int index) { |
||||
BackgroundDetailPane quickPane = cacheMap.get(index); |
||||
if (quickPane == null) { |
||||
quickPane = createDetailPaneByIndex(index); |
||||
tabbedPane.setComponentAt(index, quickPane); |
||||
cacheMap.put(index, quickPane); |
||||
quickPane.addChangeListener(backgroundChangeListener); |
||||
} |
||||
return quickPane; |
||||
} |
||||
|
||||
public BackgroundDetailPane createDetailPaneByIndex(int index) { |
||||
for (BackgroundUIWrapper wrapper : cardSwitchButton.values()) { |
||||
if (wrapper.getIndex() == index) { |
||||
return BackgroundFactory.createByWrapper(wrapper); |
||||
} |
||||
} |
||||
return new NullBackgroundPane(); |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue