diff --git a/designer/src/com/fr/start/Designer.java b/designer/src/com/fr/start/Designer.java index 2f484553a0..e52530c8e6 100644 --- a/designer/src/com/fr/start/Designer.java +++ b/designer/src/com/fr/start/Designer.java @@ -130,6 +130,9 @@ public class Designer extends BaseDesigner { if (ActionFactory.getChartPreStyleAction() != null) { menuDef.addShortCut(ActionFactory.getChartPreStyleAction()); } + if (ActionFactory.getChartEmptyDataStyleAction() != null) { + menuDef.addShortCut(ActionFactory.getChartEmptyDataStyleAction()); + } if (ActionFactory.getChartMapEditorAction() != null) { menuDef.addShortCut(ActionFactory.getChartMapEditorAction()); } diff --git a/designer_base/src/com/fr/design/actions/core/ActionFactory.java b/designer_base/src/com/fr/design/actions/core/ActionFactory.java index 7bc73acbb6..f89e9ed843 100644 --- a/designer_base/src/com/fr/design/actions/core/ActionFactory.java +++ b/designer_base/src/com/fr/design/actions/core/ActionFactory.java @@ -50,6 +50,7 @@ public class ActionFactory { private static ConcurrentMap> cellEditorClass = new ConcurrentHashMap<>(); private static UpdateAction chartPreStyleAction = null; + private static UpdateAction chartEmptyDataStyleAction = null; private static UpdateAction chartMapEditorAction = null; private ActionFactory() { @@ -126,6 +127,15 @@ public class ActionFactory { chartPreStyleAction = action; } + /** + * 注册图表的 空数据提示样式. + * + * @param action 注册的图表空数据提示样式action + */ + public static void registerChartEmptyDataStyleAction(UpdateAction action) { + chartEmptyDataStyleAction = action; + } + /** * kunsnat: 图表注册 悬浮元素编辑器 , 因为ChartCollection和ChartQuickEditor一个在Chart,一个在Designer, 所以分开注册. * @@ -157,6 +167,15 @@ public class ActionFactory { return chartPreStyleAction; } + /** + * 图表空数据提示样式Action + * + * @return 图表空数据提示样式Action + */ + public static UpdateAction getChartEmptyDataStyleAction() { + return chartEmptyDataStyleAction; + } + /** * 图表编辑器Action diff --git a/designer_base/src/com/fr/design/images/chart/EmptyChart.png b/designer_base/src/com/fr/design/images/chart/EmptyChart.png new file mode 100644 index 0000000000..1613f98b20 Binary files /dev/null and b/designer_base/src/com/fr/design/images/chart/EmptyChart.png differ diff --git a/designer_base/src/com/fr/design/locale/designer.properties b/designer_base/src/com/fr/design/locale/designer.properties index 9fb56799ca..cd54b84933 100644 --- a/designer_base/src/com/fr/design/locale/designer.properties +++ b/designer_base/src/com/fr/design/locale/designer.properties @@ -2149,6 +2149,8 @@ FR-Designer_Provide_Choose_All= FR-Designer_Decimal_Places= FR-Designer_Env_Des_Https=If HTTPS is enabled or the HTTPS configuration (certificate path, HTTPS key) is modified, you must restart the designer to take effect. FR-Designer_Format_JavaScript=Format Code +FR-Designer_Tip_Content= +FR-Designer_Chart_Empty_Data= FR-Designer-Vcs_tab_click=Please exit the version management status and then switch the template FR-Designer_Preference_CachingTemplate=Template memory optimization FR-Designer_Preference_MaxCachingTemplate=The designer maximum cache template number: diff --git a/designer_base/src/com/fr/design/locale/designer_en_US.properties b/designer_base/src/com/fr/design/locale/designer_en_US.properties index 5246c0c1b7..e40d22099c 100644 --- a/designer_base/src/com/fr/design/locale/designer_en_US.properties +++ b/designer_base/src/com/fr/design/locale/designer_en_US.properties @@ -2148,6 +2148,8 @@ FR-Designer_Provide_Choose_All= FR-Designer_Decimal_Places= FR-Designer_Env_Des_Https=If HTTPS is enabled or the HTTPS configuration (certificate path, HTTPS key) is modified, you must restart the designer to take effect. FR-Designer_Format_JavaScript=Format Code +FR-Designer_Tip_Content= +FR-Designer_Chart_Empty_Data= FR-Designer-Vcs_tab_click=Please exit the version management status and then switch the template FR-Designer_Preference_CachingTemplate=Template memory optimization FR-Designer_Preference_MaxCachingTemplate=The designer maximum cache template number: @@ -2163,4 +2165,4 @@ FR-Designer_Tab_Template_Three=Template Three FR-Designer_Tab_Template_Four=Template Four FR-Designer_Tab_Template_Five=Template Five FR-Designer_Tab_Template_Six=Template Six -FR-Designer_Tab_Display_Position=Display Position +FR-Designer_Tab_Display_Position=Display Position \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_ja_JP.properties b/designer_base/src/com/fr/design/locale/designer_ja_JP.properties index 62871a21a4..3b2c34d297 100644 --- a/designer_base/src/com/fr/design/locale/designer_ja_JP.properties +++ b/designer_base/src/com/fr/design/locale/designer_ja_JP.properties @@ -2149,6 +2149,8 @@ FR-Designer_Decimal_Places=\u5C0F\u6570\u67A0\u6570: FR-Base-Load_Resource_File=\u8A2D\u5B9A\u30D5\u30A1\u30A4\u30EB\u30ED\u30FC\u30C9 FR-Designer_Env_Des_Https= FR-Designer_Format_JavaScript=Format Code +FR-Designer_Tip_Content= +FR-Designer_Chart_Empty_Data= FR-Designer-Vcs_tab_click= FR-Designer_Move_Up= FR-Designer_Move_Down= diff --git a/designer_base/src/com/fr/design/locale/designer_ko_KR.properties b/designer_base/src/com/fr/design/locale/designer_ko_KR.properties index f177b3f081..92cc47a236 100644 --- a/designer_base/src/com/fr/design/locale/designer_ko_KR.properties +++ b/designer_base/src/com/fr/design/locale/designer_ko_KR.properties @@ -2149,6 +2149,8 @@ FR-Designer_Export_Background= FR-Designer_Print_Background= FR-Designer_Env_Des_Https= FR-Designer_Format_JavaScript=Format Code +FR-Designer_Tip_Content= +FR-Designer_Chart_Empty_Data= FR-Designer-Vcs_tab_click= FR-Designer_Move_Up= FR-Designer_Move_Down= diff --git a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties index ec2887ab1c..82734f02f9 100644 --- a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties +++ b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties @@ -2149,6 +2149,8 @@ FR-Designer_Provide_Choose_All= FR-Designer_Decimal_Places= FR-Designer_Env_Des_Https=\u82E5\u542F\u7528https\u6216\u4FEE\u6539https\u914D\u7F6E\uFF08\u8BC1\u4E66\u8DEF\u5F84\u3001https\u79D8\u94A5\uFF09\uFF0C\u5FC5\u987B\u91CD\u542F\u8BBE\u8BA1\u5668\u624D\u80FD\u751F\u6548\u3002 FR-Designer_Format_JavaScript=\u683C\u5F0F\u5316\u4EE3\u7801 +FR-Designer_Tip_Content=\u63D0\u793A\u5185\u5BB9 +FR-Designer_Chart_Empty_Data=\u56FE\u8868\u7A7A\u6570\u636E\u63D0\u793A FR-Designer-Vcs_tab_click=\u8BF7\u5148\u9000\u51FA\u7248\u672C\u7BA1\u7406\u72B6\u6001\u518D\u5207\u6362\u6A21\u677F FR-Designer_Preference_CachingTemplate=\u6A21\u677F\u5185\u5B58\u4F18\u5316 FR-Designer_Preference_MaxCachingTemplate=\u8BBE\u8BA1\u5668\u6700\u5927\u7F13\u5B58\u6A21\u677F\u4E2A\u6570\uFF1A @@ -2164,4 +2166,4 @@ FR-Designer_Tab_Template_Three=\u6A21\u677F\u4E09 FR-Designer_Tab_Template_Four=\u6A21\u677F\u56DB FR-Designer_Tab_Template_Five=\u6A21\u677F\u4E94 FR-Designer_Tab_Template_Six=\u6A21\u677F\u516D -FR-Designer_Tab_Display_Position=\u663E\u793A\u4F4D\u7F6E +FR-Designer_Tab_Display_Position=\u663E\u793A\u4F4D\u7F6E \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_zh_TW.properties b/designer_base/src/com/fr/design/locale/designer_zh_TW.properties index f3653ed691..7f274e7157 100644 --- a/designer_base/src/com/fr/design/locale/designer_zh_TW.properties +++ b/designer_base/src/com/fr/design/locale/designer_zh_TW.properties @@ -2148,6 +2148,8 @@ FR-Designer_Provide_Choose_All= FR-Designer_Decimal_Places= FR-Designer_Env_Des_Https=\u82E5\u555F\u7528https\u6216\u4FEE\u6539https\u914D\u7F6E\uFF08\u8B49\u66F8\u8DEF\u5F91\u3001https\u7955\u9470\uFF09\uFF0C\u5FC5\u9808\u91CD\u555F\u8A2D\u8A08\u5668\u624D\u80FD\u751F\u6548\u3002 FR-Designer_Format_JavaScript=Format Code +FR-Designer_Tip_Content= +FR-Designer_Chart_Empty_Data= FR-Designer-Vcs_tab_click= FR-Designer_Preference_CachingTemplate=\u7BC4\u672C\u8A18\u61B6\u9AD4\u512A\u5316 FR-Designer_Preference_MaxCachingTemplate=\u8A2D\u8A08\u5668\u6700\u5927\u7DE9\u5B58\u7BC4\u672C\u500B\u6578\uFF1A diff --git a/designer_chart/src/com/fr/design/images/us_emptydata.png b/designer_chart/src/com/fr/design/images/us_emptydata.png new file mode 100644 index 0000000000..d3ab9923e4 Binary files /dev/null and b/designer_chart/src/com/fr/design/images/us_emptydata.png differ diff --git a/designer_chart/src/com/fr/design/images/zh_emptydata.png b/designer_chart/src/com/fr/design/images/zh_emptydata.png new file mode 100644 index 0000000000..0ffd8e1239 Binary files /dev/null and b/designer_chart/src/com/fr/design/images/zh_emptydata.png differ diff --git a/designer_chart/src/com/fr/design/module/ChartDesignerModule.java b/designer_chart/src/com/fr/design/module/ChartDesignerModule.java index 586910774a..85cb0bce78 100644 --- a/designer_chart/src/com/fr/design/module/ChartDesignerModule.java +++ b/designer_chart/src/com/fr/design/module/ChartDesignerModule.java @@ -53,6 +53,7 @@ public class ChartDesignerModule extends DesignModule { DesignModuleFactory.registerChartPropertyPaneClass(ChartPropertyPane.class); ActionFactory.registerChartPreStyleAction(new ChartPreStyleAction()); + ActionFactory.registerChartEmptyDataStyleAction(new ChartEmptyDataStyleAction()); ActionFactory.registerChartMapEditorAction(new ChartMapEditorAction()); } diff --git a/designer_chart/src/com/fr/design/module/ChartEmptyDataStyleAction.java b/designer_chart/src/com/fr/design/module/ChartEmptyDataStyleAction.java new file mode 100644 index 0000000000..7c6bdb0959 --- /dev/null +++ b/designer_chart/src/com/fr/design/module/ChartEmptyDataStyleAction.java @@ -0,0 +1,46 @@ +package com.fr.design.module; + +import com.fr.design.actions.UpdateAction; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.DesignerFrame; +import com.fr.general.IOUtils; +import com.fr.general.Inter; + +import java.awt.event.ActionEvent; + +/** + * Created by mengao on 2017/11/23. + * 空数据配置action + */ +public class ChartEmptyDataStyleAction extends UpdateAction { + + public ChartEmptyDataStyleAction() { + this.setSmallIcon(IOUtils.readIcon("com/fr/design/images/chart/EmptyChart.png")); + this.setName(Inter.getLocText("FR-Designer_Chart_Empty_Data")); + } + + @Override + public void actionPerformed(ActionEvent e) { + DesignerFrame designerFrame = DesignerContext.getDesignerFrame(); + final ChartEmptyDataStylePane pane = new ChartEmptyDataStylePane(); + BasicDialog dialog = pane.showWindow(designerFrame); + dialog.addDialogActionListener(new DialogActionAdapter() { + @Override + public void doOk() { + pane.updateBean(); + + } + + @Override + public void doCancel() { + //直接关闭弹出框 + } + }); + + pane.populateBean(); + dialog.setVisible(true); + } + +} diff --git a/designer_chart/src/com/fr/design/module/ChartEmptyDataStylePane.java b/designer_chart/src/com/fr/design/module/ChartEmptyDataStylePane.java new file mode 100644 index 0000000000..42de5bacdf --- /dev/null +++ b/designer_chart/src/com/fr/design/module/ChartEmptyDataStylePane.java @@ -0,0 +1,237 @@ +package com.fr.design.module; + +import com.fr.base.BaseUtils; +import com.fr.base.ChartEmptyDataStyleManagerProvider; +import com.fr.base.ChartEmptyDataStyleServerManager; +import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.ibutton.UIRadioButton; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.DesignerFrame; +import com.fr.design.style.background.image.ImageFileChooser; +import com.fr.design.style.background.image.ImagePreviewPane; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.FRLogger; +import com.fr.general.GeneralContext; +import com.fr.general.IOUtils; +import com.fr.general.Inter; +import com.fr.stable.CoreGraphHelper; +import com.fr.stable.StringUtils; + +import java.awt.BorderLayout; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import javax.swing.BorderFactory; +import javax.swing.JFileChooser; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.ButtonGroup; +import java.awt.Image; +import java.awt.Dimension; +import java.awt.Component; +import java.awt.GridLayout; + +/** + * Created by mengao on 2017/11/23. + */ +public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane { + private static final int WIDTH = 150; + private static final int HEIGHT = 20; + private static final int FIVE = 5; + private static final int TEN = 10; + private static final int THIRTY = 30; + private static Image DEFAULT_EMPTY_DATA_IMAGE; + + + private UIButtonGroup emptyData; + private UIRadioButton defaultRadioButton; + private UIRadioButton customRadioButton; + private UIButton selectPictureButton; + + private ImagePreviewPane previewPane; + private ImageFileChooser imageFileChooser; + + private Image emptyDataImage = DEFAULT_EMPTY_DATA_IMAGE; + + + static { + DEFAULT_EMPTY_DATA_IMAGE = GeneralContext.isChineseEnv() ? IOUtils.readImage("com/fr/design/images/zh_emptydata.png") + : IOUtils.readImage("com/fr/design/images/us_emptydata.png"); + } + + @Override + protected JPanel createContentPane() { + JPanel content = new JPanel(new BorderLayout()); + content.add(creatNorthPane(), BorderLayout.NORTH); + content.add(creatCenterPane(), BorderLayout.CENTER); + return content; + } + + private JPanel creatNorthPane() { + emptyData = new UIButtonGroup(new String[]{Inter.getLocText("Plugin-ChartF_Open"), Inter.getLocText("Plugin-ChartF_Close")}); + emptyData.setSelectedIndex(0); + emptyData.setPreferredSize(new Dimension(WIDTH, HEIGHT)); + emptyData.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + checkEmptyDataStyle(); + repaintPreviewPane(); + } + }); + + UILabel promptContent = new UILabel(Inter.getLocText("FR-Designer_Tip_Content")); + JPanel northPane = GUICoreUtils.createFlowPane(new Component[]{promptContent, emptyData}, FlowLayout.LEFT, TEN, 0); + northPane.setBorder(BorderFactory.createEmptyBorder(0, FIVE, 0, 0)); + return northPane; + } + + private JPanel creatCenterPane() { + JPanel centerPane = new JPanel(FRGUIPaneFactory.createBorderLayout()); + + // preview pane + JPanel previewContainerPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); + centerPane.add(previewContainerPane, BorderLayout.CENTER); + + JPanel previewOwnerPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("FR-Designer_Preview")); + previewOwnerPane.setLayout(new BorderLayout()); + previewContainerPane.add(previewOwnerPane, BorderLayout.CENTER); + previewContainerPane.add(initSelectFilePane(), BorderLayout.EAST); + previewPane = new ImagePreviewPane(); + previewOwnerPane.add(new JScrollPane(previewPane)); + + + // init image file chooser. + imageFileChooser = new ImageFileChooser(); + imageFileChooser.setMultiSelectionEnabled(false); + return centerPane; + } + + public JPanel initSelectFilePane() { + + JPanel selectFilePane = FRGUIPaneFactory.createBorderLayout_L_Pane(); + + selectFilePane.setBorder(BorderFactory.createEmptyBorder(TEN, FIVE, 0, THIRTY)); + + defaultRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer_DEFAULT")); + customRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer-Widget-Style_Custom")); + ButtonGroup buttonGroup = new ButtonGroup(); + defaultRadioButton.setSelected(true); + buttonGroup.add(defaultRadioButton); + buttonGroup.add(customRadioButton); + + defaultRadioButton.addActionListener(getLayoutActionListener()); + customRadioButton.addActionListener(getLayoutActionListener()); + + JPanel jp = new JPanel(new GridLayout(3, 1, 0, TEN)); + jp.add(defaultRadioButton); + jp.add(customRadioButton); + + selectPictureButton = new UIButton( + Inter.getLocText("FR-Designer_Background_Image_Select")); + selectPictureButton.addActionListener(getSelectPictureActionListener()); + jp.add(selectPictureButton); + + + selectFilePane.add(jp, BorderLayout.NORTH); + return selectFilePane; + } + + private ActionListener getLayoutActionListener() { + return new ActionListener() { + + public void actionPerformed(ActionEvent evt) { + emptyDataImage = null; + checkCustomImage(); + repaintPreviewPane(); + } + }; + } + + /** + * Select picture. + */ + private ActionListener getSelectPictureActionListener() { + return new ActionListener() { + + public void actionPerformed(ActionEvent evt) { + int returnVal = imageFileChooser.showOpenDialog(ChartEmptyDataStylePane.this); + if (returnVal != JFileChooser.CANCEL_OPTION) { + File selectedFile = imageFileChooser.getSelectedFile(); + + if (selectedFile != null && selectedFile.isFile()) { + emptyDataImage = BaseUtils.readImage(selectedFile.getPath()); + CoreGraphHelper.waitForImage(emptyDataImage); + repaintPreviewPane(); + + } else { + previewPane.setImage(null); + } + } + + } + }; + } + + private void checkEmptyDataStyle() { + boolean b = emptyData.getSelectedIndex() == 0; + defaultRadioButton.setEnabled(b); + customRadioButton.setEnabled(b); + selectPictureButton.setEnabled(b); + } + + private void checkCustomImage() { + selectPictureButton.setVisible(customRadioButton.isSelected()); + } + + private void repaintPreviewPane() { + emptyDataImage = customRadioButton.isSelected() ? emptyDataImage : DEFAULT_EMPTY_DATA_IMAGE; + previewPane.setImage(emptyData.getSelectedIndex() == 0 ? emptyDataImage : null); + previewPane.repaint(); + } + + @Override + public String getIconPath() { + return StringUtils.EMPTY; + } + + @Override + public String title4PopupWindow() { + return Inter.getLocText("FR-Designer_Chart_Empty_Data"); + } + + public void populateBean() { + ChartEmptyDataStyleManagerProvider manager = ChartEmptyDataStyleServerManager.getProviderInstance(); + emptyData.setSelectedIndex(manager.isOpenEmptyDataStyle() == true ? 0 : 1); + customRadioButton.setSelected(manager.isCustomEmptyDataStyle()); + emptyDataImage = manager.getEmptyDataImage(); + + checkEmptyDataStyle(); + checkCustomImage(); + repaintPreviewPane(); + } + + public void updateBean() { + ChartEmptyDataStyleManagerProvider manager = ChartEmptyDataStyleServerManager.getProviderInstance(); + + manager.setOpenEmptyDataStyle(emptyData.getSelectedIndex() == 0); + manager.setCustomEmptyDataStyle(customRadioButton.isSelected()); + manager.setEmptyDataImage(emptyDataImage); + + try { + manager.writeResource(); + } catch (Exception e) { + FRLogger.getLogger().error(e.getMessage()); + } + + // 通知报表整个刷新. + DesignerFrame frame = DesignerContext.getDesignerFrame(); + if (frame != null) { + frame.repaint(); + } + } +}