From 08ba6060241ebb8ec41fbcee67d7ad7ee5005222 Mon Sep 17 00:00:00 2001 From: Fangjie Hu Date: Wed, 2 Nov 2016 17:27:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BE=E8=A1=A8=E4=BC=98=E5=85=88=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/ChartTypeInterfaceManager.java | 183 +++++++++--------- .../mainframe/chart/gui/ChartTypePane.java | 4 +- 2 files changed, 91 insertions(+), 96 deletions(-) diff --git a/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java b/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java index 51d03ab3d..873a96750 100644 --- a/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java +++ b/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java @@ -54,6 +54,7 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh if (classManager == null) { classManager = new ChartTypeInterfaceManager(); chartTypeInterfaces.clear(); + classManager.readDefault(); } return classManager; } @@ -70,9 +71,6 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh GeneralContext.addPluginReadListener(new PluginReadListener() { @Override public void success() { - if (chartTypeInterfaces.size() == 0) { - ChartTypeInterfaceManager.getInstance().readDefault(); - } //重新注册designModuleFactory DesignModuleFactory.registerExtraWidgetOptions(initWidgetOption()); } @@ -127,6 +125,9 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh } private static void readDefault() { + if (chartTypeInterfaces.containsKey(ChartTypeManager.CHART_PRIORITY)){ + return; + } LinkedHashMap chartUIList = new LinkedHashMap(); chartUIList.put(ChartConstants.COLUMN_CHART, new ColumnIndependentChartInterface()); chartUIList.put(ChartConstants.LINE_CHART, new LineIndependentChartInterface()); @@ -146,7 +147,7 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh chartUIList.put(ChartConstants.GIS_CHAER, new GisMapIndependentChartInterface()); chartUIList.put(ChartConstants.FUNNEL_CHART, new FunnelIndependentChartInterface()); - chartTypeInterfaces.put(ChartTypeManager.DEFAULT_CHART_ID, chartUIList); + chartTypeInterfaces.put(ChartTypeManager.CHART_PRIORITY, chartUIList); } public String getIconPath(String plotID) { @@ -154,8 +155,8 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh Iterator iterator = chartTypeInterfaces.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry) iterator.next(); - String chartID = (String) entry.getKey(); - String imagePath = getIconPath(chartID, plotID); + String priority = (String) entry.getKey(); + String imagePath = getIconPath(priority, plotID); if (!StringUtils.isEmpty(imagePath)) { return imagePath; } @@ -164,23 +165,23 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh return StringUtils.EMPTY; } - private String getIconPath(String chartID, String plotID) { - if (chartTypeInterfaces.get(chartID) != null && chartTypeInterfaces.get(chartID).get(plotID) != null) { - return chartTypeInterfaces.get(chartID).get(plotID).getIconPath(); + private String getIconPath(String priority, String plotID) { + if (chartTypeInterfaces.get(priority) != null && chartTypeInterfaces.get(priority).get(plotID) != null) { + return chartTypeInterfaces.get(priority).get(plotID).getIconPath(); }else { return StringUtils.EMPTY; } } - public static void addChartTypeInterface(IndependentChartUIProvider provider, String chartID, String plotID) { + public static void addChartTypeInterface(IndependentChartUIProvider provider, String priority, String plotID) { if (chartTypeInterfaces != null){ - if (!chartTypeInterfaces.containsKey(chartID)){ + if (!chartTypeInterfaces.containsKey(priority)){ //新建一个具体图表列表 LinkedHashMap chartUIList = new LinkedHashMap(); chartUIList.put(plotID, provider); - chartTypeInterfaces.put(chartID, chartUIList); + chartTypeInterfaces.put(priority, chartUIList); }else { - LinkedHashMap chartUIList = chartTypeInterfaces.get(chartID); + LinkedHashMap chartUIList = chartTypeInterfaces.get(priority); if (!chartUIList.containsKey(plotID)) { chartUIList.put(plotID, provider); } @@ -194,7 +195,7 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh * @param className 类名 * @param plotID 标志ID */ - public void addChartInterface(String className, String chartID, String plotID, PluginSimplify simplify) { + public void addChartInterface(String className, String priority, String plotID, PluginSimplify simplify) { if (StringUtils.isNotBlank(className)) { try { Class clazz = Class.forName(className); @@ -206,7 +207,7 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh if (PluginCollector.getCollector().isError(provider, IndependentChartUIProvider.CURRENT_API_LEVEL, simplify.getPluginName()) || !containsChart(plotID)) { PluginMessage.remindUpdate(className); } else { - ChartTypeInterfaceManager.getInstance().addChartTypeInterface(provider, chartID, plotID); + ChartTypeInterfaceManager.getInstance().addChartTypeInterface(provider, priority, plotID); } } catch (ClassNotFoundException e) { FRLogger.getLogger().error("class not found:" + e.getMessage()); @@ -230,8 +231,8 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh Iterator iterator = chartTypeInterfaces.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry) iterator.next(); - String chartID = (String) entry.getKey(); - Iterator chartUIIterator = chartTypeInterfaces.get(chartID).entrySet().iterator(); + String priority = (String) entry.getKey(); + Iterator chartUIIterator = chartTypeInterfaces.get(priority).entrySet().iterator(); while (chartUIIterator.hasNext()) { Map.Entry chartUIEntry = (Map.Entry) chartUIIterator.next(); IndependentChartUIProvider provider = (IndependentChartUIProvider) chartUIEntry.getValue(); @@ -240,13 +241,13 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh } } - public String[] getTitle4PopupWindow(String chartID){ - if (chartID.isEmpty()){ + public String[] getTitle4PopupWindow(String priority){ + if (priority.isEmpty()){ return getTitle4PopupWindow(); } - String[] names = new String[getChartSize(chartID)]; - if (chartTypeInterfaces != null && chartTypeInterfaces.containsKey(chartID)){ - HashMap chartUIList = chartTypeInterfaces.get(chartID); + String[] names = new String[getChartSize(priority)]; + if (chartTypeInterfaces != null && chartTypeInterfaces.containsKey(priority)){ + HashMap chartUIList = chartTypeInterfaces.get(priority); Iterator iterator = chartUIList.entrySet().iterator(); int i = 0; while (iterator.hasNext()){ @@ -261,13 +262,13 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh /** * 获取指定图表的标题 - * @param chartID + * @param priority * @return */ - public String getTitle4PopupWindow(String chartID, String plotID){ - if (chartTypeInterfaces != null && chartTypeInterfaces.containsKey(chartID) && chartTypeInterfaces.get(chartID).containsKey(plotID)){ - HashMap chartUIList = chartTypeInterfaces.get(chartID); - IndependentChartUIProvider provider = chartTypeInterfaces.get(chartID).get(plotID); + public String getTitle4PopupWindow(String priority, String plotID){ + if (chartTypeInterfaces != null && chartTypeInterfaces.containsKey(priority) && chartTypeInterfaces.get(priority).containsKey(plotID)){ + HashMap chartUIList = chartTypeInterfaces.get(priority); + IndependentChartUIProvider provider = chartTypeInterfaces.get(priority).get(plotID); return provider.getPlotTypePane().title4PopupWindow(); } @@ -275,34 +276,28 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh } private String[] getTitle4PopupWindow(){ + List priorityList = new ArrayList(); int size = 0; if (chartTypeInterfaces != null){ Iterator iterator = chartTypeInterfaces.entrySet().iterator(); while (iterator.hasNext()){ Map.Entry entry = (Map.Entry) iterator.next(); - String chartID = (String) entry.getKey(); - size += getChartSize(chartID); + String priority = (String) entry.getKey(); + priorityList.add(Integer.valueOf(priority)); + size += getChartSize(priority); } String[] names = new String[size]; + priorityList = ChartTypeManager.orderInPriority(priorityList); + int index = 0; - //处理vanChart - Iterator vanChartUI = chartTypeInterfaces.get(ChartTypeManager.vanChartID).entrySet().iterator(); - index = fetchNames(vanChartUI, names, index); - //处理chart - Iterator chartUI = chartTypeInterfaces.get(ChartTypeManager.chartID).entrySet().iterator(); - index = fetchNames(chartUI, names, index); - //其它图表 - Iterator i = chartTypeInterfaces.entrySet().iterator(); - while (i.hasNext()){ - Map.Entry entry = (Map.Entry) i.next(); - String chartID = (String) entry.getKey(); - if (!(ComparatorUtils.equals(chartID, ChartTypeManager.chartID) || ComparatorUtils.equals(chartID, ChartTypeManager.vanChartID))) { - Iterator otherChartUI = chartTypeInterfaces.get(chartID).entrySet().iterator(); - index = fetchNames(otherChartUI, names, index); - } + for (int i = 0; i < priorityList.size(); i++){ + String priority = String.valueOf(priorityList.get(i)); + Iterator chartUI = chartTypeInterfaces.get(priority).entrySet().iterator(); + index = fetchNames(chartUI, names, index); } + return names; } @@ -322,26 +317,26 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh Iterator iterator = chartTypeInterfaces.entrySet().iterator(); while (iterator.hasNext()){ Map.Entry entry = (Map.Entry) iterator.next(); - String chartID = (String) entry.getKey(); - if (plotInChart(plotID, chartID)) { - return getChartDataPane(chartID, plotID, listener); + String priority = (String) entry.getKey(); + if (plotInChart(plotID, priority)) { + return getChartDataPane(priority, plotID, listener); } } - return getChartDataPane(ChartTypeManager.DEFAULT_CHART_ID, plotID, listener); + return getChartDataPane(ChartTypeManager.CHART_PRIORITY, plotID, listener); } - private ChartDataPane getChartDataPane(String chartID, String plotID, AttributeChangeListener listener) { - return chartTypeInterfaces.get(chartID).get(plotID).getChartDataPane(listener); + private ChartDataPane getChartDataPane(String priority, String plotID, AttributeChangeListener listener) { + return chartTypeInterfaces.get(priority).get(plotID).getChartDataPane(listener); } /** * 获取对应ID的图表数量 - * @param chartID + * @param key * @return */ - private int getChartSize(String chartID){ - if (chartTypeInterfaces != null && chartTypeInterfaces.containsKey(chartID)){ - return chartTypeInterfaces.get(chartID).size(); + private int getChartSize(String key){ + if (chartTypeInterfaces != null && chartTypeInterfaces.containsKey(key)){ + return chartTypeInterfaces.get(key).size(); } return 0; } @@ -350,32 +345,32 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh Iterator iterator = chartTypeInterfaces.entrySet().iterator(); while (iterator.hasNext()){ Map.Entry entry = (Map.Entry) iterator.next(); - String chartID = (String) entry.getKey(); - if (plotInChart(plotID, chartID)) { - return getAttrPaneArray(chartID, plotID, listener); + String priority = (String) entry.getKey(); + if (plotInChart(plotID, priority)) { + return getAttrPaneArray(priority, plotID, listener); } } - return getAttrPaneArray(ChartTypeManager.DEFAULT_CHART_ID, plotID, listener); + return getAttrPaneArray(ChartTypeManager.CHART_PRIORITY, plotID, listener); } - private AbstractChartAttrPane[] getAttrPaneArray(String chartID, String plotID, AttributeChangeListener listener) { - return chartTypeInterfaces.get(chartID).get(plotID).getAttrPaneArray(listener); + private AbstractChartAttrPane[] getAttrPaneArray(String priority, String plotID, AttributeChangeListener listener) { + return chartTypeInterfaces.get(priority).get(plotID).getAttrPaneArray(listener); } public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent) { Iterator iterator = chartTypeInterfaces.entrySet().iterator(); while (iterator.hasNext()){ Map.Entry entry = (Map.Entry) iterator.next(); - String chartID = (String) entry.getKey(); - if (plotInChart(plot.getPlotID(), chartID)) { - return getTableDataSourcePane(chartID, plot, parent); + String priority = (String) entry.getKey(); + if (plotInChart(plot.getPlotID(), priority)) { + return getTableDataSourcePane(priority, plot, parent); } } - return getTableDataSourcePane(ChartTypeManager.DEFAULT_CHART_ID, plot, parent); + return getTableDataSourcePane(ChartTypeManager.CHART_PRIORITY, plot, parent); } - private AbstractTableDataContentPane getTableDataSourcePane(String chartID, Plot plot, ChartDataPane parent) { - return chartTypeInterfaces.get(chartID).get(plot.getPlotID()).getTableDataSourcePane(plot, parent); + private AbstractTableDataContentPane getTableDataSourcePane(String priority, Plot plot, ChartDataPane parent) { + return chartTypeInterfaces.get(priority).get(plot.getPlotID()).getTableDataSourcePane(plot, parent); } @@ -383,23 +378,23 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh Iterator iterator = chartTypeInterfaces.entrySet().iterator(); while (iterator.hasNext()){ Map.Entry entry = (Map.Entry) iterator.next(); - String chartID = (String) entry.getKey(); + String priority = (String) entry.getKey(); String plotID = plot.getPlotID(); - if (plotInChart(plotID, chartID)) { - return getReportDataSourcePane(chartID, plot, parent); + if (plotInChart(plotID, priority)) { + return getReportDataSourcePane(priority, plot, parent); } } - return getReportDataSourcePane(ChartTypeManager.DEFAULT_CHART_ID, plot, parent); + return getReportDataSourcePane(ChartTypeManager.CHART_PRIORITY, plot, parent); } - private boolean plotInChart(String plotID, String chartID) { + private boolean plotInChart(String plotID, String priority) { return chartTypeInterfaces != null - && chartTypeInterfaces.containsKey(chartID) - && chartTypeInterfaces.get(chartID).containsKey(plotID); + && chartTypeInterfaces.containsKey(priority) + && chartTypeInterfaces.get(priority).containsKey(plotID); } - private AbstractReportDataContentPane getReportDataSourcePane(String chartID, Plot plot, ChartDataPane parent) { - return chartTypeInterfaces.get(chartID).get(plot.getPlotID()).getReportDataSourcePane(plot, parent); + private AbstractReportDataContentPane getReportDataSourcePane(String priority, Plot plot, ChartDataPane parent) { + return chartTypeInterfaces.get(priority).get(plot.getPlotID()).getReportDataSourcePane(plot, parent); } @@ -407,16 +402,16 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh Iterator iterator = chartTypeInterfaces.entrySet().iterator(); while (iterator.hasNext()){ Map.Entry entry = (Map.Entry) iterator.next(); - String chartID = (String) entry.getKey(); - if (plotInChart(plot.getPlotID(), chartID)) { - return getPlotConditionPane(chartID, plot); + String priority = (String) entry.getKey(); + if (plotInChart(plot.getPlotID(), priority)) { + return getPlotConditionPane(priority, plot); } } - return getPlotConditionPane(ChartTypeManager.DEFAULT_CHART_ID, plot); + return getPlotConditionPane(ChartTypeManager.CHART_PRIORITY, plot); } - private ConditionAttributesPane getPlotConditionPane(String chartID, Plot plot) { - return chartTypeInterfaces.get(chartID).get(plot.getPlotID()).getPlotConditionPane(plot); + private ConditionAttributesPane getPlotConditionPane(String priority, Plot plot) { + return chartTypeInterfaces.get(priority).get(plot.getPlotID()).getPlotConditionPane(plot); } @@ -424,16 +419,16 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh Iterator iterator = chartTypeInterfaces.entrySet().iterator(); while (iterator.hasNext()){ Map.Entry entry = (Map.Entry) iterator.next(); - String chartID = (String) entry.getKey(); - if (plotInChart(plot.getPlotID(), chartID)) { - return getPlotSeriesPane(chartID, parent, plot); + String priority = (String) entry.getKey(); + if (plotInChart(plot.getPlotID(), priority)) { + return getPlotSeriesPane(priority, parent, plot); } } - return getPlotSeriesPane(ChartTypeManager.DEFAULT_CHART_ID, parent, plot); + return getPlotSeriesPane(ChartTypeManager.CHART_PRIORITY, parent, plot); } - private BasicBeanPane getPlotSeriesPane(String chartID, ChartStylePane parent, Plot plot) { - return chartTypeInterfaces.get(chartID).get(plot.getPlotID()).getPlotSeriesPane(parent, plot); + private BasicBeanPane getPlotSeriesPane(String priority, ChartStylePane parent, Plot plot) { + return chartTypeInterfaces.get(priority).get(plot.getPlotID()).getPlotSeriesPane(parent, plot); } /** @@ -446,19 +441,19 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh Iterator iterator = chartTypeInterfaces.entrySet().iterator(); while (iterator.hasNext()){ Map.Entry entry = (Map.Entry) iterator.next(); - String chartID = (String) entry.getKey(); - if (chartTypeInterfaces.get(chartID).containsKey(plotID)){ - return isUseDefaultPane(chartID, plotID); + String priority = (String) entry.getKey(); + if (chartTypeInterfaces.get(priority).containsKey(plotID)){ + return isUseDefaultPane(priority, plotID); } } return true; } - private boolean isUseDefaultPane(String chartID, String plotID){ + private boolean isUseDefaultPane(String priority, String plotID){ - if (chartTypeInterfaces.containsKey(chartID) && chartTypeInterfaces.get(chartID).containsKey(plotID)) { - return chartTypeInterfaces.get(chartID).get(plotID).isUseDefaultPane(); + if (chartTypeInterfaces.containsKey(priority) && chartTypeInterfaces.get(priority).containsKey(plotID)) { + return chartTypeInterfaces.get(priority).get(plotID).isUseDefaultPane(); } return true; @@ -476,7 +471,7 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh extraChartDesignInterfaceList.add(tagName); } if (IndependentChartUIProvider.XML_TAG.equals(tagName)) { - addChartInterface(reader.getAttrAsString("class", ""), reader.getAttrAsString("chartID", ChartTypeManager.DEFAULT_CHART_ID),reader.getAttrAsString("plotID", ""), simplify); + addChartInterface(reader.getAttrAsString("class", ""), reader.getAttrAsString("priority", ChartTypeManager.CHART_PRIORITY),reader.getAttrAsString("plotID", ""), simplify); } } } diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypePane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypePane.java index 78f3f6271..229206f4d 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypePane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypePane.java @@ -188,7 +188,7 @@ public class ChartTypePane extends AbstractChartAttrPane{ public void reactor(ChartCollection collection){ //重构需要重构下拉框选项和cardNames Chart chart = collection.getSelectedChart(); - String chartID = chart.getChartID(); + String chartID = chart.getPriority(); if (collection.getState() == SwitchState.DEFAULT){ chartID = StringUtils.EMPTY; } @@ -197,7 +197,7 @@ public class ChartTypePane extends AbstractChartAttrPane{ //重构下拉框选项 reactorComboBox(); //重新选择选中的下拉项 - chartID = chart.getChartID(); + chartID = chart.getPriority(); String plotID = chart.getPlot().getPlotID(); Object item = ChartTypeInterfaceManager.getInstance().getTitle4PopupWindow(chartID, plotID); jcb.setSelectedItem(item);