Browse Source

Merge branch 'feature/x' of ssh://code.fineres.com:7999/~tommy/design into feature/x

research/11.0
kuangshuai 3 years ago
parent
commit
17ba276c01
  1. 8
      designer-base/src/main/java/com/fr/design/gui/style/AbstractTranslucentBackgroundSpecialPane.java
  2. 6
      designer-base/src/main/java/com/fr/design/gui/style/ComponentIntegralStylePane.java
  3. 10
      designer-base/src/main/java/com/fr/design/gui/style/ComponentTitleStylePane.java
  4. 9
      designer-base/src/main/java/com/fr/design/gui/style/FollowingThemePane.java
  5. 871
      designer-base/src/main/java/com/fr/design/javascript/ExportJavaScriptPane.java
  6. 7
      designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java
  7. 1
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  8. 55
      designer-base/src/main/java/com/fr/design/report/fit/AdaptiveFrmFitAttrModel.java
  9. 229
      designer-base/src/main/java/com/fr/design/report/fit/BaseFitAttrPane.java
  10. 51
      designer-base/src/main/java/com/fr/design/report/fit/CptFitAttrModel.java
  11. 44
      designer-base/src/main/java/com/fr/design/report/fit/FitAttrModel.java
  12. 53
      designer-base/src/main/java/com/fr/design/report/fit/FrmFitAttrModel.java
  13. 10
      designer-base/src/main/java/com/fr/design/report/fit/menupane/ReportFitAttrAction.java
  14. 105
      designer-base/src/main/java/com/fr/design/report/fit/menupane/TemplateFitAttrPane.java
  15. 18
      designer-base/src/main/java/com/fr/design/report/fit/provider/AbstractFitAttrModelProvider.java
  16. 11
      designer-base/src/main/java/com/fr/design/report/fit/provider/FitAttrModelProvider.java
  17. 17
      designer-form/src/main/java/com/fr/design/actions/FormFitAttrAction.java
  18. 11
      designer-form/src/main/java/com/fr/design/mainframe/share/generate/task/ComponentCreator.java
  19. 118
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/DownloadSuitableThemeAction.java
  20. 35
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/OnlineWidgetBlock.java
  21. 5
      designer-form/src/main/java/com/fr/design/mainframe/share/util/ShareComponentUtils.java
  22. 35
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java
  23. 25
      designer-realize/src/main/java/com/fr/design/webattr/EditReportServerParameterPane.java
  24. 2
      designer-realize/src/main/java/com/fr/design/webattr/PageToolBarPane.java
  25. 2
      designer-realize/src/main/java/com/fr/design/webattr/PageWebSettingPane.java
  26. 78
      designer-realize/src/main/java/com/fr/design/webattr/ServerFitAttrPane.java

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;
}
/** /**
* 计算宽度 * 计算宽度
* *

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

@ -1800,7 +1800,6 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
public void setTemplateOpenFailedTip(String templateOpenFailedTip) { public void setTemplateOpenFailedTip(String templateOpenFailedTip) {
this.templateOpenFailedTip = templateOpenFailedTip; this.templateOpenFailedTip = templateOpenFailedTip;
} }
}
@Override @Override
public void setTemplateTheme(TemplateTheme newTheme, TemplateThemeCompatible compatible) { public void setTemplateTheme(TemplateTheme newTheme, TemplateThemeCompatible compatible) {

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

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

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

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

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

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;

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

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

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

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