@ -3,13 +3,16 @@ package com.fr.design.widget.ui.designer.mobile.component;
import com.fr.base.mobile.MobileScanCodeAttr ;
import com.fr.base.mobile.MobileScanCodeAttr ;
import com.fr.design.beans.BasicBeanPane ;
import com.fr.design.beans.BasicBeanPane ;
import com.fr.design.constants.LayoutConstants ;
import com.fr.design.constants.LayoutConstants ;
import com.fr.design.gui.ibutton.UIRadioButton ;
import com.fr.design.gui.icheckbox.UICheckBox ;
import com.fr.design.gui.icheckbox.UICheckBox ;
import com.fr.design.gui.ilable.UILabel ;
import com.fr.design.gui.ilable.UILabel ;
import com.fr.design.i18n.Toolkit ;
import com.fr.design.i18n.Toolkit ;
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.design.layout.VerticalFlowLayout ;
import javax.swing.ButtonGroup ;
import javax.swing.JPanel ;
import javax.swing.JPanel ;
import java.awt.BorderLayout ;
import java.awt.BorderLayout ;
import java.awt.Component ;
import java.awt.Component ;
@ -25,25 +28,38 @@ public class MobileTextFieldInputSettingPane extends BasicBeanPane<MobileScanCod
private final UICheckBox scanCodeCheckBox ;
private final UICheckBox scanCodeCheckBox ;
private final UICheckBox nfcInputCheckBox ;
private final UICheckBox nfcInputCheckBox ;
/ * *
* NFC内容类型面板
* /
private final NfcContentTypePane nfcContentTypePane = new NfcContentTypePane ( ) ;
public MobileTextFieldInputSettingPane ( ) {
public MobileTextFieldInputSettingPane ( ) {
this . setLayout ( FRGUIPaneFactory . createBorderLayout ( ) ) ;
this . setLayout ( FRGUIPaneFactory . createBorderLayout ( ) ) ;
manualInputCheckBox = new UICheckBox ( Toolkit . i18nText ( "Fine-Design_Mobile_Manual_Input" ) , true ) ;
manualInputCheckBox = new UICheckBox ( Toolkit . i18nText ( "Fine-Design_Mobile_Manual_Input" ) , true ) ;
scanCodeCheckBox = new UICheckBox ( Toolkit . i18nText ( "Fine-Design_Mobile_Scan_Code_Input" ) , true ) ;
scanCodeCheckBox = new UICheckBox ( Toolkit . i18nText ( "Fine-Design_Mobile_Scan_Code_Input" ) , true ) ;
nfcInputCheckBox = new UICheckBox ( Toolkit . i18nText ( "Fine-Design_Mobile_NFC_Input" ) , false ) ;
nfcInputCheckBox = new UICheckBox ( Toolkit . i18nText ( "Fine-Design_Mobile_NFC_Input" ) , false ) ;
nfcInputCheckBox . addChangeListener ( e - > {
UICheckBox source = ( UICheckBox ) e . getSource ( ) ;
// 更新面板是否可见
updateNfcContentTypePane ( source . isSelected ( ) , nfcContentTypePane . getSelectedType ( ) ) ;
} ) ;
initComponents ( ) ;
initComponents ( ) ;
// 初始状态,内容类型面板不可见
nfcContentTypePane . setVisible ( false ) ;
}
}
private void initComponents ( ) {
private void initComponents ( ) {
Component [ ] [ ] components = new Component [ ] [ ] {
Component [ ] [ ] components = new Component [ ] [ ] {
new Component [ ] { new UILabel ( Toolkit . i18nText ( "Fine-Design_Mobile_Input_Way" ) ) , manualInputCheckBox } ,
new Component [ ] { new UILabel ( Toolkit . i18nText ( "Fine-Design_Mobile_Input_Way" ) ) , manualInputCheckBox } ,
new Component [ ] { null , scanCodeCheckBox } ,
new Component [ ] { null , scanCodeCheckBox } ,
new Component [ ] { null , nfcInputCheckBox }
new Component [ ] { null , nfcInputCheckBox } ,
new Component [ ] { null , nfcContentTypePane } ,
} ;
} ;
double p = TableLayout . PREFERRED ;
double p = TableLayout . PREFERRED ;
double f = TableLayout . FILL ;
double f = TableLayout . FILL ;
double [ ] rowSize = { p , p , p } ;
double [ ] rowSize = { p , p , p , p } ;
double [ ] columnSize = { p , f } ;
double [ ] columnSize = { p , f } ;
int [ ] [ ] rowCount = { { 1 , 1 } , { 1 , 1 } , { 1 , 1 } } ;
int [ ] [ ] rowCount = { { 1 , 1 } , { 1 , 1 } , { 1 , 1 } , { 1 , 1 } } ;
JPanel settingPane = TableLayoutHelper . createGapTableLayoutPane ( components , rowSize , columnSize , rowCount , LayoutConstants . HGAP_LARGE , LayoutConstants . VGAP_LARGE ) ;
JPanel settingPane = TableLayoutHelper . createGapTableLayoutPane ( components , rowSize , columnSize , rowCount , LayoutConstants . HGAP_LARGE , LayoutConstants . VGAP_LARGE ) ;
this . add ( settingPane , BorderLayout . NORTH ) ;
this . add ( settingPane , BorderLayout . NORTH ) ;
}
}
@ -53,6 +69,7 @@ public class MobileTextFieldInputSettingPane extends BasicBeanPane<MobileScanCod
manualInputCheckBox . setSelected ( ob . isSupportManual ( ) ) ;
manualInputCheckBox . setSelected ( ob . isSupportManual ( ) ) ;
scanCodeCheckBox . setSelected ( ob . isSupportScan ( ) ) ;
scanCodeCheckBox . setSelected ( ob . isSupportScan ( ) ) ;
nfcInputCheckBox . setSelected ( ob . isSupportNFC ( ) ) ;
nfcInputCheckBox . setSelected ( ob . isSupportNFC ( ) ) ;
updateNfcContentTypePane ( ob . isSupportNFC ( ) , ob . getNfcContentType ( ) ) ;
}
}
@Override
@Override
@ -66,6 +83,18 @@ public class MobileTextFieldInputSettingPane extends BasicBeanPane<MobileScanCod
ob . setSupportManual ( manualInputCheckBox . isSelected ( ) ) ;
ob . setSupportManual ( manualInputCheckBox . isSelected ( ) ) ;
ob . setSupportScan ( scanCodeCheckBox . isSelected ( ) ) ;
ob . setSupportScan ( scanCodeCheckBox . isSelected ( ) ) ;
ob . setSupportNFC ( nfcInputCheckBox . isSelected ( ) ) ;
ob . setSupportNFC ( nfcInputCheckBox . isSelected ( ) ) ;
ob . setNfcContentType ( nfcContentTypePane . getSelectedType ( ) ) ;
}
/ * *
* 更新NFC内容类型面板 ( 可见 、 选项 )
*
* @param visible 是否可见
* @param contentType 内容类型
* /
private void updateNfcContentTypePane ( boolean visible , MobileScanCodeAttr . NFCContentType contentType ) {
nfcContentTypePane . setVisible ( visible ) ;
nfcContentTypePane . setSelectedType ( contentType ) ;
}
}
@ -74,4 +103,59 @@ public class MobileTextFieldInputSettingPane extends BasicBeanPane<MobileScanCod
return null ;
return null ;
}
}
/ * *
* NFC内容类型面板封装
* /
private class NfcContentTypePane extends JPanel {
/ * *
* 类型 - 卡片内容
* /
private UIRadioButton contentTypeButton ;
/ * *
* 类型 - UID
* /
private UIRadioButton uidTypeButton ;
NfcContentTypePane ( ) {
VerticalFlowLayout layout = new VerticalFlowLayout ( ) ;
layout . setAlignLeft ( true ) ;
this . setLayout ( layout ) ;
contentTypeButton = new UIRadioButton ( Toolkit . i18nText ( "Fine-Design_Mobile_NFC_Content_Type_Content" ) ) ;
uidTypeButton = new UIRadioButton ( Toolkit . i18nText ( "Fine-Design_Mobile_NFC_Content_Type_UID" ) ) ;
contentTypeButton . setSelected ( true ) ;
uidTypeButton . setSelected ( false ) ;
ButtonGroup buttonGroup = new ButtonGroup ( ) ;
buttonGroup . add ( contentTypeButton ) ;
buttonGroup . add ( uidTypeButton ) ;
this . add ( contentTypeButton ) ;
this . add ( uidTypeButton ) ;
}
/ * *
* 根据NFCContentType , 设置Button的选中状态
*
* @param contentType
* /
void setSelectedType ( MobileScanCodeAttr . NFCContentType contentType ) {
contentTypeButton . setSelected ( contentType = = MobileScanCodeAttr . NFCContentType . CONTENT ) ;
uidTypeButton . setSelected ( contentType = = MobileScanCodeAttr . NFCContentType . UID ) ;
}
/ * *
* 获取当前选中Button代表的NFCContentType
*
* @return
* /
MobileScanCodeAttr . NFCContentType getSelectedType ( ) {
return uidTypeButton . isSelected ( ) ?
MobileScanCodeAttr . NFCContentType . UID :
MobileScanCodeAttr . NFCContentType . CONTENT ;
}
}
}
}