Browse Source

Merge branch 'feature/x' of https://code.fineres.com/scm/~fly.li/design into feature/x

research/11.0
fly.li 3 years ago
parent
commit
d7625f987f
  1. 88
      designer-base/src/main/java/com/fr/design/formula/FormulaChecker.java
  2. 74
      designer-base/src/main/java/com/fr/design/formula/FormulaPane.java
  3. 8
      designer-base/src/main/java/com/fr/design/gui/style/AbstractTranslucentBackgroundSpecialPane.java
  4. 6
      designer-base/src/main/java/com/fr/design/gui/style/ComponentIntegralStylePane.java
  5. 10
      designer-base/src/main/java/com/fr/design/gui/style/ComponentTitleStylePane.java
  6. 9
      designer-base/src/main/java/com/fr/design/gui/style/FollowingThemePane.java
  7. 871
      designer-base/src/main/java/com/fr/design/javascript/ExportJavaScriptPane.java
  8. 7
      designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java
  9. 5
      designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java
  10. 32
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  11. 10
      designer-base/src/main/java/com/fr/design/mainframe/OpenFailedPane.java
  12. 90
      designer-base/src/main/java/com/fr/design/mainframe/authority/FormulaAuthorityChecker.java
  13. 24
      designer-base/src/main/java/com/fr/design/mainframe/authority/JTemplateAuthorityChecker.java
  14. 27
      designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ComponentPreviewPane.java
  15. 55
      designer-base/src/main/java/com/fr/design/report/fit/AdaptiveFrmFitAttrModel.java
  16. 229
      designer-base/src/main/java/com/fr/design/report/fit/BaseFitAttrPane.java
  17. 51
      designer-base/src/main/java/com/fr/design/report/fit/CptFitAttrModel.java
  18. 44
      designer-base/src/main/java/com/fr/design/report/fit/FitAttrModel.java
  19. 53
      designer-base/src/main/java/com/fr/design/report/fit/FrmFitAttrModel.java
  20. 10
      designer-base/src/main/java/com/fr/design/report/fit/menupane/ReportFitAttrAction.java
  21. 107
      designer-base/src/main/java/com/fr/design/report/fit/menupane/TemplateFitAttrPane.java
  22. 18
      designer-base/src/main/java/com/fr/design/report/fit/provider/AbstractFitAttrModelProvider.java
  23. 11
      designer-base/src/main/java/com/fr/design/report/fit/provider/FitAttrModelProvider.java
  24. 22
      designer-base/src/main/java/com/fr/design/style/color/NewColorSelectPane.java
  25. 26
      designer-base/src/main/java/com/fr/design/worker/open/OpenWorker.java
  26. 7
      designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/other/VanChartDrillMapInteractivePane.java
  27. 17
      designer-form/src/main/java/com/fr/design/actions/FormFitAttrAction.java
  28. 15
      designer-form/src/main/java/com/fr/design/designer/beans/models/NewFormModel.java
  29. 2
      designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java
  30. 11
      designer-form/src/main/java/com/fr/design/mainframe/share/generate/task/ComponentCreator.java
  31. 118
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/DownloadSuitableThemeAction.java
  32. 3
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/AbstractOnlineWidgetBlock.java
  33. 35
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/OnlineWidgetBlock.java
  34. 6
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetPopupPreviewPane.java
  35. 17
      designer-form/src/main/java/com/fr/design/mainframe/share/util/DownloadUtils.java
  36. 5
      designer-form/src/main/java/com/fr/design/mainframe/share/util/ShareComponentUtils.java
  37. 2
      designer-form/src/main/java/com/fr/design/widget/ui/designer/PredefinedLayoutPane.java
  38. 6
      designer-form/src/main/resources/com/fr/design/form/layouts/config.json
  39. BIN
      designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_1.png
  40. BIN
      designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_10.png
  41. BIN
      designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_11.png
  42. BIN
      designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_12.png
  43. BIN
      designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_13.png
  44. BIN
      designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_14.png
  45. BIN
      designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_15.png
  46. BIN
      designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_16.png
  47. BIN
      designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_17.png
  48. BIN
      designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_18.png
  49. BIN
      designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_2.png
  50. BIN
      designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_3.png
  51. BIN
      designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_4.png
  52. BIN
      designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_5.png
  53. BIN
      designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_6.png
  54. BIN
      designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_7.png
  55. BIN
      designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_8.png
  56. BIN
      designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_9.png
  57. 35
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java
  58. 35
      designer-realize/src/main/java/com/fr/design/webattr/EditReportServerParameterPane.java
  59. 2
      designer-realize/src/main/java/com/fr/design/webattr/PageToolBarPane.java
  60. 2
      designer-realize/src/main/java/com/fr/design/webattr/PageWebSettingPane.java
  61. 78
      designer-realize/src/main/java/com/fr/design/webattr/ServerFitAttrPane.java

88
designer-base/src/main/java/com/fr/design/formula/FormulaChecker.java

@ -0,0 +1,88 @@
package com.fr.design.formula;
import com.fr.design.i18n.Toolkit;
import com.fr.log.FineLoggerFactory;
import com.fr.parser.FRLexer;
import com.fr.parser.FRParser;
import com.fr.script.checker.FunctionCheckerDispatcher;
import com.fr.script.checker.exception.ConditionCheckWrongException;
import com.fr.script.checker.exception.FunctionCheckWrongException;
import com.fr.script.rules.FunctionParameterType;
import com.fr.script.rules.FunctionRule;
import com.fr.stable.StringUtils;
import com.fr.stable.script.Expression;
import com.fr.stable.script.Node;
import java.io.StringReader;
import java.util.List;
/**
* @author Hoky
* @date 2021/9/28
*/
public class FormulaChecker {
private static final String VALID_FORMULA = Toolkit.i18nText("Fine-Design_Basic_FormulaD_Valid_Formula");
private static final String INVALID_FORMULA = Toolkit.i18nText("Fine-Design_Basic_FormulaD_Invalid_Formula");
public static final String COLON = ":";
public static String check(String formulaText) {
StringReader in = new StringReader(formulaText);
FRLexer lexer = new FRLexer(in);
FRParser parser = new FRParser(lexer);
try {
Expression expression = parser.parse();
Node node = expression.getConditionalExpression();
return FunctionCheckerDispatcher.getInstance()
.getFunctionChecker(node)
.checkFunction(node) ? VALID_FORMULA : INVALID_FORMULA;
} catch (ConditionCheckWrongException cce) {
String functionName = cce.getFunctionName();
return functionName + Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Condition_Tips") + COLON;
} catch (FunctionCheckWrongException ce) {
List<FunctionRule> rules = ce.getRules();
String functionName = ce.getFunctionName();
StringBuilder errorMsg = new StringBuilder(functionName + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Error_Tips") + COLON);
for (int i = 0; i < rules.size(); i++) {
errorMsg.append("(");
if (rules.get(i).getParameterList().isEmpty()) {
errorMsg.append(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_No_Param"));
}
for (FunctionParameterType functionParameterType : rules.get(i).getParameterList()) {
errorMsg.append(getTypeString(functionParameterType)).append(",");
}
if (",".equals(errorMsg.charAt(errorMsg.length() - 1) + "")) {
errorMsg.deleteCharAt(errorMsg.length() - 1);
}
errorMsg.append(")");
if (i != rules.size() - 1) {
errorMsg.append(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Or"));
}
}
return errorMsg.toString();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return INVALID_FORMULA;
// alex:继续往下面走,expression为null时告知不合法公式
}
}
private static String getTypeString(FunctionParameterType type) {
switch (type) {
case NUMBER:
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_ParamType_Number");
case STRING:
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_ParamType_String");
case ANY:
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_ParamType_Any");
case DATE:
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_ParamType_Date");
case BOOLEAN:
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_ParamType_Boolean");
case ARRAY:
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_ParamType_Array");
}
return StringUtils.EMPTY;
}
}

74
designer-base/src/main/java/com/fr/design/formula/FormulaPane.java

@ -38,18 +38,11 @@ import com.fr.log.FineLoggerFactory;
import com.fr.parser.ArrayExpression; import com.fr.parser.ArrayExpression;
import com.fr.parser.BlockIntervalLiteral; import com.fr.parser.BlockIntervalLiteral;
import com.fr.parser.ColumnRowRangeInPage; import com.fr.parser.ColumnRowRangeInPage;
import com.fr.parser.FRLexer;
import com.fr.parser.FRParser;
import com.fr.parser.NumberLiteral; import com.fr.parser.NumberLiteral;
import com.fr.parser.SheetIntervalLiteral; import com.fr.parser.SheetIntervalLiteral;
import com.fr.report.core.namespace.SimpleCellValueNameSpace; import com.fr.report.core.namespace.SimpleCellValueNameSpace;
import com.fr.script.Calculator; import com.fr.script.Calculator;
import com.fr.script.ScriptConstants; import com.fr.script.ScriptConstants;
import com.fr.script.checker.FunctionCheckerDispatcher;
import com.fr.script.checker.exception.ConditionCheckWrongException;
import com.fr.script.checker.exception.FunctionCheckWrongException;
import com.fr.script.rules.FunctionParameterType;
import com.fr.script.rules.FunctionRule;
import com.fr.stable.EncodeConstants; import com.fr.stable.EncodeConstants;
import com.fr.stable.EssentialUtils; import com.fr.stable.EssentialUtils;
import com.fr.stable.ParameterProvider; import com.fr.stable.ParameterProvider;
@ -657,7 +650,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
// Execute Formula default cell element. // Execute Formula default cell element.
String formulaText = formulaTextArea.getText().trim(); String formulaText = formulaTextArea.getText().trim();
String formulaValidMessage = getFormulaValidMessage(formulaText); String formulaValidMessage = FormulaChecker.check(formulaText);
FineJOptionPane.showMessageDialog( FineJOptionPane.showMessageDialog(
FormulaPane.this, FormulaPane.this,
formulaValidMessage + ".", formulaValidMessage + ".",
@ -666,73 +659,12 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
} }
}; };
private static String getFormulaValidMessage(String formulaText) {
StringReader in = new StringReader(formulaText);
FRLexer lexer = new FRLexer(in);
FRParser parser = new FRParser(lexer);
try {
Expression expression = parser.parse();
Node node = expression.getConditionalExpression();
return FunctionCheckerDispatcher.getInstance()
.getFunctionChecker(node)
.checkFunction(node) ? VALID_FORMULA : INVALID_FORMULA;
} catch (ConditionCheckWrongException cce) {
String functionName = cce.getFunctionName();
StringBuilder errorMsg = new StringBuilder(functionName + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Condition_Tips") + ":");
return errorMsg.toString();
} catch (FunctionCheckWrongException ce) {
List<FunctionRule> rules = ce.getRules();
String functionName = ce.getFunctionName();
StringBuilder errorMsg = new StringBuilder(functionName + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Error_Tips") + ":");
for (int i = 0; i < rules.size(); i++) {
errorMsg.append("(");
if (rules.get(i).getParameterList().isEmpty()) {
errorMsg.append(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_No_Param"));
}
for (FunctionParameterType functionParameterType : rules.get(i).getParameterList()) {
errorMsg.append(getTypeString(functionParameterType)).append(",");
}
if (",".equals(errorMsg.charAt(errorMsg.length() - 1) + "")) {
errorMsg.deleteCharAt(errorMsg.length() - 1);
}
errorMsg.append(")");
if (i != rules.size() - 1) {
errorMsg.append(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Or"));
}
}
return errorMsg.toString();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return INVALID_FORMULA;
// alex:继续往下面走,expression为null时告知不合法公式
}
}
private static String getTypeString(FunctionParameterType type) {
switch (type) {
case NUMBER:
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_ParamType_Number");
case STRING:
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_ParamType_String");
case ANY:
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_ParamType_Any");
case DATE:
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_ParamType_Date");
case BOOLEAN:
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_ParamType_Boolean");
case ARRAY:
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_ParamType_Array");
}
return "";
}
private final ActionListener calculateActionListener = new ActionListener() { private final ActionListener calculateActionListener = new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
String formulaText = formulaTextArea.getText().trim(); String formulaText = formulaTextArea.getText().trim();
String formulaValidMessage = getFormulaValidMessage(formulaText); String formulaValidMessage = FormulaChecker.check(formulaText);
;
String unSupportFormula = containsUnsupportedSimulationFormulas(formulaText); String unSupportFormula = containsUnsupportedSimulationFormulas(formulaText);
if (unSupportFormula != null) { if (unSupportFormula != null) {
FineJOptionPane.showMessageDialog( FineJOptionPane.showMessageDialog(

8
designer-base/src/main/java/com/fr/design/gui/style/AbstractTranslucentBackgroundSpecialPane.java

@ -2,13 +2,13 @@ package com.fr.design.gui.style;
import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.IntervalConstants;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.BasicScrollPane;
import com.fr.design.gui.frpane.UIPercentDragPane; import com.fr.design.gui.frpane.UIPercentDragPane;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.backgroundpane.GradientBackgroundQuickPane; import com.fr.design.mainframe.backgroundpane.GradientBackgroundQuickPane;
import com.fr.design.widget.FRWidgetFactory;
import com.fr.general.Background; import com.fr.general.Background;
import com.fr.general.act.BackgroundPacker; import com.fr.general.act.BackgroundPacker;
@ -51,8 +51,8 @@ public abstract class AbstractTranslucentBackgroundSpecialPane<T extends Backgro
// 确保BackgroundSpecialPane高度变化时,Label依然保持与其顶部对齐 // 确保BackgroundSpecialPane高度变化时,Label依然保持与其顶部对齐
JPanel backgroundLabelPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel backgroundLabelPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
backgroundLabelPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, 0, 0)); backgroundLabelPane.setBorder(BorderFactory.createEmptyBorder(7, 0, 0, 0));
backgroundLabelPane.add(new UILabel(backgroundName), BorderLayout.NORTH); backgroundLabelPane.add(FRWidgetFactory.createLineWrapLabel(backgroundName), BorderLayout.NORTH);
JPanel backgroundComposedPane = TableLayoutHelper.createGapTableLayoutPane( JPanel backgroundComposedPane = TableLayoutHelper.createGapTableLayoutPane(
new JComponent[][]{ new JComponent[][]{
@ -62,7 +62,7 @@ public abstract class AbstractTranslucentBackgroundSpecialPane<T extends Backgro
JPanel opacityComposedPane = TableLayoutHelper.createGapTableLayoutPane( JPanel opacityComposedPane = TableLayoutHelper.createGapTableLayoutPane(
new JComponent[][]{ new JComponent[][]{
{new UILabel(""), new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Alpha"))}, {new UILabel(""), FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Alpha"))},
{new UILabel(""), opacityPane} {new UILabel(""), opacityPane}
}, },
new double[]{p, p}, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1); new double[]{p, p}, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1);

6
designer-base/src/main/java/com/fr/design/gui/style/ComponentIntegralStylePane.java

@ -2,11 +2,11 @@ package com.fr.design.gui.style;
import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.IntervalConstants;
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.ispinner.UISpinner; import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.widget.FRWidgetFactory;
import com.fr.general.act.BorderPacker; import com.fr.general.act.BorderPacker;
import javax.swing.JComponent; import javax.swing.JComponent;
@ -72,9 +72,9 @@ public class ComponentIntegralStylePane extends AbstractBorderPackerPane {
double[] columnSize = {this.uiLabelWidth, this.uiSettingWidth > 0 ? this.uiSettingWidth : f}; double[] columnSize = {this.uiLabelWidth, this.uiSettingWidth > 0 ? this.uiSettingWidth : f};
JPanel content = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{ JPanel content = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Render_Style")), borderStyleCombo}, {FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Render_Style")), FRGUIPaneFactory.createBorderLayoutNorthPaneWithComponent(borderStyleCombo)},
{this.borderPane, null}, {this.borderPane, null},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Radius")), cornerSpinner}, {FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Radius")), cornerSpinner},
}, },
rowSize, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1); rowSize, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1);

10
designer-base/src/main/java/com/fr/design/gui/style/ComponentTitleStylePane.java

@ -9,10 +9,10 @@ import com.fr.design.gui.ibutton.UIColorButton;
import com.fr.design.gui.ibutton.UIToggleButton; import com.fr.design.gui.ibutton.UIToggleButton;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icheckbox.UICheckBox;
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.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.widget.FRWidgetFactory;
import com.fr.form.ui.LayoutBorderStyle; import com.fr.form.ui.LayoutBorderStyle;
import com.fr.form.ui.WidgetTitle; import com.fr.form.ui.WidgetTitle;
import com.fr.general.FRFont; import com.fr.general.FRFont;
@ -168,7 +168,7 @@ public class ComponentTitleStylePane extends AbstractBorderPackerPane {
visibleCheckbox.setSelected(false); visibleCheckbox.setSelected(false);
container.add(visibleCheckbox, BorderLayout.WEST); container.add(visibleCheckbox, BorderLayout.WEST);
container.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Visible")), BorderLayout.CENTER); container.add(FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Visible")), BorderLayout.CENTER);
visibleCheckbox.addChangeListener(new ChangeListener() { visibleCheckbox.addChangeListener(new ChangeListener() {
@Override @Override
@ -192,7 +192,7 @@ public class ComponentTitleStylePane extends AbstractBorderPackerPane {
double[] columnSize = {this.uiLabelWidth, this.uiSettingWidth > 0 ? this.uiSettingWidth : f}; double[] columnSize = {this.uiLabelWidth, this.uiSettingWidth > 0 ? this.uiSettingWidth : f};
return TableLayoutHelper.createCommonTableLayoutPane( return TableLayoutHelper.createCommonTableLayoutPane(
new JComponent[][]{{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Content")), textContentPane}}, new JComponent[][]{{FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Content")), textContentPane}},
rowSize, columnSize, IntervalConstants.INTERVAL_L1); rowSize, columnSize, IntervalConstants.INTERVAL_L1);
} }
@ -203,10 +203,10 @@ public class ComponentTitleStylePane extends AbstractBorderPackerPane {
double[] columnSize = {this.uiLabelWidth, this.uiSettingWidth > 0 ? this.uiSettingWidth : f}; double[] columnSize = {this.uiLabelWidth, this.uiSettingWidth > 0 ? this.uiSettingWidth : f};
JComponent[][] components = new JComponent[][]{ JComponent[][] components = new JComponent[][]{
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Format")), fontFamilyComboBox}, {FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Format")), FRGUIPaneFactory.createBorderLayoutNorthPaneWithComponent(fontFamilyComboBox)},
{null, createTitleFontButtonPane()}, {null, createTitleFontButtonPane()},
{insetImagePane, null}, {insetImagePane, null},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Text_Align")), alignPane}, {FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Text_Align")), alignPane},
{backgroundPane, null} {backgroundPane, null}
}; };

9
designer-base/src/main/java/com/fr/design/gui/style/FollowingThemePane.java

@ -1,10 +1,7 @@
package com.fr.design.gui.style; package com.fr.design.gui.style;
import com.fr.base.theme.FormTheme;
import com.fr.base.theme.TemplateTheme; import com.fr.base.theme.TemplateTheme;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.event.GlobalNameListener;
import com.fr.design.event.GlobalNameObserver;
import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener; import com.fr.design.event.UIObserverListener;
import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListCache;
@ -15,12 +12,12 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.widget.FRWidgetFactory;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.util.ArrayList; import java.util.ArrayList;
@ -66,12 +63,12 @@ public class FollowingThemePane extends BasicPane implements UIObserver {
} }
}); });
UILabel followingThemeLabel = new UILabel(name); UILabel followingThemeLabel = FRWidgetFactory.createLineWrapLabel(name);
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double f = TableLayout.FILL; double f = TableLayout.FILL;
JPanel followingThemePane = JPanel followingThemePane =
TableLayoutHelper.createGapTableLayoutPane( new Component[][]{new Component[] { followingThemeLabel, followingThemeButtonGroup}}, TableLayoutHelper.createGapTableLayoutPane( new Component[][]{new Component[] { followingThemeLabel, FRGUIPaneFactory.createBorderLayoutNorthPaneWithComponent(followingThemeButtonGroup)}},
new double[] { p }, new double[] { SETTING_LABEL_WIDTH, f }, 10, 0); new double[] { p }, new double[] { SETTING_LABEL_WIDTH, f }, 10, 0);
followingThemePane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); followingThemePane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
followingThemePane.setVisible(false); followingThemePane.setVisible(false);

871
designer-base/src/main/java/com/fr/design/javascript/ExportJavaScriptPane.java

@ -3,6 +3,7 @@ package com.fr.design.javascript;
import com.fr.base.BaseFormula; import com.fr.base.BaseFormula;
import com.fr.base.Parameter; import com.fr.base.Parameter;
import com.fr.base.extension.FileExtension; import com.fr.base.extension.FileExtension;
import com.fr.design.border.UITitledBorder;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
@ -15,6 +16,10 @@ import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIComboBoxRenderer; import com.fr.design.gui.icombobox.UIComboBoxRenderer;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itableeditorpane.ParameterTableModel;
import com.fr.design.gui.itableeditorpane.UITableEditAction;
import com.fr.design.gui.itableeditorpane.UITableEditorPane;
import com.fr.design.gui.itableeditorpane.UITableModelAdapter;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.gui.itree.filetree.TemplateFileTree; import com.fr.design.gui.itree.filetree.TemplateFileTree;
import com.fr.design.hyperlink.AbstractHyperLinkPane; import com.fr.design.hyperlink.AbstractHyperLinkPane;
@ -23,32 +28,40 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.scrollruler.ModLineBorder;
import com.fr.file.filetree.IOFileNodeFilter; import com.fr.file.filetree.IOFileNodeFilter;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
import com.fr.js.ExportJavaScript; import com.fr.js.ExportJavaScript;
import com.fr.js.SingleJavaScript;
import com.fr.stable.ParameterProvider; import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.AbstractButton; import javax.swing.AbstractButton;
import javax.swing.AbstractCellEditor;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.ButtonGroup; import javax.swing.ButtonGroup;
import javax.swing.DefaultComboBoxModel; import javax.swing.DefaultComboBoxModel;
import javax.swing.JList; import javax.swing.JList;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.event.CellEditorListener;
import javax.swing.event.ChangeEvent;
import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener; import javax.swing.event.TableModelListener;
import javax.swing.table.TableCellEditor;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.CardLayout; import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -59,21 +72,20 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
private ExportRadioGroup templateRadioGroup; private ExportRadioGroup templateRadioGroup;
private UIRadioButton currentTemplateRadio; private UIRadioButton currentTemplateRadio;
private UIRadioButton otherTemplateRadio; private UIRadioButton otherTemplateRadio;
private UITextField reportPathTextField;
private UIButton browserButton;
private UIComboBox exportTypeComboBox; private UIComboBox exportTypeComboBox;
private ExportRadioGroup fileNameRadioGroup; private CardLayout card;
private UIRadioButton defaultNameRadio; private JPanel templatePanel;
private UIRadioButton customNameRadio; private CurrentTemplatePane currentTemplatePane;
private FormulaEditor fileNameFormulaEditor; private OtherTemplatePane otherTemplatePane;
private UICheckBox extendParametersCheckBox;
private ReportletParameterViewPane parameterViewPane;
private static final double p = TableLayout.PREFERRED; private static final double p = TableLayout.PREFERRED;
private static final Map<String, String> EXPORT_TYPES_MAP = new HashMap<>(); private static final Map<String, String> EXPORT_TYPES_MAP = new HashMap<>();
private static final String CURRENT_TEMPLATE = "current"; private static final Map<String, String> FILENAME_TYPE_MAP = new HashMap<>();
private static final String DEFAULT_FILENAME = "default"; private static final Map<String, String> PARAMETER_TYPE_MAP = new HashMap<>();
private static final String DEFAULT = "default";
private static final String CUSTOM = "custom";
private static final String CURRENT_TEMPLATE = "cur";
private static final String OTHER_TEMPLATE = "other";
static { static {
EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_PDF, Toolkit.i18nText("Fine-Design_Basic_Export_JS_PDF")); EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_PDF, Toolkit.i18nText("Fine-Design_Basic_Export_JS_PDF"));
@ -82,134 +94,601 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_EXCEL_SHEET, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Excel_Sheet")); EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_EXCEL_SHEET, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Excel_Sheet"));
EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_WORD, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Word")); EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_WORD, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Word"));
EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_IMAGE, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Image")); EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_IMAGE, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Image"));
FILENAME_TYPE_MAP.put(DEFAULT, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Filename_Default"));
FILENAME_TYPE_MAP.put(CUSTOM, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Custom"));
PARAMETER_TYPE_MAP.put(DEFAULT, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Extend_Parameters"));
PARAMETER_TYPE_MAP.put(CUSTOM, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Custom"));
} }
public ExportJavaScriptPane() { // 当前模板
initComponents(); class CurrentTemplatePane extends BasicPane {
}
private void initComponents() { private ExportRadioGroup fileNameRadioGroup;
this.setLayout(FRGUIPaneFactory.createBorderLayout()); private UIRadioButton defaultNameRadio;
this.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), Toolkit.i18nText("Fine-Design_Basic_Export_JS_Setting"))); private UIRadioButton customNameRadio;
private FormulaEditor fileNameFormulaEditor;
private UICheckBox extendParametersCheckBox;
private ReportletParameterViewPane parameterViewPane;
//导出模板+导出方式+导出文件名 public CurrentTemplatePane() {
JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(UITitledBorder.createBorderWithTitle(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Current")));
//导出模板 JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
JPanel chooseTemplatePane = initChooseTemplatePane(); //导出方式
northPane.add(chooseTemplatePane, BorderLayout.NORTH); JPanel exportTypePane = initExportTypePane();
northPane.add(exportTypePane, BorderLayout.CENTER);
//导出方式 //导出文件名
JPanel exportTypePane = initExportTypePane(); JPanel fileNamePane = initFileNamePane();
northPane.add(exportTypePane, BorderLayout.CENTER); northPane.add(fileNamePane, BorderLayout.SOUTH);
//导出文件名 //参数
JPanel fileNamePane = initFileNamePane(); JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
northPane.add(fileNamePane, BorderLayout.SOUTH); JPanel paramsPane = initParamsPane();
centerPane.add(paramsPane);
//参数 this.add(northPane, BorderLayout.NORTH);
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); this.add(centerPane, BorderLayout.CENTER);
JPanel paramsPane = initParamsPane(); }
centerPane.add(paramsPane);
this.add(northPane, BorderLayout.NORTH); private JPanel initParamsPane() {
this.add(centerPane, BorderLayout.CENTER); UILabel parameterLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Parameters_Setting") + ':');
} extendParametersCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Extend_Parameters"));
extendParametersCheckBox.setSelected(true);
parameterViewPane = new ReportletParameterViewPane(getChartParaType(), getValueEditorPane(), getValueEditorPane());
parameterViewPane.setVisible(false);
addListener(parameterViewPane);
extendParametersCheckBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
parameterViewPane.setVisible(e.getStateChange() == ItemEvent.DESELECTED);
}
});
JPanel paramsPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
Component[][] components = new Component[][]{{parameterLabel, extendParametersCheckBox}};
JPanel paramsCheckPane = TableLayoutHelper.createTableLayoutPane(components, new double[]{p}, new double[]{p, p});
paramsCheckPane.setBorder(BorderFactory.createEmptyBorder(0, 2, 5, 2));
JPanel dynamicPaneWrapper = FRGUIPaneFactory.createBorderLayout_S_Pane();
dynamicPaneWrapper.add(parameterViewPane);
paramsPane.add(paramsCheckPane, BorderLayout.NORTH);
paramsPane.add(dynamicPaneWrapper, BorderLayout.CENTER);
return paramsPane;
}
private JPanel initParamsPane() { private JPanel initFileNamePane() {
extendParametersCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Extends_Report_Parameters")); UILabel nameLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Filename") + ":");
extendParametersCheckBox.setSelected(true); fileNameRadioGroup = new ExportRadioGroup();
parameterViewPane = new ReportletParameterViewPane(getChartParaType(), getValueEditorPane(), getValueEditorPane()); defaultNameRadio = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Filename_Default"));
parameterViewPane.setVisible(false); defaultNameRadio.setSelected(true);
parameterViewPane.addTableEditorListener(new TableModelListener() { customNameRadio = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Custom"));
public void tableChanged(TableModelEvent e) { addRadioToGroup(fileNameRadioGroup, defaultNameRadio, customNameRadio);
List<ParameterProvider> list = parameterViewPane.update(); fileNameFormulaEditor = new FormulaEditor(Toolkit.i18nText("Fine-Design_Report_Parameter_Formula"));
HashSet<String> tempSet = new HashSet<>(); fileNameFormulaEditor.setVisible(false);
for (int i = 0; i < list.size(); i++) { fileNameFormulaEditor.setEnabled(false);
if (StringUtils.isEmpty(list.get(i).getName())) { UILabel fileNameTipLabel = new UILabel("<html><body style=\"color:rgb(147,147,147)\">" + Toolkit.i18nText("Fine-Design_Basic_Export_JS_Title_Tip_Front") + "\\/:*?\"<>|" + Toolkit.i18nText("Fine-Design_Basic_Export_JS_Title_Tip_Back") + "</html>");
continue; fileNameTipLabel.setVisible(false);
fileNameRadioGroup.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (defaultNameRadio.isSelected()) {
fileNameFormulaEditor.setVisible(false);
fileNameFormulaEditor.setEnabled(false);
fileNameTipLabel.setVisible(false);
} else {
fileNameFormulaEditor.setVisible(true);
fileNameFormulaEditor.setEnabled(true);
fileNameTipLabel.setVisible(true);
} }
if (tempSet.contains(list.get(i).toString())) {
list.remove(i);
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Parameter_Duplicate_Name") + "!");
return;
}
tempSet.add(list.get(i).toString());
} }
});
Component[][] components = new Component[][]{{nameLabel, defaultNameRadio, customNameRadio, fileNameFormulaEditor}};
JPanel fileNameRadioPane = TableLayoutHelper.createTableLayoutPane(components, new double[]{p}, new double[]{p, p, p, p});
JPanel fileNameTipPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
fileNameTipPane.add(fileNameTipLabel);
JPanel fileNamePane = FRGUIPaneFactory.createBorderLayout_S_Pane();
fileNamePane.add(fileNameRadioPane, BorderLayout.NORTH);
fileNamePane.add(fileNameTipPane, BorderLayout.CENTER);
fileNameTipPane.setBorder(BorderFactory.createEmptyBorder(5, 2, 5, 2));
fileNamePane.setBorder(BorderFactory.createEmptyBorder(5, 2, 5, 2));
return fileNamePane;
}
@Override
protected String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Basic_Export_JS_Setting");
}
}
// 其他模板
class OtherTemplatePane extends BasicPane {
private UITableEditorPane<SingleJavaScript> editorPane;
public OtherTemplatePane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(UITitledBorder.createBorderWithTitle(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Other")));
editorPane = new UITableEditorPane<>(new ExportJSTableModel());
this.add(editorPane, BorderLayout.CENTER);
}
@Override
protected String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Basic_Export_JS_Setting");
}
}
class ExportJSTableModel extends UITableModelAdapter<SingleJavaScript> {
private static final long serialVersionUID = -3697206557955735642L;
public ExportJSTableModel() {
super(new String[]{
Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_File"),
Toolkit.i18nText("Fine-Design_Basic_Export_JS_Type"),
Toolkit.i18nText("Fine-Design_Basic_Export_JS_Filename"),
Toolkit.i18nText("Fine-Design_Basic_Export_JS_Filename_Custom"),
Toolkit.i18nText("Fine-Design_Basic_Export_JS_Parameters_Setting"),
StringUtils.EMPTY});
this.setColumnClass(new Class[]{
ExportTemplateChooser.class,
ExportTypeCombobox.class,
FileNameCombobox.class,
FileNameFormulaEditor.class,
ParameterCombobox.class,
ParameterSettingButton.class
});
this.setDefaultEditor(ExportTemplateChooser.class, new ExportTemplateChooser());
this.setDefaultEditor(ExportTypeCombobox.class, new ExportTypeCombobox());
this.setDefaultEditor(FileNameCombobox.class, new FileNameCombobox());
this.setDefaultEditor(FileNameFormulaEditor.class, new FileNameFormulaEditor());
this.setDefaultEditor(ParameterCombobox.class, new ParameterCombobox());
this.setDefaultEditor(ParameterSettingButton.class, new ParameterSettingButton());
this.createTable().getColumnModel().getColumn(2).setMaxWidth(60);
this.createTable().getColumnModel().getColumn(4).setMaxWidth(60);
this.createTable().getColumnModel().getColumn(5).setMaxWidth(40);
}
@Override
public UITableEditAction[] createAction() {
return new UITableEditAction[] {new AddJSAction(), new DeleteAction()};
}
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
SingleJavaScript js = this.getList().get(rowIndex);
switch (columnIndex) {
case 0:
return js.getTemplatePath();
case 1:
return EXPORT_TYPES_MAP.get(js.getExportType());
case 2:
return js.isDefaultFileName() ? Toolkit.i18nText("Fine-Design_Basic_Export_JS_Filename_Default") : Toolkit.i18nText("Fine-Design_Basic_Export_JS_Custom");
case 3:
return js.getFileName();
case 4:
return js.isExtendParameters() ? Toolkit.i18nText("Fine-Design_Basic_Export_JS_Extend_Parameters") : Toolkit.i18nText("Fine-Design_Basic_Export_JS_Custom");
case 5:
return js.getParameters();
} }
}); return null;
extendParametersCheckBox.addItemListener(new ItemListener() { }
@Override
public void itemStateChanged(ItemEvent e) { @Override
parameterViewPane.setVisible(e.getStateChange() == ItemEvent.DESELECTED); public boolean isCellEditable(int row, int col) {
if(col == 3) {
// 命名详情
return this.getList().get(row) != null && !this.getList().get(row).isDefaultFileName();
}
if (col == 5) {
// 参数设置按钮
return this.getList().get(row) != null && !this.getList().get(row).isExtendParameters();
}
return true;
}
private class AddJSAction extends AddTableRowAction {
public AddJSAction() {
} }
});
JPanel paramsPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
paramsPane.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), Toolkit.i18nText("Fine-Design_Basic_Parameters")));
paramsPane.add(extendParametersCheckBox, BorderLayout.NORTH);
JPanel dynamicPaneWrapper = FRGUIPaneFactory.createBorderLayout_S_Pane();
dynamicPaneWrapper.add(parameterViewPane);
paramsPane.add(dynamicPaneWrapper, BorderLayout.CENTER);
return paramsPane;
}
private JPanel initFileNamePane() {
UILabel nameLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Filename") + ":");
fileNameRadioGroup = new ExportRadioGroup();
defaultNameRadio = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Filename_Default"));
defaultNameRadio.setSelected(true);
customNameRadio = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Filename_Custom"));
addRadioToGroup(fileNameRadioGroup, defaultNameRadio, customNameRadio);
fileNameFormulaEditor = new FormulaEditor(Toolkit.i18nText("Fine-Design_Report_Parameter_Formula"));
fileNameFormulaEditor.setEnabled(false);
fileNameRadioGroup.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (defaultNameRadio.isSelected()) { super.actionPerformed(e);
fileNameFormulaEditor.setEnabled(false); if (otherTemplatePane.editorPane.getTableModel().getList().size() <= 50) {
addJS();
} else { } else {
fileNameFormulaEditor.setEnabled(true); FineJOptionPane.showMessageDialog(otherTemplatePane, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Batch_Export_Limit"));
} }
} }
}); }
Component[][] components = new Component[][]{{nameLabel, defaultNameRadio, customNameRadio, fileNameFormulaEditor}};
JPanel fileNameRadioPane = TableLayoutHelper.createTableLayoutPane(components, new double[]{p}, new double[]{p, p, p, p});
JPanel fileNameTipPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
UILabel fileNameTipLabel = new UILabel("<html><body style=\"color:red\">" + Toolkit.i18nText("Fine-Design_Basic_Export_JS_Title_Tip_Front") + "\\/:*?\"<>|" + Toolkit.i18nText("Fine-Design_Basic_Export_JS_Title_Tip_Back") + "</html>");
fileNameTipPane.add(fileNameTipLabel);
JPanel fileNamePane = FRGUIPaneFactory.createBorderLayout_S_Pane();
fileNamePane.add(fileNameRadioPane, BorderLayout.NORTH);
fileNamePane.add(fileNameTipPane, BorderLayout.CENTER);
fileNameTipPane.setBorder(BorderFactory.createEmptyBorder(5,2,5,2));
fileNamePane.setBorder(BorderFactory.createEmptyBorder(5,2,5,2));
return fileNamePane;
}
private JPanel initExportTypePane() { private void addJS() {
UILabel typeLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Type") + ":"); SingleJavaScript js = new SingleJavaScript();
exportTypeComboBox = new UIComboBox(new DefaultComboBoxModel<String>()); addRow(js);
DefaultComboBoxModel<String> comboBoxModel = (DefaultComboBoxModel<String>) exportTypeComboBox.getModel(); fireTableDataChanged();
String[] allExportTypes = new String[]{ExportJavaScript.EXPORT_PDF, ExportJavaScript.EXPORT_EXCEL_PAGE, ExportJavaScript.EXPORT_EXCEL_SIMPLE, ExportJavaScript.EXPORT_EXCEL_SHEET, ExportJavaScript.EXPORT_WORD, ExportJavaScript.EXPORT_IMAGE}; table.getSelectionModel().setSelectionInterval(table.getRowCount() - 1, table.getRowCount() - 1);
for (int i = 0; i < allExportTypes.length; i++) {
comboBoxModel.addElement(allExportTypes[i]);
} }
this.exportTypeComboBox.setRenderer(new UIComboBoxRenderer() {
// 导出文件选择
class ExportTemplateChooser extends AbstractCellEditor implements TableCellEditor {
private static final long serialVersionUID = -9112506131272704717L;
private JPanel reportletNamePane;
private UITextField reportPathTextField;
private UIButton browserButton;
public ExportTemplateChooser() {
reportletNamePane = FRGUIPaneFactory.createBorderLayout_S_Pane();
// 路径输入框
reportPathTextField = new UITextField(7);
reportPathTextField.setEnabled(false);
reportletNamePane.add(reportPathTextField, BorderLayout.WEST);
// 选择路径按钮
browserButton = new UIButton("...");
browserButton.setVisible(true);
reportletNamePane.add(browserButton, BorderLayout.EAST);
browserButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
final ReportletPane reportletPane = new ReportletPane();
reportletPane.setSelectedReportletPath(reportPathTextField.getText());
BasicDialog reportletDialog = reportletPane.showWindow(SwingUtilities.getWindowAncestor(ExportJavaScriptPane.this));
reportletDialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
reportPathTextField.setText(reportletPane.getSelectedReportletPath());
}
});
reportletDialog.setVisible(true);
}
});
this.addCellEditorListener(new CellEditorListener() {
@Override
public void editingCanceled(ChangeEvent e) {
}
@Override
public void editingStopped(ChangeEvent e) {
if (table.getSelectedRow() == -1){
return;
}
SingleJavaScript js = getList().get(table.getSelectedRow());
String value = StringUtils.trimToNull(reportPathTextField.getText());
js.setTemplatePath(value);
js.setCurrentTemplate(false);
fireTableDataChanged();
}
});
}
@Override @Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); reportPathTextField.setText((String) value);
if (value instanceof String) { return reportletNamePane;
this.setText(EXPORT_TYPES_MAP.get(value)); }
@Override
public Object getCellEditorValue() {
return reportPathTextField.getText();
}
}
// 导出方式下拉框
class ExportTypeCombobox extends AbstractCellEditor implements TableCellEditor {
private static final long serialVersionUID = -6564079764032351372L;
public ExportTypeCombobox() {
exportTypeComboBox = getComboBoxWithModel(new String[]{ExportJavaScript.EXPORT_PDF, ExportJavaScript.EXPORT_EXCEL_PAGE, ExportJavaScript.EXPORT_EXCEL_SIMPLE, ExportJavaScript.EXPORT_EXCEL_SHEET, ExportJavaScript.EXPORT_WORD, ExportJavaScript.EXPORT_IMAGE}
, EXPORT_TYPES_MAP);
this.addCellEditorListener(new CellEditorListener() {
@Override
public void editingCanceled(ChangeEvent e) {
}
@Override
public void editingStopped(ChangeEvent e) {
if (table.getSelectedRow() == -1){
return;
}
SingleJavaScript js = getList().get(table.getSelectedRow());
Object ob = exportTypeComboBox.getSelectedItem();
if (ob != null) {
String value = ob.toString();
js.setExportType(value);
}
fireTableDataChanged();
}
});
}
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
exportTypeComboBox.setSelectedItem(value);
return exportTypeComboBox;
}
@Override
public Object getCellEditorValue() {
Object ob = exportTypeComboBox.getSelectedItem();
if (ob != null) {
return ob.toString();
} }
return this; return ExportJavaScript.EXPORT_PDF;
} }
}); }
// 命名方式下拉框
class FileNameCombobox extends AbstractCellEditor implements TableCellEditor {
private static final long serialVersionUID = 1829005772744444269L;
private UIComboBox fileNameComboBox;
public FileNameCombobox() {
fileNameComboBox = getComboBoxWithModel(new String[]{DEFAULT, CUSTOM}, FILENAME_TYPE_MAP);
this.addCellEditorListener(new CellEditorListener() {
@Override
public void editingCanceled(ChangeEvent e) {
}
@Override
public void editingStopped(ChangeEvent e) {
if (table.getSelectedRow() == -1){
return;
}
SingleJavaScript js = getList().get(table.getSelectedRow());
Object ob = fileNameComboBox.getSelectedItem();
if (ob != null) {
String value = ob.toString();
js.setDefaultFileName(StringUtils.equals(value, DEFAULT));
}
fireTableDataChanged();
}
});
}
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
fileNameComboBox.setSelectedItem(value);
return fileNameComboBox;
}
@Override
public Object getCellEditorValue() {
return fileNameComboBox.getSelectedItem().toString();
}
}
// 命名方式公式框
class FileNameFormulaEditor extends AbstractCellEditor implements TableCellEditor {
private static final long serialVersionUID = 7120075192535645493L;
private FormulaEditor fileNameFormulaEditor;
public FileNameFormulaEditor() {
fileNameFormulaEditor = new FormulaEditor(Toolkit.i18nText("Fine-Design_Report_Parameter_Formula"));
this.addCellEditorListener(new CellEditorListener() {
@Override
public void editingCanceled(ChangeEvent e) {
}
@Override
public void editingStopped(ChangeEvent e) {
if (table.getSelectedRow() == -1){
return;
}
SingleJavaScript js = getList().get(table.getSelectedRow());
String value = fileNameFormulaEditor.getUITextField().getText();
js.setFileName(value);
fireTableDataChanged();
}
});
}
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
fileNameFormulaEditor.setValue(BaseFormula.createFormulaBuilder().build());
return fileNameFormulaEditor;
}
@Override
public Object getCellEditorValue() {
return fileNameFormulaEditor.getUITextField().getText();
}
public FormulaEditor getFileNameEditor() {
return fileNameFormulaEditor;
}
}
//参数设置下拉框
class ParameterCombobox extends AbstractCellEditor implements TableCellEditor {
private static final long serialVersionUID = 2630964402770993584L;
private UIComboBox parameterSetting;
public ParameterCombobox() {
parameterSetting = getComboBoxWithModel(new String[]{DEFAULT, CUSTOM}, PARAMETER_TYPE_MAP);
this.addCellEditorListener(new CellEditorListener() {
@Override
public void editingCanceled(ChangeEvent e) {
}
@Override
public void editingStopped(ChangeEvent e) {
if (table.getSelectedRow() == -1){
return;
}
SingleJavaScript js = getList().get(table.getSelectedRow());
Object ob = parameterSetting.getSelectedItem();
if (ob != null) {
String value = ob.toString();
js.setExtendParameters(StringUtils.equals(value, DEFAULT));
}
fireTableDataChanged();
}
});
}
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
parameterSetting.setSelectedItem(value);
return parameterSetting;
}
@Override
public Object getCellEditorValue() {
return parameterSetting.getSelectedItem().toString();
}
}
// 参数设置按钮
class ParameterSettingButton extends AbstractCellEditor implements TableCellEditor {
private static final long serialVersionUID = 4021592871993049137L;
private UIButton paraButton;
private ParameterSettingPane paraSettingPane;
ParameterProvider[] parameterArr;
public ParameterSettingButton() {
paraSettingPane = new ParameterSettingPane();
paraButton = new UIButton();
paraButton.setBackground(Color.GRAY);
paraButton.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
BasicDialog dialog = paraSettingPane.showWindow(SwingUtilities.getWindowAncestor(ExportJavaScriptPane.this));
dialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
List<ParameterProvider> parameterList = paraSettingPane.getParameterList();
parameterArr = parameterList.toArray(new Parameter[parameterList.size()]);
}
});
dialog.setVisible(true);
}
});
this.addCellEditorListener(new CellEditorListener() {
@Override
public void editingCanceled(ChangeEvent e) {
}
@Override
public void editingStopped(ChangeEvent e) {
if (table.getSelectedRow() == -1){
return;
}
SingleJavaScript js = getList().get(table.getSelectedRow());
js.setParameters(parameterArr);
fireTableDataChanged();
}
});
}
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
paraSettingPane.refresh(new ArrayList<>(Arrays.asList((ParameterProvider[]) value)));
return paraButton;
}
@Override
public Object getCellEditorValue() {
return paraSettingPane.getParameterList();
}
}
// 参数设置弹出框
class ParameterSettingPane extends BasicPane {
private ReportletParameterViewPane parameterViewPane;
public ParameterSettingPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
parameterViewPane = new ReportletParameterViewPane(ParameterTableModel.NO_CHART_USE, getValueEditorPane(), getValueEditorPane());
addListener(parameterViewPane);
this.add(parameterViewPane);
}
@Override
protected String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Basic_Export_JS_Parameters_Setting");
}
public List<ParameterProvider> getParameterList() {
return parameterViewPane.update();
}
public void refresh(List list) {
parameterViewPane.update(list);
}
}
}
public ExportJavaScriptPane() {
initComponents();
}
private void initComponents() {
JPanel totalPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
totalPanel.setBorder(UITitledBorder.createBorderWithTitle(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Setting")));
// 导出模板
JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
JPanel chooseTemplatePane = initChooseTemplatePane();
northPane.add(chooseTemplatePane, BorderLayout.NORTH);
// 默认当前模板
currentTemplatePane = new CurrentTemplatePane();
otherTemplatePane = new OtherTemplatePane();
templatePanel = FRGUIPaneFactory.createCardLayout_S_Pane();
card = new CardLayout();
templatePanel.setLayout(card);
templatePanel.add(CURRENT_TEMPLATE, currentTemplatePane);
templatePanel.add(OTHER_TEMPLATE, otherTemplatePane);
totalPanel.add(northPane, BorderLayout.NORTH);
totalPanel.add(templatePanel, BorderLayout.CENTER);
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.add(totalPanel);
}
private JPanel initExportTypePane() {
UILabel typeLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Type") + ":");
exportTypeComboBox = getComboBoxWithModel(new String[]{ExportJavaScript.EXPORT_PDF, ExportJavaScript.EXPORT_EXCEL_PAGE, ExportJavaScript.EXPORT_EXCEL_SIMPLE, ExportJavaScript.EXPORT_EXCEL_SHEET, ExportJavaScript.EXPORT_WORD, ExportJavaScript.EXPORT_IMAGE}
, EXPORT_TYPES_MAP);
Component[][] components = new Component[][]{{typeLabel, exportTypeComboBox}}; Component[][] components = new Component[][]{{typeLabel, exportTypeComboBox}};
JPanel exportTypePane = TableLayoutHelper.createTableLayoutPane(components, new double[]{p}, new double[]{p, p}); JPanel exportTypePane = TableLayoutHelper.createTableLayoutPane(components, new double[]{p}, new double[]{p, p});
exportTypePane.setBorder(BorderFactory.createEmptyBorder(5,2,5,2)); exportTypePane.setBorder(BorderFactory.createEmptyBorder(5, 2, 5, 2));
return exportTypePane; return exportTypePane;
} }
@ -220,51 +699,28 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
currentTemplateRadio.setSelected(true); currentTemplateRadio.setSelected(true);
otherTemplateRadio = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Other")); otherTemplateRadio = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Other"));
addRadioToGroup(templateRadioGroup, currentTemplateRadio, otherTemplateRadio); addRadioToGroup(templateRadioGroup, currentTemplateRadio, otherTemplateRadio);
templateRadioGroup.addActionListener(new ActionListener() { currentTemplateRadio.addItemListener(new ItemListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void itemStateChanged(ItemEvent e) {
if (currentTemplateRadio.isSelected()) { if (e.getStateChange() == ItemEvent.SELECTED) {
browserButton.setEnabled(false); card.show(templatePanel, CURRENT_TEMPLATE);
} else {
browserButton.setEnabled(true);
} }
} }
}); });
Component[][] components = new Component[][]{{templateLabel, currentTemplateRadio, otherTemplateRadio}}; otherTemplateRadio.addItemListener(new ItemListener() {
JPanel reportletRadioPane = TableLayoutHelper.createTableLayoutPane(components, new double[]{p}, new double[]{p, p, p});
JPanel reportletNamePane = FRGUIPaneFactory.createBorderLayout_S_Pane();
// 路径输入框
reportPathTextField = new UITextField(20);
reportPathTextField.setEnabled(false);
reportletNamePane.add(reportPathTextField, BorderLayout.CENTER);
// 选择路径按钮
browserButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Select"));
browserButton.setPreferredSize(new Dimension(browserButton.getPreferredSize().width, 20));
browserButton.setEnabled(false);
reportletNamePane.add(browserButton, BorderLayout.EAST);
browserButton.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent evt) { public void itemStateChanged(ItemEvent e) {
final ReportletPane reportletPane = new ReportletPane(); if (e.getStateChange() == ItemEvent.SELECTED) {
reportletPane.setSelectedReportletPath(reportPathTextField.getText()); card.show(templatePanel, OTHER_TEMPLATE);
BasicDialog reportletDialog = reportletPane.showWindow(SwingUtilities.getWindowAncestor(ExportJavaScriptPane.this)); }
reportletDialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
reportPathTextField.setText(reportletPane.getSelectedReportletPath());
}
});
reportletDialog.setVisible(true);
} }
}); });
Component[][] components = new Component[][]{{templateLabel, currentTemplateRadio, otherTemplateRadio}};
JPanel reportletRadioPane = TableLayoutHelper.createTableLayoutPane(components, new double[]{p}, new double[]{p, p, p});
JPanel chooseTemplatePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel chooseTemplatePane = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane();
chooseTemplatePane.add(reportletRadioPane, BorderLayout.NORTH); chooseTemplatePane.add(reportletRadioPane, BorderLayout.NORTH);
chooseTemplatePane.add(reportletNamePane, BorderLayout.CENTER); chooseTemplatePane.setBorder(BorderFactory.createEmptyBorder(0, 7, 5, 2));
chooseTemplatePane.setBorder(BorderFactory.createEmptyBorder(0,2,5,2));
return chooseTemplatePane; return chooseTemplatePane;
} }
@ -276,27 +732,26 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
} }
this.templateRadioGroup.selectIndexButton(ob.isCurrentTemplate() ? 0 : 1); this.templateRadioGroup.selectIndexButton(ob.isCurrentTemplate() ? 0 : 1);
if (ob.isCurrentTemplate()) { if (ob.isCurrentTemplate()) {
this.browserButton.setEnabled(false); SingleJavaScript js = ob.getJavaScript();
} else { exportTypeComboBox.setSelectedItem(js.getExportType());
this.browserButton.setEnabled(true); currentTemplatePane.fileNameRadioGroup.selectIndexButton(js.isDefaultFileName() ? 0 : 1);
this.reportPathTextField.setText(ob.getTemplatePath()); if (!js.isDefaultFileName()) {
} currentTemplatePane.fileNameFormulaEditor.setEnabled(true);
this.exportTypeComboBox.setSelectedItem(ob.getExportType()); currentTemplatePane.fileNameFormulaEditor.setVisible(true);
this.fileNameRadioGroup.selectIndexButton(ob.isDefaultFileName() ? 0 : 1); currentTemplatePane.fileNameFormulaEditor.setValue(BaseFormula.createFormulaBuilder().build(js.getFileName()));
if (ob.isDefaultFileName()) { }
this.fileNameFormulaEditor.setEnabled(false); if (js.isExtendParameters()) {
} else { currentTemplatePane.extendParametersCheckBox.setSelected(true);
this.fileNameFormulaEditor.setEnabled(true); } else {
this.fileNameFormulaEditor.setValue(BaseFormula.createFormulaBuilder().build(ob.getFileName())); currentTemplatePane.extendParametersCheckBox.setSelected(false);
} List<ParameterProvider> parameterList = this.parameterViewPane.update();
if (ob.isExtendParameters()) { parameterList.clear();
this.extendParametersCheckBox.setSelected(true); ParameterProvider[] parameters = js.getParameters();
this.parameterViewPane.populate(parameters);
}
} else { } else {
this.extendParametersCheckBox.setSelected(false); OtherTemplatePane pane = (OtherTemplatePane) this.templatePanel.getComponent(1);
List<ParameterProvider> parameterList = this.parameterViewPane.update(); pane.editorPane.populate(ob.getJsList().toArray(new SingleJavaScript[ob.getJsList().size()]));
parameterList.clear();
ParameterProvider[] parameters = ob.getParameters();
this.parameterViewPane.populate(parameters);
} }
} }
@ -309,32 +764,78 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
@Override @Override
public void updateBean(ExportJavaScript exportJavaScript) { public void updateBean(ExportJavaScript exportJavaScript) {
exportJavaScript.setCurrentTemplate(this.currentTemplateRadio.isSelected()); boolean selected = currentTemplateRadio.isSelected();
exportJavaScript.setTemplatePath(getTemplatePath()); exportJavaScript.setCurrentTemplate(selected);
exportJavaScript.setExportType(GeneralUtils.objectToString(this.exportTypeComboBox.getSelectedItem())); if (selected) {
exportJavaScript.setDefaultFileName(this.defaultNameRadio.isSelected()); SingleJavaScript js = new SingleJavaScript();
exportJavaScript.setFileName(getFileName()); js.setCurrentTemplate(true);
exportJavaScript.setExtendParameters(this.extendParametersCheckBox.isSelected()); js.setTemplatePath(DEFAULT);
if (extendParametersCheckBox.isSelected()) { js.setExportType(GeneralUtils.objectToString(exportTypeComboBox.getSelectedItem()));
exportJavaScript.setParameters(null); js.setDefaultFileName(currentTemplatePane.defaultNameRadio.isSelected());
js.setFileName(getFileName());
js.setExtendParameters(currentTemplatePane.extendParametersCheckBox.isSelected());
if (currentTemplatePane.extendParametersCheckBox.isSelected()) {
exportJavaScript.setParameters(null);
} else {
List<ParameterProvider> parameterList = parameterViewPane.update();
if (!parameterList.isEmpty()) {
Parameter[] parameters = new Parameter[parameterList.size()];
parameterList.toArray(parameters);
js.setParameters(parameters);
}
}
exportJavaScript.addJS(js);
} else { } else {
List<ParameterProvider> parameterList = this.parameterViewPane.update(); List<SingleJavaScript> javaScripts = otherTemplatePane.editorPane.update();
if (!parameterList.isEmpty()) { for (SingleJavaScript js : javaScripts) {
Parameter[] parameters = new Parameter[parameterList.size()]; exportJavaScript.addJS(js);
parameterList.toArray(parameters);
exportJavaScript.setParameters(parameters);
} }
} }
} }
private String getTemplatePath() { private String getFileName() {
return currentTemplateRadio.isSelected() ? CURRENT_TEMPLATE : reportPathTextField.getText(); return currentTemplatePane.defaultNameRadio.isSelected() ? DEFAULT : currentTemplatePane.fileNameFormulaEditor.getUITextField().getText();
} }
private String getFileName() { private UIComboBox getComboBoxWithModel(String[] itemTextArr, Map<String, String> itemTextDic) {
return defaultNameRadio.isSelected() ? DEFAULT_FILENAME : fileNameFormulaEditor.getUITextField().getText(); UIComboBox comboBox = new UIComboBox(new DefaultComboBoxModel<String>());
DefaultComboBoxModel<String> comboBoxModel = (DefaultComboBoxModel<String>) comboBox.getModel();
for (int i = 0; i < itemTextArr.length; i++) {
comboBoxModel.addElement(itemTextArr[i]);
}
comboBox.setRenderer(new UIComboBoxRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof String) {
this.setText(itemTextDic.get(value));
}
return this;
}
});
return comboBox;
} }
private void addListener(ReportletParameterViewPane paraPane) {
paraPane.addTableEditorListener(new TableModelListener() {
public void tableChanged(TableModelEvent e) {
List<ParameterProvider> list = paraPane.update();
HashSet<String> tempSet = new HashSet<>();
for (int i = 0; i < list.size(); i++) {
if (StringUtils.isEmpty(list.get(i).getName())) {
continue;
}
if (tempSet.contains(list.get(i).toString())) {
list.remove(i);
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Parameter_Duplicate_Name") + "!");
return;
}
tempSet.add(list.get(i).toString());
}
}
});
}
@Override @Override
public boolean accept(Object ob) { public boolean accept(Object ob) {

7
designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java

@ -7,6 +7,7 @@ import com.fr.stable.AssistUtils;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.BoxLayout; import javax.swing.BoxLayout;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JRadioButton; import javax.swing.JRadioButton;
import java.awt.BorderLayout; import java.awt.BorderLayout;
@ -631,6 +632,12 @@ public class FRGUIPaneFactory {
return iconRadioPane; return iconRadioPane;
} }
public static JPanel createBorderLayoutNorthPaneWithComponent(JComponent content) {
JPanel jPanel = new JPanel(new BorderLayout());
jPanel.add(content, BorderLayout.NORTH);
return jPanel;
}
/** /**
* 计算宽度 * 计算宽度
* *

5
designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java

@ -92,7 +92,7 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener
} else if (jt.isOpening()) { } else if (jt.isOpening()) {
showOpenStatus(); showOpenStatus();
} else if (jt.isOpenFailed()) { } else if (jt.isOpenFailed()) {
showOpenFailedCover(); showOpenFailedCover(jt.getTemplateOpenFailedTip());
} else { } else {
hideCover(); hideCover();
} }
@ -121,7 +121,8 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener
layeredPane.moveToFront(loadingPane); layeredPane.moveToFront(loadingPane);
} }
public void showOpenFailedCover() { public void showOpenFailedCover(String text) {
failedPane.setFailedTip(text);
layeredPane.moveToFront(failedPane); layeredPane.moveToFront(failedPane);
} }

32
designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java

@ -134,6 +134,8 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
private JComponent centerPane; private JComponent centerPane;
private DesignModelAdapter<T, ?> designModel; private DesignModelAdapter<T, ?> designModel;
private PreviewProvider previewType; private PreviewProvider previewType;
private String templateOpenFailedTip;
/** /**
* 统计模板制作耗时 * 统计模板制作耗时
* *
@ -1129,35 +1131,49 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
/** /**
* 判断是否是新版设计器 * 判断是否是新版设计器
* *
* @param showTipPane 是否需要展示弹窗
* @return 是返回true * @return 是返回true
*/ */
public boolean isNewDesigner() { public boolean isNewDesigner(boolean showTipPane) {
String xmlDesignerVersion = getTarget().getXMLDesignerVersion(); String xmlDesignerVersion = getTarget().getXMLDesignerVersion();
if (isLowerThanHBB(xmlDesignerVersion)) { if (isLowerThanHBB(xmlDesignerVersion)) {
String info = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Open-New_Form_Tip"); String info = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Open-New_Form_Tip");
String moreInfo = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Server_Version_Tip_More_Info"); String moreInfo = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Server_Version_Tip_More_Info");
new InformationWarnPane(info, moreInfo, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips")).show(); if (showTipPane) {
new InformationWarnPane(info, moreInfo, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips")).show();
}
return true; return true;
} }
return false; return false;
} }
public boolean isNewDesigner() {
return isNewDesigner(true);
}
/** /**
* 是否是就版本设计器 * 是否是就版本设计器
* *
* @param showTipPane 是否需要展示弹窗
* @return 是就返回true * @return 是就返回true
*/ */
public boolean isOldDesigner() { public boolean isOldDesigner(boolean showTipPane) {
String xmlDesignerVersion = getTarget().getXMLDesignerVersion(); String xmlDesignerVersion = getTarget().getXMLDesignerVersion();
if (isHigherThanCurrent(xmlDesignerVersion)) { if (isHigherThanCurrent(xmlDesignerVersion)) {
String infor = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Template_Version_Not_Match", DesignUtils.parseVersion(xmlDesignerVersion)); String infor = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Template_Version_Not_Match", DesignUtils.parseVersion(xmlDesignerVersion));
String moreInfo = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Server_Version_Tip_More_Info"); String moreInfo = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Server_Version_Tip_More_Info");
new InformationWarnPane(infor, moreInfo, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips")).show(); if (showTipPane) {
new InformationWarnPane(infor, moreInfo, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips")).show();
}
return true; return true;
} }
return false; return false;
} }
public boolean isOldDesigner() {
return isOldDesigner(true);
}
/** /**
* *
*/ */
@ -1777,6 +1793,14 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
themeAttrMark.setDark(theme.isDark()); themeAttrMark.setDark(theme.isDark());
} }
public String getTemplateOpenFailedTip() {
return templateOpenFailedTip;
}
public void setTemplateOpenFailedTip(String templateOpenFailedTip) {
this.templateOpenFailedTip = templateOpenFailedTip;
}
@Override @Override
public void setTemplateTheme(TemplateTheme newTheme, TemplateThemeCompatible compatible) { public void setTemplateTheme(TemplateTheme newTheme, TemplateThemeCompatible compatible) {
ThemedTemplate.super.setTemplateTheme(newTheme, compatible); ThemedTemplate.super.setTemplateTheme(newTheme, compatible);

10
designer-base/src/main/java/com/fr/design/mainframe/OpenFailedPane.java

@ -24,6 +24,7 @@ public class OpenFailedPane extends JPanel {
private UILabel label; private UILabel label;
private MessageWithLink link; private MessageWithLink link;
private String defaultFailedText;
public OpenFailedPane() { public OpenFailedPane() {
this.setLayout(new LayoutManager() { this.setLayout(new LayoutManager() {
@ -83,11 +84,18 @@ public class OpenFailedPane extends JPanel {
}); });
} }
}; };
this.defaultFailedText = link.getText();
link.setBackground(Color.WHITE); link.setBackground(Color.WHITE);
this.add(label); this.add(label);
this.add(link); this.add(link);
} }
public void setFailedTip(String text) {
if (StringUtils.isEmpty(text)) {
this.link.setText(defaultFailedText);
} else {
this.link.setText(text);
}
}
} }

90
designer-base/src/main/java/com/fr/design/mainframe/authority/FormulaAuthorityChecker.java

@ -1,27 +1,97 @@
package com.fr.design.mainframe.authority; package com.fr.design.mainframe.authority;
import com.fr.base.Formula; import com.fr.base.Formula;
import com.fr.general.ComparatorUtils;
import com.fr.parser.FunctionCall;
import com.fr.parser.StringLiteral;
import com.fr.script.Calculator;
import com.fr.stable.script.Node;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class FormulaAuthorityChecker extends ElementAuthorityChecker<Formula> { public class FormulaAuthorityChecker extends ElementAuthorityChecker<Formula> {
private static final Pattern FORMULA_PATTERN = Pattern.compile("^=SQL\\(\"(.+?)\","); private static final Set<FormulaParser> CONNECTION_NAME_FORMULA_PARSER = new HashSet<>();
private static final Set<FormulaParser> DATASET_NAME_FORMULA_PARSER = new HashSet<>();
static {
CONNECTION_NAME_FORMULA_PARSER.add(new FormulaParser("SQL", 0));
DATASET_NAME_FORMULA_PARSER.add(new FormulaParser("VALUE", 0));
}
@Override @Override
@Nullable @Nullable
public Set<String> getNoAuthConnectionNames(Formula formula, Set<String> authConnectionNames) { public Set<String> getNoAuthConnectionNames(Formula formula, Set<String> authConnectionNames) {
String content = formula.getContent(); return getNoAuthNames(formula, CONNECTION_NAME_FORMULA_PARSER, authConnectionNames);
Matcher matcher = FORMULA_PATTERN.matcher(content); }
if (matcher.find()) {
if (!authConnectionNames.contains(matcher.group(1))) {
return new HashSet<>(Arrays.asList(matcher.group(1))); @Override
@Nullable
Set<String> getNoAuthDatasetNames(Formula formula, Set<String> authDatasetNames) {
return getNoAuthNames(formula, DATASET_NAME_FORMULA_PARSER, authDatasetNames);
}
private Set<String> getNoAuthNames(Formula formula, Set<FormulaParser> formulaParsers, Set<String> authNames) {
Set<String> noAuthNames = new HashSet<>();
try {
FunctionCall functionCall = (FunctionCall) Calculator.createCalculator().parse(formula.getContent()).getConditionalExpression();
handleNoAuthNames(functionCall, formulaParsers, authNames, noAuthNames);
} catch (Exception ignore) {
} finally {
return noAuthNames;
}
}
private void handleNoAuthNames(FunctionCall functionCall, Set<FormulaParser> formulaParsers, Set<String> authNames, Set<String> noAuthNames) {
for (FormulaParser formulaPattern : formulaParsers) {
String noAuthName = formulaPattern.getNoAuthName(functionCall, authNames);
if (noAuthName != null) {
noAuthNames.add(noAuthName);
} }
} }
return null; Node[] nodes = functionCall.getArguments();
if (nodes != null) {
for (int i = 0; i < nodes.length; i++) {
Node node = nodes[i];
if (node instanceof FunctionCall) {
handleNoAuthNames((FunctionCall) node, formulaParsers, authNames, noAuthNames);
}
}
}
} }
static class FormulaParser {
//函数的名称
public String name;
//要检测的位置
public int index;
FormulaParser(String name, int index) {
this.name = name;
this.index = index;
}
String getNoAuthName(FunctionCall functionCall, Set<String> authNames) {
if (functionCall.getName() != null && ComparatorUtils.equals(functionCall.getName().toUpperCase(), name)) {
Node node = functionCall.getArguments()[index];
if (node instanceof StringLiteral) {
String stringLiteral = node.toString();
if (stringLiteral.length() > 2) {
String value = stringLiteral.substring(1, stringLiteral.length() - 1);
if (!authNames.contains(value)) {
return value;
}
}
}
}
return null;
}
}
} }

24
designer-base/src/main/java/com/fr/design/mainframe/authority/JTemplateAuthorityChecker.java

@ -7,11 +7,11 @@ import com.fr.design.i18n.Toolkit;
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.mod.ModClassFilter; import com.fr.design.mod.ModClassFilter;
import com.fr.file.ConnectionConfig;
import com.fr.file.TableDataConfig;
import com.fr.invoke.ClassHelper; import com.fr.invoke.ClassHelper;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.rpc.ExceptionHandler;
import com.fr.rpc.RPCInvokerExceptionInfo;
import com.fr.stable.Filter; import com.fr.stable.Filter;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.server.authority.user.UserAuthority; import com.fr.workspace.server.authority.user.UserAuthority;
@ -19,7 +19,6 @@ import com.fr.workspace.server.authority.user.UserAuthority;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -29,7 +28,9 @@ import static javax.swing.JOptionPane.WARNING_MESSAGE;
public class JTemplateAuthorityChecker { public class JTemplateAuthorityChecker {
JTemplate<?, ?> jTemplate; JTemplate<?, ?> jTemplate;
Set<String> allConnectionNames;
Set<String> authConnectionNames; Set<String> authConnectionNames;
Set<String> allDatasetNames;
Set<String> authDatasetNames; Set<String> authDatasetNames;
Map<String, ElementAuthorityChecker> checkerMap = new HashMap<>(); Map<String, ElementAuthorityChecker> checkerMap = new HashMap<>();
Set<String> authFailConnectionNames = new HashSet<>(); Set<String> authFailConnectionNames = new HashSet<>();
@ -45,18 +46,20 @@ public class JTemplateAuthorityChecker {
} }
private void initAuthNames() { private void initAuthNames() {
allDatasetNames = new HashSet<>();
for (String authServerDataSetName : TableDataConfig.getInstance().getTableDatas().keySet()) {
allDatasetNames.add(authServerDataSetName);
}
allConnectionNames = ConnectionConfig.getInstance().getConnections().keySet();
UserAuthority templateAuthority = WorkContext.getCurrent().get(UserAuthority.class); UserAuthority templateAuthority = WorkContext.getCurrent().get(UserAuthority.class);
Map<String, Set<String>> authNamesMap = templateAuthority.getAuthServerDataSetAndConnectionNames(); Map<String, Set<String>> authNamesMap = templateAuthority.getAuthServerDataSetAndConnectionNames();
if (authNamesMap != null) { if (authNamesMap != null) {
//有权限的数据连接名称 //有权限的数据连接名称
authConnectionNames = authNamesMap.get(UserAuthority.AUTH_CONNECTION_NAMES); authConnectionNames = authNamesMap.get(UserAuthority.AUTH_CONNECTION_NAMES);
//有权限的数据集名称(模板数据集和服务器数据集) //有权限的数据集名称
authDatasetNames = authNamesMap.get(UserAuthority.AUTH_SERVER_DATASET_NAMES); authDatasetNames = authNamesMap.get(UserAuthority.AUTH_SERVER_DATASET_NAMES);
Iterator<String> iterator = jTemplate.getTarget().getTableDataNameIterator();
while (iterator.hasNext()) {
String datasetName = iterator.next();
authDatasetNames.add(datasetName);
}
} }
} }
@ -95,7 +98,8 @@ public class JTemplateAuthorityChecker {
} }
} }
} }
authFailConnectionNames.retainAll(allConnectionNames);
authFailDatasetNames.retainAll(allDatasetNames);
FineLoggerFactory.getLogger().info("JTemplateAuthorityChecker check time consume:" + (System.currentTimeMillis() - s)); FineLoggerFactory.getLogger().info("JTemplateAuthorityChecker check time consume:" + (System.currentTimeMillis() - s));
return authFailConnectionNames.size() == 0 && authFailDatasetNames.size() == 0; return authFailConnectionNames.size() == 0 && authFailDatasetNames.size() == 0;
} }

27
designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ComponentPreviewPane.java

@ -31,6 +31,7 @@ import java.awt.Dimension;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Image; import java.awt.Image;
import java.awt.Insets;
import java.awt.RenderingHints; import java.awt.RenderingHints;
import java.awt.Shape; import java.awt.Shape;
import java.awt.Stroke; import java.awt.Stroke;
@ -99,7 +100,20 @@ public abstract class ComponentPreviewPane extends UINoOpaquePanel implements Th
Utils.clipByRoundBorder(g2d, getWidth(), getHeight(), roundedBorder.getRoundedCorner(), roundedBorder.getThickness()); Utils.clipByRoundBorder(g2d, getWidth(), getHeight(), roundedBorder.getRoundedCorner(), roundedBorder.getThickness());
} }
int titleHeight = titlePane == null ? 0 : titlePane.getHeight(); Border containerBorder = container.getBorder();
Insets insets = containerBorder.getBorderInsets(container);
int titleHeight = titlePane == null ? 0 : titlePane.getHeight() + insets.top;
//绘制标题背景
if (titlePane != null) {
Label data = titlePane.getData();
float opacity = data.getBackgroundOpacity();
Background background = data.getBackground();
if (background != null) {
Utils.paintBackground((Graphics2D) g, background, new Rectangle2D.Double(0, 0, getWidth(), titleHeight), opacity);
}
}
//绘制主体背景
Utils.paintBackground(g2d, style.getBackground(), new Rectangle2D.Double(0, titleHeight, getWidth(), getHeight() - titleHeight), style.getAlpha()); Utils.paintBackground(g2d, style.getBackground(), new Rectangle2D.Double(0, titleHeight, getWidth(), getHeight() - titleHeight), style.getAlpha());
Utils.paintBackground(g2d, style.getBorderImage(), new Rectangle2D.Double(0, 0, getWidth(), getHeight()), style.getBorderImageOpacity()); Utils.paintBackground(g2d, style.getBorderImage(), new Rectangle2D.Double(0, 0, getWidth(), getHeight()), style.getBorderImageOpacity());
@ -133,17 +147,14 @@ public abstract class ComponentPreviewPane extends UINoOpaquePanel implements Th
this.setBorder(new BottomLineBorder(componentStyle.getStyle().getColor(), componentStyle.getStyle().getBorder())); this.setBorder(new BottomLineBorder(componentStyle.getStyle().getColor(), componentStyle.getStyle().getBorder()));
} }
public Label getData(){
return data;
}
@Override @Override
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
super.paintComponent(g); super.paintComponent(g);
Dimension size = getSize();
Background background = data.getBackground();
float opacity = data.getBackgroundOpacity();
if (background != null) {
Utils.paintBackground((Graphics2D) g, background, new Rectangle2D.Double(0, 0, size.getWidth(), size.getHeight()), opacity);
}
Graphics2D g2d = (Graphics2D) g.create(); Graphics2D g2d = (Graphics2D) g.create();
Background inset = data.getInsetImage(); Background inset = data.getInsetImage();
Image insetImage = inset instanceof ImageBackground ? ((ImageBackground) inset).getImage() : null; Image insetImage = inset instanceof ImageBackground ? ((ImageBackground) inset).getImage() : null;

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;
}
}

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

@ -0,0 +1,229 @@
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(jwb);
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) {

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

@ -1,55 +1,92 @@
package com.fr.design.report.fit.menupane; package com.fr.design.report.fit.menupane;
import com.fr.design.beans.BasicBeanPane; 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() { private JTemplate jwb;
public TemplateFitAttrPane(JTemplate jwb) {
this.jwb = jwb;
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(jwb)) {
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();
* @param fitAttr 自适应属性 }
*/
public void populateBean(ReportFitAttr fitAttr) { super.setEnabled(isTemplateSingleSet());
attrPane.populateBean(fitAttr); super.populateBean(reportFitAttr);
} }
/**
* 提交数据
*
* @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()){
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;
}

22
designer-base/src/main/java/com/fr/design/style/color/NewColorSelectPane.java

@ -39,8 +39,10 @@ import java.util.List;
public class NewColorSelectPane extends BasicPane implements ColorSelectable { public class NewColorSelectPane extends BasicPane implements ColorSelectable {
private static final long serialVersionUID = -8634152305687249392L; private static final long serialVersionUID = -8634152305687249392L;
private static final int WIDTH = 197; private static final int WIDTH = 216;
private static final int HEIGHT = 250; private static final int HEIGHT = 230;
private static final int DEFAULT_COLOR_HOR_INTERVAL = 4;
//颜色衍生的数量 //颜色衍生的数量
private static final int DEFAULT_DERIVE_COUNT = 5; private static final int DEFAULT_DERIVE_COUNT = 5;
@ -81,7 +83,7 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
initSelectButton(isSupportTransparent); initSelectButton(isSupportTransparent);
// center // center
JPanel centerPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); JPanel centerPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane();
centerPane.setBorder(BorderFactory.createEmptyBorder(10, 4, 0, 4)); centerPane.setBorder(BorderFactory.createEmptyBorder(10, 6, 0, 6));
this.add(centerPane, BorderLayout.CENTER); this.add(centerPane, BorderLayout.CENTER);
menuColorPane = getMenuColorPane(); menuColorPane = getMenuColorPane();
@ -126,14 +128,14 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
customButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); customButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
JPanel centerPane1 = new JPanel(new BorderLayout(0, 0)); JPanel centerPane1 = new JPanel(new BorderLayout(0, 0));
centerPane1.setBorder(BorderFactory.createEmptyBorder(9, 0, 11, 0)); centerPane1.setBorder(BorderFactory.createEmptyBorder(8, 0, 9, 0));
centerPane1.add(customButton, BorderLayout.CENTER); centerPane1.add(customButton, BorderLayout.CENTER);
customButton.setPreferredSize(new Dimension(197, 20)); customButton.setPreferredSize(new Dimension(197, 20));
centerPane.add(centerPane1); centerPane.add(centerPane1);
} }
private JPanel createStandardColorPane() { private JPanel createStandardColorPane() {
JPanel jPanel = new JPanel(new GridLayout(1, 10, 3, 0)); JPanel jPanel = new JPanel(new GridLayout(1, 10, DEFAULT_COLOR_HOR_INTERVAL, 0));
Color[] colorArray = ColorFactory.STANDARD_COLORS; Color[] colorArray = ColorFactory.STANDARD_COLORS;
for (int i = 0; i < colorArray.length; i++) { for (int i = 0; i < colorArray.length; i++) {
jPanel.add(new ColorCell(colorArray[i], this)); jPanel.add(new ColorCell(colorArray[i], this));
@ -150,8 +152,8 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
themeColorPane.add(menuColorPane, BorderLayout.SOUTH); themeColorPane.add(menuColorPane, BorderLayout.SOUTH);
menuColorPane.setLayout(new BorderLayout(0, 10)); menuColorPane.setLayout(new BorderLayout(0, 10));
JPanel northPane = new JPanel(new GridLayout(1, 8, 3, 0)); JPanel northPane = new JPanel(new GridLayout(1, 8, DEFAULT_COLOR_HOR_INTERVAL, 0));
JPanel centerPane = new JPanel(new GridLayout(1, 8, 3, 0)); JPanel centerPane = new JPanel(new GridLayout(1, 8, DEFAULT_COLOR_HOR_INTERVAL, 0));
menuColorPane.add(northPane, BorderLayout.NORTH); menuColorPane.add(northPane, BorderLayout.NORTH);
menuColorPane.add(centerPane, BorderLayout.CENTER); menuColorPane.add(centerPane, BorderLayout.CENTER);
@ -189,7 +191,7 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
northPane.add(themeColorCellGrid[i][0]); northPane.add(themeColorCellGrid[i][0]);
} }
for (int i = 0; i < colorArray.length; i++) { for (int i = 0; i < colorArray.length; i++) {
JPanel columnPane = new JPanel(new GridLayout(DEFAULT_DERIVE_COUNT - 1, 1, 0, 3)); JPanel columnPane = new JPanel(new GridLayout(DEFAULT_DERIVE_COUNT - 1, 1, 0, 0));
for (int j = 1; j < DEFAULT_DERIVE_COUNT; j++) { for (int j = 1; j < DEFAULT_DERIVE_COUNT; j++) {
columnPane.add(themeColorCellGrid[i][j]); columnPane.add(themeColorCellGrid[i][j]);
} }
@ -233,7 +235,7 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
private void initMenuColorPane() { private void initMenuColorPane() {
menuColorPane.setLayout(new GridLayout(5, 8, 3, 3)); menuColorPane.setLayout(new GridLayout(5, 8, DEFAULT_COLOR_HOR_INTERVAL, 0));
Color[] colorArray = this.getColorArray(); Color[] colorArray = this.getColorArray();
for (int i = 0; i < colorArray.length; i++) { for (int i = 0; i < colorArray.length; i++) {
Color color = colorArray[i] == null ? UsedColorPane.DEFAULT_COLOR : colorArray[i]; Color color = colorArray[i] == null ? UsedColorPane.DEFAULT_COLOR : colorArray[i];
@ -409,7 +411,7 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
private void initialComponents() { private void initialComponents() {
int total = columns; int total = columns;
JPanel panel = new JPanel(); JPanel panel = new JPanel();
panel.setLayout(new GridLayout(1, columns + 1, 3, 3)); panel.setLayout(new GridLayout(1, columns + 1, DEFAULT_COLOR_HOR_INTERVAL, 0));
panel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); panel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
//最近使用颜色 //最近使用颜色
Color[] colors = DesignerEnvManager.getEnvManager().getColorConfigManager().getColors(); Color[] colors = DesignerEnvManager.getEnvManager().getColorConfigManager().getColors();

26
designer-base/src/main/java/com/fr/design/worker/open/OpenWorker.java

@ -7,12 +7,14 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrameFileDealerPane; import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.utils.DesignUtils;
import com.fr.design.worker.WorkerManager; import com.fr.design.worker.WorkerManager;
import com.fr.exception.DecryptTemplateException; import com.fr.exception.DecryptTemplateException;
import com.fr.file.FILE; import com.fr.file.FILE;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.SwingWorker; import javax.swing.SwingWorker;
import javax.swing.UIManager; import javax.swing.UIManager;
@ -51,6 +53,7 @@ public class OpenWorker<T> extends SwingWorker<T, Void> {
@Override @Override
protected T doInBackground() throws Exception { protected T doInBackground() throws Exception {
TimeUnit.SECONDS.sleep(5);
return this.callable.call(); return this.callable.call();
} }
@ -61,7 +64,7 @@ public class OpenWorker<T> extends SwingWorker<T, Void> {
} catch (CancellationException ignored) { } catch (CancellationException ignored) {
return; return;
} catch (Throwable t) { } catch (Throwable t) {
processFailed(); processFailed(StringUtils.EMPTY);
Throwable cause = t.getCause(); Throwable cause = t.getCause();
if (cause instanceof DecryptTemplateException) { if (cause instanceof DecryptTemplateException) {
FineJOptionPane.showMessageDialog( FineJOptionPane.showMessageDialog(
@ -91,6 +94,11 @@ public class OpenWorker<T> extends SwingWorker<T, Void> {
if (slowly && templateCallable != null) { if (slowly && templateCallable != null) {
try { try {
JTemplate<?, ?> book = templateCallable.call(); JTemplate<?, ?> book = templateCallable.call();
if (inValidDesigner(book)) {
String text = Toolkit.i18nText("Fine-Design_Report_Template_Version_Not_Match", DesignUtils.parseVersion(book.getTarget().getDesignerVersion()));
processFailed(text);
return;
}
FILE tplFile = book.getEditingFILE(); FILE tplFile = book.getEditingFILE();
JTemplate<?, ?> currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); JTemplate<?, ?> currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
// 当前tab页是正在打开的模板 // 当前tab页是正在打开的模板
@ -117,11 +125,21 @@ public class OpenWorker<T> extends SwingWorker<T, Void> {
WorkerManager.getInstance().removeWorker(taskName); WorkerManager.getInstance().removeWorker(taskName);
} }
private void processFailed() { private boolean inValidDesigner(JTemplate<?, ?> jt) {
return jt.isOldDesigner(false) || (!jt.isJWorkBook() && jt.isNewDesigner(false));
}
private void processFailed(String text) {
this.template.setOpenFailed(true); this.template.setOpenFailed(true);
this.template.setOpening(false); this.template.setOpening(false);
DesignerContext.getDesignerFrame().getCenterTemplateCardPane().showOpenFailedCover(); JTemplate<?, ?> currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
DesignerFrameFileDealerPane.getInstance().stateChange(); // 需要判断当前打开的模板是不是异步执行后失败的模板 是的话立即展示失败后的提示内容 否则只设置下失败的提示内容
if (ComparatorUtils.equals(currentTemplate.getEditingFILE().getName(), this.template.getName())) {
DesignerContext.getDesignerFrame().getCenterTemplateCardPane().showOpenFailedCover(text);
DesignerFrameFileDealerPane.getInstance().stateChange();
} else {
this.template.setTemplateOpenFailedTip(text);
}
WorkerManager.getInstance().removeWorker(taskName); WorkerManager.getInstance().removeWorker(taskName);
} }

7
designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/other/VanChartDrillMapInteractivePane.java

@ -100,7 +100,12 @@ public class VanChartDrillMapInteractivePane extends VanChartInteractivePaneWith
double f = TableLayout.FILL; double f = TableLayout.FILL;
double[] columnSize = {f}; double[] columnSize = {f};
double[] rowSize = {p, p, p, p, p, p}; double[] rowSize = {p, p, p, p, p, p};
Component[][] components = new Component[][]{ Component[][] components = ChartEditContext.duchampMode() ? new Component[][]{
new Component[]{null},
new Component[]{createTitlePane(Toolkit.i18nText("Fine-Design_Chart_Character"), textAttrPane)},
new Component[]{backgroundPane},
new Component[]{selectBackgroundPane}
} : new Component[][]{
new Component[]{null}, new Component[]{null},
new Component[]{createTitlePane(Toolkit.i18nText("Fine-Design_Chart_Character"), textAttrPane)}, new Component[]{createTitlePane(Toolkit.i18nText("Fine-Design_Chart_Character"), textAttrPane)},
new Component[]{backgroundPane}, new Component[]{backgroundPane},

17
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) {

15
designer-form/src/main/java/com/fr/design/designer/beans/models/NewFormModel.java

@ -1,6 +1,7 @@
package com.fr.design.designer.beans.models; package com.fr.design.designer.beans.models;
import com.fr.design.designer.beans.PredefinedLayout; import com.fr.design.designer.beans.PredefinedLayout;
import com.fr.design.i18n.Toolkit;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -9,13 +10,20 @@ import com.fr.third.fasterxml.jackson.databind.ObjectMapper;
import java.io.InputStream; import java.io.InputStream;
import java.io.Serializable; import java.io.Serializable;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public class NewFormModel implements Serializable { public class NewFormModel implements Serializable {
private static final String CONFIG_FILE_PATH = "/com/fr/design/form/layouts/config.json"; private static final String CONFIG_FILE_PATH = "/com/fr/design/form/layouts/config.json";
private static NewFormModel holder = null; private static NewFormModel holder = null;
private Map<String, List<PredefinedLayout>> config = new HashMap<>(); private Map<String, List<PredefinedLayout>> config = new LinkedHashMap<>();
private final Map<String, String> i18nMap = new HashMap<String, String>() {{
put("2-4", Toolkit.i18nText("Fine-Design_Layout_Two_To_Four_Module"));
put("5-7", Toolkit.i18nText("Fine-Design_Layout_Five_To_Seven_Module"));
put("multi", Toolkit.i18nText("Fine-Design_Layout_Multi_Module"));
}};
public static NewFormModel getInstance() { public static NewFormModel getInstance() {
if (holder == null) { if (holder == null) {
@ -52,6 +60,9 @@ public class NewFormModel implements Serializable {
} }
public void setConfig(Map<String, List<PredefinedLayout>> config) { public void setConfig(Map<String, List<PredefinedLayout>> config) {
this.config = config; for (String key : config.keySet()) {
String i18nKey = StringUtils.isNotEmpty(i18nMap.get(key)) ? i18nMap.get(key) : key;
this.config.put(i18nKey, config.get(key));
}
} }
} }

2
designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java

@ -220,4 +220,4 @@ public class LayoutStylePane extends BasicBeanPane<LayoutBorderStyle> {
namedIntegralStylePane.setVisible(supporting); namedIntegralStylePane.setVisible(supporting);
} }
} }
} }

11
designer-form/src/main/java/com/fr/design/mainframe/share/generate/task/ComponentCreator.java

@ -4,6 +4,7 @@ import com.fr.base.TableData;
import com.fr.base.iofile.attr.ExtendSharableAttrMark; import com.fr.base.iofile.attr.ExtendSharableAttrMark;
import com.fr.base.iofile.attr.SharableAttrMark; import com.fr.base.iofile.attr.SharableAttrMark;
import com.fr.base.theme.TemplateTheme; import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.TemplateThemeConfig;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.share.generate.impl.AbstractComponentCreatorProcessor; import com.fr.design.mainframe.share.generate.impl.AbstractComponentCreatorProcessor;
@ -18,6 +19,7 @@ import com.fr.form.share.utils.ShareUtils;
import com.fr.form.ui.AbstractBorderStyleWidget; import com.fr.form.ui.AbstractBorderStyleWidget;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import com.fr.stable.fun.IOFileAttrMark; import com.fr.stable.fun.IOFileAttrMark;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -61,8 +63,13 @@ public class ComponentCreator extends AbstractComponentCreatorProcessor {
private void setSuitableTemplateThemeName(JTemplate<?, ?> jt, DefaultSharableWidget info) { private void setSuitableTemplateThemeName(JTemplate<?, ?> jt, DefaultSharableWidget info) {
TemplateTheme theme = jt.getTemplateTheme(); TemplateTheme theme = jt.getTemplateTheme();
if (theme != null) { if (theme != null ) {
info.setSuitableTemplateThemeName(theme.getName()); String name = theme.getName();
TemplateThemeConfig<? extends TemplateTheme> config = jt.getUsingTemplateThemeConfig();
String name4LegacyTemplate = config.getThemeName4LegacyTemplate();
if (!StringUtils.equals(name, name4LegacyTemplate)) {
info.setSuitableTemplateThemeName(name);
}
} }
} }

118
designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/DownloadSuitableThemeAction.java

@ -14,6 +14,7 @@ import com.fr.design.login.DesignerLoginSource;
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.mainframe.share.util.DownloadUtils; import com.fr.design.mainframe.share.util.DownloadUtils;
import com.fr.design.mainframe.theme.dialog.TemplateThemeUsingDialog;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.transaction.CallBackAdaptor; import com.fr.transaction.CallBackAdaptor;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
@ -21,7 +22,11 @@ import com.fr.workspace.WorkContext;
import javax.swing.Action; import javax.swing.Action;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.SwingWorker; import javax.swing.SwingWorker;
import java.awt.Window;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.concurrent.ExecutionException;
/** /**
* @author Starryi * @author Starryi
@ -31,6 +36,7 @@ import java.awt.event.ActionEvent;
public class DownloadSuitableThemeAction extends UpdateAction { public class DownloadSuitableThemeAction extends UpdateAction {
private final String themePath; private final String themePath;
private boolean downloading = false; private boolean downloading = false;
private JTemplate<?, ?> currentTemplate;
public DownloadSuitableThemeAction(String themePath) { public DownloadSuitableThemeAction(String themePath) {
this.themePath = themePath; this.themePath = themePath;
@ -40,9 +46,8 @@ public class DownloadSuitableThemeAction extends UpdateAction {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (checkAuthority()) { currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
saveTheme(); fetchTheme();
}
} }
private boolean checkAuthority() { private boolean checkAuthority() {
@ -63,43 +68,43 @@ public class DownloadSuitableThemeAction extends UpdateAction {
return true; return true;
} }
private void saveTheme() { private void fetchTheme() {
if (!checkAuthority()) {
onThemeFetched(null);
return;
}
if (downloading) { if (downloading) {
return; return;
} }
downloading = true; downloading = true;
final JTemplate<?,?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); new SwingWorker<FormTheme, Void>() {
new SwingWorker<Boolean, Void>() {
@Override @Override
protected Boolean doInBackground() { protected FormTheme doInBackground() {
FormTheme theme = fetchRemoteTheme(); return DownloadUtils.downloadThemeFile(themePath);
if (theme == null) {
return false;
}
theme = ensureThemeHasUniqueName(theme, theme.getName());
if (theme == null) {
return false;
}
String themeName = theme.getName();
saveThemeToConfig(theme, new SaveToThemeConfigCallback(template, themeName));
return true;
} }
@Override @Override
protected void done() { protected void done() {
FormTheme theme = null;
try {
theme = get();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
onThemeFetched(theme);
downloading = false; downloading = false;
} }
}.execute(); }.execute();
} }
private FormTheme fetchRemoteTheme() { public void onThemeFetched(FormTheme theme) {
return DownloadUtils.downloadThemeFile(themePath); if (theme == null) {
return;
}
saveTheme(theme);
} }
private FormTheme ensureThemeHasUniqueName(FormTheme theme, String expectedName) { private FormTheme ensureThemeHasUniqueName(FormTheme theme, String expectedName) {
@ -118,36 +123,65 @@ public class DownloadSuitableThemeAction extends UpdateAction {
} }
} }
private void saveThemeToConfig(final FormTheme theme, CallBackAdaptor callback) { private void saveTheme(FormTheme theme) {
FormThemeConfig.getInstance().addTheme(theme, true, callback); final FormTheme uniqueNamedTheme = ensureThemeHasUniqueName(theme, theme.getName());
if (uniqueNamedTheme != null) {
FormThemeConfig.getInstance().addTheme(theme, true, new CallBackAdaptor() {
@Override
public void afterCommit() {
super.afterCommit();
onThemeSaved(uniqueNamedTheme);
}
@Override
public void afterRollback() {
super.afterRollback();
onThemeSaved(null);
}
});
} else {
onThemeSaved(null);
}
}
public void onThemeSaved(FormTheme theme) {
if (theme == null) {
return;
}
Window designerFrame = DesignerContext.getDesignerFrame();
TemplateThemeUsingDialog<FormTheme> dialog = new TemplateThemeUsingDialog<>(designerFrame, currentTemplate, FormThemeConfig.getInstance());
dialog.addWindowListener(new UsingDialogAdapter(theme));
dialog.setVisible(true);
}
public void applyTheme(JTemplate<?, ?> template, final String name, Window dialog) {
TemplateThemeConfig<? extends TemplateTheme> config = template.getUsingTemplateThemeConfig();
TemplateTheme theme = config.cachedFetch(name);
template.setTemplateTheme(theme);
dialog.repaint();
} }
public static class SaveToThemeConfigCallback extends CallBackAdaptor { private class UsingDialogAdapter extends WindowAdapter {
private final JTemplate<?,?> template; private final FormTheme theme;
private final String themeName;
public SaveToThemeConfigCallback(JTemplate<?, ?> template, String themeName) { public UsingDialogAdapter(FormTheme theme) {
this.template = template; this.theme = theme;
this.themeName = themeName;
} }
@Override @Override
public void afterCommit() { public void windowOpened(WindowEvent e) {
super.afterCommit(); super.windowOpened(e);
Window window = e.getWindow();
int returnVal = FineJOptionPane.showConfirmDialog( int returnVal = FineJOptionPane.showConfirmDialog(
DesignerContext.getDesignerFrame(), window,
Toolkit.i18nText("Fine-Design_Share_Apply_Suitable_Theme_Tip"), Toolkit.i18nText("Fine-Design_Share_Apply_Suitable_Theme_Tip"),
Toolkit.i18nText("Fine-Design_Basic_Confirm"), Toolkit.i18nText("Fine-Design_Basic_Confirm"),
FineJOptionPane.OK_CANCEL_OPTION); FineJOptionPane.OK_CANCEL_OPTION);
if (returnVal == JOptionPane.YES_OPTION) { if (returnVal == JOptionPane.YES_OPTION) {
applyTheme(template, themeName); applyTheme(currentTemplate, theme.getName(), window);
} }
} window.removeWindowListener(this);
private void applyTheme(JTemplate<?,?> template, final String name) {
TemplateThemeConfig<? extends TemplateTheme> config = template.getUsingTemplateThemeConfig();
TemplateTheme theme = config.cachedFetch(name);
template.setTemplateTheme(theme);
} }
} }
} }

3
designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/AbstractOnlineWidgetBlock.java

@ -117,8 +117,7 @@ public abstract class AbstractOnlineWidgetBlock extends PreviewWidgetBlock<Onlin
popupMenu.setBackground(UIConstants.DEFAULT_BG_RULER); popupMenu.setBackground(UIConstants.DEFAULT_BG_RULER);
OnlineShareWidget widget = getWidget(); OnlineShareWidget widget = getWidget();
OnlineShareWidget parentPackage = widget.getParentPackage(); String suitableThemeFile = widget.getThemePath();
String suitableThemeFile = parentPackage != null ? parentPackage.getThemePath() : null;
if (StringUtils.isNotEmpty(suitableThemeFile)) { if (StringUtils.isNotEmpty(suitableThemeFile)) {
popupMenu.add(new DownloadSuitableThemeAction(suitableThemeFile).createMenuItem()); popupMenu.add(new DownloadSuitableThemeAction(suitableThemeFile).createMenuItem());
} }

35
designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/OnlineWidgetBlock.java

@ -35,8 +35,11 @@ import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.SwingConstants; import javax.swing.SwingConstants;
import javax.swing.SwingWorker; import javax.swing.SwingWorker;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import java.awt.AlphaComposite; import java.awt.AlphaComposite;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
@ -60,9 +63,10 @@ import java.util.concurrent.ExecutionException;
* Created by kerry on 2020-10-19 * Created by kerry on 2020-10-19
* 商城组件块 * 商城组件块
*/ */
public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock { public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock implements PopupMenuListener {
private boolean isMouseEnter = false; private boolean isMouseEnter = false;
private boolean downloading = false; private boolean downloading = false;
private boolean popupMenuVisible = false;
private static final Color COVER_COLOR = Color.decode("#333334"); private static final Color COVER_COLOR = Color.decode("#333334");
protected MouseEvent lastPressEvent; protected MouseEvent lastPressEvent;
private double process = 0D; private double process = 0D;
@ -89,6 +93,13 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock {
return southPane; return southPane;
} }
@Override
public JPopupMenu createRightClickPopupMenu() {
JPopupMenu popupMenu = super.createRightClickPopupMenu();
popupMenu.addPopupMenuListener(this);
return popupMenu;
}
@Override @Override
public void mouseEntered(MouseEvent e) { public void mouseEntered(MouseEvent e) {
super.mouseEntered(e); super.mouseEntered(e);
@ -113,7 +124,7 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock {
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
super.mouseClicked(e); super.mouseClicked(e);
boolean isLeftClickDownloadIcon = e.getButton() != MouseEvent.BUTTON3 && getDownloadIconRec().contains(e.getX(), e.getY()); boolean isLeftClickDownloadIcon = e.getButton() != MouseEvent.BUTTON3 && getDownloadIconRec().contains(e.getX(), e.getY());
if (isLeftClickDownloadIcon && !checkWidgetInstalled()) { if (!popupMenuVisible && isLeftClickDownloadIcon && !checkWidgetInstalled()) {
downLoadWidget(); downLoadWidget();
} }
} }
@ -270,7 +281,7 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock {
return; return;
} }
//如果鼠标移动到布局内且布局不可编辑,画出编辑蒙层 //如果鼠标移动到布局内且布局不可编辑,画出编辑蒙层
if (isMouseEnter || downloading) { if (!popupMenuVisible && (isMouseEnter || downloading)) {
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
Composite oldComposite = g2d.getComposite(); Composite oldComposite = g2d.getComposite();
//画白色的编辑层 //画白色的编辑层
@ -299,6 +310,24 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock {
} }
} }
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
this.popupMenuVisible = true;
repaint();
}
@Override
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
this.popupMenuVisible = false;
repaint();
}
@Override
public void popupMenuCanceled(PopupMenuEvent e) {
this.popupMenuVisible = false;
repaint();
}
class WidgetDownloadProcess implements com.fr.design.extra.Process<Double> { class WidgetDownloadProcess implements com.fr.design.extra.Process<Double> {

6
designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetPopupPreviewPane.java

@ -159,10 +159,10 @@ public class OnlineWidgetPopupPreviewPane extends AbstractWidgetPopupPreviewPane
@Override @Override
public void populateBean(PreviewWidgetBlock<OnlineShareWidget> block) { public void populateBean(PreviewWidgetBlock<OnlineShareWidget> block) {
OnlineShareWidget widget = block.getWidget(); OnlineShareWidget widget = block.getWidget();
OnlineShareWidget parentPackage = widget.getParentPackage(); String themeName = widget.getThemeName();
if (parentPackage != null && StringUtils.isNotEmpty(parentPackage.getThemeName())) { if (StringUtils.isNotEmpty(themeName)) {
suitableThemeNamePane.setVisible(true); suitableThemeNamePane.setVisible(true);
suitableThemeNameLabel.setText(parentPackage.getThemeName()); suitableThemeNameLabel.setText(themeName);
} else { } else {
suitableThemeNamePane.setVisible(false); suitableThemeNamePane.setVisible(false);
} }

17
designer-form/src/main/java/com/fr/design/mainframe/share/util/DownloadUtils.java

@ -1,7 +1,6 @@
package com.fr.design.mainframe.share.util; package com.fr.design.mainframe.share.util;
import com.fr.base.theme.FormTheme; import com.fr.base.theme.FormTheme;
import com.fr.base.theme.TemplateTheme;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.extra.PluginConstants; import com.fr.design.extra.PluginConstants;
import com.fr.form.share.base.CancelCheck; import com.fr.form.share.base.CancelCheck;
@ -15,7 +14,6 @@ import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLReaderHelper; import com.fr.stable.xml.XMLReaderHelper;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
import com.fr.third.javax.xml.stream.XMLStreamException;
import com.fr.third.org.apache.http.HttpEntity; import com.fr.third.org.apache.http.HttpEntity;
import com.fr.third.org.apache.http.HttpException; import com.fr.third.org.apache.http.HttpException;
import com.fr.third.org.apache.http.HttpStatus; import com.fr.third.org.apache.http.HttpStatus;
@ -30,11 +28,12 @@ import com.fr.third.org.apache.http.impl.client.HttpClients;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import javax.crypto.Cipher; import javax.crypto.Cipher;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.security.KeyFactory; import java.security.KeyFactory;
import java.security.interfaces.RSAPublicKey; import java.security.interfaces.RSAPublicKey;
@ -147,8 +146,16 @@ public class DownloadUtils {
} }
if (fileRes.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { if (fileRes.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
HttpEntity entity = fileRes.getEntity(); HttpEntity entity = fileRes.getEntity();
InputStream content = entity.getContent();
XMLableReader reader = XMLReaderHelper.createXMLableReader(content, XMLPrintWriter.XML_ENCODER); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(entity.getContent()));
StringBuilder stringBuilder = new StringBuilder();
String line;
while ((line = bufferedReader.readLine()) != null) {
stringBuilder.append(line);
}
String content = stringBuilder.toString();
XMLableReader reader = XMLReaderHelper.createXMLableReader(new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8)), XMLPrintWriter.XML_ENCODER);
FormTheme theme = new FormTheme(); FormTheme theme = new FormTheme();
reader.readXMLObject(theme); reader.readXMLObject(theme);

5
designer-form/src/main/java/com/fr/design/mainframe/share/util/ShareComponentUtils.java

@ -3,6 +3,7 @@ package com.fr.design.mainframe.share.util;
import com.fr.base.io.IOFile; import com.fr.base.io.IOFile;
import com.fr.base.iofile.attr.ExtendSharableAttrMark; import com.fr.base.iofile.attr.ExtendSharableAttrMark;
import com.fr.base.theme.FormTheme; import com.fr.base.theme.FormTheme;
import com.fr.base.theme.FormThemeConfig;
import com.fr.base.theme.TemplateTheme; import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.TemplateThemeCompatible; import com.fr.base.theme.TemplateThemeCompatible;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
@ -58,9 +59,11 @@ public class ShareComponentUtils {
JTemplate<?,?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); JTemplate<?,?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
TemplateTheme theme = template.getTemplateTheme(); TemplateTheme theme = template.getTemplateTheme();
if (theme instanceof FormTheme) { if (theme instanceof FormTheme) {
String themeName4LegacyTemplate = FormThemeConfig.getInstance().getThemeName4LegacyTemplate();
boolean isCurrentUsingThemeSuitSharedComponent = StringUtils.isNotEmpty(theme.getName()) && boolean isCurrentUsingThemeSuitSharedComponent = StringUtils.isNotEmpty(theme.getName()) &&
StringUtils.isNotEmpty(suitableTemplateThemeName) && StringUtils.isNotEmpty(suitableTemplateThemeName) &&
StringUtils.equals(theme.getName(), suitableTemplateThemeName); StringUtils.equals(theme.getName(), suitableTemplateThemeName) &&
!StringUtils.equals(theme.getName(), themeName4LegacyTemplate);
XCreatorUtils.setupTemplateTheme(creator, false, (FormTheme) theme, isCurrentUsingThemeSuitSharedComponent ? TemplateThemeCompatible.NONE : TemplateThemeCompatible.ABSENT); XCreatorUtils.setupTemplateTheme(creator, false, (FormTheme) theme, isCurrentUsingThemeSuitSharedComponent ? TemplateThemeCompatible.NONE : TemplateThemeCompatible.ABSENT);
} }
return creator; return creator;

2
designer-form/src/main/java/com/fr/design/widget/ui/designer/PredefinedLayoutPane.java

@ -11,6 +11,7 @@ import com.fr.stable.StringUtils;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.CardLayout; import java.awt.CardLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
@ -37,6 +38,7 @@ public class PredefinedLayoutPane extends JPanel {
this.setLayout(cardLayout); this.setLayout(cardLayout);
this.add(realStyle, 0); this.add(realStyle, 0);
this.add(simpleStyle, 1); this.add(simpleStyle, 1);
this.setPreferredSize(new Dimension(235, 134));
this.initListener(); this.initListener();
} }

6
designer-form/src/main/resources/com/fr/design/form/layouts/config.json

@ -1,6 +1,6 @@
{ {
"config":{ "config":{
"2-4模块":[ "2-4":[
{ {
"template":"2-4/1.frm", "template":"2-4/1.frm",
"realStyle":"real_style_1", "realStyle":"real_style_1",
@ -32,7 +32,7 @@
"simpleStyle":"simple_style_6" "simpleStyle":"simple_style_6"
} }
], ],
"5-7模块":[ "5-7":[
{ {
"template":"5-7/1.frm", "template":"5-7/1.frm",
"realStyle":"real_style_7", "realStyle":"real_style_7",
@ -64,7 +64,7 @@
"simpleStyle":"simple_style_12" "simpleStyle":"simple_style_12"
} }
], ],
"多模块":[ "multi":[
{ {
"template":"multi/1.frm", "template":"multi/1.frm",
"realStyle":"real_style_13", "realStyle":"real_style_13",

BIN
designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 35 KiB

BIN
designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_10.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 44 KiB

BIN
designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_11.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 50 KiB

BIN
designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_12.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 54 KiB

BIN
designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_13.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 46 KiB

BIN
designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_14.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 43 KiB

BIN
designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_15.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 37 KiB

BIN
designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_16.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 52 KiB

BIN
designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_17.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

BIN
designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_18.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 44 KiB

BIN
designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_2.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

BIN
designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_3.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

BIN
designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_4.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

BIN
designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_5.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 42 KiB

BIN
designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_6.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

BIN
designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_7.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 32 KiB

BIN
designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_8.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 38 KiB

BIN
designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_9.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 32 KiB

35
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java

@ -32,19 +32,17 @@ import com.fr.design.mainframe.alphafine.search.manager.impl.RecentSearchManager
import com.fr.design.mainframe.alphafine.search.manager.impl.RecommendSearchManager; import com.fr.design.mainframe.alphafine.search.manager.impl.RecommendSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.SegmentationManager; import com.fr.design.mainframe.alphafine.search.manager.impl.SegmentationManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.SimilarSearchManager; import com.fr.design.mainframe.alphafine.search.manager.impl.SimilarSearchManager;
import com.fr.form.main.Form;
import com.fr.form.main.FormIO;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpClient;
import com.fr.io.TemplateWorkBookIO;
import com.fr.io.exporter.ImageExporter;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.main.impl.WorkBook;
import com.fr.stable.CodeUtils; import com.fr.stable.CodeUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.exporter.LocalExportOperator;
import com.fr.workspace.server.exporter.TemplateExportOperator;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.DefaultListModel; import javax.swing.DefaultListModel;
@ -601,14 +599,15 @@ public class AlphaFineDialog extends UIDialog {
checkWorker(); checkWorker();
this.showWorker = new SwingWorker<BufferedImage, Void>() { this.showWorker = new SwingWorker<BufferedImage, Void>() {
@Override @Override
protected BufferedImage doInBackground() { protected BufferedImage doInBackground() throws Exception {
Form form = null; byte[] bytes = null;
try { try {
form = FormIO.readForm(fileName); bytes = WorkContext.getCurrent().get(TemplateExportOperator.class).exportFormAsImageData(fileName);
} catch (Exception e) { } catch (Exception ignored) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); // 兼容下老版本
bytes = new LocalExportOperator().exportFormAsImageData(fileName);
} }
return FormIO.exportFormAsImage(form); return TemplateExportOperator.byteDataToImage(bytes);
} }
@Override @Override
@ -631,15 +630,15 @@ public class AlphaFineDialog extends UIDialog {
checkWorker(); checkWorker();
this.showWorker = new SwingWorker<BufferedImage, Void>() { this.showWorker = new SwingWorker<BufferedImage, Void>() {
@Override @Override
protected BufferedImage doInBackground() { protected BufferedImage doInBackground() throws Exception {
WorkBook workBook = null; byte[] bytes = null;
try { try {
workBook = (WorkBook) TemplateWorkBookIO.readTemplateWorkBook(fileName); bytes = WorkContext.getCurrent().get(TemplateExportOperator.class).exportWorkBookAsImageData(fileName);
} catch (Exception e) { } catch (Exception ignored) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); // 兼容下老版本
bytes = new LocalExportOperator().exportWorkBookAsImageData(fileName);
} }
BufferedImage bufferedImage = new ImageExporter().exportToImage(workBook); return TemplateExportOperator.byteDataToImage(bytes);
return bufferedImage;
} }
@Override @Override

35
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;
@ -35,18 +37,20 @@ public class EditReportServerParameterPane extends LoadingBasicPane {
private WriteToolBarPane writePane; private WriteToolBarPane writePane;
private ReportWebAttr webAttr; private ReportWebAttr webAttr;
private PrintSettingsAttrMark printSettings; private PrintSettingsAttrMark printSettings;
private WebCssPane cssPane; private WebCssPane cssPane;
private WebJsPane jsPane; private WebJsPane jsPane;
private ErrorTemplatePane errorTemplatePane; private ErrorTemplatePane errorTemplatePane;
private PrintSettingPane printSettingPane; private PrintSettingPane printSettingPane;
private ServerFitAttrPane serverFitAttrPane;
@Override @Override
protected synchronized void initComponents(JPanel container) { protected synchronized void initComponents(JPanel container) {
JPanel defaultPane = container; JPanel defaultPane = container;
defaultPane.setLayout(FRGUIPaneFactory.createBorderLayout()); defaultPane.setLayout(FRGUIPaneFactory.createBorderLayout());
@ -61,11 +65,14 @@ 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
protected String title4PopupWindow() { protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ReportServerP_Report_Server_Parameter"); return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ReportServerP_Report_Server_Parameter");
} }
public void populate(ServerPreferenceConfig reportServerPreferenceConfig) { public void populate(ServerPreferenceConfig reportServerPreferenceConfig) {
@ -78,28 +85,31 @@ 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);
jsPane.populate(webAttr); jsPane.populate(webAttr);
printSettings = ReportUtils.getPrintSettingsFromServerConfig(); printSettings = ReportUtils.getPrintSettingsFromServerConfig();
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();
}
} }
} }

2
designer-realize/src/main/java/com/fr/design/webattr/PageToolBarPane.java

@ -60,7 +60,7 @@ public class PageToolBarPane extends AbstractEditToolBarPane {
private UICheckBox isPageFixedRowBox; private UICheckBox isPageFixedRowBox;
private UITextField pageFixedRowCountTextField; private UITextField pageFixedRowCountTextField;
private static final Color TIPS_FONT_COLOR = new Color(0x8f8f92); private static final Color TIPS_FONT_COLOR = new Color(0x8f8f92);
private static final Pattern ROW_COUNT = Pattern.compile("^[1-5][\\d]*$"); private static final Pattern ROW_COUNT = Pattern.compile("^[1-9][\\d]{0,2}$");
//固定行数分页,每页最多500行,最少1行数据 //固定行数分页,每页最多500行,最少1行数据
private static final int MAX_ROW_COUNT = 500; private static final int MAX_ROW_COUNT = 500;

2
designer-realize/src/main/java/com/fr/design/webattr/PageWebSettingPane.java

@ -41,7 +41,7 @@ public class PageWebSettingPane extends WebSettingPane<WebPage> {
private UICheckBox isPageFixedRowBox; private UICheckBox isPageFixedRowBox;
private UITextField pageFixedRowCountTextField; private UITextField pageFixedRowCountTextField;
private static final Color TIPS_FONT_COLOR = new Color(0x8f8f92); private static final Color TIPS_FONT_COLOR = new Color(0x8f8f92);
private static final Pattern ROW_COUNT = Pattern.compile("^[1-5][\\d]*$"); private static final Pattern ROW_COUNT = Pattern.compile("^[1-9][\\d]{0,2}$");
private static final String DEFAULT_ROW_COUNT = "30"; private static final String DEFAULT_ROW_COUNT = "30";
//固定行数分页,每页最多500行,最少1行数据 //固定行数分页,每页最多500行,最少1行数据

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