From b5b3bc4c4c572a2cff2595814d571e6652280dfb Mon Sep 17 00:00:00 2001 From: xiaohu Date: Tue, 5 Jul 2016 14:49:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=92=E4=BB=B6=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/ChartTypeInterfaceManager.java | 73 ++++++++++++------- 1 file changed, 47 insertions(+), 26 deletions(-) diff --git a/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java b/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java index 9002f4af79..ae2164de90 100644 --- a/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java +++ b/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java @@ -1,23 +1,30 @@ package com.fr.design; import com.fr.chart.base.ChartConstants; +import com.fr.chart.base.ChartInternationalNameContentBean; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.chart.charttypes.ChartTypeManager; import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.chart.fun.IndependentChartUIProvider; +import com.fr.design.chart.gui.ChartWidgetOption; import com.fr.design.chartinterface.*; import com.fr.design.condition.ConditionAttributesPane; +import com.fr.design.gui.core.WidgetOption; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.mainframe.chart.AbstractChartAttrPane; import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane; import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; +import com.fr.design.module.DesignModuleFactory; import com.fr.file.XMLFileManager; +import com.fr.form.ui.ChartEditor; import com.fr.general.FRLogger; import com.fr.general.GeneralContext; +import com.fr.general.IOUtils; +import com.fr.general.Inter; import com.fr.plugin.PluginCollector; import com.fr.plugin.PluginLicenseManager; import com.fr.plugin.PluginMessage; @@ -30,6 +37,7 @@ import com.fr.stable.plugin.PluginSimplify; import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLableReader; +import javax.swing.*; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; @@ -72,46 +80,59 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh public void success() { if (chartTypeInterfaces != null) { readDefault(); + //重新注册designModuleFactory + DesignModuleFactory.registerExtraWidgetOptions(initWidgetOption()); } } }); } + public static WidgetOption[] initWidgetOption(){ + ChartInternationalNameContentBean[] typeName = ChartTypeManager.getInstance().getAllChartBaseNames(); + ChartWidgetOption[] child = new ChartWidgetOption[typeName.length]; + for (int i = 0; i < typeName.length; i++) { + String plotID = typeName[i].getPlotID(); + Chart[] rowChart = ChartTypeManager.getInstance().getChartTypes(plotID); + if(rowChart == null) { + continue; + } + String iconPath = ChartTypeInterfaceManager.getInstance().getIconPath(plotID); + Icon icon = IOUtils.readIcon(iconPath); + child[i] = new ChartWidgetOption(Inter.getLocText(typeName[i].getName()), icon, ChartEditor.class, rowChart[0]); + } + return child; + } + private synchronized static void envChanged() { classManager = null; } private static void readDefault() { - - if (!isReadDefault) { - chartTypeInterfaces.put(ChartConstants.COLUMN_CHART, new ColumnIndependentChartInterface()); - chartTypeInterfaces.put(ChartConstants.LINE_CHART, new LineIndependentChartInterface()); - chartTypeInterfaces.put(ChartConstants.BAR_CHART, new BarIndependentChartInterface()); - chartTypeInterfaces.put(ChartConstants.PIE_CHART, new PieIndependentChartInterface()); - chartTypeInterfaces.put(ChartConstants.AREA_CHART, new AreaIndependentChartInterface()); - chartTypeInterfaces.put(ChartConstants.SCATTER_CHART, new XYScatterIndependentChartInterface()); - chartTypeInterfaces.put(ChartConstants.BUBBLE_CHART, new BubbleIndependentChartInterface()); - chartTypeInterfaces.put(ChartConstants.RADAR_CHART, new RadarIndependentChartInterface()); - chartTypeInterfaces.put(ChartConstants.STOCK_CHART, new StockIndependentChartInterface()); - chartTypeInterfaces.put(ChartConstants.METER_CHART, new MeterIndependentChartInterface()); - chartTypeInterfaces.put(ChartConstants.RANGE_CHART, new RangeIndependentChartInterface()); - chartTypeInterfaces.put(ChartConstants.CUSTOM_CHART, new CustomIndependentChartInterface()); - chartTypeInterfaces.put(ChartConstants.GANTT_CHART, new GanttIndependentChartInterface()); - chartTypeInterfaces.put(ChartConstants.DONUT_CHART, new DonutIndependentChartInterface()); - chartTypeInterfaces.put(ChartConstants.MAP_CHART, new MapIndependentChartInterface()); - chartTypeInterfaces.put(ChartConstants.GIS_CHAER, new GisMapIndependentChartInterface()); - chartTypeInterfaces.put(ChartConstants.FUNNEL_CHART, new FunnelIndependentChartInterface()); - isReadDefault = true; - } - - + chartTypeInterfaces.put(ChartConstants.COLUMN_CHART, new ColumnIndependentChartInterface()); + chartTypeInterfaces.put(ChartConstants.LINE_CHART, new LineIndependentChartInterface()); + chartTypeInterfaces.put(ChartConstants.BAR_CHART, new BarIndependentChartInterface()); + chartTypeInterfaces.put(ChartConstants.PIE_CHART, new PieIndependentChartInterface()); + chartTypeInterfaces.put(ChartConstants.AREA_CHART, new AreaIndependentChartInterface()); + chartTypeInterfaces.put(ChartConstants.SCATTER_CHART, new XYScatterIndependentChartInterface()); + chartTypeInterfaces.put(ChartConstants.BUBBLE_CHART, new BubbleIndependentChartInterface()); + chartTypeInterfaces.put(ChartConstants.RADAR_CHART, new RadarIndependentChartInterface()); + chartTypeInterfaces.put(ChartConstants.STOCK_CHART, new StockIndependentChartInterface()); + chartTypeInterfaces.put(ChartConstants.METER_CHART, new MeterIndependentChartInterface()); + chartTypeInterfaces.put(ChartConstants.RANGE_CHART, new RangeIndependentChartInterface()); + chartTypeInterfaces.put(ChartConstants.CUSTOM_CHART, new CustomIndependentChartInterface()); + chartTypeInterfaces.put(ChartConstants.GANTT_CHART, new GanttIndependentChartInterface()); + chartTypeInterfaces.put(ChartConstants.DONUT_CHART, new DonutIndependentChartInterface()); + chartTypeInterfaces.put(ChartConstants.MAP_CHART, new MapIndependentChartInterface()); + chartTypeInterfaces.put(ChartConstants.GIS_CHAER, new GisMapIndependentChartInterface()); + chartTypeInterfaces.put(ChartConstants.FUNNEL_CHART, new FunnelIndependentChartInterface()); } public String getIconPath(String plotID) { - if (!isReadDefault){ - readDefault(); + if (chartTypeInterfaces.get(plotID) != null) { + return chartTypeInterfaces.get(plotID).getIconPath(); + }else { + return StringUtils.EMPTY; } - return chartTypeInterfaces.get(plotID).getIconPath(); } /**