John.Ying-应志浩
2 years ago
9 changed files with 259 additions and 69 deletions
@ -1,62 +0,0 @@
|
||||
package com.fr.design.widget.btn; |
||||
|
||||
import com.fr.design.gui.icombobox.DictionaryComboBox; |
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.widget.btn.ButtonConstants; |
||||
import com.fr.form.ui.Button; |
||||
|
||||
|
||||
import javax.swing.event.ChangeEvent; |
||||
import javax.swing.event.ChangeListener; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* Created by IntelliJ IDEA. |
||||
* Author : Richer |
||||
* Version: 6.5.6 |
||||
* Date : 11-11-15 |
||||
* Time : 下午6:21 |
||||
*/ |
||||
public abstract class ButtonDetailPane<T extends Button> extends BasicPane { |
||||
private List<ChangeListener> ls = new ArrayList<ChangeListener>(); |
||||
|
||||
@Override |
||||
public String title4PopupWindow() { |
||||
return com.fr.design.i18n.Toolkit.i18nText("Button"); |
||||
} |
||||
|
||||
public void populate(T button) { |
||||
|
||||
} |
||||
|
||||
public abstract T createButton(); |
||||
|
||||
public abstract T update(); |
||||
|
||||
protected void typeChange(Object obj) { |
||||
for (int i = 0, len = ls.size(); i < len; i++) { |
||||
ls.get(i).stateChanged(new ChangeEvent(obj)); |
||||
} |
||||
} |
||||
|
||||
public void addTypeChangeListener(ChangeListener l) { |
||||
ls.add(l); |
||||
} |
||||
|
||||
public abstract Class classType(); |
||||
|
||||
protected DictionaryComboBox createButtonTypeComboBox() { |
||||
final DictionaryComboBox dictionaryComboBox = new DictionaryComboBox(ButtonConstants.CLASSES4BUTTON, ButtonConstants.TYPES4BUTTON, false); |
||||
dictionaryComboBox.setSelectedItem(classType()); |
||||
dictionaryComboBox.addActionListener(new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
typeChange(dictionaryComboBox.getSelectedItem()); |
||||
} |
||||
}); |
||||
return dictionaryComboBox; |
||||
} |
||||
} |
@ -0,0 +1,151 @@
|
||||
package com.fr.design.widget.btn; |
||||
|
||||
import com.fr.design.ExtraDesignClassManager; |
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.fun.WidgetAdvancedPaneProvider; |
||||
import com.fr.design.gui.icombobox.DictionaryComboBox; |
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.form.ui.Button; |
||||
import com.fr.general.GeneralContext; |
||||
import com.fr.plugin.observer.PluginEvent; |
||||
import com.fr.plugin.observer.PluginEventListener; |
||||
|
||||
|
||||
import javax.swing.JPanel; |
||||
import javax.swing.event.ChangeEvent; |
||||
import javax.swing.event.ChangeListener; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
import java.util.Set; |
||||
|
||||
/** |
||||
* Created by IntelliJ IDEA. |
||||
* Author : Richer |
||||
* Version: 6.5.6 |
||||
* Date : 11-11-15 |
||||
* Time : 下午6:21 |
||||
*/ |
||||
public abstract class ButtonDetailPane<T extends Button> extends BasicPane { |
||||
private List<ChangeListener> ls = new ArrayList<ChangeListener>(); |
||||
protected final List<BasicBeanPane<T>> extraPaneList = new ArrayList<>(); |
||||
protected JPanel extraPane; |
||||
protected boolean containsExtraPane; |
||||
protected static double F = TableLayout.FILL; |
||||
protected static double P = TableLayout.PREFERRED; |
||||
@Override |
||||
public String title4PopupWindow() { |
||||
return com.fr.design.i18n.Toolkit.i18nText("Button"); |
||||
} |
||||
|
||||
public void populate(T button) { |
||||
|
||||
} |
||||
|
||||
public abstract T createButton(); |
||||
|
||||
public abstract T update(); |
||||
|
||||
protected void typeChange(Object obj) { |
||||
for (int i = 0, len = ls.size(); i < len; i++) { |
||||
ls.get(i).stateChanged(new ChangeEvent(obj)); |
||||
} |
||||
} |
||||
|
||||
public void addTypeChangeListener(ChangeListener l) { |
||||
ls.add(l); |
||||
} |
||||
|
||||
public abstract Class classType(); |
||||
|
||||
protected DictionaryComboBox createButtonTypeComboBox() { |
||||
// final DictionaryComboBox dictionaryComboBox = new DictionaryComboBox(ButtonConstants.CLASSES4BUTTON, ButtonConstants.TYPES4BUTTON, false);
|
||||
// dictionaryComboBox.setSelectedItem(classType());
|
||||
// dictionaryComboBox.addActionListener(new ActionListener() {
|
||||
// @Override
|
||||
// public void actionPerformed(ActionEvent e) {
|
||||
// typeChange(dictionaryComboBox.getSelectedItem());
|
||||
// }
|
||||
// });
|
||||
// return dictionaryComboBox;
|
||||
return createButtonTypeComboBox(false); |
||||
} |
||||
|
||||
private DictionaryComboBox initDictionaryComboBox(DictionaryComboBox dictionaryComboBox) { |
||||
dictionaryComboBox.setSelectedItem(classType()); |
||||
dictionaryComboBox.addActionListener(new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
typeChange(dictionaryComboBox.getSelectedItem()); |
||||
} |
||||
}); |
||||
return dictionaryComboBox; |
||||
// return createButtonTypeComboBox();
|
||||
} |
||||
|
||||
protected DictionaryComboBox createButtonTypeComboBox(Boolean containsExtraPane) { |
||||
final DictionaryComboBox dictionaryComboBox; |
||||
if (!containsExtraPane) { |
||||
dictionaryComboBox = new DictionaryComboBox(ButtonConstants.CLASSES4BUTTON, ButtonConstants.TYPES4BUTTON, false); |
||||
} else { |
||||
dictionaryComboBox = new DictionaryComboBox(ButtonConstants.CLASSES4BUTTON4STRONGEST_CONTROL, ButtonConstants.TYPES4BUTTON4STRONGEST_CONTROL, false); |
||||
} |
||||
return initDictionaryComboBox(dictionaryComboBox); |
||||
} |
||||
|
||||
|
||||
|
||||
protected void initExtraPane() { |
||||
initPluginListener(); |
||||
refreshExtraAdvancedPane(); |
||||
} |
||||
|
||||
protected void refreshExtraAdvancedPane() { |
||||
// do nothing
|
||||
} |
||||
|
||||
protected void refreshExtraAdvancedPane(Class cls) { |
||||
extraPaneList.clear(); |
||||
boolean containsExtraPane = false; |
||||
Set<WidgetAdvancedPaneProvider<T>> providers = ExtraDesignClassManager.getInstance().getArray(WidgetAdvancedPaneProvider.XML_TAG); |
||||
for (WidgetAdvancedPaneProvider<T> provider : providers) { |
||||
if (!provider.accept(cls)) { |
||||
continue; |
||||
} |
||||
insertShortCut(provider.getInsertPosition(extraPaneList.size()), provider.createExtraAdvancedPane()); |
||||
containsExtraPane = true; |
||||
} |
||||
if (containsExtraPane) { |
||||
extraPane = FRGUIPaneFactory.createYBoxEmptyBorderPane(); |
||||
for (BasicBeanPane<T> pane : extraPaneList) { |
||||
extraPane.add(pane); |
||||
} |
||||
} |
||||
this.containsExtraPane = containsExtraPane; |
||||
|
||||
} |
||||
|
||||
protected void initPluginListener() { |
||||
GeneralContext.listenPluginRunningChanged(new PluginEventListener() { |
||||
@Override |
||||
public void on(PluginEvent event) { |
||||
refreshExtraAdvancedPane(); |
||||
} |
||||
}, pluginContext -> pluginContext.getRuntime().contain(WidgetAdvancedPaneProvider.XML_TAG)); |
||||
} |
||||
|
||||
/** |
||||
* 插入配置项面板 |
||||
* |
||||
* @param index 插入的位置 |
||||
* @param pane 配置项面板 |
||||
*/ |
||||
protected void insertShortCut(int index, BasicBeanPane<T> pane) { |
||||
int size = extraPaneList.size(); |
||||
index = Math.min(index, size); |
||||
extraPaneList.add(index, pane); |
||||
} |
||||
} |
Loading…
Reference in new issue