@ -1,11 +1,13 @@
package com.fr.design.hyperlink.popup ;
import com.fine.theme.utils.FineUIStyle ;
import com.formdev.flatlaf.util.ScaledEmptyBorder ;
import com.fr.design.constants.LayoutConstants ;
import com.fr.design.dialog.BasicPane ;
import com.fr.design.gui.ibutton.UIRadioButton ;
import com.fr.design.gui.ilable.UILabel ;
import com.fr.design.gui.ispinner.UISpinner ;
import com.fr.design.i18n.Toolkit ;
import com.fr.design.layout.VerticalFlowLayout ;
import com.fr.stable.StringUtils ;
import javax.swing.* ;
@ -13,6 +15,11 @@ import java.awt.*;
import java.awt.event.ActionEvent ;
import java.awt.event.ActionListener ;
import static com.fine.swing.ui.layout.Layouts.column ;
import static com.fine.swing.ui.layout.Layouts.cell ;
import static com.fine.swing.ui.layout.Layouts.row ;
import static com.fine.swing.ui.layout.Layouts.flex ;
public class MobilePopupRegularPane extends BasicPane {
private String label ;
@ -35,13 +42,15 @@ public class MobilePopupRegularPane extends BasicPane {
private void initComponent ( ) {
this . setLayout ( new BorderLayout ( ) ) ;
this . add ( this . createRadioButtonGroupPane ( ) , BorderLayout . NORTH ) ;
spinnerGroupPane = this . createSpinnerPane ( ) ;
this . add ( spinnerGroupPane , BorderLayout . CENTER ) ;
this . add ( column ( LayoutConstants . VERTICAL_GAP ,
cell ( this . createRadioButtonGroupPane ( ) ) ,
row ( flex ( 1 ) , cell ( spinnerGroupPane ) . weight ( 3 ) )
) . getComponent ( ) ) ;
}
private JPanel createRadioButtonGroupPane ( ) {
radiosPane = new JPanel ( new FlowLayout ( FlowLayout . LEFT , 5 , 5 ) ) ;
radiosPane = new JPanel ( new BorderLayout ( ) ) ;
customRadio = new UIRadioButton ( Toolkit . i18nText ( "FR-Plugin-Designer_Mobile_Popup_Custom" ) ) ;
customRadio . addActionListener ( radioActionListener ) ;
@ -52,10 +61,8 @@ public class MobilePopupRegularPane extends BasicPane {
radioButtons . add ( customRadio ) ;
radioButtons . add ( autoRadio ) ;
radiosPane . add ( customRadio ) ;
radiosPane . add ( autoRadio ) ;
return MobilePopupUIUtils . createLeftTileRightContentPanel ( this . label , radiosPane , Color . GRAY , 20 ) ;
radiosPane . add ( row ( 30 , cell ( customRadio ) , cell ( autoRadio ) , flex ( ) ) . getComponent ( ) ) ;
return row ( cell ( new UILabel ( this . label , FineUIStyle . LABEL_SECONDARY ) ) . weight ( 1 ) , cell ( radiosPane ) . weight ( 3 ) ) . getComponent ( ) ;
}
private ActionListener radioActionListener = new ActionListener ( ) {
@ -66,40 +73,32 @@ public class MobilePopupRegularPane extends BasicPane {
} ;
private JPanel createSpinnerPane ( ) {
JPanel spinnerPane = new JPanel ( new FlowLayout ( FlowLayout . LEFT , 15 , 5 ) ) ;
spinnerPane . setBorder ( BorderFactory . create EmptyBorder( 0 , MobilePopupUIUtils . Left_Title_width , 0 , 0 ) ) ;
JPanel spinnerPane = new JPanel ( new FlowLayout ( FlowLayout . LEFT , 15 , 0 ) ) ;
spinnerPane . setBorder ( new Scaled EmptyBorder( 0 , 0 , 0 , 0 ) ) ;
widthSpinner = new UISpinner ( 0 , 100 , 1 , 95 ) ;
widthSpinnerPane = this . createSpinnerLabelPane ( widthSpinner , Toolkit . i18nText ( "FR-Plugin-Designer_Mobile_Popup_Width" ) ) ;
heightSpinner = new UISpinner ( 0 , 100 , 1 , 95 ) ;
heightSpinnerPane = this . createSpinnerLabelPane ( heightSpinner , Toolkit . i18nText ( "FR-Plugin-Designer_Mobile_Popup_Height" ) ) ;
spinnerPane . add ( widthSpinnerPane ) ;
spinnerPane . add ( heightSpinnerPane ) ;
spinnerPane . add ( row ( cell ( widthSpinnerPane ) , cell ( heightSpinnerPane ) ) . getComponent ( ) ) ;
return spinnerPane ;
}
private JPanel createSpinnerLabelPane ( UISpinner spinner , String labelText ) {
JPanel spinnerLabelPane = new JPanel ( new VerticalFlowLayout ( VerticalFlowLayout . TOP , 0 , 5 ) ) ;
JPanel spinnerPane = new JPanel ( new FlowLayout ( FlowLayout . LEFT , 2 , 0 ) ) ;
JPanel spinnerLabelPane = new JPanel ( new BorderLayout ( ) ) ;
UILabel percent = new UILabel ( "%" ) ;
spinnerPane . add ( spinner ) ;
spinnerPane . add ( percent ) ;
UILabel label = new UILabel ( labelText ) ;
label . setHorizontalAlignment ( SwingConstants . CENTER ) ;
spinnerLabelPane . add ( spinnerPane ) ;
spinnerLabelPane . add ( label ) ;
spinnerLabelPane . add ( column ( LayoutConstants . VGAP_SMALL ,
row ( cell ( spinner ) . weight ( 1 ) , cell ( percent ) ) . weight ( 1 ) ,
cell ( label )
) . getComponent ( ) ) ;
return spinnerLabelPane ;
}
private void resetSpinnerGroupPane ( boolean showHeightSpinnerPane ) {
spinnerGroupPane . removeAll ( ) ;
spinnerGroupPane . add ( widthSpinnerPane ) ;
if ( showHeightSpinnerPane ) {
if ( showHeightSpinnerPane ) {
spinnerGroupPane . add ( heightSpinnerPane ) ;
}
spinnerGroupPane . revalidate ( ) ;