diff --git a/designer_base/src/com/fr/design/file/HistoryTemplateListPane.java b/designer_base/src/com/fr/design/file/HistoryTemplateListPane.java index cb0e43712..50eb2a46f 100644 --- a/designer_base/src/com/fr/design/file/HistoryTemplateListPane.java +++ b/designer_base/src/com/fr/design/file/HistoryTemplateListPane.java @@ -8,6 +8,7 @@ import com.fr.design.DesignerEnvManager; import com.fr.design.constants.UIConstants; import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.datapane.TableDataTreePane; +import com.fr.design.gui.chart.DownLoadOnLineSourcesHelper; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilist.UIList; @@ -232,6 +233,13 @@ public class HistoryTemplateListPane extends JPanel implements FileOperations, C getCurrentEditingTemplate().repaint(); } + @Override + public void downLoadSources() { + DownLoadOnLineSourcesHelper pane = new DownLoadOnLineSourcesHelper(); + pane.addMapJSONSiteInfo(); + pane.addPhantomSiteInfo(); + pane.installOnline(); + } private class HistoryListCellRender extends DefaultListCellRenderer { diff --git a/designer_base/src/com/fr/design/gui/chart/DownLoadOnLineSourcesHelper.java b/designer_base/src/com/fr/design/gui/chart/DownLoadOnLineSourcesHelper.java new file mode 100644 index 000000000..a8baa2593 --- /dev/null +++ b/designer_base/src/com/fr/design/gui/chart/DownLoadOnLineSourcesHelper.java @@ -0,0 +1,224 @@ +package com.fr.design.gui.chart; + +import com.fr.base.FRContext; +import com.fr.design.RestartHelper; +import com.fr.design.extra.PluginConstants; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.IOUtils; +import com.fr.general.Inter; +import com.fr.general.SiteCenter; +import com.fr.general.http.HttpClient; +import com.fr.stable.StableUtils; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.net.HttpURLConnection; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by shine on 2017/8/21. + */ +public class DownLoadOnLineSourcesHelper { + // 定义加载窗口大小 + private static final int LOAD_WIDTH = 455; + private static final int INCIDENT_HEIGHT = 15; + private static final int LOAD_HEIGHT = 295; + private static final int PERCENT = 100; + + //进度显示界面 + private JDialog dialog; + //进度条 + private JProgressBar progressbar; + + private List list = new ArrayList<>(); + //安装结果 + private boolean result = true; + //链接服务器的客户端 + private HttpClient httpClient; + + //总共字节数 + private double totalBytes = 0; + + + private static final double PHANTOM_MB = 96.1 * 1024 * 1024; + + public void addPhantomSiteInfo() { + this.addSiteInfo("plugin.phantomjs", "/assist/phantomjs", PHANTOM_MB); + } + + private static final double MAP_JSON_MB = 3.8 * 1024 * 1024; + + public void addMapJSONSiteInfo() { + this.addSiteInfo("map.json", "/assets/map", MAP_JSON_MB); + } + + public void addSiteInfo(String siteKind, String localDir, double megaBits) { + if (new File(FRContext.getCurrentEnv().getPath() + localDir).exists()) { + //本地有这个资源,不下载 + return; + } + httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind(siteKind)); + if (httpClient.getResponseCode() != HttpURLConnection.HTTP_OK) { + //服务器连不上,不下载 + return; + } + totalBytes += megaBits; + list.add(new SiteInfo(siteKind, localDir)); + } + + public void installOnline() { + + int choose = JOptionPane.showConfirmDialog(null, Inter.getLocText("FR-Designer-Download_Online_Sources"), null, JOptionPane.YES_NO_OPTION); + + if (choose == JOptionPane.OK_OPTION) { + initDialog(); + + dialog.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + //取消下载 + result = false; + exitDialog(); + } + + public void windowOpened(WindowEvent e) { + downloadAndInstallPluginDependenceFile(); + exitDialog(); + } + + }); + + dialog.setVisible(true); + } + } + + /** + * 下载和安装不分开是因为,本地如果只安装好了一个依赖,下次就不需要重复下载了 + * 如果下载依赖后不安装,则后面的插件会把前面的插件覆盖,故而下载好了一个安装一个 + * + * @return + * @throws Exception + */ + private void downloadAndInstallPluginDependenceFile() { + try { + double currentBytesRead = 0; + + for (int i = 0; i < list.size(); i++) { + SiteInfo siteInfo = list.get(i); + + httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind(siteInfo.siteKind)); + if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) { + InputStream reader = httpClient.getResponseStream(); + String temp = StableUtils.pathJoin(PluginConstants.DOWNLOAD_PATH, PluginConstants.TEMP_FILE); + File file = new File(temp); + StableUtils.makesureFileExist(file); + FileOutputStream writer = new FileOutputStream(temp); + byte[] buffer = new byte[PluginConstants.BYTES_NUM]; + int bytesRead; + while ((bytesRead = reader.read(buffer)) > 0 && result) { + writer.write(buffer, 0, bytesRead); + buffer = new byte[PluginConstants.BYTES_NUM]; + + currentBytesRead += bytesRead; + setProgress(currentBytesRead); + } + reader.close(); + writer.flush(); + writer.close(); + + + if (result) { + //安装文件 + IOUtils.unZipFilesGBK(temp, FRContext.getCurrentEnv().getPath() + siteInfo.localDir); + } + } else { + result = false; + } + } + } catch (Exception e) { + result = false; + } + } + + + private void initDialog() { + + // 创建标签,并在标签上放置一张图片 + BufferedImage image = IOUtils.readImage("/com/fr/design/gui/chart/background.png"); + ImageIcon imageIcon = new ImageIcon(image); + UILabel label = new UILabel(imageIcon); + label.setBounds(0, 0, LOAD_WIDTH, LOAD_HEIGHT); + + progressbar = new JProgressBar(); + // 显示当前进度值信息 + progressbar.setStringPainted(true); + // 设置进度条边框不显示 + progressbar.setBorderPainted(false); + // 设置进度条的前景色 + progressbar.setForeground(new Color(0x38aef5)); + // 设置进度条的背景色 + progressbar.setBackground(new Color(188, 190, 194)); + progressbar.setBounds(0, LOAD_HEIGHT, LOAD_WIDTH, INCIDENT_HEIGHT); + progressbar.setMinimum(0); + progressbar.setMaximum((int) totalBytes); + setProgress(0); + + dialog = new JDialog(); + dialog.setTitle(Inter.getLocText("FR-Designer-Dependence_Install_Online")); + + JPanel contentPane = new JPanel(new BorderLayout()); + contentPane.add(label, BorderLayout.CENTER); + contentPane.add(progressbar, BorderLayout.SOUTH); + dialog.getContentPane().add(contentPane); + + + dialog.setModal(true); + dialog.setResizable(true); + dialog.setSize(LOAD_WIDTH, LOAD_HEIGHT + INCIDENT_HEIGHT); + dialog.setResizable(false); + GUICoreUtils.centerWindow(dialog); + + dialog.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); + } + + private void setProgress(double current) { + progressbar.setValue((int) current); + progressbar.setString(current / totalBytes * PERCENT + "%"); + progressbar.paintImmediately(new Rectangle(0, 0, LOAD_WIDTH, INCIDENT_HEIGHT * 2)); + } + + + private void exitDialog() { + dialog.dispose(); + + if (result) { + int choose = JOptionPane.showConfirmDialog(null, Inter.getLocText("FR-Designer_Work_After_Restart_Designer"), null, JOptionPane.YES_NO_OPTION); + + if (choose == JOptionPane.OK_OPTION) { + RestartHelper.restart(); + } + } else { + JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Dependence_Install_Failed")); + } + } + + private class SiteInfo { + String siteKind; + String localDir; + + SiteInfo(String siteKind, String localDir) { + this.siteKind = siteKind; + this.localDir = localDir; + } + } + +} + + diff --git a/designer_base/src/com/fr/design/gui/chart/background.png b/designer_base/src/com/fr/design/gui/chart/background.png new file mode 100644 index 000000000..45bf328e3 Binary files /dev/null and b/designer_base/src/com/fr/design/gui/chart/background.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 3bd68da18..9423c23a7 100644 --- a/designer_base/src/com/fr/design/locale/designer.properties +++ b/designer_base/src/com/fr/design/locale/designer.properties @@ -2127,5 +2127,6 @@ FS-Designer_DS_Filter_Specify_Tip=Specify_Tip FR-Designer_Mobile-Height-Percent=Max Percent FR-Designer_Mobile-Height-Limit=Height Limit FR-Designer-AlphaFine_NO_Result=no search result +FR-Designer-Download_Online_Sources= FR-Designer_Select_Color=Select Color -FR-Designer-Basic_Dynamic_Parameter_Injection=Injection +FR-Designer-Basic_Dynamic_Parameter_Injection=Injection \ No newline at end of file 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 9e1b7b7cf..bb48b927d 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 @@ -2123,5 +2123,6 @@ FS-Designer_DS_Filter_Odd_Tip=Odd_Tip FS-Designer_DS_Filter_Even_Tip=Even_Tip FS-Designer_DS_Filter_Specify_Tip=Specify_Tip FR-Designer-AlphaFine_NO_Result=no search result +FR-Designer-Download_Online_Sources= FR-Designer_Select_Color=Select Color -FR-Designer-Basic_Dynamic_Parameter_Injection=Injection +FR-Designer-Basic_Dynamic_Parameter_Injection=Injection \ 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 b93a54a8a..94768d087 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 @@ -2121,5 +2121,6 @@ FS-Designer_DS_Filter_Even_Tip= FS-Designer_DS_Filter_Specify_Tip= FR-Designer_Mobile-Height-Percent= FR-Designer_Mobile-Height-Limit= +FR-Designer-Download_Online_Sources= FR-Designer_Select_Color= FR-Designer-Basic_Dynamic_Parameter_Injection=\ 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 fcfbecd2d..c9cacdb7e 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 @@ -2122,5 +2122,6 @@ FS-Designer_DS_Filter_Even_Tip= FS-Designer_DS_Filter_Specify_Tip= FR-Designer_Mobile-Height-Percent= FR-Designer_Mobile-Height-Limit= +FR-Designer-Download_Online_Sources= FR-Designer_Select_Color= -FR-Designer-Basic_Dynamic_Parameter_Injection=\ +FR-Designer-Basic_Dynamic_Parameter_Injection= \ No newline at end of file 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 864c7192c..d4cfbba9c 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 @@ -2134,5 +2134,6 @@ FS-Designer_DS_Filter_Odd_Tip=\u63D0\u793A\uFF1A\u5E8F\u53F7\u4ECE1\u5F00\u59CB\ FS-Designer_DS_Filter_Even_Tip=\u63D0\u793A\uFF1A\u5E8F\u53F7\u4ECE1\u5F00\u59CB\uFF0C\u9009\u62E9\u4E86\u5076\u6570\u96C6(2,4,6...) FS-Designer_DS_Filter_Specify_Tip=\u63D0\u793A\uFF1A\u683C\u5F0F\u4E3A1,2-3,5,8\uFF0C\u5E8F\u53F7\u4ECE1\u5F00\u59CB\uFF0C\u5185\u503C\u53C2\u6570$_count_\u8868\u793A\u603B\u4E2A\u6570 FR-Designer-AlphaFine_NO_Result=\u65E0\u641C\u7D22\u7ED3\u679C +FR-Designer-Download_Online_Sources=\u56FE\u8868\u9700\u8981\u4E0B\u8F7D\u6700\u65B0\u7684\u8D44\u6E90\u6587\u4EF6\uFF0C\u662F\u5426\u5B89\u88C5\uFF1F FR-Designer_Select_Color=\u9009\u62E9\u989C\u8272 -FR-Designer-Basic_Dynamic_Parameter_Injection=\u6CE8\u5165 +FR-Designer-Basic_Dynamic_Parameter_Injection=\u6CE8\u5165 \ 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 b5f9fbf16..fe2839aee 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 @@ -2126,5 +2126,6 @@ FS-Designer_DS_Filter_Even_Tip=\u63D0\u793A\uFF1A\u5E8F\u865F\u5F9E1\u958B\u59CB FS-Designer_DS_Filter_Specify_Tip=\u63D0\u793A\uFF1A\u683C\u5F0F\u70BA1,2-3,5,8\uFF0C\u5E8F\u865F\u5F9E1\u958B\u59CB\uFF0C\u5185\u7F6E\u53C3\u6578$_count_\u8868\u793A\u7E02\u500B\u6578 M-New_FormBook=\u65B0\u589E\u6C7A\u7B56\u5831\u8868 FR-Designer-AlphaFine_NO_Result=\u7121\u641C\u7D22\u7D50\u679C +FR-Designer-Download_Online_Sources= FR-Designer_Select_Color= FR-Designer-Basic_Dynamic_Parameter_Injection=\u6CE8\u5165 diff --git a/designer_chart/src/com/fr/design/chart/gui/ChartComponent.java b/designer_chart/src/com/fr/design/chart/gui/ChartComponent.java index 9c48aaa36..2caa2a0b9 100644 --- a/designer_chart/src/com/fr/design/chart/gui/ChartComponent.java +++ b/designer_chart/src/com/fr/design/chart/gui/ChartComponent.java @@ -331,4 +331,10 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene public void callback() { this.repaint(); } + + @Override + public void downLoadSources() { + HistoryTemplateListPane.getInstance().downLoadSources(); + } + } \ No newline at end of file diff --git a/designer_chart/src/com/fr/plugin/chart/custom/CustomPlotDesignerPaneFactory.java b/designer_chart/src/com/fr/plugin/chart/custom/CustomPlotDesignerPaneFactory.java index b4f4138a4..341149b4e 100644 --- a/designer_chart/src/com/fr/plugin/chart/custom/CustomPlotDesignerPaneFactory.java +++ b/designer_chart/src/com/fr/plugin/chart/custom/CustomPlotDesignerPaneFactory.java @@ -10,17 +10,16 @@ import com.fr.plugin.chart.PiePlot4VanChart; import com.fr.plugin.chart.attr.plot.VanChartAxisPlot; import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.bubble.VanChartBubblePlot; -import com.fr.plugin.chart.custom.CustomPlotFactory; +import com.fr.plugin.chart.bubble.data.VanChartBubblePlotTableDataContentPane; import com.fr.plugin.chart.custom.component.CustomPlotLocationPane; import com.fr.plugin.chart.custom.type.CustomPlotType; -import com.fr.plugin.chart.bubble.data.VanChartBubblePlotTableDataContentPane; -import com.fr.plugin.chart.scatter.data.VanChartScatterPlotTableDataContentPane; import com.fr.plugin.chart.designer.style.VanChartStylePane; import com.fr.plugin.chart.designer.style.axis.VanChartAxisPane; import com.fr.plugin.chart.designer.style.axis.gauge.VanChartGaugeAxisPane; import com.fr.plugin.chart.gauge.VanChartGaugePlot; import com.fr.plugin.chart.radar.VanChartRadarPlot; import com.fr.plugin.chart.scatter.VanChartScatterPlot; +import com.fr.plugin.chart.scatter.data.VanChartScatterPlotTableDataContentPane; import java.lang.reflect.Constructor; import java.util.HashMap; diff --git a/designer_chart/src/com/fr/plugin/chart/custom/VanChartCustomPlotPane.java b/designer_chart/src/com/fr/plugin/chart/custom/VanChartCustomPlotPane.java index 94be28fd2..843bbfc16 100644 --- a/designer_chart/src/com/fr/plugin/chart/custom/VanChartCustomPlotPane.java +++ b/designer_chart/src/com/fr/plugin/chart/custom/VanChartCustomPlotPane.java @@ -11,12 +11,11 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.type.ChartImagePane; import com.fr.general.FRLogger; import com.fr.general.Inter; -import com.fr.plugin.chart.base.VanChartTools; import com.fr.plugin.chart.base.VanChartAttrLine; +import com.fr.plugin.chart.base.VanChartTools; import com.fr.plugin.chart.custom.component.VanChartCustomPlotSelectPane; import com.fr.plugin.chart.custom.type.CustomPlotType; import com.fr.plugin.chart.custom.type.CustomStyle; -import com.fr.plugin.chart.custom.CustomPlotFactory; import com.fr.plugin.chart.designer.type.AbstractVanChartTypePane; import com.fr.plugin.chart.vanchart.VanChart; @@ -45,7 +44,7 @@ public class VanChartCustomPlotPane extends AbstractVanChartTypePane { //自定义和自动版面的容器,cardLayOut布局 private JPanel contentPane; - protected Component[][] getPaneComponents(JPanel typePane){ + protected Component[][] getPaneComponents(JPanel typePane) { initContent(); @@ -72,14 +71,14 @@ public class VanChartCustomPlotPane extends AbstractVanChartTypePane { double[] columnSize = {p, f}; double[] rowSize = {p, p}; - customPane = TableLayoutHelper.createTableLayoutPane(components, rowSize , columnSize); + customPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); - contentPane = new JPanel(new CardLayout()){ + contentPane = new JPanel(new CardLayout()) { @Override public Dimension getPreferredSize() { - if(isCustom){ + if (isCustom) { return customPane.getPreferredSize(); - } else{ + } else { return new Dimension(autoPane.getWidth(), 0); } } @@ -98,7 +97,6 @@ public class VanChartCustomPlotPane extends AbstractVanChartTypePane { } - @Override protected String[] getTypeIconPath() { return new String[]{"/com/fr/plugin/chart/custom/images/column_line.png", @@ -143,22 +141,22 @@ public class VanChartCustomPlotPane extends AbstractVanChartTypePane { } Chart[] customChart = CustomIndependentVanChart.CustomVanChartTypes; - for(int i = 0, len = customChart.length; i < len; i++){ - if(typeDemo.get(i).isPressing){ - if (i == customChart.length-1){ + for (int i = 0, len = customChart.length; i < len; i++) { + if (typeDemo.get(i).isPressing) { + if (i == customChart.length - 1) { isCustom = true; //先重置自定义组合面板,如果不重置,无法获取选择顺序 - if (lastState == customChart.length-1 && samePlot) { + if (lastState == customChart.length - 1 && samePlot) { //更新数据配置,刪除已经不在的图表数据 dealCustomDefinition(chart); customSelectPane.updateBean(chart); - }else if (samePlot){//如果是同一个图表切换过来,则重置面板 + } else if (samePlot) {//如果是同一个图表切换过来,则重置面板 customSelectPane.populateBean(chart); } } - }else { + } else { isCustom = false; } } @@ -170,20 +168,20 @@ public class VanChartCustomPlotPane extends AbstractVanChartTypePane { private void dealCustomDefinition(Chart chart) { CustomDefinition definition = (CustomDefinition) chart.getFilterDefinition(); - if (definition == null){ + if (definition == null) { return; } Map definitionMap = definition.getDefinitionProviderMap(); - if (definitionMap == null){ + if (definitionMap == null) { return; } Map newDefinitionMap = new HashMap(); VanChartCustomPlot customPlot = (VanChartCustomPlot) chart.getPlot(); - for (int i = 0; i < customPlot.getCustomPlotList().size(); i++){ + for (int i = 0; i < customPlot.getCustomPlotList().size(); i++) { CustomPlotType plotType = CustomPlotFactory.getCustomType(customPlot.getCustomPlotList().get(i)); TopDefinitionProvider definitionProvider = definitionMap.get(plotType); @@ -195,16 +193,17 @@ public class VanChartCustomPlotPane extends AbstractVanChartTypePane { /** * 不同图表切換,重置chart屬性 + * * @param chart * @param newPlot */ @Override - protected void resetChartAttr(Chart chart, Plot newPlot){ + protected void resetChartAttr(Chart chart, Plot newPlot) { super.resetChartAttr(chart, newPlot); //切换图表清空数据配置 chart.setFilterDefinition(null); //设置默认不排序 - VanChartTools tools = ((VanChart)chart).getVanChartTools(); + VanChartTools tools = ((VanChart) chart).getVanChartTools(); if (tools != null) { tools.setSort(false); } @@ -214,19 +213,19 @@ public class VanChartCustomPlotPane extends AbstractVanChartTypePane { * 更新界面内容 */ public void populateBean(Chart chart) { - for(ChartImagePane imagePane : typeDemo) { + for (ChartImagePane imagePane : typeDemo) { imagePane.isPressing = false; } //获取上次选中的图标 - VanChartCustomPlot customPlot = (VanChartCustomPlot)chart.getPlot(); + VanChartCustomPlot customPlot = (VanChartCustomPlot) chart.getPlot(); lastTypeIndex = customPlot.getCustomStyle().ordinal(); typeDemo.get(lastTypeIndex).isPressing = true; isCustom = customPlot.getCustomStyle() == CustomStyle.CUSTOM; //自定义选择时,更新自定义面板 - if (isCustom){ + if (isCustom) { customSelectPane.populateBean(chart); } @@ -246,17 +245,17 @@ public class VanChartCustomPlotPane extends AbstractVanChartTypePane { return VanChartCustomPlot.VAN_CHART_CUSTOM_PLOT_ID; } - protected Plot getSelectedClonedPlot(){ + protected Plot getSelectedClonedPlot() { VanChartCustomPlot newPlot = null; Chart[] customChart = CustomIndependentVanChart.CustomVanChartTypes; - for(int i = 0, len = customChart.length; i < len; i++){ - if(typeDemo.get(i).isPressing){ - newPlot = (VanChartCustomPlot)customChart[i].getPlot(); + for (int i = 0, len = customChart.length; i < len; i++) { + if (typeDemo.get(i).isPressing) { + newPlot = (VanChartCustomPlot) customChart[i].getPlot(); } } Plot cloned = null; try { - cloned = (Plot)newPlot.clone(); + cloned = (Plot) newPlot.clone(); } catch (CloneNotSupportedException e) { FRLogger.getLogger().error("Error In ScatterChart"); } @@ -271,7 +270,7 @@ public class VanChartCustomPlotPane extends AbstractVanChartTypePane { /** *删除配置的条件属性 */ - protected void cloneOldConditionCollection(Plot oldPlot, Plot newPlot) throws CloneNotSupportedException{ + protected void cloneOldConditionCollection(Plot oldPlot, Plot newPlot) throws CloneNotSupportedException { cloneOldDefaultAttrConditionCollection(oldPlot, newPlot); } @@ -279,7 +278,7 @@ public class VanChartCustomPlotPane extends AbstractVanChartTypePane { /** * 删除线型配置 */ - protected void cloneOldDefaultAttrConditionCollection(Plot oldPlot, Plot newPlot) throws CloneNotSupportedException{ + protected void cloneOldDefaultAttrConditionCollection(Plot oldPlot, Plot newPlot) throws CloneNotSupportedException { if (oldPlot.getConditionCollection() != null) { ConditionCollection newCondition = new ConditionCollection(); newCondition.setDefaultAttr((ConditionAttr) oldPlot.getConditionCollection().getDefaultAttr().clone()); @@ -288,7 +287,7 @@ public class VanChartCustomPlotPane extends AbstractVanChartTypePane { //删除线型设置 ConditionAttr attrList = newCondition.getDefaultAttr(); DataSeriesCondition attr = attrList.getExisted(VanChartAttrLine.class); - if (attr != null){ + if (attr != null) { attrList.remove(VanChartAttrLine.class); } } diff --git a/designer_chart/src/com/fr/plugin/chart/custom/component/VanChartCustomPlotSelectPane.java b/designer_chart/src/com/fr/plugin/chart/custom/component/VanChartCustomPlotSelectPane.java index 02761a195..30024e2cd 100644 --- a/designer_chart/src/com/fr/plugin/chart/custom/component/VanChartCustomPlotSelectPane.java +++ b/designer_chart/src/com/fr/plugin/chart/custom/component/VanChartCustomPlotSelectPane.java @@ -8,11 +8,11 @@ import com.fr.general.FRLogger; import com.fr.general.Inter; import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.attr.plot.VanChartRectanglePlot; +import com.fr.plugin.chart.custom.CustomPlotDesignerPaneFactory; +import com.fr.plugin.chart.custom.CustomPlotFactory; import com.fr.plugin.chart.custom.VanChartCustomPlot; import com.fr.plugin.chart.custom.type.CustomPlotType; import com.fr.plugin.chart.custom.type.CustomStyle; -import com.fr.plugin.chart.custom.CustomPlotDesignerPaneFactory; -import com.fr.plugin.chart.custom.CustomPlotFactory; import javax.swing.*; import java.awt.*; diff --git a/designer_chart/src/com/fr/plugin/chart/custom/style/VanChartCustomAxisAreaPane.java b/designer_chart/src/com/fr/plugin/chart/custom/style/VanChartCustomAxisAreaPane.java index 64554aa53..916452aab 100644 --- a/designer_chart/src/com/fr/plugin/chart/custom/style/VanChartCustomAxisAreaPane.java +++ b/designer_chart/src/com/fr/plugin/chart/custom/style/VanChartCustomAxisAreaPane.java @@ -2,9 +2,9 @@ package com.fr.plugin.chart.custom.style; import com.fr.chart.chartattr.Plot; import com.fr.plugin.chart.attr.plot.VanChartPlot; -import com.fr.plugin.chart.custom.VanChartCustomPlot; import com.fr.plugin.chart.custom.CustomPlotDesignerPaneFactory; import com.fr.plugin.chart.custom.CustomPlotFactory; +import com.fr.plugin.chart.custom.VanChartCustomPlot; import com.fr.plugin.chart.designer.style.background.VanChartAxisAreaPane; import java.util.List; diff --git a/designer_chart/src/com/fr/plugin/chart/custom/style/VanChartCustomPlotLabelTabPane.java b/designer_chart/src/com/fr/plugin/chart/custom/style/VanChartCustomPlotLabelTabPane.java index 15cba4ff7..944f4719d 100644 --- a/designer_chart/src/com/fr/plugin/chart/custom/style/VanChartCustomPlotLabelTabPane.java +++ b/designer_chart/src/com/fr/plugin/chart/custom/style/VanChartCustomPlotLabelTabPane.java @@ -5,10 +5,10 @@ import com.fr.chart.chartglyph.ConditionAttr; import com.fr.design.dialog.BasicPane; import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.base.AttrLabel; +import com.fr.plugin.chart.custom.CustomPlotFactory; import com.fr.plugin.chart.custom.VanChartCustomPlot; import com.fr.plugin.chart.custom.component.VanChartCustomPlotTabPane; import com.fr.plugin.chart.custom.type.CustomPlotType; -import com.fr.plugin.chart.custom.CustomPlotFactory; import com.fr.plugin.chart.designer.PlotFactory; import com.fr.plugin.chart.designer.style.VanChartStylePane; import com.fr.plugin.chart.designer.style.label.VanChartPlotLabelPane; diff --git a/designer_form/src/com/fr/design/mainframe/WidgetPropertyPane.java b/designer_form/src/com/fr/design/mainframe/WidgetPropertyPane.java index d24e79c5a..ff6a8c640 100644 --- a/designer_form/src/com/fr/design/mainframe/WidgetPropertyPane.java +++ b/designer_form/src/com/fr/design/mainframe/WidgetPropertyPane.java @@ -49,6 +49,7 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetPrope private CardLayout cardLayout; // 卡片布局,选中参数面板时显示mobileWidgetTable,选中body时显示mobileBodyWidgetTable private JTableHeader header;//把表头单独get出来作为一个组件 private UIHeadGroup tabsHeaderIconPane; + private XComponent lastAffectedCreator; public static WidgetPropertyPane getInstance() { @@ -132,9 +133,7 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetPrope */ private void createPropertyTable() { formWidgetCardPane = new FormWidgetCardPane(designer); - designer.addDesignerEditListener(new WidgetPropertyDesignerAdapter(formWidgetCardPane)); - psp = new UIScrollPane(formWidgetCardPane); // 用来装载属性表table psp.setBorder(null); } @@ -318,6 +317,7 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetPrope private class WidgetPropertyDesignerAdapter implements DesignerEditListener { FormWidgetCardPane formWidgetCardPane; + WidgetPropertyDesignerAdapter(FormWidgetCardPane formWidgetCardPane) { this.formWidgetCardPane = formWidgetCardPane; } @@ -329,14 +329,19 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetPrope || evt.getCreatorEventID() == DesignerEvent.CREATOR_RESIZED) { formWidgetCardPane.populate(); }else if(evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED){ - formWidgetCardPane = new FormWidgetCardPane(designer); + // 防止多次触发 + if (lastAffectedCreator != null && lastAffectedCreator == evt.getAffectedCreator()) { + return; + } + lastAffectedCreator = evt.getAffectedCreator(); + refreshDockingView(); formWidgetCardPane.populate(); } } @Override public boolean equals(Object o) { - return o instanceof WidgetPropertyDesignerAdapter && ((WidgetPropertyDesignerAdapter) o).formWidgetCardPane == this.formWidgetCardPane; + return o instanceof WidgetPropertyDesignerAdapter; } } @@ -345,7 +350,6 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetPrope */ private class EventPropertyDesignerAdapter implements DesignerEditListener { EventPropertyTable propertyTable; - private XComponent lastAffectedCreator; EventPropertyDesignerAdapter(EventPropertyTable eventTable) { this.propertyTable = eventTable; diff --git a/designer_form/src/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java b/designer_form/src/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java index 2a8e1de2b..29327fa1e 100644 --- a/designer_form/src/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java +++ b/designer_form/src/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java @@ -27,7 +27,7 @@ import java.awt.*; * Created by ibm on 2017/7/25. */ public class FormWidgetCardPane extends AbstractAttrNoScrollPane { - private AttributeChangeListener listener2; + private AttributeChangeListener listener; private FormDesigner designer; //当前的编辑器属性定义面板 private DataModify currentEditorDefinePane; @@ -81,7 +81,6 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane { } else { return null; } - } /** @@ -138,7 +137,7 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane { jPanel.add(attriCardPane, BorderLayout.CENTER); - this.listener2 = new AttributeChangeListener() { + this.listener = new AttributeChangeListener() { @Override public void attributeChange() { updateCreator(); @@ -196,7 +195,7 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane { } widgetPropertyPane.populate(cellWidget); reinitAllListeners(); - this.addAttributeChangeListener(listener2); + this.addAttributeChangeListener(listener); }