John.Ying-应志浩
2 years ago
11 changed files with 214 additions and 244 deletions
@ -0,0 +1,74 @@
|
||||
package com.fr.design.widget.btn; |
||||
|
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.gui.icombobox.DictionaryComboBox; |
||||
import com.fr.design.dialog.BasicPane; |
||||
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>(); |
||||
protected final List<BasicBeanPane<T>> extraPaneList = new ArrayList<>(); |
||||
@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() { |
||||
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; |
||||
} |
||||
|
||||
protected DictionaryComboBox createButtonTypeComboBox(Boolean containsExtraPane) { |
||||
final DictionaryComboBox dictionaryComboBox; |
||||
if (!containsExtraPane) { |
||||
dictionaryComboBox = new DictionaryComboBox(ButtonConstants.CLASSES4BUTTON, ButtonConstants.TYPES4BUTTON, false); |
||||
} else { |
||||
dictionaryComboBox = new DictionaryComboBox(ButtonConstants.CLASSES_BUTTON_NO_FREE, ButtonConstants.TYPES_BUTTON_NO_FREE, false); |
||||
} |
||||
return initDictionaryComboBox(dictionaryComboBox); |
||||
} |
||||
} |
@ -1,151 +0,0 @@
|
||||
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); |
||||
} |
||||
} |
@ -0,0 +1,111 @@
|
||||
package com.fr.design.widget.ui.btn; |
||||
|
||||
import com.fr.design.ExtraDesignClassManager; |
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.fun.WidgetAdvancedPaneProvider; |
||||
import com.fr.design.gui.icombobox.DictionaryComboBox; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.design.widget.btn.ButtonWithHotkeysDetailPane; |
||||
import com.fr.form.ui.Button; |
||||
import com.fr.general.GeneralContext; |
||||
import com.fr.plugin.observer.PluginEvent; |
||||
import com.fr.plugin.observer.PluginEventListener; |
||||
import org.jetbrains.annotations.Nullable; |
||||
|
||||
import javax.swing.JPanel; |
||||
import java.awt.Component; |
||||
import java.util.Set; |
||||
|
||||
|
||||
public abstract class ExtraButtonPane<T extends Button> extends ButtonWithHotkeysDetailPane<T> { |
||||
protected JPanel extraPane; |
||||
protected boolean containsExtraPane; |
||||
protected static double F = TableLayout.FILL; |
||||
protected static double P = TableLayout.PREFERRED; |
||||
|
||||
protected void initExtraPane() { |
||||
initPluginListener(); |
||||
refreshExtraAdvancedPane(classType()); |
||||
} |
||||
|
||||
|
||||
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(classType()); |
||||
} |
||||
}, 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); |
||||
} |
||||
|
||||
@Override |
||||
public void populate(T button) { |
||||
super.populate(button); |
||||
for (BasicBeanPane<T> pane : extraPaneList) { |
||||
pane.populateBean(button); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public T update() { |
||||
T button = super.update(); |
||||
for (BasicBeanPane<T> pane : extraPaneList) { |
||||
pane.updateBean(button); |
||||
} |
||||
return button; |
||||
} |
||||
|
||||
@Override |
||||
protected DictionaryComboBox createCustomButtonTypeComboBox() { |
||||
return createButtonTypeComboBox(containsExtraPane); |
||||
} |
||||
|
||||
protected Component createExtraPane(@Nullable BasicPane pane) { |
||||
initExtraPane(); |
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{pane, null}, |
||||
new Component[]{extraPane, null} |
||||
}; |
||||
double[] rowSize = {P, P}; |
||||
double[] columnSize = {P, F}; |
||||
int[][] rowCount = {{1, 1},{1, 1}}; |
||||
return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, 10, 7); |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue