Browse Source

MOBILE-23952 文本控件支持只能扫码

feature/big-screen
hades 5 years ago
parent
commit
7e5e781651
  1. 36
      designer-base/src/main/java/com/fr/design/gui/ibutton/ModeButtonGroup.java
  2. 44
      designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ScanCodeMobileDefinePane.java
  3. 42
      designer-realize/src/main/java/com/fr/design/widget/ui/mobile/ScanCodeMobilePane.java

36
designer-base/src/main/java/com/fr/design/gui/ibutton/ModeButtonGroup.java

@ -0,0 +1,36 @@
package com.fr.design.gui.ibutton;
import javax.swing.*;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* 互斥的按钮
* @author hades
* @version 10.0
* Created by hades on 2019/11/12
*/
public class ModeButtonGroup<T> extends ButtonGroup {
private Map<T, AbstractButton> buttonMap = new LinkedHashMap<>();
public void put(T t, AbstractButton button) {
add(button);
buttonMap.put(t, button);
}
public void setSelectButton(T t) {
buttonMap.get(t).setSelected(true);
}
public T getCurrentSelected() {
for (Map.Entry<T, AbstractButton> entry : buttonMap.entrySet()) {
if (entry.getValue().isSelected()) {
return entry.getKey();
}
}
return buttonMap.entrySet().iterator().next().getKey();
}
}

44
designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ScanCodeMobileDefinePane.java

@ -1,24 +1,24 @@
package com.fr.design.widget.ui.designer.mobile; package com.fr.design.widget.ui.designer.mobile;
import com.fr.base.mobile.MobileScanCodeAttr; import com.fr.base.mobile.MobileScanCodeAttr;
import com.fr.base.mobile.ScanCodeState; import com.fr.base.mobile.TextInputMode;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ibutton.ModeButtonGroup;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.form.ui.TextEditor; import com.fr.form.ui.TextEditor;
import javax.swing.BorderFactory; import javax.swing.*;
import javax.swing.JPanel; import java.awt.*;
import java.awt.BorderLayout;
public class ScanCodeMobileDefinePane extends MobileWidgetDefinePane { public class ScanCodeMobileDefinePane extends MobileWidgetDefinePane {
private XCreator xCreator; private XCreator xCreator;
private UICheckBox appScanCodeCheck; private ModeButtonGroup<TextInputMode> buttonGroup;
public ScanCodeMobileDefinePane(XCreator xCreator) { public ScanCodeMobileDefinePane(XCreator xCreator) {
this.xCreator = xCreator; this.xCreator = xCreator;
@ -33,14 +33,31 @@ public class ScanCodeMobileDefinePane extends MobileWidgetDefinePane {
} }
private UIExpandablePane getMobileSettingsPane() { private UIExpandablePane getMobileSettingsPane() {
JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel panel = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10);
appScanCodeCheck = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Support_Scan_Code"), true); buttonGroup = new ModeButtonGroup<>();
appScanCodeCheck.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0)); UIRadioButton scanCodeAndManualInput = new UIRadioButton(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design__Mobile_Support_Scan_Code_And_Manual_Input"), true);
UIRadioButton onlyManualInput = new UIRadioButton(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Only_Support_Manual_Input"), false);
UIRadioButton onlyScanCodeInput = new UIRadioButton(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Only_Support_Scan_Code_Input"), false);
scanCodeAndManualInput.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
onlyManualInput.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
onlyScanCodeInput.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
buttonGroup.put(TextInputMode.SUPPORT_SCAN_CODE_And_MANUAL, scanCodeAndManualInput);
buttonGroup.put(TextInputMode.ONLY_SUPPORT_MANUAL, onlyManualInput);
buttonGroup.put(TextInputMode.ONLY_SUPPORT_SCAN_CODE, onlyScanCodeInput);
buttonGroup.add(scanCodeAndManualInput);
buttonGroup.add(onlyManualInput);
buttonGroup.add(onlyScanCodeInput);
panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
panel.add(appScanCodeCheck); panel.add(scanCodeAndManualInput);
panel.add(onlyManualInput);
panel.add(onlyScanCodeInput);
final JPanel panelWrapper = FRGUIPaneFactory.createBorderLayout_S_Pane(); final JPanel panelWrapper = FRGUIPaneFactory.createBorderLayout_S_Pane();
panelWrapper.add(panel, BorderLayout.NORTH); panelWrapper.add(panel, BorderLayout.NORTH);
return new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, panelWrapper); return new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20,
panelWrapper);
} }
private void bindListeners2Widgets() { private void bindListeners2Widgets() {
@ -61,15 +78,14 @@ public class ScanCodeMobileDefinePane extends MobileWidgetDefinePane {
@Override @Override
public void populate(FormDesigner designer) { public void populate(FormDesigner designer) {
MobileScanCodeAttr mobileScanCodeAttr = ((TextEditor) xCreator.toData()).getMobileScanCodeAttr(); MobileScanCodeAttr mobileScanCodeAttr = ((TextEditor) xCreator.toData()).getMobileScanCodeAttr();
ScanCodeState scanCodeState = mobileScanCodeAttr.getScanCodeState(); buttonGroup.setSelectButton(mobileScanCodeAttr.getTextInputMode());
appScanCodeCheck.setSelected(scanCodeState.getState());
this.bindListeners2Widgets(); this.bindListeners2Widgets();
} }
@Override @Override
public void update() { public void update() {
MobileScanCodeAttr mobileScanCodeAttr = ((TextEditor) xCreator.toData()).getMobileScanCodeAttr(); MobileScanCodeAttr mobileScanCodeAttr = ((TextEditor) xCreator.toData()).getMobileScanCodeAttr();
mobileScanCodeAttr.setScanCodeState(ScanCodeState.parse(appScanCodeCheck.isSelected())); mobileScanCodeAttr.setTextInputMode(buttonGroup.getCurrentSelected());
DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified(); DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified();
} }

42
designer-realize/src/main/java/com/fr/design/widget/ui/mobile/ScanCodeMobilePane.java

@ -1,49 +1,63 @@
package com.fr.design.widget.ui.mobile; package com.fr.design.widget.ui.mobile;
import com.fr.base.mobile.MobileScanCodeAttr; import com.fr.base.mobile.MobileScanCodeAttr;
import com.fr.base.mobile.ScanCodeState; import com.fr.base.mobile.TextInputMode;
import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ibutton.ModeButtonGroup;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.widget.mobile.WidgetMobilePane; import com.fr.design.widget.mobile.WidgetMobilePane;
import com.fr.form.ui.TextEditor; import com.fr.form.ui.TextEditor;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import javax.swing.BorderFactory; import javax.swing.*;
import javax.swing.JPanel; import java.awt.*;
import java.awt.BorderLayout;
public class ScanCodeMobilePane extends WidgetMobilePane { public class ScanCodeMobilePane extends WidgetMobilePane {
private UICheckBox appScanCodeCheck; private ModeButtonGroup<TextInputMode> buttonGroup;
@Override
protected void init() { protected void init() {
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.add(getMobileSettingPane(), BorderLayout.NORTH); this.add(getMobileSettingPane(), BorderLayout.NORTH);
} }
private UIExpandablePane getMobileSettingPane() { private UIExpandablePane getMobileSettingPane() {
JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel panel = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10);
appScanCodeCheck = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Support_Scan_Code"), true); buttonGroup = new ModeButtonGroup<>();
appScanCodeCheck.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0)); UIRadioButton scanCodeAndManualInput = new UIRadioButton(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design__Mobile_Support_Scan_Code_And_Manual_Input"), true);
UIRadioButton onlyManualInput = new UIRadioButton(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Only_Support_Manual_Input"), false);
UIRadioButton onlyScanCodeInput = new UIRadioButton(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Only_Support_Scan_Code_Input"), false);
scanCodeAndManualInput.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
onlyManualInput.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
onlyScanCodeInput.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
buttonGroup.put(TextInputMode.SUPPORT_SCAN_CODE_And_MANUAL, scanCodeAndManualInput);
buttonGroup.put(TextInputMode.ONLY_SUPPORT_MANUAL, onlyManualInput);
buttonGroup.put(TextInputMode.ONLY_SUPPORT_SCAN_CODE, onlyScanCodeInput);
panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
panel.add(appScanCodeCheck); panel.add(scanCodeAndManualInput);
panel.add(onlyManualInput);
panel.add(onlyScanCodeInput);
final JPanel panelWrapper = FRGUIPaneFactory.createBorderLayout_S_Pane(); final JPanel panelWrapper = FRGUIPaneFactory.createBorderLayout_S_Pane();
panelWrapper.add(panel, BorderLayout.NORTH); panelWrapper.add(panel, BorderLayout.NORTH);
return new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, panelWrapper); return new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20,
panelWrapper);
} }
@Override @Override
public void populate(Widget widget) { public void populate(Widget widget) {
MobileScanCodeAttr mobileScanCodeAttr = ((TextEditor) widget).getMobileScanCodeAttr(); MobileScanCodeAttr mobileScanCodeAttr = ((TextEditor) widget).getMobileScanCodeAttr();
ScanCodeState scanCodeState = mobileScanCodeAttr.getScanCodeState(); buttonGroup.setSelectButton(mobileScanCodeAttr.getTextInputMode());
appScanCodeCheck.setSelected(scanCodeState.getState());
} }
@Override @Override
public void update(Widget widget) { public void update(Widget widget) {
MobileScanCodeAttr mobileScanCodeAttr = ((TextEditor) widget).getMobileScanCodeAttr(); MobileScanCodeAttr mobileScanCodeAttr = ((TextEditor) widget).getMobileScanCodeAttr();
mobileScanCodeAttr.setScanCodeState(ScanCodeState.parse(appScanCodeCheck.isSelected())); mobileScanCodeAttr.setTextInputMode(buttonGroup.getCurrentSelected());
} }

Loading…
Cancel
Save