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] =?UTF-8?q?=E4=BF=9D=E8=AF=81=E8=8E=B7=E5=8F=96=E4=B8=8D?= =?UTF-8?q?=E5=88=B0=E5=B7=B2=E7=BB=8F=E7=A6=81=E7=94=A8=E4=BA=86=E7=9A=84?= =?UTF-8?q?=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); }