@ -1,21 +1,35 @@
package com.fr.design.widget.ui ;
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.designer.IntervalConstants ;
import com.fr.design.foldablepane.UIExpandablePane ;
import com.fr.design.foldablepane.UIExpandablePane ;
import com.fr.design.fun.WidgetAdvancedPaneProvider ;
import com.fr.design.gui.ilable.UILabel ;
import com.fr.design.gui.ilable.UILabel ;
import com.fr.design.gui.itextfield.UITextField ;
import com.fr.design.gui.itextfield.UITextField ;
import com.fr.design.layout.FRGUIPaneFactory ;
import com.fr.design.layout.FRGUIPaneFactory ;
import com.fr.design.layout.TableLayout ;
import com.fr.design.layout.TableLayout ;
import com.fr.design.layout.TableLayoutHelper ;
import com.fr.design.layout.TableLayoutHelper ;
import com.fr.form.ui.CheckBox ;
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 javax.swing.BorderFactory ;
import java.awt.* ;
import javax.swing.JPanel ;
import java.awt.Component ;
import java.util.ArrayList ;
import java.util.List ;
import java.util.Set ;
public class CheckBoxDefinePane extends AbstractDataModify < CheckBox > {
public class CheckBoxDefinePane extends AbstractDataModify < CheckBox > {
private UITextField text ;
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 ( ) {
public CheckBoxDefinePane ( ) {
this . iniComponents ( ) ;
this . iniComponents ( ) ;
}
}
@ -23,14 +37,14 @@ public class CheckBoxDefinePane extends AbstractDataModify<CheckBox> {
private void iniComponents ( ) {
private void iniComponents ( ) {
this . setLayout ( FRGUIPaneFactory . createBorderLayout ( ) ) ;
this . setLayout ( FRGUIPaneFactory . createBorderLayout ( ) ) ;
text = new UITextField ( ) ;
text = new UITextField ( ) ;
double f = TableLayout . FILL ;
initExtraPane ( ) ;
double p = TableLayout . PREFERRED ;
Component [ ] [ ] components = new Component [ ] [ ] {
Component [ ] [ ] components = new Component [ ] [ ] {
new Component [ ] { new UILabel ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Report_Text" ) ) , text } ,
new Component [ ] { new UILabel ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Report_Text" ) ) , text } ,
new Component [ ] { extraPane , null } ,
} ;
} ;
double [ ] rowSize = { p } ;
double [ ] rowSize = { P , P } ;
double [ ] columnSize = { p , f } ;
double [ ] columnSize = { P , F } ;
int [ ] [ ] rowCount = { { 1 , 1 } } ;
int [ ] [ ] rowCount = { { 1 , 1 } , { 1 , 1 } } ;
JPanel pane = TableLayoutHelper . createGapTableLayoutPane ( components , rowSize , columnSize , rowCount , IntervalConstants . INTERVAL_W3 , IntervalConstants . INTERVAL_L1 ) ;
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 ) ;
UIExpandablePane uiExpandablePane = new UIExpandablePane ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Report_Advanced" ) , 280 , 24 , pane ) ;
@ -39,6 +53,51 @@ public class CheckBoxDefinePane extends AbstractDataModify<CheckBox> {
this . add ( uiExpandablePane ) ;
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
@Override
protected String title4PopupWindow ( ) {
protected String title4PopupWindow ( ) {
return "CheckBox" ;
return "CheckBox" ;
@ -47,12 +106,18 @@ public class CheckBoxDefinePane extends AbstractDataModify<CheckBox> {
@Override
@Override
public void populateBean ( CheckBox check ) {
public void populateBean ( CheckBox check ) {
text . setText ( check . getText ( ) ) ;
text . setText ( check . getText ( ) ) ;
for ( BasicBeanPane < CheckBox > pane : extraPaneList ) {
pane . populateBean ( check ) ;
}
}
}
@Override
@Override
public CheckBox updateBean ( ) {
public CheckBox updateBean ( ) {
CheckBox box = new CheckBox ( ) ;
CheckBox box = new CheckBox ( ) ;
box . setText ( text . getText ( ) ) ;
box . setText ( text . getText ( ) ) ;
for ( BasicBeanPane < CheckBox > pane : extraPaneList ) {
pane . updateBean ( box ) ;
}
return box ;
return box ;
}
}
}
}