|
|
|
@ -1,21 +1,34 @@
|
|
|
|
|
package com.fr.design.widget.ui; |
|
|
|
|
|
|
|
|
|
import com.fr.design.ExtraDesignClassManager; |
|
|
|
|
import com.fr.design.beans.BasicBeanPane; |
|
|
|
|
import com.fr.design.designer.IntervalConstants; |
|
|
|
|
import com.fr.design.foldablepane.UIExpandablePane; |
|
|
|
|
import com.fr.design.fun.WidgetAdvancedPaneProvider; |
|
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
|
import com.fr.design.gui.itextfield.UITextField; |
|
|
|
|
import com.fr.design.layout.FRGUIPaneFactory; |
|
|
|
|
import com.fr.design.layout.TableLayout; |
|
|
|
|
import com.fr.design.layout.TableLayoutHelper; |
|
|
|
|
import com.fr.form.ui.CheckBox; |
|
|
|
|
import com.fr.general.GeneralContext; |
|
|
|
|
import com.fr.plugin.observer.PluginEvent; |
|
|
|
|
import com.fr.plugin.observer.PluginEventListener; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
|
import java.awt.*; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Set; |
|
|
|
|
|
|
|
|
|
public class CheckBoxDefinePane extends AbstractDataModify<CheckBox> { |
|
|
|
|
private UITextField text; |
|
|
|
|
protected final List<BasicBeanPane<CheckBox>> extraPaneList = new ArrayList<>(); |
|
|
|
|
protected JPanel extraPane; |
|
|
|
|
|
|
|
|
|
protected static double F = TableLayout.FILL; |
|
|
|
|
protected static double P = TableLayout.PREFERRED; |
|
|
|
|
public CheckBoxDefinePane() { |
|
|
|
|
this.iniComponents(); |
|
|
|
|
} |
|
|
|
@ -23,14 +36,14 @@ public class CheckBoxDefinePane extends AbstractDataModify<CheckBox> {
|
|
|
|
|
private void iniComponents() { |
|
|
|
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
|
|
|
text = new UITextField(); |
|
|
|
|
double f = TableLayout.FILL; |
|
|
|
|
double p = TableLayout.PREFERRED; |
|
|
|
|
initExtraPane(); |
|
|
|
|
Component[][] components = new Component[][]{ |
|
|
|
|
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Text")), text}, |
|
|
|
|
new Component[]{extraPane, null}, |
|
|
|
|
}; |
|
|
|
|
double[] rowSize = {p}; |
|
|
|
|
double[] columnSize = {p, f}; |
|
|
|
|
int[][] rowCount = {{1, 1}}; |
|
|
|
|
double[] rowSize = {P,P}; |
|
|
|
|
double[] columnSize = {P, F}; |
|
|
|
|
int[][] rowCount = {{1, 1}, {1, 1}}; |
|
|
|
|
JPanel pane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W3, IntervalConstants.INTERVAL_L1); |
|
|
|
|
|
|
|
|
|
UIExpandablePane uiExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 24, pane); |
|
|
|
@ -39,6 +52,51 @@ public class CheckBoxDefinePane extends AbstractDataModify<CheckBox> {
|
|
|
|
|
this.add(uiExpandablePane); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected void initExtraPane() { |
|
|
|
|
initPluginListener(); |
|
|
|
|
refreshExtraAdvancedPane(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected void refreshExtraAdvancedPane() { |
|
|
|
|
extraPaneList.clear(); |
|
|
|
|
boolean containsExtraPane = false; |
|
|
|
|
Set<WidgetAdvancedPaneProvider<CheckBox>> providers = ExtraDesignClassManager.getInstance().getArray(WidgetAdvancedPaneProvider.XML_TAG); |
|
|
|
|
for (WidgetAdvancedPaneProvider<CheckBox> provider : providers) { |
|
|
|
|
if (!provider.accept(CheckBox.class)) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
insertShortCut(provider.getInsertPosition(extraPaneList.size()), provider.createExtraAdvancedPane()); |
|
|
|
|
containsExtraPane = true; |
|
|
|
|
} |
|
|
|
|
if (containsExtraPane) { |
|
|
|
|
extraPane = FRGUIPaneFactory.createYBoxEmptyBorderPane(); |
|
|
|
|
for (BasicBeanPane<CheckBox> pane : extraPaneList) { |
|
|
|
|
extraPane.add(pane); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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<CheckBox> pane) { |
|
|
|
|
int size = extraPaneList.size(); |
|
|
|
|
index = Math.min(index, size); |
|
|
|
|
extraPaneList.add(index, pane); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected String title4PopupWindow() { |
|
|
|
|
return "CheckBox"; |
|
|
|
@ -47,12 +105,18 @@ public class CheckBoxDefinePane extends AbstractDataModify<CheckBox> {
|
|
|
|
|
@Override |
|
|
|
|
public void populateBean(CheckBox check) { |
|
|
|
|
text.setText(check.getText()); |
|
|
|
|
for (BasicBeanPane<CheckBox> pane : extraPaneList) { |
|
|
|
|
pane.populateBean(check); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public CheckBox updateBean() { |
|
|
|
|
CheckBox box = new CheckBox(); |
|
|
|
|
box.setText(text.getText()); |
|
|
|
|
for (BasicBeanPane<CheckBox> pane : extraPaneList) { |
|
|
|
|
pane.updateBean(box); |
|
|
|
|
} |
|
|
|
|
return box; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|