diff --git a/designer-form/src/main/java/com/fr/design/actions/FormParallelAction.java b/designer-form/src/main/java/com/fr/design/actions/FormParallelAction.java index 9011a5d15..25a15ae41 100644 --- a/designer-form/src/main/java/com/fr/design/actions/FormParallelAction.java +++ b/designer-form/src/main/java/com/fr/design/actions/FormParallelAction.java @@ -29,8 +29,7 @@ public class FormParallelAction extends JTemplateAction { @Override public String getMenuName() { - //todo 国际化 - return Toolkit.i18nText("Fine-Designer_PC_Fit_Attr"); + return Toolkit.i18nText("Fine-Designer_Parallel_Setting"); } @Override @@ -70,7 +69,6 @@ public class FormParallelAction extends JTemplateAction { parallelAttr = FormParallelAttr.getDefaultParallelAttr(); } attrPane.populateBean(parallelAttr); - //注意这里的pane大小 UIDialog dialog = attrPane.showWindowWithCustomSize(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { @Override public void doOk() { 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 ff92e3738..2533e7145 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 @@ -4,8 +4,8 @@ import com.fr.design.beans.BasicBeanPane; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.mainframe.JForm; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.form.main.parallel.FormParallelAttr; import com.fr.form.main.parallel.ParallelAttrMark; @@ -32,76 +32,47 @@ import java.awt.event.MouseEvent; * Created on 2022/03/18 */ public class FormParallelSettingPane extends BasicBeanPane { - private AbstractParallelSettingPane calculatePane; - private AbstractParallelSettingPane fetchDataPane; + private ParallelSettingPane parallelCalculatePane; public FormParallelSettingPane(){ initPane(); } private void initPane(){ - JPanel calSettingPane = FRGUIPaneFactory.createTitledBorderPane("报表块并行计算设置"); + JPanel calSettingPane = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Designer_Form_Block_Parallel_Setting")); calSettingPane.add(getCalculateSettingPane()); calSettingPane.setPreferredSize(new Dimension(550,110)); this.add(calSettingPane); - JPanel fetchDataSettingPane = FRGUIPaneFactory.createTitledBorderPane("并行取数设置"); - fetchDataSettingPane.add(getFetchDataSettingPane()); - fetchDataSettingPane.setPreferredSize(new Dimension(550, 110)); - this.add(fetchDataSettingPane); - JPanel tip = new JPanel(); - tip.setLayout(new BorderLayout()); - tip.add(new JLabel("注意:在多报表块共用一个数据集并且开启报表块并行计算时,建议同时开启并行取数"), BorderLayout.WEST); - tip.setPreferredSize(new Dimension(500, 20)); - this.add(tip); } - private AbstractParallelSettingPane getCalculateSettingPane(){ - if (calculatePane == null){ - this.calculatePane = new AbstractParallelSettingPane("开启报表块并行计算") { - @Override - protected void populateServerSettings() { - //这里获取全局设置并刷新数据到面板 - parallelSwitchLabel.setSwitchState(FormParallelCalConfig.getInstance().isParallelCal()); - } - }; + private ParallelSettingPane getCalculateSettingPane(){ + if (parallelCalculatePane == null){ + this.parallelCalculatePane = new ParallelSettingPane(); } - return calculatePane; + return parallelCalculatePane; } - private AbstractParallelSettingPane getFetchDataSettingPane(){ - if (fetchDataPane == null){ - this.fetchDataPane = new AbstractParallelSettingPane("开启并行取数") { - @Override - protected void populateServerSettings() { - parallelSwitchLabel.setSwitchState(FormParallelCalConfig.getInstance().isParallelFetchData()); - } - }; - } - return fetchDataPane; - } @Override public void populateBean(FormParallelAttr ob) { getCalculateSettingPane().populateBean(ob.getParallelCalculateMark()); - getFetchDataSettingPane().populateBean(ob.getParallelFetchDataMark()); } @Override public FormParallelAttr updateBean() { FormParallelAttr formParallelAttr = new FormParallelAttr(); - formParallelAttr.setParallelCalculateMark(calculatePane.updateBean()); - formParallelAttr.setParallelFetchDataMark(fetchDataPane.updateBean()); + formParallelAttr.setParallelCalculateMark(parallelCalculatePane.updateBean()); return formParallelAttr; } @Override protected String title4PopupWindow() { - return "Form并行设置"; + return Toolkit.i18nText("Fine-Designer_Parallel_Setting"); } - abstract static class AbstractParallelSettingPane extends BasicPane { + static class ParallelSettingPane extends BasicPane { private static final String[] CHOOSEITEM = new String[] { - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_I_Want_To_Set_Single"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Using_Server_Report_View_Settings") + 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; @@ -111,24 +82,20 @@ public class FormParallelSettingPane extends BasicBeanPane { //并行计算开关 ParallelSwitchLabel parallelSwitchLabel; - public AbstractParallelSettingPane(String tip){ + public ParallelSettingPane(){ this.setLayout(new BorderLayout()); JPanel comboxPane = new JPanel(); - UILabel belowSetLabel = new UILabel("设置方式"); + 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); - comboxPane.setLayout(new BorderLayout()); - comboxPane.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10)); this.add(buttonPane, BorderLayout.NORTH); - this.add(getContentPane(tip), BorderLayout.CENTER); - } - - protected JPanel getContentPane(String tip) { - return getSwitchPane(tip); + this.add(getSwitchPane(Toolkit.i18nText("Fine-Designer_Enable_Form_Block_Parallel_Calculate")), BorderLayout.CENTER); } - public UIComboBox getCombox() { + private UIComboBox getCombox() { if (combox == null){ combox = new UIComboBox(CHOOSEITEM); combox.setFont(new Font(null, 0, 11)); @@ -146,17 +113,11 @@ public class FormParallelSettingPane extends BasicBeanPane { return combox; } - /** - * 从服务器拿数据 - * */ - protected abstract void populateServerSettings(); - 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); @@ -167,7 +128,7 @@ public class FormParallelSettingPane extends BasicBeanPane { private JLabel getSwitchLabel(){ if (parallelSwitchLabel == null){ parallelSwitchLabel = new ParallelSwitchLabel(); - parallelSwitchLabel.setSwitchState(false); + combox.setSelectedIndex(SERVER_SET); parallelSwitchLabel.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { @@ -180,16 +141,25 @@ public class FormParallelSettingPane extends BasicBeanPane { return parallelSwitchLabel; } + private boolean isUsingServerSettings(){ + return combox.getSelectedIndex() == SERVER_SET; + } + public void populateBean(ParallelAttrMark parallelAttrMark){ - combox.setSelectedIndex(parallelAttrMark.isUseServerSetting() ? 1 : 0); - //只有在单模板设置时才需要在这里设置开关状态,服务器设置在setSelectedIndex的时候自动获取了服务器设置 - if (!parallelAttrMark.isUseServerSetting()){ - parallelSwitchLabel.setSwitchState(parallelAttrMark.isEnableParallel()); + combox.setSelectedIndex(parallelAttrMark.isUseServerSetting() ? SERVER_SET : SINGLE_SET); + if (parallelAttrMark.isUseServerSetting()){ + populateServerSettings(); + } else { + populateSingleTemplateSetting(parallelAttrMark); } } - private boolean isUsingServerSettings(){ - return combox.getSelectedIndex() == SERVER_SET; + private void populateServerSettings(){ + parallelSwitchLabel.setSwitchState(FormParallelCalConfig.getInstance().isParallelCal()); + } + + private void populateSingleTemplateSetting(ParallelAttrMark parallelAttrMark){ + parallelSwitchLabel.setSwitchState(parallelAttrMark.isEnableParallel()); } public ParallelAttrMark updateBean(){ @@ -223,7 +193,6 @@ public class FormParallelSettingPane extends BasicBeanPane { parallel = !parallel; setSwitchState(parallel); } - public boolean isParallel() { return parallel; }