diff --git a/designer-base/src/main/java/com/fr/design/javascript/ExportJavaScriptPane.java b/designer-base/src/main/java/com/fr/design/javascript/ExportJavaScriptPane.java new file mode 100644 index 0000000000..a1546025f9 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/javascript/ExportJavaScriptPane.java @@ -0,0 +1,453 @@ +package com.fr.design.javascript; + +import com.fr.base.BaseFormula; +import com.fr.base.Parameter; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.BasicPane; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.editor.editor.FormulaEditor; +import com.fr.design.gui.frpane.ReportletParameterViewPane; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ibutton.UIRadioButton; +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.itextfield.UITextField; +import com.fr.design.gui.itree.filetree.TemplateFileTree; +import com.fr.design.hyperlink.AbstractHyperLinkPane; +import com.fr.design.i18n.Toolkit; +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.stable.ParameterProvider; +import com.fr.stable.StringUtils; + +import javax.swing.AbstractButton; +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.SwingUtilities; +import javax.swing.event.TableModelEvent; +import javax.swing.event.TableModelListener; +import java.awt.BorderLayout; +import java.awt.CardLayout; +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.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; + +public class ExportJavaScriptPane extends AbstractHyperLinkPane { + + 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 static final double p = TableLayout.PREFERRED; + private static final Map EXPORT_TYPES_MAP = new HashMap<>(); + private static final String CURRENT_TEMPLATE = "current"; + private static final String DEFAULT_FILENAME = "default"; + + + static { + EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_PDF, Toolkit.i18nText("Fine-Design_Basic_Export_JS_PDF")); + EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_EXCEL_PAGE, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Excel_Page")); + EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_EXCEL_SIMPLE, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Excel_Simple")); + 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")); + } + + public ExportJavaScriptPane() { + initComponents(); + } + + private void initComponents() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), Toolkit.i18nText("Fine-Design_Basic_Export_JS_Setting"))); + + //导出模板+导出方式+导出文件名 + JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + + //导出模板 + JPanel chooseTemplatePane = initChooseTemplatePane(); + northPane.add(chooseTemplatePane, BorderLayout.NORTH); + + //导出方式 + JPanel exportTypePane = initExportTypePane(); + northPane.add(exportTypePane, BorderLayout.CENTER); + + //导出文件名 + JPanel fileNamePane = initFileNamePane(); + northPane.add(fileNamePane, BorderLayout.SOUTH); + + //参数 + JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + JPanel paramsPane = initParamsPane(); + centerPane.add(paramsPane); + + this.add(northPane, BorderLayout.NORTH); + this.add(centerPane, BorderLayout.CENTER); + } + + private JPanel initParamsPane() { + extendParametersCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Extends_Report_Parameters")); + parameterViewPane = new ReportletParameterViewPane(getChartParaType(), getValueEditorPane(), getValueEditorPane()); + parameterViewPane.addTableEditorListener(new TableModelListener() { + public void tableChanged(TableModelEvent e) { + List list = parameterViewPane.update(); + HashSet 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()); + } + } + }); + extendParametersCheckBox.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + parameterViewPane.setVisible(e.getStateChange() == ItemEvent.DESELECTED); + } + }); + 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")); + fileNameRadioGroup.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (defaultNameRadio.isSelected()) { + fileNameFormulaEditor.setEnabled(false); + } else { + fileNameFormulaEditor.setEnabled(true); + } + } + }); + 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("" + Toolkit.i18nText("Fine-Design_Basic_Export_JS_Title_Tip_Front") + "\\/:*?\"<>|" + Toolkit.i18nText("Fine-Design_Basic_Export_JS_Title_Tip_Back") + ""); + 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() { + UILabel typeLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Type") + ":"); + exportTypeComboBox = new UIComboBox(new DefaultComboBoxModel()); + DefaultComboBoxModel comboBoxModel = (DefaultComboBoxModel) 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]); + } + 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)); + } + return this; + } + }); + 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); + templateRadioGroup.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (currentTemplateRadio.isSelected()) { + reportPathTextField.setEnabled(false); + browserButton.setEnabled(false); + } else { + reportPathTextField.setEnabled(true); + browserButton.setEnabled(true); + } + } + }); + Component[][] components = new Component[][]{{templateLabel, currentTemplateRadio, otherTemplateRadio}}; + JPanel reportletRadioPane = TableLayoutHelper.createTableLayoutPane(components, new double[]{p}, new double[]{p, p, p}); + + JPanel reportletNamePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + // 路径输入框 + reportPathTextField = new UITextField(20); + reportletNamePane.add(reportPathTextField, BorderLayout.CENTER); + + // 选择路径按钮 + browserButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Select")); + browserButton.setPreferredSize(new Dimension(browserButton.getPreferredSize().width, 20)); + 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); + } + }); + + JPanel chooseTemplatePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + chooseTemplatePane.add(reportletRadioPane, BorderLayout.NORTH); + chooseTemplatePane.add(reportletNamePane, BorderLayout.CENTER); + chooseTemplatePane.setBorder(BorderFactory.createEmptyBorder(0,2,5,2)); + + return chooseTemplatePane; + } + + @Override + public void populateBean(ExportJavaScript ob) { + if (ob == null) { + ob = new ExportJavaScript(); + } + this.templateRadioGroup.selectIndexButton(ob.isCurrentTemplate() ? 0 : 1); + if (ob.isCurrentTemplate()) { + this.reportPathTextField.setEnabled(false); + this.browserButton.setEnabled(false); + } else { + this.reportPathTextField.setEnabled(true); + 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); + List parameterList = this.parameterViewPane.update(); + parameterList.clear(); + ParameterProvider[] parameters = ob.getParameters(); + this.parameterViewPane.populate(parameters); + } + } + + @Override + public ExportJavaScript updateBean() { + ExportJavaScript exportJavaScript = new ExportJavaScript(); + updateBean(exportJavaScript); + return 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()) { + exportJavaScript.setParameters(null); + } else { + List parameterList = this.parameterViewPane.update(); + if (!parameterList.isEmpty()) { + Parameter[] parameters = new Parameter[parameterList.size()]; + parameterList.toArray(parameters); + exportJavaScript.setParameters(parameters); + } + } + } + + private String getTemplatePath() { + return currentTemplateRadio.isSelected() ? CURRENT_TEMPLATE : reportPathTextField.getText(); + } + + private String getFileName() { + return defaultNameRadio.isSelected() ? DEFAULT_FILENAME : fileNameFormulaEditor.getUITextField().getText(); + } + + + @Override + public boolean accept(Object ob) { + return ob instanceof ExportJavaScript; + } + + @Override + public void reset() { + populateBean(null); + } + + @Override + public java.lang.String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Basic_Export_JS_Event"); + } + + private void addRadioToGroup(ButtonGroup buttonGroup, UIRadioButton... radios) { + for (UIRadioButton radio : radios) { + buttonGroup.add(radio); + } + } + + class ExportRadioGroup extends ButtonGroup { + private List radioButtons = new ArrayList<>(); + + @Override + public void add(AbstractButton button) { + super.add(button); + + UIRadioButton radioButton = (UIRadioButton) button; + radioButtons.add(radioButton); + } + + public void selectIndexButton(int index) { + if (index < 0 || index > radioButtons.size() - 1) { + return; + } + + UIRadioButton button = radioButtons.get(index); + button.setSelected(true); + } + + public void addActionListener(ActionListener actionListener) { + for (UIRadioButton radioButton : radioButtons) { + radioButton.addActionListener(actionListener); + } + } + } + + class ReportletPane extends BasicPane { + private TemplateFileTree templateReportletTree; + private JScrollPane t_panel; + + private JPanel cardPane; + + public ReportletPane() { + this.setLayout(FRGUIPaneFactory.createM_BorderLayout()); + + JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + this.add(centerPane, BorderLayout.CENTER); + + cardPane = FRGUIPaneFactory.createCardLayout_S_Pane(); + centerPane.add(cardPane, BorderLayout.CENTER); + cardPane.setLayout(new CardLayout()); + templateReportletTree = new TemplateFileTree(); + IOFileNodeFilter filter = new IOFileNodeFilter(new String[]{".cpt"}); + templateReportletTree.setFileNodeFilter(filter); + cardPane.add(t_panel = new JScrollPane(templateReportletTree), "TEMPLATE"); + + this.refreshEnv(); + } + + /** + * 检查是否符合规范 + * + * @throws Exception 抛错 + */ + @Override + public void checkValid() throws Exception { + String path = this.getSelectedReportletPath(); + if (path == null) { + throw new Exception(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Function_The_Selected_File_Cannot_Be_Null")); + } + } + + /** + * 刷新Env + */ + public void refreshEnv() { + this.templateReportletTree.refreshEnv(); + } + + @Override + protected String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Basic_Export_JS_Event"); + } + + /* + * 返回选中的Reportlet的路径 + */ + public String getSelectedReportletPath() { + if (t_panel.isVisible()) { + return templateReportletTree.getSelectedTemplatePath(); + } + return null; + } + + /* + * 选中某Reportlet + */ + public void setSelectedReportletPath(String reportletPath) { + if (reportletPath == null) { + return; + } + templateReportletTree.setSelectedTemplatePath(reportletPath); + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/javascript/JavaScriptActionPane.java b/designer-base/src/main/java/com/fr/design/javascript/JavaScriptActionPane.java index f54b070b0a..168d514049 100644 --- a/designer-base/src/main/java/com/fr/design/javascript/JavaScriptActionPane.java +++ b/designer-base/src/main/java/com/fr/design/javascript/JavaScriptActionPane.java @@ -44,6 +44,10 @@ public abstract class JavaScriptActionPane extends UIComboBoxPane { contentDBManiPane.add(createDBManipulationPane()); paneList.add(new Commit2DBJavaScriptPane(this, contentDBManiPane)); paneList.add(initEmaiPane()); + boolean workbook = DesignerContext.getDesignerFrame().getSelectedJTemplate().isJWorkBook(); + if (workbook) { + paneList.add(new ExportJavaScriptPane()); + } Set javaScriptActionProviders = ExtraDesignClassManager.getInstance().getArray(JavaScriptActionProvider.XML_TAG); if (javaScriptActionProviders != null) { for (JavaScriptActionProvider jsp : javaScriptActionProviders) { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/reuse/ComponentReuseNotificationInfo.java b/designer-base/src/main/java/com/fr/design/mainframe/reuse/ComponentReuseNotificationInfo.java index 0ec6f26ad4..3d305d8ace 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/reuse/ComponentReuseNotificationInfo.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/reuse/ComponentReuseNotificationInfo.java @@ -25,6 +25,8 @@ public class ComponentReuseNotificationInfo implements XMLable { private long lastGuidePopUpTime = 0; + private String historyCreatedReuses = "[]"; + public long getLastNotifyTime() { return lastNotifyTime; } @@ -62,12 +64,21 @@ public class ComponentReuseNotificationInfo implements XMLable { DesignerEnvManager.getEnvManager().saveXMLFile(); } + public String getHistoryCreatedReuses() { + return historyCreatedReuses; + } + + public void setHistoryCreatedReuses(String historyCreatedReuses) { + this.historyCreatedReuses = historyCreatedReuses; + } + @Override public void readXML(XMLableReader reader) { this.setLastNotifyTime(reader.getAttrAsLong("lastNotifyTime", 0L)); this.setNotifiedNumber(reader.getAttrAsInt("notifiedNumber", 0)); this.setClickedWidgetLib(reader.getAttrAsBoolean("clickedWidgetLib", false)); this.setLastGuidePopUpTime(reader.getAttrAsLong("lastGuidePopUpTime", 0L)); + this.setHistoryCreatedReuses(reader.getAttrAsString("historyCreatedReuses", "[]")); } @Override @@ -76,7 +87,8 @@ public class ComponentReuseNotificationInfo implements XMLable { writer.attr("lastNotifyTime", this.lastNotifyTime) .attr("notifiedNumber", this.notifiedNumber) .attr("clickedWidgetLib", this.clickedWidgetLib) - .attr("lastGuidePopUpTime", this.lastGuidePopUpTime); + .attr("lastGuidePopUpTime", this.lastGuidePopUpTime) + .attr("historyCreatedReuses", this.historyCreatedReuses);; writer.end(); } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/UIColorPickerPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/UIColorPickerPane.java index fb2d1c31ad..6529efce05 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/UIColorPickerPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/UIColorPickerPane.java @@ -277,11 +277,11 @@ public class UIColorPickerPane extends BasicPane implements UIObserver { */ public Dimension getPreferredSize() { if (designTypeButtonGroup.getSelectedIndex() == 0) { - return new Dimension(colorGroup.getPreferredSize().width + textGroup.getPreferredSize().width, upControlPane.getPreferredSize().height + getBoundY()); + return new Dimension(colorGroup.getPreferredSize().width + textGroup.getPreferredSize().width, upControlPane.getPreferredSize().height + getPreferredMarginY()); } else { - int extra = stagePanel == null ? 0 : stagePanel.getPreferredSize().height + getBoundY(); + int extra = stagePanel == null ? 0 : stagePanel.getPreferredSize().height + getPreferredMarginY(); return new Dimension(colorGroup.getPreferredSize().width + textGroup.getPreferredSize().width, - extra + textGroup.getPreferredSize().height + upControlPane.getPreferredSize().height + OFF_HEIGHT + getBoundY()); + extra + textGroup.getPreferredSize().height + upControlPane.getPreferredSize().height + OFF_HEIGHT + getPreferredMarginY()); } } @@ -662,6 +662,10 @@ public class UIColorPickerPane extends BasicPane implements UIObserver { return UPCONTROLPANE_WIDTH; } + protected int getPreferredMarginY() { + return MARGIN_TOP; + } + /** *刷新颜色选取器 * @param colorArray 颜色值 diff --git a/designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugeSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugeSeriesPane.java index afdd2d4ca9..d3f997295b 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugeSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugeSeriesPane.java @@ -132,6 +132,10 @@ public class VanChartGaugeSeriesPane extends VanChartMultiColorSeriesPane { return 10; } + protected int getPreferredMarginY() { + return 10; + } + protected double getDescriptionWidth() { double descriptionWidth = super.getDescriptionWidth(); if (valueFillStylePane == null) { diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java b/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java index 8980c09a12..ed90a1c540 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java @@ -865,4 +865,11 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo public boolean isParentAbsolute() { return ((XCreator) this.getParent()).acceptType(XWAbsoluteLayout.class); } + + public int getLevel() { + if (this.getParent() == null) { + return 1; + } + return ((XCreator) this.getParent()).getLevel() + 1; + } } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java index 87b55e1756..25726a5634 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java @@ -318,6 +318,8 @@ public class EditingMouseListener extends MouseInputAdapter { offsetEventPoint(e); XCreator component = designer.getComponentAt(e); + designer.getSpacingLineDrawer().updateMouseEvent(e, true); + setCoverPaneNotDisplay(component, e, false); if (processTopLayoutMouseMove(component, e)) { @@ -353,7 +355,6 @@ public class EditingMouseListener extends MouseInputAdapter { return; } - designer.getSpacingLineDrawer().updateMouseEvent(e, true); processChartEditorMouseMove(component, e); e.translatePoint(oldX - e.getX(), oldY - e.getY()); designer.repaint(); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java b/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java index 9f49de1d89..7d7b341663 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java @@ -835,6 +835,38 @@ public class FormDesigner extends TargetComponent
implements TreeSelection return null; } + /** + * 从root里面查找层级为level的控件 + */ + private XCreator xCreatorAt(int x, int y, XCreator root, int level) { + if (root == null || !root.isVisible()) { + return null; + } + x -= root.getX(); + y -= root.getY(); + + if (root instanceof XLayoutContainer) { + XLayoutContainer rootContainer = (XLayoutContainer) root; + int count = rootContainer.getXCreatorCount(); + for (int i = 0; i < count; i++) { + XCreator child = rootContainer.getXCreator(i); + XCreator dest = xCreatorAt(x, y, child, level); + + if (dest != null && dest.getLevel() == level) { + return dest; + } + } + } + + Rectangle rect = ComponentUtils.computeVisibleRect(root); + if (isIntersectArea(x, y, rect)) { + // 判断是否处于交叉区域 + return root; + } + + return null; + } + /** * 从已选择的组件中找x,y所在的组件 */ @@ -1095,25 +1127,38 @@ public class FormDesigner extends TargetComponent implements TreeSelection * */ @Override public XCreator getComponentAt(int x, int y) { - XLayoutContainer container = y < paraHeight - formArea.getVerticalValue() ? paraComponent : rootComponent; - if (container == null) { - container = rootComponent; - } - int relativeX = x + (int) (formArea.getHorizontalValue() / scale) - container.getX(); - int relativeY = y + (int) (formArea.getVerticalValue() / scale) - container.getY(); - XCreator result = xCreatorAt(relativeX, relativeY, container); + XLayoutContainer container = getRootContainer(y); + XCreator result = xCreatorAt(getRelativeScaleX(x) - container.getX(), getRelativeScaleY(y) - container.getY(), container); return result == null ? getComponentAt(x, y, null) : result; } @Nullable public XCreator getComponentAt(int x, int y, XCreator[] except) { + XLayoutContainer container = getRootContainer(y); + XCreator comp = xCreatorAt(getRelativeScaleX(x), getRelativeScaleY(y), container, except); + return comp == null ? container : comp; + } + + public XCreator getComponentAt(int x, int y, int level) { + XLayoutContainer container = getRootContainer(y); + XCreator comp = xCreatorAt(getRelativeScaleX(x), getRelativeScaleY(y), container, level); + return comp == null ? container : comp; + } + + private XLayoutContainer getRootContainer(int y) { XLayoutContainer container = y < paraHeight - formArea.getVerticalValue() ? paraComponent : rootComponent; if (container == null) { container = rootComponent; } - XCreator comp = xCreatorAt(x + (int)(formArea.getHorizontalValue()/scale), (int)(y + formArea.getVerticalValue()/scale), container, - except); - return comp == null ? container : comp; + return container; + } + + private int getRelativeScaleX(int x) { + return x + (int)(formArea.getHorizontalValue() / scale); + } + + private int getRelativeScaleY(int y) { + return y + (int)(formArea.getVerticalValue() / scale); } public SelectionModel getSelectionModel() { diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java b/designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java index a46a59af49..f70df03c30 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java @@ -21,7 +21,7 @@ public class FormSpacingLineDrawer { private static final int MIN_SPACING = 10; private FormDesigner designer; - private XCreator hoverCreator; + private XCreator hoverCreator = null; private Rectangle selectedRec; private boolean isMouseMoveEvent = false; @@ -30,7 +30,10 @@ public class FormSpacingLineDrawer { } public void updateMouseEvent(MouseEvent e, boolean isMouseMoveEvent) { - this.hoverCreator = designer.getComponentAt(e); + XCreator creator = designer.getSelectionModel().getSelection().getSelectedCreator(); + if (creator != null) { + this.hoverCreator = designer.getComponentAt(e.getX(), e.getY(), creator.getLevel()); + } this.isMouseMoveEvent = isMouseMoveEvent; } @@ -131,14 +134,6 @@ public class FormSpacingLineDrawer { designer.getSelectionModel().getSelection().getSelectedCreator().getParent() == null; } - private boolean isHoveredRootComponent() { - return designer.isRoot(hoverCreator); - } - - private boolean isHoveredForm() { - return hoverCreator.getParent() == null; - } - private boolean isNeedExtendedLine(AbstractFormParallelLine[] nearestSides) { return nearestSides[0].isVerticalCenterLineBeforeTheParallelLine(nearestSides[1]) || nearestSides[0].isVerticalCenterLineBehindTheParallelLine(nearestSides[1]); } @@ -147,12 +142,13 @@ public class FormSpacingLineDrawer { return isSelectedForm() || isSelectedRootComponent(); } - private boolean isHoveredRootPane() { - return isHoveredForm() || isHoveredRootComponent(); + private boolean isSelectedCreatorSameParentWithHoveredCreator() { + XCreator selectedCreator = designer.getSelectionModel().getSelection().getSelectedCreator(); + return selectedCreator != null && hoverCreator != null && selectedCreator.getParent() == hoverCreator.getParent(); } private boolean isDrawSpacingLine() { - return !isSelectedRootPane() && !isHoveredRootPane() && isMouseMoveEvent; + return !isSelectedRootPane() && isSelectedCreatorSameParentWithHoveredCreator() && isMouseMoveEvent; } private AbstractFormParallelLine[] getNearestHorizontalSide() { diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java index 77e6a67d86..c1dda9cc95 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java @@ -32,10 +32,10 @@ public class FormMultiWidgetCardPane extends FormWidgetCardPane { public FormMultiWidgetCardPane(FormDesigner designer) { super(designer); - arrangement = new MultiSelectionArrangement(designer); } public void initPropertyPane() { + arrangement = new MultiSelectionArrangement(designer); content.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 0)); content.add(createArrangementLayoutPane(), BorderLayout.CENTER); } diff --git a/designer-realize/src/main/java/com/fr/design/javascript/ListenerEditPane.java b/designer-realize/src/main/java/com/fr/design/javascript/ListenerEditPane.java index b89971f879..df05e7880d 100644 --- a/designer-realize/src/main/java/com/fr/design/javascript/ListenerEditPane.java +++ b/designer-realize/src/main/java/com/fr/design/javascript/ListenerEditPane.java @@ -25,6 +25,7 @@ import java.awt.FlowLayout; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Set; @@ -39,6 +40,7 @@ public class ListenerEditPane extends BasicBeanPane { private static final String DBCOMMIT = Toolkit.i18nText("Fine-Design_Basic_JavaScript_Commit_To_Database"); private static final String CUSTOMACTION = Toolkit.i18nText("Fine-Design_Report_Submit_Type_Custom"); private static final String EMAIL = Toolkit.i18nText("Fine-Design_Report_Email_Sent_Email"); + private static final String EXPORT = Toolkit.i18nText("Fine-Design_Basic_Export_JS_Event"); private Listener listener; @@ -62,8 +64,12 @@ public class ListenerEditPane extends BasicBeanPane { nameText = new UITextField(8); nameText.setEditable(false); namePane.add(nameText, BorderLayout.WEST); - final String[] style = {JS, DBCOMMIT, CUSTOMACTION, EMAIL}; - styleBox = new UIComboBox(style); + final List style = new ArrayList<>(Arrays.asList(JS, DBCOMMIT, CUSTOMACTION, EMAIL)); + boolean workbook = DesignerContext.getDesignerFrame().getSelectedJTemplate().isJWorkBook(); + if (workbook) { + style.add(EXPORT); + } + styleBox = new UIComboBox(style.toArray()); namePane.add(styleBox); namePane = GUICoreUtils.createFlowPane(new Component[]{ new UILabel(" " + Toolkit.i18nText("Fine-Design_Report_Event_Name") + ":"), @@ -90,6 +96,12 @@ public class ListenerEditPane extends BasicBeanPane { // 发送邮件 EmailPane emailPane = new EmailPane(); hyperlinkPane.add(EMAIL, emailPane); + // 导出事件 + if (workbook) { + ExportJavaScriptPane exportJavaScriptPane = new ExportJavaScriptPane(); + hyperlinkPane.add(EXPORT, exportJavaScriptPane); + cards.add(exportJavaScriptPane); + } cards.add(javaScriptPane); cards.add(commit2DBJavaScriptPane); cards.add(customActionPane); diff --git a/designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareMainPane.java b/designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareMainPane.java index a4fc73fbe7..ea5298cf26 100644 --- a/designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareMainPane.java +++ b/designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareMainPane.java @@ -20,6 +20,7 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.design.login.DesignerLoginHelper; import com.fr.design.login.DesignerLoginSource; import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.reuse.ComponentReuseNotificationInfo; import com.fr.design.mainframe.share.constants.ComponentType; import com.fr.design.mainframe.share.constants.ComponentTypes; import com.fr.design.mainframe.share.constants.DisplayDevice; @@ -36,6 +37,9 @@ import com.fr.form.share.bean.StyleThemeBean; import com.fr.form.share.constants.ShareComponentConstants; import com.fr.form.share.group.DefaultShareGroupManager; import com.fr.form.share.Group; +import com.fr.json.JSON; +import com.fr.json.JSONArray; +import com.fr.json.JSONFactory; import com.fr.plugin.context.PluginContext; import com.fr.plugin.manage.PluginFilter; import com.fr.plugin.manage.PluginManager; @@ -622,6 +626,15 @@ public class ShareMainPane extends JPanel { provider.setDesignerVersion(ProductConstants.VERSION); provider.setVendor(loginLabel.getText()); provider.setFileName(provider.getNameWithID()); + provider.setVendorUid(DesignerEnvManager.getEnvManager().getDesignerLoginUid()); + provider.setCreateTime(System.currentTimeMillis()); + JSONArray historyCreatedReuses = JSONFactory.createJSON( + JSON.ARRAY, + ComponentReuseNotificationInfo.getInstance().getHistoryCreatedReuses() + ); + historyCreatedReuses.add(uuid); + ComponentReuseNotificationInfo.getInstance().setHistoryCreatedReuses(historyCreatedReuses.toString()); + DesignerEnvManager.getEnvManager().saveXMLFile(); if (upload) { provider.setSummary(content.getText());