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. 733
      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. 13
      designer-form/src/main/java/com/fr/design/actions/FormFitAttrAction.java
  18. 9
      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. 13
      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.dialog.BasicPane;
import com.fr.design.dialog.BasicScrollPane;
import com.fr.design.gui.frpane.UIPercentDragPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.backgroundpane.GradientBackgroundQuickPane;
import com.fr.design.widget.FRWidgetFactory;
import com.fr.general.Background;
import com.fr.general.act.BackgroundPacker;
@ -51,8 +51,8 @@ public abstract class AbstractTranslucentBackgroundSpecialPane<T extends Backgro
// 确保BackgroundSpecialPane高度变化时,Label依然保持与其顶部对齐
JPanel backgroundLabelPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
backgroundLabelPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, 0, 0));
backgroundLabelPane.add(new UILabel(backgroundName), BorderLayout.NORTH);
backgroundLabelPane.setBorder(BorderFactory.createEmptyBorder(7, 0, 0, 0));
backgroundLabelPane.add(FRWidgetFactory.createLineWrapLabel(backgroundName), BorderLayout.NORTH);
JPanel backgroundComposedPane = TableLayoutHelper.createGapTableLayoutPane(
new JComponent[][]{
@ -62,7 +62,7 @@ public abstract class AbstractTranslucentBackgroundSpecialPane<T extends Backgro
JPanel opacityComposedPane = TableLayoutHelper.createGapTableLayoutPane(
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 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.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.widget.FRWidgetFactory;
import com.fr.general.act.BorderPacker;
import javax.swing.JComponent;
@ -72,9 +72,9 @@ public class ComponentIntegralStylePane extends AbstractBorderPackerPane {
double[] columnSize = {this.uiLabelWidth, this.uiSettingWidth > 0 ? this.uiSettingWidth : f};
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},
{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);

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.icheckbox.UICheckBox;
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.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.widget.FRWidgetFactory;
import com.fr.form.ui.LayoutBorderStyle;
import com.fr.form.ui.WidgetTitle;
import com.fr.general.FRFont;
@ -168,7 +168,7 @@ public class ComponentTitleStylePane extends AbstractBorderPackerPane {
visibleCheckbox.setSelected(false);
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() {
@Override
@ -192,7 +192,7 @@ public class ComponentTitleStylePane extends AbstractBorderPackerPane {
double[] columnSize = {this.uiLabelWidth, this.uiSettingWidth > 0 ? this.uiSettingWidth : f};
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);
}
@ -203,10 +203,10 @@ public class ComponentTitleStylePane extends AbstractBorderPackerPane {
double[] columnSize = {this.uiLabelWidth, this.uiSettingWidth > 0 ? this.uiSettingWidth : f};
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()},
{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}
};

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

@ -1,10 +1,7 @@
package com.fr.design.gui.style;
import com.fr.base.theme.FormTheme;
import com.fr.base.theme.TemplateTheme;
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.UIObserverListener;
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.TableLayoutHelper;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.widget.FRWidgetFactory;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
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 f = TableLayout.FILL;
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);
followingThemePane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
followingThemePane.setVisible(false);

733
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.Parameter;
import com.fr.base.extension.FileExtension;
import com.fr.design.border.UITitledBorder;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.BasicPane;
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.UIComboBoxRenderer;
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.itree.filetree.TemplateFileTree;
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.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.scrollruler.ModLineBorder;
import com.fr.file.filetree.IOFileNodeFilter;
import com.fr.general.GeneralUtils;
import com.fr.js.ExportJavaScript;
import com.fr.js.SingleJavaScript;
import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils;
import javax.swing.AbstractButton;
import javax.swing.AbstractCellEditor;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.event.CellEditorListener;
import javax.swing.event.ChangeEvent;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.TableCellEditor;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@ -59,21 +72,20 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
private ExportRadioGroup templateRadioGroup;
private UIRadioButton currentTemplateRadio;
private UIRadioButton otherTemplateRadio;
private UITextField reportPathTextField;
private UIButton browserButton;
private UIComboBox exportTypeComboBox;
private ExportRadioGroup fileNameRadioGroup;
private UIRadioButton defaultNameRadio;
private UIRadioButton customNameRadio;
private FormulaEditor fileNameFormulaEditor;
private UICheckBox extendParametersCheckBox;
private ReportletParameterViewPane parameterViewPane;
private CardLayout card;
private JPanel templatePanel;
private CurrentTemplatePane currentTemplatePane;
private OtherTemplatePane otherTemplatePane;
private static final double p = TableLayout.PREFERRED;
private static final Map<String, String> EXPORT_TYPES_MAP = new HashMap<>();
private static final String CURRENT_TEMPLATE = "current";
private static final String DEFAULT_FILENAME = "default";
private static final Map<String, String> FILENAME_TYPE_MAP = new HashMap<>();
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 {
EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_PDF, Toolkit.i18nText("Fine-Design_Basic_Export_JS_PDF"));
@ -82,23 +94,27 @@ 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_WORD, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Word"));
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;
private UIRadioButton defaultNameRadio;
private UIRadioButton customNameRadio;
private FormulaEditor fileNameFormulaEditor;
private UICheckBox extendParametersCheckBox;
private ReportletParameterViewPane parameterViewPane;
public CurrentTemplatePane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), Toolkit.i18nText("Fine-Design_Basic_Export_JS_Setting")));
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);
@ -117,27 +133,12 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
}
private JPanel initParamsPane() {
extendParametersCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Extends_Report_Parameters"));
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);
parameterViewPane.addTableEditorListener(new TableModelListener() {
public void tableChanged(TableModelEvent e) {
List<ParameterProvider> list = parameterViewPane.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(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Parameter_Duplicate_Name") + "!");
return;
}
tempSet.add(list.get(i).toString());
}
}
});
addListener(parameterViewPane);
extendParametersCheckBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
@ -145,10 +146,12 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
}
});
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);
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;
}
@ -158,17 +161,24 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
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"));
customNameRadio = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Custom"));
addRadioToGroup(fileNameRadioGroup, defaultNameRadio, customNameRadio);
fileNameFormulaEditor = new FormulaEditor(Toolkit.i18nText("Fine-Design_Report_Parameter_Formula"));
fileNameFormulaEditor.setVisible(false);
fileNameFormulaEditor.setEnabled(false);
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>");
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);
}
}
});
@ -176,7 +186,6 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
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();
@ -187,62 +196,145 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
return fileNamePane;
}
private JPanel initExportTypePane() {
UILabel typeLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Type") + ":");
exportTypeComboBox = new UIComboBox(new DefaultComboBoxModel<String>());
DefaultComboBoxModel<String> comboBoxModel = (DefaultComboBoxModel<String>) exportTypeComboBox.getModel();
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};
for (int i = 0; i < allExportTypes.length; i++) {
comboBoxModel.addElement(allExportTypes[i]);
@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);
}
this.exportTypeComboBox.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(EXPORT_TYPES_MAP.get(value));
protected String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Basic_Export_JS_Setting");
}
return this;
}
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
});
Component[][] components = new Component[][]{{typeLabel, exportTypeComboBox}};
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;
}
@Override
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 exportTypePane = TableLayoutHelper.createTableLayoutPane(components, new double[]{p}, new double[]{p, p});
exportTypePane.setBorder(BorderFactory.createEmptyBorder(5,2,5,2));
return exportTypePane;
}
private JPanel initChooseTemplatePane() {
UILabel templateLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template") + ":");
templateRadioGroup = new ExportRadioGroup();
currentTemplateRadio = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Current"));
currentTemplateRadio.setSelected(true);
otherTemplateRadio = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Other"));
addRadioToGroup(templateRadioGroup, currentTemplateRadio, otherTemplateRadio);
templateRadioGroup.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (currentTemplateRadio.isSelected()) {
browserButton.setEnabled(false);
super.actionPerformed(e);
if (otherTemplatePane.editorPane.getTableModel().getList().size() <= 50) {
addJS();
} else {
browserButton.setEnabled(true);
FineJOptionPane.showMessageDialog(otherTemplatePane, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Batch_Export_Limit"));
}
}
});
Component[][] components = new Component[][]{{templateLabel, currentTemplateRadio, otherTemplateRadio}};
JPanel reportletRadioPane = TableLayoutHelper.createTableLayoutPane(components, new double[]{p}, new double[]{p, p, p});
}
private void addJS() {
SingleJavaScript js = new SingleJavaScript();
addRow(js);
fireTableDataChanged();
table.getSelectionModel().setSelectionInterval(table.getRowCount() - 1, table.getRowCount() - 1);
}
// 导出文件选择
class ExportTemplateChooser extends AbstractCellEditor implements TableCellEditor {
private static final long serialVersionUID = -9112506131272704717L;
private JPanel reportletNamePane;
private UITextField reportPathTextField;
private UIButton browserButton;
JPanel reportletNamePane = FRGUIPaneFactory.createBorderLayout_S_Pane();
public ExportTemplateChooser() {
reportletNamePane = FRGUIPaneFactory.createBorderLayout_S_Pane();
// 路径输入框
reportPathTextField = new UITextField(20);
reportPathTextField = new UITextField(7);
reportPathTextField.setEnabled(false);
reportletNamePane.add(reportPathTextField, BorderLayout.CENTER);
reportletNamePane.add(reportPathTextField, BorderLayout.WEST);
// 选择路径按钮
browserButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Select"));
browserButton.setPreferredSize(new Dimension(browserButton.getPreferredSize().width, 20));
browserButton.setEnabled(false);
browserButton = new UIButton("...");
browserButton.setVisible(true);
reportletNamePane.add(browserButton, BorderLayout.EAST);
browserButton.addActionListener(new ActionListener() {
@Override
@ -260,11 +352,375 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
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
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
reportPathTextField.setText((String) value);
return reportletNamePane;
}
@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 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}};
JPanel exportTypePane = TableLayoutHelper.createTableLayoutPane(components, new double[]{p}, new double[]{p, p});
exportTypePane.setBorder(BorderFactory.createEmptyBorder(5, 2, 5, 2));
return exportTypePane;
}
private JPanel initChooseTemplatePane() {
UILabel templateLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template") + ":");
templateRadioGroup = new ExportRadioGroup();
currentTemplateRadio = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Current"));
currentTemplateRadio.setSelected(true);
otherTemplateRadio = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Other"));
addRadioToGroup(templateRadioGroup, currentTemplateRadio, otherTemplateRadio);
currentTemplateRadio.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
card.show(templatePanel, CURRENT_TEMPLATE);
}
}
});
otherTemplateRadio.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
card.show(templatePanel, OTHER_TEMPLATE);
}
}
});
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(reportletNamePane, BorderLayout.CENTER);
chooseTemplatePane.setBorder(BorderFactory.createEmptyBorder(0,2,5,2));
chooseTemplatePane.setBorder(BorderFactory.createEmptyBorder(0, 7, 5, 2));
return chooseTemplatePane;
}
@ -276,28 +732,27 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
}
this.templateRadioGroup.selectIndexButton(ob.isCurrentTemplate() ? 0 : 1);
if (ob.isCurrentTemplate()) {
this.browserButton.setEnabled(false);
SingleJavaScript js = ob.getJavaScript();
exportTypeComboBox.setSelectedItem(js.getExportType());
currentTemplatePane.fileNameRadioGroup.selectIndexButton(js.isDefaultFileName() ? 0 : 1);
if (!js.isDefaultFileName()) {
currentTemplatePane.fileNameFormulaEditor.setEnabled(true);
currentTemplatePane.fileNameFormulaEditor.setVisible(true);
currentTemplatePane.fileNameFormulaEditor.setValue(BaseFormula.createFormulaBuilder().build(js.getFileName()));
}
if (js.isExtendParameters()) {
currentTemplatePane.extendParametersCheckBox.setSelected(true);
} else {
this.browserButton.setEnabled(true);
this.reportPathTextField.setText(ob.getTemplatePath());
}
this.exportTypeComboBox.setSelectedItem(ob.getExportType());
this.fileNameRadioGroup.selectIndexButton(ob.isDefaultFileName() ? 0 : 1);
if (ob.isDefaultFileName()) {
this.fileNameFormulaEditor.setEnabled(false);
} else {
this.fileNameFormulaEditor.setEnabled(true);
this.fileNameFormulaEditor.setValue(BaseFormula.createFormulaBuilder().build(ob.getFileName()));
}
if (ob.isExtendParameters()) {
this.extendParametersCheckBox.setSelected(true);
} else {
this.extendParametersCheckBox.setSelected(false);
currentTemplatePane.extendParametersCheckBox.setSelected(false);
List<ParameterProvider> parameterList = this.parameterViewPane.update();
parameterList.clear();
ParameterProvider[] parameters = ob.getParameters();
ParameterProvider[] parameters = js.getParameters();
this.parameterViewPane.populate(parameters);
}
} else {
OtherTemplatePane pane = (OtherTemplatePane) this.templatePanel.getComponent(1);
pane.editorPane.populate(ob.getJsList().toArray(new SingleJavaScript[ob.getJsList().size()]));
}
}
@Override
@ -309,32 +764,78 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
@Override
public void updateBean(ExportJavaScript exportJavaScript) {
exportJavaScript.setCurrentTemplate(this.currentTemplateRadio.isSelected());
exportJavaScript.setTemplatePath(getTemplatePath());
exportJavaScript.setExportType(GeneralUtils.objectToString(this.exportTypeComboBox.getSelectedItem()));
exportJavaScript.setDefaultFileName(this.defaultNameRadio.isSelected());
exportJavaScript.setFileName(getFileName());
exportJavaScript.setExtendParameters(this.extendParametersCheckBox.isSelected());
if (extendParametersCheckBox.isSelected()) {
boolean selected = currentTemplateRadio.isSelected();
exportJavaScript.setCurrentTemplate(selected);
if (selected) {
SingleJavaScript js = new SingleJavaScript();
js.setCurrentTemplate(true);
js.setTemplatePath(DEFAULT);
js.setExportType(GeneralUtils.objectToString(exportTypeComboBox.getSelectedItem()));
js.setDefaultFileName(currentTemplatePane.defaultNameRadio.isSelected());
js.setFileName(getFileName());
js.setExtendParameters(currentTemplatePane.extendParametersCheckBox.isSelected());
if (currentTemplatePane.extendParametersCheckBox.isSelected()) {
exportJavaScript.setParameters(null);
} else {
List<ParameterProvider> parameterList = this.parameterViewPane.update();
List<ParameterProvider> parameterList = parameterViewPane.update();
if (!parameterList.isEmpty()) {
Parameter[] parameters = new Parameter[parameterList.size()];
parameterList.toArray(parameters);
exportJavaScript.setParameters(parameters);
js.setParameters(parameters);
}
}
exportJavaScript.addJS(js);
} else {
List<SingleJavaScript> javaScripts = otherTemplatePane.editorPane.update();
for (SingleJavaScript js : javaScripts) {
exportJavaScript.addJS(js);
}
}
private String getTemplatePath() {
return currentTemplateRadio.isSelected() ? CURRENT_TEMPLATE : reportPathTextField.getText();
}
private String getFileName() {
return defaultNameRadio.isSelected() ? DEFAULT_FILENAME : fileNameFormulaEditor.getUITextField().getText();
return currentTemplatePane.defaultNameRadio.isSelected() ? DEFAULT : currentTemplatePane.fileNameFormulaEditor.getUITextField().getText();
}
private UIComboBox getComboBoxWithModel(String[] itemTextArr, Map<String, String> itemTextDic) {
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
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.BoxLayout;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import java.awt.BorderLayout;
@ -631,6 +632,12 @@ public class FRGUIPaneFactory {
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) {
this.templateOpenFailedTip = templateOpenFailedTip;
}
}
@Override
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;
import com.fr.base.svg.IconUtils;
import com.fr.design.actions.JTemplateAction;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.dialog.DialogActionAdapter;
@ -82,13 +81,8 @@ public class ReportFitAttrAction extends JTemplateAction {
}
final FitProvider wbTpl = (FitProvider) jwb.getTarget();
ReportFitAttr fitAttr = wbTpl.getReportFitAttr();
if (jwb.isJWorkBook()) {
final TemplateFitAttrPane attrPane = new TemplateFitAttrPane();
showReportFitDialog(fitAttr, jwb, wbTpl, attrPane);
} else {
final ReportFitAttrPane attrPane = new ReportFitAttrPane();
showReportFitDialog(fitAttr, jwb, wbTpl, attrPane);
}
TemplateFitAttrPane templateFitAttrPane = new TemplateFitAttrPane(jwb);
showReportFitDialog(fitAttr, jwb, wbTpl, templateFitAttrPane);
}
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;
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 javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import java.awt.event.ItemEvent;
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();
}
private void initComponents() {
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
attrPane = new TemplateBrowserFitAttrPane();
this.add(attrPane);
@Override
protected void initComponents() {
super.initComponents();
for (FitAttrModel fitAttrModel : fitAttrModelList) {
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) {
attrPane.populateBean(fitAttr);
super.setEnabled(isTemplateSingleSet());
super.populateBean(reportFitAttr);
}
/**
* 提交数据
*
* @return 界面上的更新数据
*/
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());
}
}
}
};
}
/**
* 标题
*
* @return 标题
*/
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_PC_Fit_Attr");
private boolean isTemplateSingleSet() {
return ComparatorUtils.equals(Toolkit.i18nText("Fine-Design_Report_I_Want_To_Set_Single"), itemChoose.getSelectedItem());
}
}

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

13
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.JTemplate;
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.ReportFitAttr;
@ -51,22 +52,16 @@ public class FormFitAttrAction extends JTemplateAction {
"/com/fr/design/images/reportfit/fit");
}
/**
* Action触发事件
*
* @param e 事件
*/
@Override
public void actionPerformed(ActionEvent e) {
final JTemplate jwb = getEditingComponent();
if (jwb == null || !(jwb instanceof NewJForm)) {
if (jwb == null) {
return;
}
final FitProvider wbTpl = (FitProvider) jwb.getTarget();
ReportFitAttr fitAttr = wbTpl.getReportFitAttr();
NewJForm newJForm = (NewJForm) jwb;
BasicBeanPane attrPane = newJForm.getJFormType().obtainAttrPane(newJForm);
showFitDialog(fitAttr, jwb, wbTpl, attrPane);
TemplateFitAttrPane templateFitAttrPane = new TemplateFitAttrPane();
showFitDialog(fitAttr, jwb, wbTpl, templateFitAttrPane);
}
private void showFitDialog(ReportFitAttr fitAttr, final JTemplate jwb, final FitProvider wbTpl, final BasicBeanPane<ReportFitAttr> attrPane) {

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

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 javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.SwingConstants;
import javax.swing.SwingWorker;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import java.awt.AlphaComposite;
import java.awt.BorderLayout;
import java.awt.Color;
@ -60,9 +63,10 @@ import java.util.concurrent.ExecutionException;
* 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 downloading = false;
private boolean popupMenuVisible = false;
private static final Color COVER_COLOR = Color.decode("#333334");
protected MouseEvent lastPressEvent;
private double process = 0D;
@ -89,6 +93,13 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock {
return southPane;
}
@Override
public JPopupMenu createRightClickPopupMenu() {
JPopupMenu popupMenu = super.createRightClickPopupMenu();
popupMenu.addPopupMenuListener(this);
return popupMenu;
}
@Override
public void mouseEntered(MouseEvent e) {
super.mouseEntered(e);
@ -113,7 +124,7 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock {
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
boolean isLeftClickDownloadIcon = e.getButton() != MouseEvent.BUTTON3 && getDownloadIconRec().contains(e.getX(), e.getY());
if (isLeftClickDownloadIcon && !checkWidgetInstalled()) {
if (!popupMenuVisible && isLeftClickDownloadIcon && !checkWidgetInstalled()) {
downLoadWidget();
}
}
@ -270,7 +281,7 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock {
return;
}
//如果鼠标移动到布局内且布局不可编辑,画出编辑蒙层
if (isMouseEnter || downloading) {
if (!popupMenuVisible && (isMouseEnter || downloading)) {
Graphics2D g2d = (Graphics2D) g;
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> {

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.iofile.attr.ExtendSharableAttrMark;
import com.fr.base.theme.FormTheme;
import com.fr.base.theme.FormThemeConfig;
import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.TemplateThemeCompatible;
import com.fr.design.designer.creator.XCreator;
@ -58,9 +59,11 @@ public class ShareComponentUtils {
JTemplate<?,?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
TemplateTheme theme = template.getTemplateTheme();
if (theme instanceof FormTheme) {
String themeName4LegacyTemplate = FormThemeConfig.getInstance().getThemeName4LegacyTemplate();
boolean isCurrentUsingThemeSuitSharedComponent = StringUtils.isNotEmpty(theme.getName()) &&
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);
}
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.SegmentationManager;
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.http.HttpClient;
import com.fr.io.TemplateWorkBookIO;
import com.fr.io.exporter.ImageExporter;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.main.impl.WorkBook;
import com.fr.stable.CodeUtils;
import com.fr.stable.StringUtils;
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.swing.BorderFactory;
import javax.swing.DefaultListModel;
@ -601,14 +599,15 @@ public class AlphaFineDialog extends UIDialog {
checkWorker();
this.showWorker = new SwingWorker<BufferedImage, Void>() {
@Override
protected BufferedImage doInBackground() {
Form form = null;
protected BufferedImage doInBackground() throws Exception {
byte[] bytes = null;
try {
form = FormIO.readForm(fileName);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
bytes = WorkContext.getCurrent().get(TemplateExportOperator.class).exportFormAsImageData(fileName);
} catch (Exception ignored) {
// 兼容下老版本
bytes = new LocalExportOperator().exportFormAsImageData(fileName);
}
return FormIO.exportFormAsImage(form);
return TemplateExportOperator.byteDataToImage(bytes);
}
@Override
@ -631,15 +630,15 @@ public class AlphaFineDialog extends UIDialog {
checkWorker();
this.showWorker = new SwingWorker<BufferedImage, Void>() {
@Override
protected BufferedImage doInBackground() {
WorkBook workBook = null;
protected BufferedImage doInBackground() throws Exception {
byte[] bytes = null;
try {
workBook = (WorkBook) TemplateWorkBookIO.readTemplateWorkBook(fileName);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
bytes = WorkContext.getCurrent().get(TemplateExportOperator.class).exportWorkBookAsImageData(fileName);
} catch (Exception ignored) {
// 兼容下老版本
bytes = new LocalExportOperator().exportWorkBookAsImageData(fileName);
}
BufferedImage bufferedImage = new ImageExporter().exportToImage(workBook);
return bufferedImage;
return TemplateExportOperator.byteDataToImage(bytes);
}
@Override

13
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.design.gui.frpane.LoadingBasicPane;
import com.fr.design.gui.frpane.UITabbedPane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.webattr.printsettings.GlobalNativePrintSettingPane;
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.WebWrite;
import com.fr.web.attr.ReportWebAttr;
import com.fr.workspace.WorkContext;
import javax.swing.JPanel;
import java.awt.BorderLayout;
@ -44,6 +46,8 @@ public class EditReportServerParameterPane extends LoadingBasicPane {
private PrintSettingPane printSettingPane;
private ServerFitAttrPane serverFitAttrPane;
@Override
protected synchronized void initComponents(JPanel container) {
@ -61,6 +65,9 @@ public class EditReportServerParameterPane extends LoadingBasicPane {
tabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ReportServerP_Import_JavaScript"), jsPane = new WebJsPane());
tabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Error_Handler_Template"), errorTemplatePane = new ErrorTemplatePane());
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
@ -93,6 +100,9 @@ public class EditReportServerParameterPane extends LoadingBasicPane {
printSettingPane.populate(printSettings);
this.errorTemplatePane.populateBean(reportServerPreferenceConfig.getErrorTemplate());
if (serverFitAttrPane != null) {
serverFitAttrPane.populateBean(null);
}
}
/**
@ -110,5 +120,8 @@ public class EditReportServerParameterPane extends LoadingBasicPane {
PrintConfig.getInstance().setPrintSettings(printSettings);
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 UITextField pageFixedRowCountTextField;
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行数据
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 UITextField pageFixedRowCountTextField;
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";
//固定行数分页,每页最多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