Browse Source

KERNEL-10650:报表块并行计算单模板独立开关

feature/x
fly.li 3 years ago
parent
commit
e4b08c5b8b
  1. 4
      designer-form/src/main/java/com/fr/design/actions/FormParallelAction.java
  2. 101
      designer-form/src/main/java/com/fr/design/widget/ui/designer/FormParallelSettingPane.java

4
designer-form/src/main/java/com/fr/design/actions/FormParallelAction.java

@ -29,8 +29,7 @@ public class FormParallelAction extends JTemplateAction<JForm> {
@Override @Override
public String getMenuName() { public String getMenuName() {
//todo 国际化 return Toolkit.i18nText("Fine-Designer_Parallel_Setting");
return Toolkit.i18nText("Fine-Designer_PC_Fit_Attr");
} }
@Override @Override
@ -70,7 +69,6 @@ public class FormParallelAction extends JTemplateAction<JForm> {
parallelAttr = FormParallelAttr.getDefaultParallelAttr(); parallelAttr = FormParallelAttr.getDefaultParallelAttr();
} }
attrPane.populateBean(parallelAttr); attrPane.populateBean(parallelAttr);
//注意这里的pane大小
UIDialog dialog = attrPane.showWindowWithCustomSize(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { UIDialog dialog = attrPane.showWindowWithCustomSize(DesignerContext.getDesignerFrame(), new DialogActionAdapter() {
@Override @Override
public void doOk() { public void doOk() {

101
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.dialog.BasicPane;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.JForm;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.form.main.parallel.FormParallelAttr; import com.fr.form.main.parallel.FormParallelAttr;
import com.fr.form.main.parallel.ParallelAttrMark; import com.fr.form.main.parallel.ParallelAttrMark;
@ -32,76 +32,47 @@ import java.awt.event.MouseEvent;
* Created on 2022/03/18 * Created on 2022/03/18
*/ */
public class FormParallelSettingPane extends BasicBeanPane<FormParallelAttr> { public class FormParallelSettingPane extends BasicBeanPane<FormParallelAttr> {
private AbstractParallelSettingPane calculatePane; private ParallelSettingPane parallelCalculatePane;
private AbstractParallelSettingPane fetchDataPane;
public FormParallelSettingPane(){ public FormParallelSettingPane(){
initPane(); initPane();
} }
private void initPane(){ private void initPane(){
JPanel calSettingPane = FRGUIPaneFactory.createTitledBorderPane("报表块并行计算设置"); JPanel calSettingPane = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Designer_Form_Block_Parallel_Setting"));
calSettingPane.add(getCalculateSettingPane()); calSettingPane.add(getCalculateSettingPane());
calSettingPane.setPreferredSize(new Dimension(550,110)); calSettingPane.setPreferredSize(new Dimension(550,110));
this.add(calSettingPane); 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());
}
};
}
return calculatePane;
} }
private AbstractParallelSettingPane getFetchDataSettingPane(){ private ParallelSettingPane getCalculateSettingPane(){
if (fetchDataPane == null){ if (parallelCalculatePane == null){
this.fetchDataPane = new AbstractParallelSettingPane("开启并行取数") { this.parallelCalculatePane = new ParallelSettingPane();
@Override
protected void populateServerSettings() {
parallelSwitchLabel.setSwitchState(FormParallelCalConfig.getInstance().isParallelFetchData());
}
};
} }
return fetchDataPane; return parallelCalculatePane;
} }
@Override @Override
public void populateBean(FormParallelAttr ob) { public void populateBean(FormParallelAttr ob) {
getCalculateSettingPane().populateBean(ob.getParallelCalculateMark()); getCalculateSettingPane().populateBean(ob.getParallelCalculateMark());
getFetchDataSettingPane().populateBean(ob.getParallelFetchDataMark());
} }
@Override @Override
public FormParallelAttr updateBean() { public FormParallelAttr updateBean() {
FormParallelAttr formParallelAttr = new FormParallelAttr(); FormParallelAttr formParallelAttr = new FormParallelAttr();
formParallelAttr.setParallelCalculateMark(calculatePane.updateBean()); formParallelAttr.setParallelCalculateMark(parallelCalculatePane.updateBean());
formParallelAttr.setParallelFetchDataMark(fetchDataPane.updateBean());
return formParallelAttr; return formParallelAttr;
} }
@Override @Override
protected String title4PopupWindow() { 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[] { private static final String[] CHOOSEITEM = new String[] {
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_I_Want_To_Set_Single"), 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_Form_Using_Server_Report_View_Settings")
}; };
protected static final int SINGLE_SET = 0; protected static final int SINGLE_SET = 0;
@ -111,24 +82,20 @@ public class FormParallelSettingPane extends BasicBeanPane<FormParallelAttr> {
//并行计算开关 //并行计算开关
ParallelSwitchLabel parallelSwitchLabel; ParallelSwitchLabel parallelSwitchLabel;
public AbstractParallelSettingPane(String tip){ public ParallelSettingPane(){
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
JPanel comboxPane = new JPanel(); 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)); belowSetLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 20));
JPanel buttonPane = GUICoreUtils.createFlowPane(new Component[] { JPanel buttonPane = GUICoreUtils.createFlowPane(new Component[] {
belowSetLabel, getCombox()}, FlowLayout.LEFT, 0, 0); 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(buttonPane, BorderLayout.NORTH);
this.add(getContentPane(tip), BorderLayout.CENTER); this.add(getSwitchPane(Toolkit.i18nText("Fine-Designer_Enable_Form_Block_Parallel_Calculate")), BorderLayout.CENTER);
}
protected JPanel getContentPane(String tip) {
return getSwitchPane(tip);
} }
public UIComboBox getCombox() { private UIComboBox getCombox() {
if (combox == null){ if (combox == null){
combox = new UIComboBox(CHOOSEITEM); combox = new UIComboBox(CHOOSEITEM);
combox.setFont(new Font(null, 0, 11)); combox.setFont(new Font(null, 0, 11));
@ -146,17 +113,11 @@ public class FormParallelSettingPane extends BasicBeanPane<FormParallelAttr> {
return combox; return combox;
} }
/**
* 从服务器拿数据
* */
protected abstract void populateServerSettings();
private JPanel getSwitchPane(String tip){ private JPanel getSwitchPane(String tip){
JPanel innerPane = new JPanel(); JPanel innerPane = new JPanel();
innerPane.setLayout(new BorderLayout()); innerPane.setLayout(new BorderLayout());
innerPane.setPreferredSize(new Dimension(500, 30)); innerPane.setPreferredSize(new Dimension(500, 30));
innerPane.setBorder(BorderFactory.createEmptyBorder(5, 70, 5, 10)); innerPane.setBorder(BorderFactory.createEmptyBorder(5, 70, 5, 10));
JLabel label = new JLabel(tip); JLabel label = new JLabel(tip);
label.setFont(new Font(null, 0, 12)); label.setFont(new Font(null, 0, 12));
innerPane.add(label, BorderLayout.WEST); innerPane.add(label, BorderLayout.WEST);
@ -167,7 +128,7 @@ public class FormParallelSettingPane extends BasicBeanPane<FormParallelAttr> {
private JLabel getSwitchLabel(){ private JLabel getSwitchLabel(){
if (parallelSwitchLabel == null){ if (parallelSwitchLabel == null){
parallelSwitchLabel = new ParallelSwitchLabel(); parallelSwitchLabel = new ParallelSwitchLabel();
parallelSwitchLabel.setSwitchState(false); combox.setSelectedIndex(SERVER_SET);
parallelSwitchLabel.addMouseListener(new MouseAdapter() { parallelSwitchLabel.addMouseListener(new MouseAdapter() {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
@ -180,16 +141,25 @@ public class FormParallelSettingPane extends BasicBeanPane<FormParallelAttr> {
return parallelSwitchLabel; return parallelSwitchLabel;
} }
private boolean isUsingServerSettings(){
return combox.getSelectedIndex() == SERVER_SET;
}
public void populateBean(ParallelAttrMark parallelAttrMark){ public void populateBean(ParallelAttrMark parallelAttrMark){
combox.setSelectedIndex(parallelAttrMark.isUseServerSetting() ? 1 : 0); combox.setSelectedIndex(parallelAttrMark.isUseServerSetting() ? SERVER_SET : SINGLE_SET);
//只有在单模板设置时才需要在这里设置开关状态,服务器设置在setSelectedIndex的时候自动获取了服务器设置 if (parallelAttrMark.isUseServerSetting()){
if (!parallelAttrMark.isUseServerSetting()){ populateServerSettings();
parallelSwitchLabel.setSwitchState(parallelAttrMark.isEnableParallel()); } else {
populateSingleTemplateSetting(parallelAttrMark);
} }
} }
private boolean isUsingServerSettings(){ private void populateServerSettings(){
return combox.getSelectedIndex() == SERVER_SET; parallelSwitchLabel.setSwitchState(FormParallelCalConfig.getInstance().isParallelCal());
}
private void populateSingleTemplateSetting(ParallelAttrMark parallelAttrMark){
parallelSwitchLabel.setSwitchState(parallelAttrMark.isEnableParallel());
} }
public ParallelAttrMark updateBean(){ public ParallelAttrMark updateBean(){
@ -223,7 +193,6 @@ public class FormParallelSettingPane extends BasicBeanPane<FormParallelAttr> {
parallel = !parallel; parallel = !parallel;
setSwitchState(parallel); setSwitchState(parallel);
} }
public boolean isParallel() { public boolean isParallel() {
return parallel; return parallel;
} }

Loading…
Cancel
Save