Browse Source

Merge pull request #1291 in DESIGN/design from ~HADES/design:release/10.0 to release/10.0

* commit '3a64382ff90794f3e3176b8a04e83cdea2246587':
  fix
  MOBILE-23952 文本控件支持只能扫码
feature/big-screen
Hades 5 years ago
parent
commit
9305c1d0b6
  1. 36
      designer-base/src/main/java/com/fr/design/gui/ibutton/ModeButtonGroup.java
  2. 2
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/UpMenuStyleDefinePane.java
  3. 44
      designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ScanCodeMobileDefinePane.java
  4. 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();
}
}

2
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/UpMenuStyleDefinePane.java

@ -75,7 +75,7 @@ public class UpMenuStyleDefinePane extends StyleDefinePaneWithSelectConf {
wrapTabWidthPanel.setBorder(BorderFactory.createEmptyBorder(0, 20, 15, 20));
wrapTabWidthPanel.setPreferredSize(new Dimension(200, 20));
JPanel outerPane = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10);
outerPane.setBorder(BorderFactory.createEmptyBorder(0, 20, 5, 20));;
outerPane.setBorder(BorderFactory.createEmptyBorder(0, 20, 5, 20));
outerPane.add(centerPane);
outerPane.add(wrapTabWidthPanel);
panel.add(outerPane);

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;
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.foldablepane.UIExpandablePane;
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.mainframe.DesignerContext;
import com.fr.design.mainframe.FormDesigner;
import com.fr.form.ui.TextEditor;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import javax.swing.*;
import java.awt.*;
public class ScanCodeMobileDefinePane extends MobileWidgetDefinePane {
private XCreator xCreator;
private UICheckBox appScanCodeCheck;
private ModeButtonGroup<TextInputMode> buttonGroup;
public ScanCodeMobileDefinePane(XCreator xCreator) {
this.xCreator = xCreator;
@ -33,14 +33,31 @@ public class ScanCodeMobileDefinePane extends MobileWidgetDefinePane {
}
private UIExpandablePane getMobileSettingsPane() {
JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane();
appScanCodeCheck = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Support_Scan_Code"), true);
appScanCodeCheck.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
JPanel panel = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10);
buttonGroup = new ModeButtonGroup<>();
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.add(appScanCodeCheck);
panel.add(scanCodeAndManualInput);
panel.add(onlyManualInput);
panel.add(onlyScanCodeInput);
final JPanel panelWrapper = FRGUIPaneFactory.createBorderLayout_S_Pane();
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() {
@ -61,15 +78,14 @@ public class ScanCodeMobileDefinePane extends MobileWidgetDefinePane {
@Override
public void populate(FormDesigner designer) {
MobileScanCodeAttr mobileScanCodeAttr = ((TextEditor) xCreator.toData()).getMobileScanCodeAttr();
ScanCodeState scanCodeState = mobileScanCodeAttr.getScanCodeState();
appScanCodeCheck.setSelected(scanCodeState.getState());
buttonGroup.setSelectButton(mobileScanCodeAttr.getTextInputMode());
this.bindListeners2Widgets();
}
@Override
public void update() {
MobileScanCodeAttr mobileScanCodeAttr = ((TextEditor) xCreator.toData()).getMobileScanCodeAttr();
mobileScanCodeAttr.setScanCodeState(ScanCodeState.parse(appScanCodeCheck.isSelected()));
mobileScanCodeAttr.setTextInputMode(buttonGroup.getCurrentSelected());
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;
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.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.widget.mobile.WidgetMobilePane;
import com.fr.form.ui.TextEditor;
import com.fr.form.ui.Widget;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import javax.swing.*;
import java.awt.*;
public class ScanCodeMobilePane extends WidgetMobilePane {
private UICheckBox appScanCodeCheck;
private ModeButtonGroup<TextInputMode> buttonGroup;
@Override
protected void init() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.add(getMobileSettingPane(), BorderLayout.NORTH);
}
private UIExpandablePane getMobileSettingPane() {
JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane();
appScanCodeCheck = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Support_Scan_Code"), true);
appScanCodeCheck.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
JPanel panel = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10);
buttonGroup = new ModeButtonGroup<>();
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.add(appScanCodeCheck);
panel.add(scanCodeAndManualInput);
panel.add(onlyManualInput);
panel.add(onlyScanCodeInput);
final JPanel panelWrapper = FRGUIPaneFactory.createBorderLayout_S_Pane();
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
public void populate(Widget widget) {
MobileScanCodeAttr mobileScanCodeAttr = ((TextEditor) widget).getMobileScanCodeAttr();
ScanCodeState scanCodeState = mobileScanCodeAttr.getScanCodeState();
appScanCodeCheck.setSelected(scanCodeState.getState());
buttonGroup.setSelectButton(mobileScanCodeAttr.getTextInputMode());
}
@Override
public void update(Widget widget) {
MobileScanCodeAttr mobileScanCodeAttr = ((TextEditor) widget).getMobileScanCodeAttr();
mobileScanCodeAttr.setScanCodeState(ScanCodeState.parse(appScanCodeCheck.isSelected()));
mobileScanCodeAttr.setTextInputMode(buttonGroup.getCurrentSelected());
}

Loading…
Cancel
Save