Browse Source

CHART-3460 设计器启动慢

final/10.0
zheng 6 years ago
parent
commit
04cbb4e932
  1. 44
      designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java
  2. 2
      designer-chart/src/main/java/com/fr/design/chart/ChartDesignerActivator.java
  3. 21
      designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java
  4. 10
      designer-chart/src/main/java/com/fr/design/chart/gui/ChartWidgetOption.java
  5. 6
      designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java
  6. 4
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java

44
designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java

@ -121,12 +121,17 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
return classManager; return classManager;
} }
static { static {
readDefault(); readDefault();
readVanChart(); readVanChart();
PluginModule.registerAgent(PluginModule.ExtraChartDesign, classManager); PluginModule.registerAgent(PluginModule.ExtraChartDesign, classManager);
}
//安装插件,图表类型热更新。
//不在static原因:放在static,启动过程中图表插件init也会触发(不需要)
public static void addPluginChangedListener() {
GeneralContext.listenPluginRunningChanged(new PluginEventListener() { GeneralContext.listenPluginRunningChanged(new PluginEventListener() {
@Override @Override
@ -151,42 +156,21 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
ChartInternationalNameContentBean[] typeName = ChartTypeManager.getInstance().getAllChartBaseNames(); ChartInternationalNameContentBean[] typeName = ChartTypeManager.getInstance().getAllChartBaseNames();
ChartWidgetOption[] child = new ChartWidgetOption[typeName.length]; ChartWidgetOption[] child = new ChartWidgetOption[typeName.length];
final Chart[][] allCharts = new Chart[typeName.length][]; int index = 0;
for (int i = 0; i < typeName.length; i++) { for (ChartInternationalNameContentBean bean : typeName) {
String plotID = typeName[i].getPlotID(); String plotID = bean.getPlotID();
Chart[] rowChart = ChartTypeManager.getInstance().getChartTypes(plotID); Chart[] rowChart = ChartTypeManager.getInstance().getChartTypes(plotID);
if (ArrayUtils.isEmpty(rowChart)) { if (ArrayUtils.isEmpty(rowChart) && !ChartTypeManager.innerChart(plotID)) {
continue; continue;
} }
String iconPath = ChartTypeInterfaceManager.getInstance().getIconPath(plotID); String iconPath = ChartTypeInterfaceManager.getInstance().getIconPath(plotID);
Icon icon = IOUtils.readIcon(iconPath); Icon icon = IOUtils.readIcon(iconPath);
child[i] = new ChartWidgetOption(com.fr.design.i18n.Toolkit.i18nText(typeName[i].getName()), icon, ChartEditor.class, rowChart[0]); child[index] = new ChartWidgetOption(com.fr.design.i18n.Toolkit.i18nText(bean.getName()), icon, ChartEditor.class, plotID);
index++;
allCharts[i] = rowChart;
} }
return child; return child;
} }
//加载所有图表图片
private static void initAllChartsDemoImage(Chart[][] allCharts) {
for (Chart[] rowChart : allCharts) {
if (rowChart == null) {
continue;
}
//加载初始化图表模型图片
initChartsDemoImage(rowChart);
}
}
private static void initChartsDemoImage(Chart[] rowChart) {
for (Chart aRowChart : rowChart) {
//此时,为图片生成模型数据
aRowChart.createSlotImage();
}
}
private static void readVanChart() { private static void readVanChart() {
@ -252,7 +236,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
} }
} }
private static IndependentChartUIProvider getChartTypeInterface(String plotID) { private IndependentChartUIProvider getChartTypeInterface(String plotID) {
if (idAndPriorityMap.containsKey(plotID)) { if (idAndPriorityMap.containsKey(plotID)) {
String priority = idAndPriorityMap.get(plotID); String priority = idAndPriorityMap.get(plotID);
if (chartTypeInterfaces.containsKey(priority)) { if (chartTypeInterfaces.containsKey(priority)) {
@ -303,7 +287,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
} }
} }
private static String getChartName(String plotID, IndependentChartUIProvider provider) { private String getChartName(String plotID, IndependentChartUIProvider provider) {
String name = provider.getPlotTypeTitle4PopupWindow(); String name = provider.getPlotTypeTitle4PopupWindow();
if (StringUtils.isEmpty(name)) { if (StringUtils.isEmpty(name)) {
name = ChartTypeManager.getInstance().getChartName(plotID); name = ChartTypeManager.getInstance().getChartName(plotID);

2
designer-chart/src/main/java/com/fr/design/chart/ChartDesignerActivator.java

@ -52,6 +52,8 @@ public class ChartDesignerActivator extends Activator implements Prepare {
DesignImageEvent.registerDefaultCallbackEvent(HistoryTemplateListPane.getInstance()); DesignImageEvent.registerDefaultCallbackEvent(HistoryTemplateListPane.getInstance());
DesignImageEvent.registerDownloadSourcesEvent(new DownloadOnlineSourcesHelper()); DesignImageEvent.registerDownloadSourcesEvent(new DownloadOnlineSourcesHelper());
ChartTypeInterfaceManager.addPluginChangedListener();
} }
@Override @Override

21
designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java

@ -15,25 +15,32 @@ import com.fr.chart.charttypes.ChartTypeManager;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.license.exception.RegistEditionException; import com.fr.license.exception.RegistEditionException;
import com.fr.license.function.VT4FR; import com.fr.license.function.VT4FR;
import javax.swing.*; import javax.swing.BorderFactory;
import javax.swing.DefaultListCellRenderer;
import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.ListCellRenderer;
import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener; import javax.swing.event.ListSelectionListener;
import java.awt.*; import java.awt.Color;
import java.awt.Component;
public class ChartTypePane extends ChartCommonWizardPane { public class ChartTypePane extends ChartCommonWizardPane {
private static final long serialVersionUID = -1175602484968520546L; private static final long serialVersionUID = -1175602484968520546L;
private ChartInternationalNameContentBean[] typeName = ChartTypeManager.getInstance().getAllChartBaseNames(); private ChartInternationalNameContentBean[] typeName = ChartTypeManager.getInstanceWithCheck().getAllChartBaseNames();
private Chart[][] charts4Icon = null; private Chart[][] charts4Icon = null;
{ {
charts4Icon = new Chart[this.typeName.length][]; charts4Icon = new Chart[this.typeName.length][];
for (int i = 0; i < this.typeName.length; i++) { for (int i = 0; i < this.typeName.length; i++) {
Chart[] rowCharts = ChartTypeManager.getInstance().getChartTypes(this.typeName[i].getPlotID()); Chart[] rowCharts = ChartTypeManager.getInstanceWithCheck().getChartTypes(this.typeName[i].getPlotID());
int rowChartsCount = rowCharts.length; int rowChartsCount = rowCharts.length;
charts4Icon[i] = new Chart[rowChartsCount]; charts4Icon[i] = new Chart[rowChartsCount];
for (int j = 0; j < rowChartsCount; j++) { for (int j = 0; j < rowChartsCount; j++) {
@ -137,7 +144,7 @@ public class ChartTypePane extends ChartCommonWizardPane {
int subIndex = 0; int subIndex = 0;
for (int i = 0; i < typeName.length; i++) { for (int i = 0; i < typeName.length; i++) {
Chart [] charts = ChartTypeManager.getInstance().getChartTypes(typeName[i].getPlotID()); Chart[] charts = ChartTypeManager.getInstanceWithCheck().getChartTypes(typeName[i].getPlotID());
for (int j = 0; j < charts.length; j++) { for (int j = 0; j < charts.length; j++) {
if (charts[j].getPlot().match4GUI(plot)) { if (charts[j].getPlot().match4GUI(plot)) {
mainIndex = i; mainIndex = i;
@ -154,7 +161,7 @@ public class ChartTypePane extends ChartCommonWizardPane {
public void update(Chart oldChart) { public void update(Chart oldChart) {
String plotID = typeName[mainTypeList.getSelectedIndex()].getPlotID(); String plotID = typeName[mainTypeList.getSelectedIndex()].getPlotID();
Chart chart = ChartTypeManager.getInstance().getChartTypes(plotID)[iconViewList.getSelectedIndex()]; Chart chart = ChartTypeManager.getInstanceWithCheck().getChartTypes(plotID)[iconViewList.getSelectedIndex()];
if(chart.getPlot() != null){ if(chart.getPlot() != null){
if(chart.getPlot() instanceof MapPlot && !supportMap()){ if(chart.getPlot() instanceof MapPlot && !supportMap()){
JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Map_Not_Supported")); JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Map_Not_Supported"));

10
designer-chart/src/main/java/com/fr/design/chart/gui/ChartWidgetOption.java

@ -2,11 +2,12 @@ package com.fr.design.chart.gui;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Chart;
import com.fr.chart.charttypes.ChartTypeManager;
import com.fr.design.gui.core.WidgetOption; import com.fr.design.gui.core.WidgetOption;
import com.fr.form.ui.ChartEditor; import com.fr.form.ui.ChartEditor;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import javax.swing.*; import javax.swing.Icon;
/** /**
* 表单中 图表控件信息, 名称, class, form中通过XcreatorUtils反射类 实现XChartEditor的初始化. * 表单中 图表控件信息, 名称, class, form中通过XcreatorUtils反射类 实现XChartEditor的初始化.
@ -19,13 +20,13 @@ public class ChartWidgetOption extends WidgetOption {
private String optionName; private String optionName;
private Icon optionIcon; private Icon optionIcon;
private Class<? extends ChartEditor> widgetClass; private Class<? extends ChartEditor> widgetClass;
private Chart chart; private String chartID;
public ChartWidgetOption(String optionName, Icon optionIcon, Class<? extends ChartEditor> widgetClass, Chart chart) { public ChartWidgetOption(String optionName, Icon optionIcon, Class<? extends ChartEditor> widgetClass, String chartID) {
this.optionName = optionName; this.optionName = optionName;
this.optionIcon = optionIcon; this.optionIcon = optionIcon;
this.widgetClass = widgetClass; this.widgetClass = widgetClass;
this.chart = chart; this.chartID = chartID;
} }
/** /**
@ -37,6 +38,7 @@ public class ChartWidgetOption extends WidgetOption {
Class<? extends ChartEditor> clz = widgetClass(); Class<? extends ChartEditor> clz = widgetClass();
try { try {
ChartEditor widget = clz.newInstance(); ChartEditor widget = clz.newInstance();
Chart chart = ChartTypeManager.getInstanceWithCheck().getChartTypes(this.chartID)[0];
widget.addChart((Chart) chart.clone()); widget.addChart((Chart) chart.clone());
return widget; return widget;
} catch (InstantiationException e) { } catch (InstantiationException e) {

6
designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java

@ -15,8 +15,8 @@ import com.fr.design.module.DesignModuleFactory;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import java.awt.BorderLayout;
import java.awt.*; import java.awt.Dimension;
import java.util.HashMap; import java.util.HashMap;
/** /**
@ -66,7 +66,7 @@ public class ChartHyperPoplinkPane extends AbstractHyperLinkPane<ChartHyperPopli
private ChartCollection createChartCollection() { private ChartCollection createChartCollection() {
ChartCollection cc = new ChartCollection(); ChartCollection cc = new ChartCollection();
Chart chart = ChartTypeManager.getFirstChart(); Chart chart = ChartTypeManager.getInstanceWithCheck().getFirstChart();
if (chart != null) { if (chart != null) {
try { try {
cc.addChart((Chart) chart.clone()); cc.addChart((Chart) chart.clone());

4
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java

@ -173,9 +173,9 @@ public class ChartTypePane extends AbstractChartAttrPane{
//plot改变的话图表类型就算改变了 //plot改变的话图表类型就算改变了
chart.setWrapperName(ChartTypeManager.getInstance().getWrapperName(plotID)); chart.setWrapperName(ChartTypeManager.getInstanceWithCheck().getWrapperName(plotID));
chart.setChartImagePath(ChartTypeManager.getInstance().getChartImagePath(plotID)); chart.setChartImagePath(ChartTypeManager.getInstanceWithCheck().getChartImagePath(plotID));
boolean isUseDefault = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(plotID); boolean isUseDefault = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(plotID);

Loading…
Cancel
Save