forked from fanruan/design
Fly.Li
3 years ago
3 changed files with 141 additions and 10 deletions
@ -0,0 +1,131 @@ |
|||||||
|
package com.fr.design.widget.ui.designer; |
||||||
|
|
||||||
|
import com.fr.design.beans.BasicBeanPane; |
||||||
|
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; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.utils.gui.GUICoreUtils; |
||||||
|
import com.fr.form.main.parallel.FormECParallelCalAttr; |
||||||
|
import com.fr.report.core.config.FormParallelCalConfig; |
||||||
|
|
||||||
|
import javax.swing.BorderFactory; |
||||||
|
import javax.swing.JPanel; |
||||||
|
import java.awt.BorderLayout; |
||||||
|
import java.awt.Component; |
||||||
|
import java.awt.Dimension; |
||||||
|
import java.awt.FlowLayout; |
||||||
|
import java.awt.event.ItemEvent; |
||||||
|
import java.awt.event.ItemListener; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author fly.li |
||||||
|
* @version 10.0 |
||||||
|
* Created on 2022/03/18 |
||||||
|
*/ |
||||||
|
public class FormECParallelCalSettingPane extends BasicBeanPane<FormECParallelCalAttr> { |
||||||
|
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 parallelSettingScope; |
||||||
|
//并行计算开关
|
||||||
|
UICheckBox parallelSwitch; |
||||||
|
|
||||||
|
public FormECParallelCalSettingPane(){ |
||||||
|
initPane(); |
||||||
|
} |
||||||
|
|
||||||
|
private void initPane(){ |
||||||
|
JPanel calSettingOutPane = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Designer_Form_Block_Parallel_Calculate")); |
||||||
|
calSettingOutPane.setPreferredSize(new Dimension(550,110)); |
||||||
|
calSettingOutPane.add(getCalSettingPane()); |
||||||
|
this.add(calSettingOutPane); |
||||||
|
} |
||||||
|
|
||||||
|
private JPanel getCalSettingPane() { |
||||||
|
JPanel calSettingPane = new JPanel(); |
||||||
|
calSettingPane.setLayout(new BorderLayout()); |
||||||
|
UILabel belowSetLabel = new UILabel(Toolkit.i18nText("Fine-Designer_Setting_Mode")); |
||||||
|
belowSetLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 20)); |
||||||
|
JPanel parallelSettingScopePane = GUICoreUtils.createFlowPane(new Component[] { |
||||||
|
belowSetLabel, getParallelSettingScope()}, FlowLayout.LEFT, 0, 0); |
||||||
|
calSettingPane.add(parallelSettingScopePane, BorderLayout.NORTH); |
||||||
|
calSettingPane.add(getSwitchPane(Toolkit.i18nText("Fine-Designer_Enable_Form_Block_Parallel_Calculate")), BorderLayout.CENTER); |
||||||
|
return calSettingPane; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return Toolkit.i18nText("Fine-Designer_Form_Block_Parallel_Calculate"); |
||||||
|
} |
||||||
|
|
||||||
|
private UIComboBox getParallelSettingScope() { |
||||||
|
if (this.parallelSettingScope == null){ |
||||||
|
parallelSettingScope = new UIComboBox(CHOOSE_ITEM); |
||||||
|
parallelSettingScope.addItemListener(new ItemListener() { |
||||||
|
@Override |
||||||
|
public void itemStateChanged(ItemEvent e) { |
||||||
|
if (e.getStateChange() == ItemEvent.SELECTED) { |
||||||
|
if (isUsingServerSettings()) { |
||||||
|
populateServerSettings(); |
||||||
|
parallelSwitch.setEnabled(false); |
||||||
|
} else { |
||||||
|
parallelSwitch.setEnabled(true); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
return this.parallelSettingScope; |
||||||
|
} |
||||||
|
|
||||||
|
private JPanel getSwitchPane(String tip){ |
||||||
|
JPanel innerPane = new JPanel(); |
||||||
|
innerPane.setLayout(new BorderLayout()); |
||||||
|
innerPane.setPreferredSize(new Dimension(500, 30)); |
||||||
|
innerPane.setBorder(BorderFactory.createEmptyBorder(10, 70, 5, 10)); |
||||||
|
innerPane.add(getParallelSwitch(tip)); |
||||||
|
return innerPane; |
||||||
|
} |
||||||
|
|
||||||
|
private UICheckBox getParallelSwitch(String tip){ |
||||||
|
if (parallelSwitch == null){ |
||||||
|
parallelSwitch = new UICheckBox(tip); |
||||||
|
} |
||||||
|
return parallelSwitch; |
||||||
|
} |
||||||
|
|
||||||
|
private boolean isUsingServerSettings(){ |
||||||
|
return parallelSettingScope.getSelectedIndex() == SERVER_SET; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populateBean(FormECParallelCalAttr formParallelAttr){ |
||||||
|
if (formParallelAttr == null){ |
||||||
|
formParallelAttr = FormECParallelCalAttr.getDefaultParallelAttr(); |
||||||
|
} |
||||||
|
parallelSettingScope.setSelectedIndex(formParallelAttr.isUseServerSetting() ? SERVER_SET : SINGLE_SET); |
||||||
|
if (formParallelAttr.isUseServerSetting()){ |
||||||
|
populateServerSettings(); |
||||||
|
} else { |
||||||
|
populateSingleTemplateSetting(formParallelAttr); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void populateServerSettings(){ |
||||||
|
parallelSwitch.setSelected(FormParallelCalConfig.getInstance().isParallelCal()); |
||||||
|
} |
||||||
|
|
||||||
|
private void populateSingleTemplateSetting(FormECParallelCalAttr parallelAttr){ |
||||||
|
parallelSwitch.setSelected(parallelAttr.isParallelCal()); |
||||||
|
} |
||||||
|
|
||||||
|
public FormECParallelCalAttr updateBean(){ |
||||||
|
return new FormECParallelCalAttr(isUsingServerSettings(), parallelSwitch.isSelected()); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue