@ -5,7 +5,6 @@ import com.fr.design.editor.editor.DateEditor;
import com.fr.design.editor.editor.DoubleEditor ;
import com.fr.design.editor.editor.Editor ;
import com.fr.design.editor.editor.FormulaEditor ;
import com.fr.design.gui.core.ReactiveCardPane ;
import com.fr.design.gui.ibutton.UIButtonGroup ;
import com.fr.design.gui.ilable.UILabel ;
import com.fr.design.mainframe.widget.editors.DataBindingEditor ;
@ -19,6 +18,9 @@ import com.fr.form.ui.concept.data.ValueInitializer;
import javax.swing.JPanel ;
import java.awt.BorderLayout ;
import java.awt.CardLayout ;
import java.awt.Component ;
import java.awt.Dimension ;
import static com.fine.swing.ui.layout.Layouts.cell ;
import static com.fine.swing.ui.layout.Layouts.column ;
@ -34,20 +36,31 @@ import static com.fr.design.constants.LayoutConstants.VERTICAL_GAP;
public class FormWidgetValuePane extends JPanel {
private UIButtonGroup widgetValueHead ;
private Editor [ ] editor ;
private ReactiveCardPane customPane ;
private JPanel customPane ;
private CardLayout cardLayout ;
public FormWidgetValuePane ( Object o , boolean onlyServer ) {
DataControl widget = ( DataControl ) o ;
editor = createWidgetValueEditor ( widget , onlyServer ) ;
this . setLayout ( new BorderLayout ( ) ) ;
customPane = ReactiveCardPane . create ( ) ;
cardLayout = new CardLayout ( ) ;
customPane = new JPanel ( cardLayout ) {
@Override
public Dimension getPreferredSize ( ) {
for ( Component comp : getComponents ( ) ) {
if ( comp . isVisible ( ) ) {
return comp . getPreferredSize ( ) ;
}
}
return new Dimension ( 0 , 0 ) ;
}
} ;
final String [ ] tabTitles = new String [ editor . length ] ;
for ( int i = 0 ; i < editor . length ; i + + ) {
Editor currentEditor = editor [ i ] ;
customPane . addSupplier ( editor [ i ] . getName ( ) , ( ) - > currentEditor ) ;
customPane . add ( currentEditor , editor [ i ] . getName ( ) ) ;
tabTitles [ i ] = editor [ i ] . getName ( ) ;
}
customPane . select ( editor [ 0 ] . getName ( ) ) . populate ( ) ;
widgetValueHead = new UIButtonGroup ( tabTitles ) ;
UILabel widgetValueLabel = FRWidgetFactory . createLineWrapLabel ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Form_Estate_Widget_Value" ) ) ;
this . add ( column ( VERTICAL_GAP ,
@ -69,7 +82,7 @@ public class FormWidgetValuePane extends JPanel {
index = 0 ;
widgetValueHead . setSelectedIndex ( index ) ;
}
customPane . select ( editor [ index ] . getName ( ) ) . populate ( ) ;
cardLayout . show ( customPane , editor [ index ] . getName ( ) ) ;
}