Browse Source

Pull request #6100: REPORT-59681 远程设计控制模板自适应权限控制

Merge in DESIGN/design from ~HENRY.WANG/design:release/11.0 to release/11.0

* commit '511d6e6aa63598e71f49cfbb4241fcf099f83419':
  REPORT-59681 远程设计控制模板自适应权限控制
bugfix/11.0
Henry.Wang 3 years ago
parent
commit
5b5278895a
  1. 55
      designer-base/src/main/java/com/fr/design/report/fit/AdaptiveFrmFitAttrModel.java
  2. 228
      designer-base/src/main/java/com/fr/design/report/fit/BaseFitAttrPane.java
  3. 51
      designer-base/src/main/java/com/fr/design/report/fit/CptFitAttrModel.java
  4. 44
      designer-base/src/main/java/com/fr/design/report/fit/FitAttrModel.java
  5. 53
      designer-base/src/main/java/com/fr/design/report/fit/FrmFitAttrModel.java
  6. 10
      designer-base/src/main/java/com/fr/design/report/fit/menupane/ReportFitAttrAction.java
  7. 102
      designer-base/src/main/java/com/fr/design/report/fit/menupane/TemplateFitAttrPane.java
  8. 18
      designer-base/src/main/java/com/fr/design/report/fit/provider/AbstractFitAttrModelProvider.java
  9. 11
      designer-base/src/main/java/com/fr/design/report/fit/provider/FitAttrModelProvider.java
  10. 15
      designer-form/src/main/java/com/fr/design/actions/FormFitAttrAction.java
  11. 21
      designer-realize/src/main/java/com/fr/design/webattr/EditReportServerParameterPane.java
  12. 78
      designer-realize/src/main/java/com/fr/design/webattr/ServerFitAttrPane.java

55
designer-base/src/main/java/com/fr/design/report/fit/AdaptiveFrmFitAttrModel.java

@ -0,0 +1,55 @@
package com.fr.design.report.fit;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.report.fit.provider.AbstractFitAttrModelProvider;
import com.fr.form.fit.common.LightTool;
import com.fr.form.fit.config.FormFitConfig;
import com.fr.form.main.Form;
import com.fr.report.fit.ReportFitAttr;
public class AdaptiveFrmFitAttrModel extends AbstractFitAttrModelProvider {
public FitType[] getFitTypes() {
return new FitType[]{
FitType.DOUBLE_FIT,
FitType.HORIZONTAL_FIT,
FitType.NOT_FIT
};
}
public String getFitName() {
return Toolkit.i18nText("Fine-Designer_Fit_Report_Scale_Method");
}
@Override
public String getModelName() {
return Toolkit.i18nText("Fine-Design_New_Decision_Report");
}
@Override
public ReportFitAttr getGlobalReportFitAttr() {
return FormFitConfig.getInstance().getNewFitAttr();
}
@Override
public void setGlobalReportFitAttr(ReportFitAttr reportFitAttr) {
FormFitConfig.getInstance().setNewFitAttr(reportFitAttr);
}
@Override
public int getPriority() {
return 2;
}
@Override
public boolean isAvailable(JTemplate jTemplate) {
if (jTemplate.getTarget() instanceof Form) {
return LightTool.containNewFormFlag((Form) jTemplate.getTarget());
}
return false;
}
}

228
designer-base/src/main/java/com/fr/design/report/fit/BaseFitAttrPane.java

@ -0,0 +1,228 @@
package com.fr.design.report.fit;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.report.fit.menupane.FitPreviewPane;
import com.fr.design.report.fit.menupane.FitRadioGroup;
import com.fr.design.report.fit.menupane.FontRadioGroup;
import com.fr.design.report.fit.provider.FitAttrModelProvider;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils;
import com.fr.report.fit.ReportFitAttr;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Set;
import java.util.stream.Collectors;
import static com.fr.design.i18n.Toolkit.i18nText;
public abstract class BaseFitAttrPane extends BasicBeanPane<ReportFitAttr> {
protected JPanel contentJPanel;
protected UIComboBox itemChoose;
protected java.util.List<FitAttrModel> fitAttrModelList = new ArrayList<>();
public FontRadioGroup fontRadioGroup;
public FitRadioGroup adaptRadioGroup;
public JPanel attrJPanel;
public FitPreviewPane previewJPanel;
public FitAttrModel fitAttrModel;
protected BaseFitAttrPane() {
initFitAttrModel();
}
private void initFitAttrModel() {
fitAttrModelList.add(new FrmFitAttrModel());
fitAttrModelList.add(new CptFitAttrModel());
fitAttrModelList.add(new AdaptiveFrmFitAttrModel());
Set<FitAttrModelProvider> fitAttrModelProviders = ExtraDesignClassManager.getInstance().getArray(FitAttrModelProvider.XML_TAG);
for (FitAttrModelProvider fitAttrModelProvider : fitAttrModelProviders) {
fitAttrModelList.add(fitAttrModelProvider);
}
fitAttrModelList = fitAttrModelList.stream().sorted(Comparator.comparing(FitAttrModel::getPriority).reversed()).collect(Collectors.toList());
}
protected void populateModel(FitAttrModel fitAttrModel) {
this.fitAttrModel = fitAttrModel;
if (attrJPanel != null) {
contentJPanel.remove(attrJPanel);
}
if (previewJPanel != null) {
contentJPanel.remove(previewJPanel);
}
fontRadioGroup = new FontRadioGroup();
adaptRadioGroup = new FitRadioGroup();
initAttrJPanel();
initPreviewJPanel();
}
protected void initAttrJPanel() {
int colCount = fitAttrModel.getFitTypes().length + 1;
Component[][] components = new Component[2][colCount];
initFitRadioGroup(fontRadioGroup, i18nText("Fine-Designer_Fit-Font"), new String[]{i18nText("Fine-Designer_Fit"), i18nText("Fine-Designer_Fit-No")}, components[0]);
initFitRadioGroup(adaptRadioGroup, fitAttrModel.getFitName(), Arrays.stream(fitAttrModel.getFitTypes()).map(FitType::description).toArray(String[]::new), components[1]);
double[] rowSize = new double[2];
double[] columnSize = new double[colCount];
for (int i = 0; i < rowSize.length; i++) {
rowSize[i] = 20;
}
for (int i = 0; i < columnSize.length; i++) {
if (i == 0) {
columnSize[i] = 80;
} else {
columnSize[i] = 100;
}
}
attrJPanel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
attrJPanel.setBorder(new EmptyBorder(0, 100, 10, 100));
contentJPanel.add(attrJPanel);
}
private void initFitRadioGroup(FitRadioGroup fitRadioGroup, String name, String[] options, Component[] components) {
components[0] = new UILabel(name);
for (int i = 0; i < options.length; i++) {
if (options[i] != null) {
UIRadioButton fontFitRadio = new UIRadioButton(options[i]);
fitRadioGroup.add(fontFitRadio);
components[i + 1] = fontFitRadio;
} else {
components[i + 1] = null;
}
}
fitRadioGroup.addActionListener(getPreviewActionListener());
}
protected ActionListener getPreviewActionListener() {
return new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
refreshPreviewJPanel();
}
};
}
protected void refreshPreviewJPanel() {
String previewIndex = getPreviewIndex();
previewJPanel.refreshPreview(previewIndex, fontRadioGroup.isEnabled());
}
protected String getPreviewIndex() {
return getStateInPC(adaptRadioGroup.getSelectRadioIndex()) + "" + fontRadioGroup.getSelectRadioIndex();
}
protected void initPreviewJPanel() {
previewJPanel = new FitPreviewPane();
contentJPanel.add(previewJPanel);
}
protected int getStateInPC(int index) {
FitType[] fitTypes = fitAttrModel.getFitTypes();
return fitTypes[index].getState();
}
protected int getOptionIndex(int state) {
FitType[] fitTypes = fitAttrModel.getFitTypes();
for (int i = 0; i < fitTypes.length; i++) {
if (ComparatorUtils.equals(state, fitTypes[i].getState())) {
return i;
}
}
return 0;
}
@Override
public void populateBean(ReportFitAttr ob) {
fontRadioGroup.selectIndexButton(ob.isFitFont() ? 0 : 1);
adaptRadioGroup.selectIndexButton(getOptionIndex(ob.fitStateInPC()));
refreshPreviewJPanel();
}
@Override
public ReportFitAttr updateBean() {
ReportFitAttr reportFitAttr = new ReportFitAttr();
reportFitAttr.setFitFont(fontRadioGroup.isFontFit());
reportFitAttr.setFitStateInPC(getStateInPC(adaptRadioGroup.getSelectRadioIndex()));
return reportFitAttr;
}
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
fontRadioGroup.setEnabled(enabled);
adaptRadioGroup.setEnabled(enabled);
refreshPreviewJPanel();
}
@Override
protected String title4PopupWindow() {
return i18nText("Fine-Designer_PC_Element_Case_Fit_Attr");
}
protected abstract String[] getItemNames();
protected void initComponents() {
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
contentJPanel = new JPanel();
contentJPanel.setLayout(FRGUIPaneFactory.createCenterFlowLayout());
this.add(contentJPanel);
initItemChoose();
}
private void initItemChoose() {
JPanel chooseJPanel = new JPanel();
chooseJPanel.setLayout(FRGUIPaneFactory.createLabelFlowLayout());
ItemListener itemListener = getItemListener();
itemChoose = new UIComboBox(getItemNames());
itemChoose.addItemListener(itemListener);
UILabel belowSetLabel = new UILabel(i18nText("Fine-Design_Report_Blow_Set"));
JPanel buttonPane = GUICoreUtils.createFlowPane(new Component[]{
belowSetLabel, itemChoose}, FlowLayout.LEFT, 0, 0);
chooseJPanel.add(buttonPane);
chooseJPanel.setPreferredSize(new Dimension(500, 50));
JPanel jPanel = new JPanel();
jPanel.setLayout(FRGUIPaneFactory.createBorderLayout());
jPanel.add(chooseJPanel, BorderLayout.WEST);
contentJPanel.add(jPanel);
}
protected abstract ItemListener getItemListener();
public void populate(ReportFitAttr reportFitAttr) {
}
protected void refresh() {
validate();
repaint();
revalidate();
}
}

51
designer-base/src/main/java/com/fr/design/report/fit/CptFitAttrModel.java

@ -0,0 +1,51 @@
package com.fr.design.report.fit;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.JTemplate;
import com.fr.report.fit.ReportFitAttr;
import com.fr.report.fit.ReportFitConfig;
public class CptFitAttrModel implements FitAttrModel {
@Override
public FitType[] getFitTypes() {
return new FitType[]{
FitType.HORIZONTAL_FIT,
FitType.DOUBLE_FIT,
FitType.NOT_FIT
};
}
@Override
public String getFitName() {
return Toolkit.i18nText("Fine-Designer_Fit-Element");
}
@Override
public String getModelName() {
return Toolkit.i18nText("Fine-Design_Basic_Plain_Report");
}
@Override
public ReportFitAttr getGlobalReportFitAttr() {
return ReportFitConfig.getInstance().getCptFitAttr();
}
@Override
public void setGlobalReportFitAttr(ReportFitAttr reportFitAttr) {
ReportFitConfig.getInstance().setCptFitAttr(reportFitAttr);
}
@Override
public int getPriority() {
return 0;
}
@Override
public boolean isAvailable(JTemplate jTemplate) {
return jTemplate.isJWorkBook();
}
}

44
designer-base/src/main/java/com/fr/design/report/fit/FitAttrModel.java

@ -0,0 +1,44 @@
package com.fr.design.report.fit;
import com.fr.design.mainframe.JTemplate;
import com.fr.report.fit.ReportFitAttr;
public interface FitAttrModel {
/**
* @Description 名称比如普通报表决策报表等
**/
String getModelName();
/**
* @Description 自适应选项的名称比如返回表格
**/
String getFitName();
/**
* @Description 自适应选项
**/
FitType[] getFitTypes();
/**
* @Description 获取全局的自适应属性
**/
ReportFitAttr getGlobalReportFitAttr();
/**
* @Description 设置全局的自适应属性
* @param: reportFitAttr
**/
void setGlobalReportFitAttr(ReportFitAttr reportFitAttr);
/**
* @Description 优先级
**/
int getPriority();
/**
* @Description 是否可用
* @param: jTemplate
**/
boolean isAvailable(JTemplate jTemplate);
}

53
designer-base/src/main/java/com/fr/design/report/fit/FrmFitAttrModel.java

@ -0,0 +1,53 @@
package com.fr.design.report.fit;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.JTemplate;
import com.fr.report.fit.ReportFitAttr;
import com.fr.report.fit.ReportFitConfig;
public class FrmFitAttrModel implements FitAttrModel {
@Override
public String getModelName() {
return Toolkit.i18nText("Fine-Design_Basic_Decision_Report");
}
@Override
public String getFitName() {
return Toolkit.i18nText("Fine-Designer_Fit-Element");
}
public FitType[] getFitTypes() {
return new FitType[]{
FitType.DEFAULT,
FitType.HORIZONTAL_FIT,
FitType.DOUBLE_FIT,
FitType.NOT_FIT
};
}
@Override
public ReportFitAttr getGlobalReportFitAttr() {
return ReportFitConfig.getInstance().getFrmFitAttr();
}
@Override
public void setGlobalReportFitAttr(ReportFitAttr reportFitAttr) {
ReportFitConfig.getInstance().setFrmFitAttr(reportFitAttr);
}
@Override
public int getPriority() {
return 1;
}
@Override
public boolean isAvailable(JTemplate jTemplate) {
return !jTemplate.isJWorkBook();
}
}

10
designer-base/src/main/java/com/fr/design/report/fit/menupane/ReportFitAttrAction.java

@ -1,6 +1,5 @@
package com.fr.design.report.fit.menupane; package com.fr.design.report.fit.menupane;
import com.fr.base.svg.IconUtils;
import com.fr.design.actions.JTemplateAction; import com.fr.design.actions.JTemplateAction;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
@ -82,13 +81,8 @@ public class ReportFitAttrAction extends JTemplateAction {
} }
final FitProvider wbTpl = (FitProvider) jwb.getTarget(); final FitProvider wbTpl = (FitProvider) jwb.getTarget();
ReportFitAttr fitAttr = wbTpl.getReportFitAttr(); ReportFitAttr fitAttr = wbTpl.getReportFitAttr();
if (jwb.isJWorkBook()) { TemplateFitAttrPane templateFitAttrPane = new TemplateFitAttrPane();
final TemplateFitAttrPane attrPane = new TemplateFitAttrPane(); showReportFitDialog(fitAttr, jwb, wbTpl, templateFitAttrPane);
showReportFitDialog(fitAttr, jwb, wbTpl, attrPane);
} else {
final ReportFitAttrPane attrPane = new ReportFitAttrPane();
showReportFitDialog(fitAttr, jwb, wbTpl, attrPane);
}
} }
private void showReportFitDialog(ReportFitAttr fitAttr, final JTemplate jwb, final FitProvider wbTpl, final BasicBeanPane<ReportFitAttr> attrPane) { private void showReportFitDialog(ReportFitAttr fitAttr, final JTemplate jwb, final FitProvider wbTpl, final BasicBeanPane<ReportFitAttr> attrPane) {

102
designer-base/src/main/java/com/fr/design/report/fit/menupane/TemplateFitAttrPane.java

@ -1,55 +1,91 @@
package com.fr.design.report.fit.menupane; package com.fr.design.report.fit.menupane;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.report.fit.BaseFitAttrPane;
import com.fr.design.report.fit.FitAttrModel;
import com.fr.general.ComparatorUtils;
import com.fr.report.fit.FitProvider;
import com.fr.report.fit.ReportFitAttr; import com.fr.report.fit.ReportFitAttr;
import javax.swing.BorderFactory; import java.awt.event.ItemEvent;
import javax.swing.BoxLayout; import java.awt.event.ItemListener;
/**
* Created by 夏翔 on 2016/6/24.
*/
public class TemplateFitAttrPane extends BasicBeanPane<ReportFitAttr> {
private TemplateBrowserFitAttrPane attrPane;
public class TemplateFitAttrPane extends BaseFitAttrPane {
public TemplateFitAttrPane() { public TemplateFitAttrPane() {
initComponents(); initComponents();
} }
private void initComponents() { @Override
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); protected void initComponents() {
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); super.initComponents();
attrPane = new TemplateBrowserFitAttrPane(); for (FitAttrModel fitAttrModel : fitAttrModelList) {
this.add(attrPane); if (fitAttrModel.isAvailable(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate())) {
populateModel(fitAttrModel);
break;
}
}
}
@Override
public void populateBean(ReportFitAttr reportFitAttr) {
if (reportFitAttr == null) {
itemChoose.setSelectedItem(Toolkit.i18nText("Fine-Design_Report_Using_Server_Report_View_Settings"));
} else {
itemChoose.setSelectedItem(Toolkit.i18nText("Fine-Design_Report_I_Want_To_Set_Single"));
}
populate(reportFitAttr);
}
public void populate(ReportFitAttr reportFitAttr) {
if (reportFitAttr == null) {
reportFitAttr = fitAttrModel.getGlobalReportFitAttr();
} }
/** super.setEnabled(isTemplateSingleSet());
* 展示界面 super.populateBean(reportFitAttr);
*
* @param fitAttr 自适应属性
*/
public void populateBean(ReportFitAttr fitAttr) {
attrPane.populateBean(fitAttr);
} }
/**
* 提交数据
*
* @return 界面上的更新数据
*/
public ReportFitAttr updateBean() { public ReportFitAttr updateBean() {
return attrPane.updateBean(); if (!isTemplateSingleSet()) {
return null;
} else {
return super.updateBean();
}
}
@Override
protected String[] getItemNames() {
return new String[]{Toolkit.i18nText("Fine-Design_Report_Using_Server_Report_View_Settings"),
Toolkit.i18nText("Fine-Design_Report_I_Want_To_Set_Single")};
}
@Override
protected ItemListener getItemListener() {
return new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
if(isTemplateSingleSet()){
JTemplate jwb = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (jwb != null) {
FitProvider wbTpl = (FitProvider) jwb.getTarget();
ReportFitAttr fitAttr = wbTpl.getReportFitAttr();
populate(fitAttr);
}
}else {
populate(fitAttrModel.getGlobalReportFitAttr());
}
}
}
};
} }
/** private boolean isTemplateSingleSet() {
* 标题 return ComparatorUtils.equals(Toolkit.i18nText("Fine-Design_Report_I_Want_To_Set_Single"), itemChoose.getSelectedItem());
*
* @return 标题
*/
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_PC_Fit_Attr");
} }
} }

18
designer-base/src/main/java/com/fr/design/report/fit/provider/AbstractFitAttrModelProvider.java

@ -0,0 +1,18 @@
package com.fr.design.report.fit.provider;
import com.fr.stable.fun.mark.API;
@API(level = FitAttrModelProvider.CURRENT_LEVEL)
public abstract class AbstractFitAttrModelProvider implements FitAttrModelProvider {
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
@Override
public String mark4Provider() {
return getClass().getName();
}
}

11
designer-base/src/main/java/com/fr/design/report/fit/provider/FitAttrModelProvider.java

@ -0,0 +1,11 @@
package com.fr.design.report.fit.provider;
import com.fr.design.report.fit.FitAttrModel;
import com.fr.stable.fun.mark.Mutable;
public interface FitAttrModelProvider extends Mutable, FitAttrModel {
String XML_TAG = "FitAttrModelProvider";
int CURRENT_LEVEL = 1;
}

15
designer-form/src/main/java/com/fr/design/actions/FormFitAttrAction.java

@ -8,6 +8,7 @@ import com.fr.design.fit.NewJForm;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.menu.MenuKeySet; import com.fr.design.menu.MenuKeySet;
import com.fr.design.report.fit.menupane.TemplateFitAttrPane;
import com.fr.report.fit.FitProvider; import com.fr.report.fit.FitProvider;
import com.fr.report.fit.ReportFitAttr; import com.fr.report.fit.ReportFitAttr;
@ -47,26 +48,20 @@ public class FormFitAttrAction extends JTemplateAction {
this.setName(getMenuKeySet().getMenuKeySetName() + "..."); this.setName(getMenuKeySet().getMenuKeySetName() + "...");
this.setMnemonic(getMenuKeySet().getMnemonic()); this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(DesignerUIModeConfig.getInstance().newUIMode() ? this.setSmallIcon(DesignerUIModeConfig.getInstance().newUIMode() ?
"/com/fr/design/images/reportfit/fit.png": "/com/fr/design/images/reportfit/fit.png" :
"/com/fr/design/images/reportfit/fit"); "/com/fr/design/images/reportfit/fit");
} }
/**
* Action触发事件
*
* @param e 事件
*/
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
final JTemplate jwb = getEditingComponent(); final JTemplate jwb = getEditingComponent();
if (jwb == null || !(jwb instanceof NewJForm)) { if (jwb == null) {
return; return;
} }
final FitProvider wbTpl = (FitProvider) jwb.getTarget(); final FitProvider wbTpl = (FitProvider) jwb.getTarget();
ReportFitAttr fitAttr = wbTpl.getReportFitAttr(); ReportFitAttr fitAttr = wbTpl.getReportFitAttr();
NewJForm newJForm = (NewJForm) jwb; TemplateFitAttrPane templateFitAttrPane = new TemplateFitAttrPane();
BasicBeanPane attrPane = newJForm.getJFormType().obtainAttrPane(newJForm); showFitDialog(fitAttr, jwb, wbTpl, templateFitAttrPane);
showFitDialog(fitAttr, jwb, wbTpl, attrPane);
} }
private void showFitDialog(ReportFitAttr fitAttr, final JTemplate jwb, final FitProvider wbTpl, final BasicBeanPane<ReportFitAttr> attrPane) { private void showFitDialog(ReportFitAttr fitAttr, final JTemplate jwb, final FitProvider wbTpl, final BasicBeanPane<ReportFitAttr> attrPane) {

21
designer-realize/src/main/java/com/fr/design/webattr/EditReportServerParameterPane.java

@ -9,6 +9,7 @@ import com.fr.config.PrintConfig;
import com.fr.config.ServerPreferenceConfig; import com.fr.config.ServerPreferenceConfig;
import com.fr.design.gui.frpane.LoadingBasicPane; import com.fr.design.gui.frpane.LoadingBasicPane;
import com.fr.design.gui.frpane.UITabbedPane; import com.fr.design.gui.frpane.UITabbedPane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.webattr.printsettings.GlobalNativePrintSettingPane; import com.fr.design.webattr.printsettings.GlobalNativePrintSettingPane;
import com.fr.design.webattr.printsettings.PrintSettingPane; import com.fr.design.webattr.printsettings.PrintSettingPane;
@ -17,6 +18,7 @@ import com.fr.report.web.WebPage;
import com.fr.report.web.WebView; import com.fr.report.web.WebView;
import com.fr.report.web.WebWrite; import com.fr.report.web.WebWrite;
import com.fr.web.attr.ReportWebAttr; import com.fr.web.attr.ReportWebAttr;
import com.fr.workspace.WorkContext;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.BorderLayout; import java.awt.BorderLayout;
@ -44,6 +46,8 @@ public class EditReportServerParameterPane extends LoadingBasicPane {
private PrintSettingPane printSettingPane; private PrintSettingPane printSettingPane;
private ServerFitAttrPane serverFitAttrPane;
@Override @Override
protected synchronized void initComponents(JPanel container) { protected synchronized void initComponents(JPanel container) {
@ -61,6 +65,9 @@ public class EditReportServerParameterPane extends LoadingBasicPane {
tabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ReportServerP_Import_JavaScript"), jsPane = new WebJsPane()); tabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ReportServerP_Import_JavaScript"), jsPane = new WebJsPane());
tabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Error_Handler_Template"), errorTemplatePane = new ErrorTemplatePane()); tabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Error_Handler_Template"), errorTemplatePane = new ErrorTemplatePane());
tabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Print_Setting"), printSettingPane = new PrintSettingPane(new GlobalNativePrintSettingPane())); tabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Print_Setting"), printSettingPane = new PrintSettingPane(new GlobalNativePrintSettingPane()));
if (WorkContext.getCurrent().isRoot()) {
tabbedPane.addTab(Toolkit.i18nText("Fine-Designer_PC_Fit_Attr"), serverFitAttrPane = new ServerFitAttrPane());
}
} }
@Override @Override
@ -78,13 +85,13 @@ public class EditReportServerParameterPane extends LoadingBasicPane {
WebPage webPage = webAttr.getWebPage(); WebPage webPage = webAttr.getWebPage();
WebView webView = webAttr.getWebView(); WebView webView = webAttr.getWebView();
WebWrite webWrite = webAttr.getWebWrite(); WebWrite webWrite = webAttr.getWebWrite();
if(webPage != null){ if (webPage != null) {
pagePane.populateBean(webPage); pagePane.populateBean(webPage);
} }
if(webView != null){ if (webView != null) {
viewPane.populateBean(webView); viewPane.populateBean(webView);
} }
if(webWrite != null){ if (webWrite != null) {
writePane.populateBean(webWrite); writePane.populateBean(webWrite);
} }
cssPane.populate(webAttr); cssPane.populate(webAttr);
@ -93,13 +100,16 @@ public class EditReportServerParameterPane extends LoadingBasicPane {
printSettingPane.populate(printSettings); printSettingPane.populate(printSettings);
this.errorTemplatePane.populateBean(reportServerPreferenceConfig.getErrorTemplate()); this.errorTemplatePane.populateBean(reportServerPreferenceConfig.getErrorTemplate());
if (serverFitAttrPane != null) {
serverFitAttrPane.populateBean(null);
}
} }
/** /**
* Update. * Update.
*/ */
public void update(ServerPreferenceConfig reportServerPreferenceConfig) { public void update(ServerPreferenceConfig reportServerPreferenceConfig) {
ReportWebAttr webAttr = ((ReportWebAttr)ConfigManager.getProviderInstance().getGlobalAttribute(ReportWebAttr.class)); ReportWebAttr webAttr = ((ReportWebAttr) ConfigManager.getProviderInstance().getGlobalAttribute(ReportWebAttr.class));
webAttr.setWebPage(pagePane.updateBean()); webAttr.setWebPage(pagePane.updateBean());
webAttr.setWebView(viewPane.updateBean()); webAttr.setWebView(viewPane.updateBean());
webAttr.setWebWrite(writePane.updateBean()); webAttr.setWebWrite(writePane.updateBean());
@ -110,5 +120,8 @@ public class EditReportServerParameterPane extends LoadingBasicPane {
PrintConfig.getInstance().setPrintSettings(printSettings); PrintConfig.getInstance().setPrintSettings(printSettings);
reportServerPreferenceConfig.setErrorTemplate(this.errorTemplatePane.updateBean()); reportServerPreferenceConfig.setErrorTemplate(this.errorTemplatePane.updateBean());
if (serverFitAttrPane != null) {
serverFitAttrPane.updateBean();
}
} }
} }

78
designer-realize/src/main/java/com/fr/design/webattr/ServerFitAttrPane.java

@ -0,0 +1,78 @@
package com.fr.design.webattr;
import com.fr.config.Configuration;
import com.fr.design.report.fit.BaseFitAttrPane;
import com.fr.design.report.fit.FitAttrModel;
import com.fr.general.ComparatorUtils;
import com.fr.report.fit.ReportFitAttr;
import com.fr.report.fit.ReportFitConfig;
import com.fr.transaction.Configurations;
import com.fr.transaction.Worker;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
public class ServerFitAttrPane extends BaseFitAttrPane {
public ServerFitAttrPane() {
super();
initComponents();
}
@Override
protected void initComponents() {
super.initComponents();
populateModel(fitAttrModelList.get(0));
}
@Override
public void populateBean(ReportFitAttr reportFitAttr) {
reportFitAttr = fitAttrModel.getGlobalReportFitAttr();
super.populateBean(reportFitAttr);
}
public ReportFitAttr updateBean() {
ReportFitAttr reportFitAttr = super.updateBean();
Configurations.update(new Worker() {
@Override
public void run() {
fitAttrModel.setGlobalReportFitAttr(reportFitAttr);
}
@Override
public Class<? extends Configuration>[] targets() {
return new Class[]{ReportFitConfig.class};
}
});
return null;
}
@Override
protected String[] getItemNames() {
return fitAttrModelList.stream().map(FitAttrModel::getModelName).toArray(String[]::new);
}
@Override
protected ItemListener getItemListener() {
ServerFitAttrPane self = this;
return new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
for (FitAttrModel fitAttrModel : fitAttrModelList) {
if (ComparatorUtils.equals(e.getItem(), fitAttrModel.getModelName())) {
self.populateModel(fitAttrModel);
populateBean(null);
refresh();
}
}
}
}
};
}
}
Loading…
Cancel
Save