From 6cba2e4318ac81fb3d0024187d5b37eb7e0daec7 Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Tue, 27 Dec 2016 10:10:11 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E4=BF=9D=E8=AF=81=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E4=B8=8D=E5=88=B0=E5=B7=B2=E7=BB=8F=E7=A6=81=E7=94=A8=E4=BA=86?= =?UTF-8?q?=E7=9A=84=E5=9B=BE=E8=A1=A8=E6=8F=92=E4=BB=B6=E5=AE=9E=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/ChartTypeInterfaceManager.java | 85 +++++++++++-------- 1 file changed, 51 insertions(+), 34 deletions(-) diff --git a/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java b/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java index 12cbef841e..adb35b3e39 100644 --- a/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java +++ b/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java @@ -22,9 +22,8 @@ import com.fr.design.module.DesignModuleFactory; import com.fr.file.XMLFileManager; import com.fr.form.ui.ChartEditor; import com.fr.general.*; -import com.fr.plugin.PluginCollector; -import com.fr.plugin.PluginLicenseManager; -import com.fr.plugin.PluginMessage; +import com.fr.plugin.*; +import com.fr.plugin.proxy.PluginInstanceProxyFactory; import com.fr.stable.ArrayUtils; import com.fr.stable.EnvChangedListener; import com.fr.stable.StringUtils; @@ -43,9 +42,6 @@ import java.util.*; */ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraChartDesignClassManagerProvider { - - - private static ClassLoader loader = Thread.currentThread().getContextClassLoader(); private static ChartTypeInterfaceManager classManager = null; @@ -173,13 +169,20 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh } private String getIconPath(String priority, String plotID) { - if (chartTypeInterfaces.get(priority) != null && chartTypeInterfaces.get(priority).get(plotID) != null) { + + if (containsPlot(priority, plotID)) { return chartTypeInterfaces.get(priority).get(plotID).getIconPath(); }else { return StringUtils.EMPTY; } } + private boolean containsPlot(String priority, String plotID) { + + return chartTypeInterfaces.get(priority) != null && chartTypeInterfaces.get(priority).get(plotID) != null + && !CloseableUtils.isClosed(chartTypeInterfaces.get(priority).get(plotID)); + } + public static void addChartTypeInterface(IndependentChartUIProvider provider, String priority, String plotID) { if (chartTypeInterfaces != null){ if (!chartTypeInterfaces.containsKey(priority)){ @@ -210,8 +213,8 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh if (authorize != null) { PluginLicenseManager.getInstance().registerPaid(authorize, simplify); } - IndependentChartUIProvider provider = (IndependentChartUIProvider) clazz.newInstance(); - if (PluginCollector.getCollector().isError(provider, IndependentChartUIProvider.CURRENT_API_LEVEL, simplify.getPluginName()) || !containsChart(plotID)) { + IndependentChartUIProvider provider = (IndependentChartUIProvider) new PluginInstanceProxyFactory(clazz, simplify).addProxy(Closeable.MASK).getProxyObj(); + if (PluginCollector.getCollector().isError(provider, IndependentChartUIProvider.CURRENT_API_LEVEL, simplify.getPluginName())) { PluginMessage.remindUpdate(className); } else { ChartTypeInterfaceManager.getInstance().addChartTypeInterface(provider, priority, plotID); @@ -224,10 +227,10 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh } } - //UI对应的chart如果没有加载,UI也不必加进去了 - private boolean containsChart(String plotID) { - return ChartTypeManager.getInstance().containsPlot(plotID); - } +// //UI对应的chart如果没有加载,UI也不必加进去了 +// private boolean containsChart(String plotID) { +// return ChartTypeManager.getInstance().containsPlot(plotID); +// } /** @@ -243,7 +246,9 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh while (chartUIIterator.hasNext()) { Map.Entry chartUIEntry = (Map.Entry) chartUIIterator.next(); IndependentChartUIProvider provider = (IndependentChartUIProvider) chartUIEntry.getValue(); - paneList.add(provider.getPlotTypePane()); + if (!CloseableUtils.isClosed(provider)) { + paneList.add(provider.getPlotTypePane()); + } } } } @@ -253,27 +258,42 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh return getTitle4PopupWindow(); } String[] names = new String[getChartSize(priority)]; - if (chartTypeInterfaces != null && chartTypeInterfaces.containsKey(priority)){ + if (containsPriority(priority)) { HashMap chartUIList = chartTypeInterfaces.get(priority); Iterator iterator = chartUIList.entrySet().iterator(); int i = 0; while (iterator.hasNext()){ Map.Entry entry = (Map.Entry) iterator.next(); IndependentChartUIProvider provider = (IndependentChartUIProvider) entry.getValue(); - names[i++] = provider.getPlotTypeTitle4PopupWindow(); + if (!CloseableUtils.isClosed(provider)) { + names[i++] = provider.getPlotTypeTitle4PopupWindow(); + } } return names; } return new String[0]; } + /** + * 判断是否包含某种优先级的图表provider--包含该级别的map并且map里面存在没有关闭的实例 + * + * @param priority 优先级 + * @return 是否包含 + */ + private boolean containsPriority(String priority) { + + return chartTypeInterfaces != null && chartTypeInterfaces.containsKey(priority) + && !CloseableUtils.allClosed(chartTypeInterfaces.get(priority)); + } + /** * 获取指定图表的标题 * @param priority * @return */ public String getTitle4PopupWindow(String priority, String plotID){ - if (chartTypeInterfaces != null && chartTypeInterfaces.containsKey(priority) && chartTypeInterfaces.get(priority).containsKey(plotID)){ + + if (containsPlot(priority, plotID)) { IndependentChartUIProvider provider = chartTypeInterfaces.get(priority).get(plotID); return provider.getPlotTypeTitle4PopupWindow(); } @@ -284,12 +304,12 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh while (iterator.hasNext()) { Map.Entry entry = (Map.Entry) iterator.next(); String defaultPriority = (String) entry.getKey(); - if (chartTypeInterfaces.get(defaultPriority).containsKey(plotID)) { + if (containsPlot(defaultPriority, plotID)) { return chartTypeInterfaces.get(defaultPriority).get(plotID).getPlotTypeTitle4PopupWindow(); } } } - return new String(); + return StringUtils.EMPTY; } private String[] getTitle4PopupWindow(){ @@ -323,7 +343,10 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh while (iterator.hasNext()) { Map.Entry entry = (Map.Entry) iterator.next(); String priority = (String) entry.getKey(); - priorityList.add(Integer.valueOf(priority)); + //包含该优先级时 + if (containsPriority(priority)) { + priorityList.add(Integer.valueOf(priority)); + } } } return ChartTypeManager.orderInPriority(priorityList); @@ -333,7 +356,9 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh while (chartUI.hasNext()) { Map.Entry chartUIEntry = (Map.Entry) chartUI.next(); IndependentChartUIProvider provider = (IndependentChartUIProvider) chartUIEntry.getValue(); - names[index++] = provider.getPlotTypeTitle4PopupWindow(); + if (CloseableUtils.isClosed(provider)) { + names[index++] = provider.getPlotTypeTitle4PopupWindow(); + } } return index; } @@ -361,7 +386,7 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh */ private int getChartSize(String key){ if (chartTypeInterfaces != null && chartTypeInterfaces.containsKey(key)){ - return chartTypeInterfaces.get(key).size(); + return CloseableUtils.openingSize(chartTypeInterfaces.get(key)); } return 0; } @@ -415,7 +440,8 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh private boolean plotInChart(String plotID, String priority) { return chartTypeInterfaces != null && chartTypeInterfaces.containsKey(priority) - && chartTypeInterfaces.get(priority).containsKey(plotID); + && chartTypeInterfaces.get(priority).containsKey(plotID) + && !CloseableUtils.isClosed(chartTypeInterfaces.get(priority).get(plotID)); } private AbstractReportDataContentPane getReportDataSourcePane(String priority, Plot plot, ChartDataPane parent) { @@ -467,23 +493,14 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh while (iterator.hasNext()){ Map.Entry entry = (Map.Entry) iterator.next(); String priority = (String) entry.getKey(); - if (chartTypeInterfaces.get(priority).containsKey(plotID)){ - return isUseDefaultPane(priority, plotID); + if (containsPlot(priority, plotID)) { + return chartTypeInterfaces.get(priority).get(plotID).isUseDefaultPane(); } } return true; } - private boolean isUseDefaultPane(String priority, String plotID){ - - if (chartTypeInterfaces.containsKey(priority) && chartTypeInterfaces.get(priority).containsKey(plotID)) { - return chartTypeInterfaces.get(priority).get(plotID).isUseDefaultPane(); - } - - return true; - } - public void readXML(XMLableReader reader) { readXML(reader, null, PluginSimplify.NULL); } From ea087d4845bb0e5d3345186131d7e29b1d4af0a4 Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Tue, 27 Dec 2016 14:23:08 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E4=BF=9D=E8=AF=81=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E4=B8=8D=E5=88=B0=E5=B7=B2=E7=BB=8F=E7=A6=81=E7=94=A8=E4=BA=86?= =?UTF-8?q?=E7=9A=84=E5=9B=BE=E8=A1=A8=E6=8F=92=E4=BB=B6=E5=AE=9E=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/ChartTypeInterfaceManager.java | 96 ++++++++----------- 1 file changed, 42 insertions(+), 54 deletions(-) diff --git a/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java b/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java index adb35b3e39..4bfc6aed67 100644 --- a/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java +++ b/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java @@ -22,11 +22,13 @@ import com.fr.design.module.DesignModuleFactory; import com.fr.file.XMLFileManager; import com.fr.form.ui.ChartEditor; import com.fr.general.*; -import com.fr.plugin.*; -import com.fr.plugin.proxy.PluginInstanceProxyFactory; +import com.fr.plugin.PluginCollector; +import com.fr.plugin.PluginLicenseManager; +import com.fr.plugin.PluginMessage; import com.fr.stable.ArrayUtils; import com.fr.stable.EnvChangedListener; import com.fr.stable.StringUtils; +import com.fr.stable.collections.map.CloseableContainedMap; import com.fr.stable.fun.Authorize; import com.fr.stable.plugin.ExtraChartDesignClassManagerProvider; import com.fr.stable.plugin.PluginReadListener; @@ -45,7 +47,9 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh private static ClassLoader loader = Thread.currentThread().getContextClassLoader(); private static ChartTypeInterfaceManager classManager = null; - private static LinkedHashMap> chartTypeInterfaces = new LinkedHashMap>(); + + private static LinkedHashMap> chartTypeInterfaces = + new LinkedHashMap<>(); public synchronized static ChartTypeInterfaceManager getInstance() { if (classManager == null) { @@ -131,7 +135,8 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh if (chartTypeInterfaces.containsKey(ChartTypeManager.CHART_PRIORITY)){ return; } - LinkedHashMap chartUIList = new LinkedHashMap(); + CloseableContainedMap chartUIList = + new CloseableContainedMap<>(LinkedHashMap.class); chartUIList.put(ChartConstants.COLUMN_CHART, new ColumnIndependentChartInterface()); chartUIList.put(ChartConstants.LINE_CHART, new LineIndependentChartInterface()); chartUIList.put(ChartConstants.BAR_CHART, new BarIndependentChartInterface()); @@ -170,28 +175,23 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh private String getIconPath(String priority, String plotID) { - if (containsPlot(priority, plotID)) { + if (chartTypeInterfaces.get(priority) != null && chartTypeInterfaces.get(priority).get(plotID) != null) { return chartTypeInterfaces.get(priority).get(plotID).getIconPath(); }else { return StringUtils.EMPTY; } } - private boolean containsPlot(String priority, String plotID) { - - return chartTypeInterfaces.get(priority) != null && chartTypeInterfaces.get(priority).get(plotID) != null - && !CloseableUtils.isClosed(chartTypeInterfaces.get(priority).get(plotID)); - } - public static void addChartTypeInterface(IndependentChartUIProvider provider, String priority, String plotID) { if (chartTypeInterfaces != null){ if (!chartTypeInterfaces.containsKey(priority)){ //新建一个具体图表列表 - LinkedHashMap chartUIList = new LinkedHashMap(); + CloseableContainedMap chartUIList + = new CloseableContainedMap<>(LinkedHashMap.class); chartUIList.put(plotID, provider); chartTypeInterfaces.put(priority, chartUIList); }else { - LinkedHashMap chartUIList = chartTypeInterfaces.get(priority); + CloseableContainedMap chartUIList = chartTypeInterfaces.get(priority); if (!chartUIList.containsKey(plotID)) { chartUIList.put(plotID, provider); } @@ -213,8 +213,8 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh if (authorize != null) { PluginLicenseManager.getInstance().registerPaid(authorize, simplify); } - IndependentChartUIProvider provider = (IndependentChartUIProvider) new PluginInstanceProxyFactory(clazz, simplify).addProxy(Closeable.MASK).getProxyObj(); - if (PluginCollector.getCollector().isError(provider, IndependentChartUIProvider.CURRENT_API_LEVEL, simplify.getPluginName())) { + IndependentChartUIProvider provider = (IndependentChartUIProvider) clazz.newInstance(); + if (PluginCollector.getCollector().isError(provider, IndependentChartUIProvider.CURRENT_API_LEVEL, simplify.getPluginName()) || !containsChart(plotID)) { PluginMessage.remindUpdate(className); } else { ChartTypeInterfaceManager.getInstance().addChartTypeInterface(provider, priority, plotID); @@ -227,10 +227,11 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh } } -// //UI对应的chart如果没有加载,UI也不必加进去了 -// private boolean containsChart(String plotID) { -// return ChartTypeManager.getInstance().containsPlot(plotID); -// } + //UI对应的chart如果没有加载,UI也不必加进去了 + private boolean containsChart(String plotID) { + + return ChartTypeManager.getInstance().containsPlot(plotID); + } /** @@ -246,9 +247,7 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh while (chartUIIterator.hasNext()) { Map.Entry chartUIEntry = (Map.Entry) chartUIIterator.next(); IndependentChartUIProvider provider = (IndependentChartUIProvider) chartUIEntry.getValue(); - if (!CloseableUtils.isClosed(provider)) { - paneList.add(provider.getPlotTypePane()); - } + paneList.add(provider.getPlotTypePane()); } } } @@ -258,34 +257,20 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh return getTitle4PopupWindow(); } String[] names = new String[getChartSize(priority)]; - if (containsPriority(priority)) { - HashMap chartUIList = chartTypeInterfaces.get(priority); + if (chartTypeInterfaces != null && chartTypeInterfaces.containsKey(priority)) { + CloseableContainedMap chartUIList = chartTypeInterfaces.get(priority); Iterator iterator = chartUIList.entrySet().iterator(); int i = 0; while (iterator.hasNext()){ Map.Entry entry = (Map.Entry) iterator.next(); IndependentChartUIProvider provider = (IndependentChartUIProvider) entry.getValue(); - if (!CloseableUtils.isClosed(provider)) { - names[i++] = provider.getPlotTypeTitle4PopupWindow(); - } + names[i++] = provider.getPlotTypeTitle4PopupWindow(); } return names; } return new String[0]; } - /** - * 判断是否包含某种优先级的图表provider--包含该级别的map并且map里面存在没有关闭的实例 - * - * @param priority 优先级 - * @return 是否包含 - */ - private boolean containsPriority(String priority) { - - return chartTypeInterfaces != null && chartTypeInterfaces.containsKey(priority) - && !CloseableUtils.allClosed(chartTypeInterfaces.get(priority)); - } - /** * 获取指定图表的标题 * @param priority @@ -293,7 +278,7 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh */ public String getTitle4PopupWindow(String priority, String plotID){ - if (containsPlot(priority, plotID)) { + if (chartTypeInterfaces != null && chartTypeInterfaces.containsKey(priority) && chartTypeInterfaces.get(priority).containsKey(plotID)) { IndependentChartUIProvider provider = chartTypeInterfaces.get(priority).get(plotID); return provider.getPlotTypeTitle4PopupWindow(); } @@ -304,12 +289,12 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh while (iterator.hasNext()) { Map.Entry entry = (Map.Entry) iterator.next(); String defaultPriority = (String) entry.getKey(); - if (containsPlot(defaultPriority, plotID)) { + if (chartTypeInterfaces.get(defaultPriority).containsKey(plotID)) { return chartTypeInterfaces.get(defaultPriority).get(plotID).getPlotTypeTitle4PopupWindow(); } } } - return StringUtils.EMPTY; + return new String(); } private String[] getTitle4PopupWindow(){ @@ -343,10 +328,7 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh while (iterator.hasNext()) { Map.Entry entry = (Map.Entry) iterator.next(); String priority = (String) entry.getKey(); - //包含该优先级时 - if (containsPriority(priority)) { - priorityList.add(Integer.valueOf(priority)); - } + priorityList.add(Integer.valueOf(priority)); } } return ChartTypeManager.orderInPriority(priorityList); @@ -356,9 +338,7 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh while (chartUI.hasNext()) { Map.Entry chartUIEntry = (Map.Entry) chartUI.next(); IndependentChartUIProvider provider = (IndependentChartUIProvider) chartUIEntry.getValue(); - if (CloseableUtils.isClosed(provider)) { - names[index++] = provider.getPlotTypeTitle4PopupWindow(); - } + names[index++] = provider.getPlotTypeTitle4PopupWindow(); } return index; } @@ -386,7 +366,7 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh */ private int getChartSize(String key){ if (chartTypeInterfaces != null && chartTypeInterfaces.containsKey(key)){ - return CloseableUtils.openingSize(chartTypeInterfaces.get(key)); + return chartTypeInterfaces.get(key).size(); } return 0; } @@ -440,8 +420,7 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh private boolean plotInChart(String plotID, String priority) { return chartTypeInterfaces != null && chartTypeInterfaces.containsKey(priority) - && chartTypeInterfaces.get(priority).containsKey(plotID) - && !CloseableUtils.isClosed(chartTypeInterfaces.get(priority).get(plotID)); + && chartTypeInterfaces.get(priority).containsKey(plotID); } private AbstractReportDataContentPane getReportDataSourcePane(String priority, Plot plot, ChartDataPane parent) { @@ -493,14 +472,23 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh while (iterator.hasNext()){ Map.Entry entry = (Map.Entry) iterator.next(); String priority = (String) entry.getKey(); - if (containsPlot(priority, plotID)) { - return chartTypeInterfaces.get(priority).get(plotID).isUseDefaultPane(); + if (chartTypeInterfaces.get(priority).containsKey(plotID)) { + return isUseDefaultPane(priority, plotID); } } return true; } + private boolean isUseDefaultPane(String priority, String plotID) { + + if (chartTypeInterfaces.containsKey(priority) && chartTypeInterfaces.get(priority).containsKey(plotID)) { + return chartTypeInterfaces.get(priority).get(plotID).isUseDefaultPane(); + } + + return true; + } + public void readXML(XMLableReader reader) { readXML(reader, null, PluginSimplify.NULL); } From d9b634132b40f8906ca7d2665a0ab2d1bd0b7387 Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Tue, 27 Dec 2016 14:45:10 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E4=BF=9D=E8=AF=81=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E4=B8=8D=E5=88=B0=E5=B7=B2=E7=BB=8F=E7=A6=81=E7=94=A8=E4=BA=86?= =?UTF-8?q?=E7=9A=84=E5=9B=BE=E8=A1=A8=E6=8F=92=E4=BB=B6=E5=AE=9E=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/ChartTypeInterfaceManager.java | 19 +++++++---- .../ChartTypeInterfaceCloseableHandler.java | 32 +++++++++++++++++++ 2 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 designer_chart/src/com/fr/design/extra/ChartTypeInterfaceCloseableHandler.java diff --git a/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java b/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java index 4bfc6aed67..f7b5c2a49e 100644 --- a/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java +++ b/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java @@ -25,6 +25,9 @@ import com.fr.general.*; import com.fr.plugin.PluginCollector; import com.fr.plugin.PluginLicenseManager; import com.fr.plugin.PluginMessage; +import com.fr.design.extra.ChartTypeInterfaceCloseableHandler; +import com.fr.plugin.proxy.PluginInstanceProxyFactory; +import com.fr.plugin.proxy.PluginInvocationHandler; import com.fr.stable.ArrayUtils; import com.fr.stable.EnvChangedListener; import com.fr.stable.StringUtils; @@ -33,6 +36,7 @@ import com.fr.stable.fun.Authorize; import com.fr.stable.plugin.ExtraChartDesignClassManagerProvider; import com.fr.stable.plugin.PluginReadListener; import com.fr.stable.plugin.PluginSimplify; +import com.fr.stable.plugin.closeable.Closeable; import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLableReader; @@ -213,24 +217,27 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh if (authorize != null) { PluginLicenseManager.getInstance().registerPaid(authorize, simplify); } - IndependentChartUIProvider provider = (IndependentChartUIProvider) clazz.newInstance(); - if (PluginCollector.getCollector().isError(provider, IndependentChartUIProvider.CURRENT_API_LEVEL, simplify.getPluginName()) || !containsChart(plotID)) { + IndependentChartUIProvider provider = getProxyObj(plotID, simplify, clazz); + if (PluginCollector.getCollector().isError(provider, IndependentChartUIProvider.CURRENT_API_LEVEL, simplify.getPluginName())) { PluginMessage.remindUpdate(className); } else { - ChartTypeInterfaceManager.getInstance().addChartTypeInterface(provider, priority, plotID); + addChartTypeInterface(provider, priority, plotID); } } catch (ClassNotFoundException e) { FRLogger.getLogger().error("class not found:" + e.getMessage()); } catch (IllegalAccessException | InstantiationException e) { FRLogger.getLogger().error("object create error:" + e.getMessage()); + } catch (NoSuchMethodException e) { + FRLogger.getLogger().error(e.getMessage()); } } } - //UI对应的chart如果没有加载,UI也不必加进去了 - private boolean containsChart(String plotID) { + private IndependentChartUIProvider getProxyObj(String plotID, PluginSimplify simplify, Class clazz) throws IllegalAccessException, InstantiationException, NoSuchMethodException { - return ChartTypeManager.getInstance().containsPlot(plotID); + PluginInstanceProxyFactory factory = new PluginInstanceProxyFactory(clazz, simplify); + PluginInvocationHandler handler = new ChartTypeInterfaceCloseableHandler(plotID); + return (IndependentChartUIProvider) factory.addProxy(Closeable.class, handler).getProxyObj(); } diff --git a/designer_chart/src/com/fr/design/extra/ChartTypeInterfaceCloseableHandler.java b/designer_chart/src/com/fr/design/extra/ChartTypeInterfaceCloseableHandler.java new file mode 100644 index 0000000000..6dd65ff38b --- /dev/null +++ b/designer_chart/src/com/fr/design/extra/ChartTypeInterfaceCloseableHandler.java @@ -0,0 +1,32 @@ +package com.fr.design.extra; + +import com.fr.chart.charttypes.ChartTypeManager; +import com.fr.plugin.proxy.CloseableInvocationHandler; + +/** + * Created by juhaoyu on 2016/12/27. + */ +public class ChartTypeInterfaceCloseableHandler extends CloseableInvocationHandler { + + + private final String plotID; + + public ChartTypeInterfaceCloseableHandler(String plotID) throws NoSuchMethodException { + + super(); + this.plotID = plotID; + } + + @Override + protected boolean invokeIsClosed() { + + //找不到Plugin对象时,默认是关闭的 + return super.invokeIsClosed() && containsChart(); + } + + //UI对应的chart如果没有关闭或者不存在,则UI关闭 + private boolean containsChart() { + + return ChartTypeManager.getInstance().containsPlot(plotID); + } +} From d9829553981fdec3b299c13eb5fa85d2cb3ff974 Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Tue, 27 Dec 2016 14:47:47 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E4=BF=9D=E8=AF=81=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E4=B8=8D=E5=88=B0=E5=B7=B2=E7=BB=8F=E7=A6=81=E7=94=A8=E4=BA=86?= =?UTF-8?q?=E7=9A=84=E5=9B=BE=E8=A1=A8=E6=8F=92=E4=BB=B6=E5=AE=9E=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/extra/ChartTypeInterfaceCloseableHandler.java | 1 - 1 file changed, 1 deletion(-) diff --git a/designer_chart/src/com/fr/design/extra/ChartTypeInterfaceCloseableHandler.java b/designer_chart/src/com/fr/design/extra/ChartTypeInterfaceCloseableHandler.java index 6dd65ff38b..a6440c5f89 100644 --- a/designer_chart/src/com/fr/design/extra/ChartTypeInterfaceCloseableHandler.java +++ b/designer_chart/src/com/fr/design/extra/ChartTypeInterfaceCloseableHandler.java @@ -20,7 +20,6 @@ public class ChartTypeInterfaceCloseableHandler extends CloseableInvocationHandl @Override protected boolean invokeIsClosed() { - //找不到Plugin对象时,默认是关闭的 return super.invokeIsClosed() && containsChart(); } From 3a948e4f9adfa5f1442f24353582c86b96e98dc5 Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Tue, 27 Dec 2016 15:41:09 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E5=B0=86Closeable=E7=9A=84=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E7=AD=89=E4=BA=8B=E6=83=85=E6=94=BE=E5=88=B0=E4=B8=93?= =?UTF-8?q?=E9=97=A8=E7=9A=84=E5=AE=B9=E5=99=A8=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/ChartTypeInterfaceManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java b/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java index f7b5c2a49e..c091c54b99 100644 --- a/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java +++ b/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java @@ -195,7 +195,7 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh chartUIList.put(plotID, provider); chartTypeInterfaces.put(priority, chartUIList); }else { - CloseableContainedMap chartUIList = chartTypeInterfaces.get(priority); + Map chartUIList = chartTypeInterfaces.get(priority); if (!chartUIList.containsKey(plotID)) { chartUIList.put(plotID, provider); } @@ -265,7 +265,7 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh } String[] names = new String[getChartSize(priority)]; if (chartTypeInterfaces != null && chartTypeInterfaces.containsKey(priority)) { - CloseableContainedMap chartUIList = chartTypeInterfaces.get(priority); + Map chartUIList = chartTypeInterfaces.get(priority); Iterator iterator = chartUIList.entrySet().iterator(); int i = 0; while (iterator.hasNext()){ From be6f8a80d66aae09147b5de8fadd70df9c374f56 Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Tue, 27 Dec 2016 16:02:09 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E5=B0=86Closeable=E7=9A=84=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E7=AD=89=E4=BA=8B=E6=83=85=E6=94=BE=E5=88=B0=E4=B8=93?= =?UTF-8?q?=E9=97=A8=E7=9A=84=E5=AE=B9=E5=99=A8=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/extra/ChartTypeInterfaceCloseableHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_chart/src/com/fr/design/extra/ChartTypeInterfaceCloseableHandler.java b/designer_chart/src/com/fr/design/extra/ChartTypeInterfaceCloseableHandler.java index a6440c5f89..bb8a029d7d 100644 --- a/designer_chart/src/com/fr/design/extra/ChartTypeInterfaceCloseableHandler.java +++ b/designer_chart/src/com/fr/design/extra/ChartTypeInterfaceCloseableHandler.java @@ -23,7 +23,7 @@ public class ChartTypeInterfaceCloseableHandler extends CloseableInvocationHandl return super.invokeIsClosed() && containsChart(); } - //UI对应的chart如果没有关闭或者不存在,则UI关闭 + //UI对应的chart如果关闭或者不存在,则UI关闭 private boolean containsChart() { return ChartTypeManager.getInstance().containsPlot(plotID); From 35782fcac18c1e3f7e19067447ee6a3fe0ff70c7 Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Tue, 27 Dec 2016 16:15:17 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/extra/ChartTypeInterfaceCloseableHandler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/designer_chart/src/com/fr/design/extra/ChartTypeInterfaceCloseableHandler.java b/designer_chart/src/com/fr/design/extra/ChartTypeInterfaceCloseableHandler.java index bb8a029d7d..8e9715574e 100644 --- a/designer_chart/src/com/fr/design/extra/ChartTypeInterfaceCloseableHandler.java +++ b/designer_chart/src/com/fr/design/extra/ChartTypeInterfaceCloseableHandler.java @@ -20,10 +20,10 @@ public class ChartTypeInterfaceCloseableHandler extends CloseableInvocationHandl @Override protected boolean invokeIsClosed() { - return super.invokeIsClosed() && containsChart(); + //UI对应的chart如果关闭或者不存在,则UI关闭 + return super.invokeIsClosed() || !containsChart(); } - //UI对应的chart如果关闭或者不存在,则UI关闭 private boolean containsChart() { return ChartTypeManager.getInstance().containsPlot(plotID);