@ -1,78 +1,50 @@
package com.fr.design.widget.ui.designer ;
import com.fr.design.data.DataCreatorUI ;
import com.fr.design.designer.IntervalConstants ;
import com.fr.design.designer.creator.XCreator ;
import com.fr.design.gui.icheckbox.UICheckBox ;
import com.fr.design.gui.ilable.UILabel ;
import com.fr.design.gui.itree.refreshabletree.TreeRootPane ;
import com.fr.design.layout.TableLayout ;
import com.fr.design.layout.TableLayoutHelper ;
import com.fr.design.layout.FRGUIPaneFactory ;
import com.fr.design.mainframe.widget.accessibles.AccessibleTreeModelEditor ;
import com.fr.design.widget.component.ReturnTypePane ;
import com.fr.form.ui.TreeEditor ;
import javax.swing.BorderFactory ;
import javax.swing.JPanel ;
import java.awt.BorderLayout ;
import java.awt.Component ;
import java.awt.event.MouseAdapter ;
import java.awt.event.MouseEvent ;
import java.awt.event.MouseListener ;
/ *
* richer : tree editor
* /
public class TreeEditorDefinePane extends CustomWritableRepeatEditorPane < TreeEditor > {
private ReturnTypePane returnTypePane ;
protected TreeRootPane treeRootPane ;
private UICheckBox mutiSelect ;
private UICheckBox loadAsync ;
private UICheckBox returnLeaf ;
private UICheckBox returnPath ;
private AccessibleTreeModelEditor accessibleTreeModelEditor ;
public TreeEditorDefinePane ( XCreator xCreator ) {
super ( xCreator ) ;
treeRootPane = new TreeRootPane ( ) ;
}
public JPanel createOtherPane ( ) {
mutiSelect = new UICheckBox ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Basic_Tree_Mutiple_Selection_Or_Not" ) ) ;
mutiSelect . setBorder ( BorderFactory . createEmptyBorder ( 0 , 0 , 0 , 0 ) ) ;
loadAsync = new UICheckBox ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Basic_Widget_Load_By_Async" ) ) ;
loadAsync . setBorder ( BorderFactory . createEmptyBorder ( 0 , 0 , 0 , 0 ) ) ;
loadAsync . addMouseListener ( new MouseAdapter ( ) {
@Override
public void mouseClicked ( MouseEvent e ) {
UICheckBox checkBox = ( UICheckBox ) e . getSource ( ) ;
doLoadTypeChange ( checkBox . isSelected ( ) ) ;
treeRootPane = new TreeRootPane ( ) ;
returnTypePane = new ReturnTypePane ( ) ;
JPanel panel = FRGUIPaneFactory . createBorderLayout_L_Pane ( ) ;
panel . add ( treeRootPane , BorderLayout . NORTH ) ;
returnTypePane . setBorder ( BorderFactory . createEmptyBorder ( 5 , 0 , 0 , 0 ) ) ;
panel . add ( returnTypePane , BorderLayout . CENTER ) ;
treeRootPane . addTreeAttrChangeListener ( treeAttr - > {
boolean showReturnTypePane = treeAttr . isMultipleSelection ( ) & & ! treeAttr . isReturnFullPath ( ) ;
returnTypePane . setVisible ( showReturnTypePane ) ;
if ( ! showReturnTypePane ) {
returnTypePane . setReturnType ( ReturnTypePane . ReturnType . ARRAY ) ;
}
} ) ;
returnLeaf = new UICheckBox ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Form_Widget_Return_Leaf" ) ) ;
returnLeaf . setBorder ( BorderFactory . createEmptyBorder ( 0 , 0 , 0 , 0 ) ) ;
returnPath = new UICheckBox ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Form_Widget_Return_Path" ) ) ;
returnPath . setBorder ( BorderFactory . createEmptyBorder ( 0 , 0 , 0 , 0 ) ) ;
double f = TableLayout . FILL ;
double p = TableLayout . PREFERRED ;
Component [ ] [ ] components = new Component [ ] [ ] {
new Component [ ] { mutiSelect } ,
new Component [ ] { loadAsync } ,
new Component [ ] { returnLeaf } ,
new Component [ ] { returnPath }
} ;
double [ ] rowSize = { p , p , p , p } ;
double [ ] columnSize = { p } ;
JPanel panel = TableLayoutHelper . createGapTableLayoutPane ( components , rowSize , columnSize , IntervalConstants . INTERVAL_L2 , IntervalConstants . INTERVAL_L1 ) ;
return panel ;
}
private void doLoadTypeChange ( Boolean selected ) {
//给埋点插件提供一个方法,埋埋点用
}
@Override
public String title4PopupWindow ( ) {
return "tree" ;
@ -89,10 +61,7 @@ public class TreeEditorDefinePane extends CustomWritableRepeatEditorPane<TreeEdi
accessibleTreeModelEditor . setValue ( e . getBuildModelConfig ( ) ) ;
formWidgetValuePane . populate ( e ) ;
treeRootPane . populate ( e . getTreeAttr ( ) ) ;
mutiSelect . setSelected ( e . isMultipleSelection ( ) ) ;
loadAsync . setSelected ( e . isAjax ( ) ) ;
returnLeaf . setSelected ( e . isSelectLeafOnly ( ) ) ;
returnPath . setSelected ( e . isReturnFullPath ( ) ) ;
returnTypePane . populate ( e ) ;
}
@ -101,11 +70,8 @@ public class TreeEditorDefinePane extends CustomWritableRepeatEditorPane<TreeEdi
TreeEditor editor = ( TreeEditor ) creator . toData ( ) ;
formWidgetValuePane . update ( editor ) ;
editor . setTreeAttr ( treeRootPane . update ( ) ) ;
editor . setMultipleSelection ( mutiSelect . isSelected ( ) ) ;
editor . setAjax ( loadAsync . isSelected ( ) ) ;
editor . setSelectLeafOnly ( returnLeaf . isSelected ( ) ) ;
editor . setReturnFullPath ( returnPath . isSelected ( ) ) ;
editor . setBuildModelConfig ( accessibleTreeModelEditor . getValue ( ) ) ;
returnTypePane . update ( editor ) ;
return editor ;
}