You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
133 lines
4.6 KiB
133 lines
4.6 KiB
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.design.widgettheme.processor.WidgetThemeCreatorPaneAcceptor; |
|
import com.fr.form.ui.CheckBox; |
|
import com.fr.general.GeneralContext; |
|
import com.fr.plugin.observer.PluginEvent; |
|
import com.fr.plugin.observer.PluginEventListener; |
|
import com.fr.stable.collections.CollectionUtils; |
|
|
|
import javax.swing.BorderFactory; |
|
import javax.swing.JPanel; |
|
import java.awt.Component; |
|
import java.util.ArrayList; |
|
import java.util.List; |
|
import java.util.Set; |
|
|
|
/** |
|
* 复选框pane |
|
* |
|
* @author obo |
|
* @version 11.0 |
|
* Created on 2023/11/13 |
|
*/ |
|
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(); |
|
} |
|
|
|
private void iniComponents() { |
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
text = new UITextField(); |
|
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,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); |
|
pane.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 0)); |
|
|
|
this.add(uiExpandablePane); |
|
} |
|
|
|
protected void initExtraPane() { |
|
initPluginListener(); |
|
refreshExtraAdvancedPane(); |
|
} |
|
|
|
protected void refreshExtraAdvancedPane() { |
|
extraPaneList.clear(); |
|
new WidgetThemeCreatorPaneAcceptor<CheckBox>().accept(CheckBox.class, extraPaneList); |
|
boolean containsExtraPane = !CollectionUtils.isEmpty(extraPaneList); |
|
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"; |
|
} |
|
|
|
@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; |
|
} |
|
}
|
|
|