From d419f39316f4c80d4fee6c863bfb15bd74f33ed4 Mon Sep 17 00:00:00 2001 From: "Fly.Li" Date: Wed, 6 Apr 2022 16:33:23 +0800 Subject: [PATCH] =?UTF-8?q?KERNEL-10650:=E6=94=B9=E5=8F=98=E5=B9=B6?= =?UTF-8?q?=E8=A1=8C=E8=AE=A1=E7=AE=97=E8=AE=BE=E7=BD=AE=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=E9=A3=8E=E6=A0=BC=EF=BC=8C=E8=B7=9F=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E9=A3=8E=E6=A0=BC=E4=BF=9D=E6=8C=81=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/designer/FormParallelSettingPane.java | 102 +++++------------- 1 file changed, 28 insertions(+), 74 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/FormParallelSettingPane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/FormParallelSettingPane.java index b7ad9cff5..3db2b4ed3 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/FormParallelSettingPane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/FormParallelSettingPane.java @@ -2,6 +2,7 @@ package com.fr.design.widget.ui.designer; import com.fr.design.beans.BasicBeanPane; import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; @@ -9,22 +10,16 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.form.main.parallel.FormParallelAttr; import com.fr.form.main.parallel.ParallelAttrMark; -import com.fr.general.IOUtils; import com.fr.report.core.config.FormParallelCalConfig; import javax.swing.BorderFactory; -import javax.swing.Icon; -import javax.swing.JLabel; import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.Component; import java.awt.Dimension; import java.awt.FlowLayout; -import java.awt.Font; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; /** * @author fly.li @@ -66,83 +61,69 @@ public class FormParallelSettingPane extends BasicBeanPane { } static class ParallelSettingPane extends BasicPane { - private static final String[] CHOOSEITEM = new String[] { + private static final String[] CHOOSE_ITEM = new String[] { Toolkit.i18nText("Fine-Design_Report_I_Want_To_Set_Single"), Toolkit.i18nText("Fine-Design_Form_Using_Server_Report_View_Settings") }; - protected static final int SINGLE_SET = 0; protected static final int SERVER_SET = 1; - //提示文字标签 - UIComboBox combox; + //并行设置范围的下拉框(服务器设置还是模板设置) + UIComboBox parallelSettingScope; //并行计算开关 - ParallelSwitchLabel parallelSwitchLabel; + UICheckBox parallelSwitch; public ParallelSettingPane(){ this.setLayout(new BorderLayout()); - JPanel comboxPane = new JPanel(); - comboxPane.setLayout(new BorderLayout()); - comboxPane.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10)); UILabel belowSetLabel = new UILabel(Toolkit.i18nText("Fine-Designer_Setting_Mode")); belowSetLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 20)); - JPanel buttonPane = GUICoreUtils.createFlowPane(new Component[] { - belowSetLabel, getCombox()}, FlowLayout.LEFT, 0, 0); - this.add(buttonPane, BorderLayout.NORTH); + JPanel parallelSettingScopePane = GUICoreUtils.createFlowPane(new Component[] { + belowSetLabel, getParallelSettingScope()}, FlowLayout.LEFT, 0, 0); + this.add(parallelSettingScopePane, BorderLayout.NORTH); this.add(getSwitchPane(Toolkit.i18nText("Fine-Designer_Enable_Form_Block_Parallel_Calculate")), BorderLayout.CENTER); } - private UIComboBox getCombox() { - if (combox == null){ - combox = new UIComboBox(CHOOSEITEM); - combox.setFont(new Font(null, 0, 11)); - combox.addItemListener(new ItemListener() { + private UIComboBox getParallelSettingScope() { + if (parallelSettingScope == null){ + parallelSettingScope = new UIComboBox(CHOOSE_ITEM); + parallelSettingScope.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { - if (combox.getSelectedIndex() == SERVER_SET) { + if (isUsingServerSettings()) { populateServerSettings(); + parallelSwitch.setEnabled(false); + } else { + parallelSwitch.setEnabled(true); } } } }); } - return combox; + return parallelSettingScope; } private JPanel getSwitchPane(String tip){ JPanel innerPane = new JPanel(); innerPane.setLayout(new BorderLayout()); innerPane.setPreferredSize(new Dimension(500, 30)); - innerPane.setBorder(BorderFactory.createEmptyBorder(5, 70, 5, 10)); - JLabel label = new JLabel(tip); - label.setFont(new Font(null, 0, 12)); - innerPane.add(label, BorderLayout.WEST); - innerPane.add(getSwitchLabel(), BorderLayout.EAST); + innerPane.setBorder(BorderFactory.createEmptyBorder(10, 70, 5, 10)); + innerPane.add(getSwitchBox(tip)); return innerPane; } - private JLabel getSwitchLabel(){ - if (parallelSwitchLabel == null){ - parallelSwitchLabel = new ParallelSwitchLabel(); - combox.setSelectedIndex(SERVER_SET); - parallelSwitchLabel.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - if (!isUsingServerSettings()){ - parallelSwitchLabel.changeSwitchState(); - } - } - }); + private UICheckBox getSwitchBox(String tip){ + if (parallelSwitch == null){ + parallelSwitch = new UICheckBox(tip); } - return parallelSwitchLabel; + return parallelSwitch; } private boolean isUsingServerSettings(){ - return combox.getSelectedIndex() == SERVER_SET; + return parallelSettingScope.getSelectedIndex() == SERVER_SET; } public void populateBean(ParallelAttrMark parallelAttrMark){ - combox.setSelectedIndex(parallelAttrMark.isUseServerSetting() ? SERVER_SET : SINGLE_SET); + parallelSettingScope.setSelectedIndex(parallelAttrMark.isUseServerSetting() ? SERVER_SET : SINGLE_SET); if (parallelAttrMark.isUseServerSetting()){ populateServerSettings(); } else { @@ -151,15 +132,15 @@ public class FormParallelSettingPane extends BasicBeanPane { } private void populateServerSettings(){ - parallelSwitchLabel.setSwitchState(FormParallelCalConfig.getInstance().isParallelCal()); + parallelSwitch.setSelected(FormParallelCalConfig.getInstance().isParallelCal()); } private void populateSingleTemplateSetting(ParallelAttrMark parallelAttrMark){ - parallelSwitchLabel.setSwitchState(parallelAttrMark.isEnableParallel()); + parallelSwitch.setSelected(parallelAttrMark.isEnableParallel()); } public ParallelAttrMark updateBean(){ - return new ParallelAttrMark(isUsingServerSettings(), parallelSwitchLabel.isParallel()); + return new ParallelAttrMark(isUsingServerSettings(), parallelSwitch.isSelected()); } @Override @@ -167,31 +148,4 @@ public class FormParallelSettingPane extends BasicBeanPane { return ""; } } - - /** - * 一个并行开关Label - * */ - private static class ParallelSwitchLabel extends JLabel{ - boolean parallel; - private final static Icon openIcon = IOUtils.readIcon("com/fr/design/form/images/open.png"); - private final static Icon closeIcon = IOUtils.readIcon("com/fr/design/form/images/close.png"); - //设置计算状态,parallel状态和图标一起变化 - public void setSwitchState(boolean parallel){ - this.parallel = parallel; - if (parallel){ - this.setIcon(openIcon); - }else { - this.setIcon(closeIcon); - } - } - - public void changeSwitchState(){ - parallel = !parallel; - setSwitchState(parallel); - } - public boolean isParallel() { - return parallel; - } - } - }