Browse Source

Merge pull request #1480 in BA/design from ~YAOH.WU/a_design_0811:release/nine to release/9.0

* commit 'fb1f22eae842b50751fb22cd9cd6d3e184d6facb':
  优先处理内存释放问题
  REPORT-5668 单元格元素与悬浮元素图表配置问题
master
superman 7 years ago
parent
commit
4960fded8e
  1. 36
      designer/src/com/fr/design/module/DesignerModule.java
  2. 91
      designer_base/src/com/fr/design/actions/core/ActionFactory.java

36
designer/src/com/fr/design/module/DesignerModule.java

@ -141,22 +141,22 @@ public class DesignerModule extends DesignModule {
*/ */
private void registerCellEditor() { private void registerCellEditor() {
ActionFactory.registerCellEditor(String.class, new CellStringQuickEditor()); ActionFactory.registerCellEditorClass(String.class, CellStringQuickEditor.class);
ActionFactory.registerCellEditor(Number.class, new CellStringQuickEditor()); ActionFactory.registerCellEditorClass(Number.class, CellStringQuickEditor.class);
ActionFactory.registerCellEditor(BaseFormula.class, new CellFormulaQuickEditor()); ActionFactory.registerCellEditorClass(BaseFormula.class, CellFormulaQuickEditor.class);
ActionFactory.registerCellEditor(SubReport.class, new CellSubReportEditor()); ActionFactory.registerCellEditorClass(SubReport.class, CellSubReportEditor.class);
ActionFactory.registerCellEditor(RichText.class, new CellRichTextEditor()); ActionFactory.registerCellEditorClass(RichText.class, CellRichTextEditor.class);
ActionFactory.registerCellEditor(DSColumn.class, new CellDSColumnEditor()); ActionFactory.registerCellEditorClass(DSColumn.class, CellDSColumnEditor.class);
ActionFactory.registerCellEditor(Image.class, new CellImageQuickEditor()); ActionFactory.registerCellEditorClass(Image.class, CellImageQuickEditor.class);
ActionFactory.registerCellEditor(BiasTextPainter.class, new CellBiasTextPainterEditor()); ActionFactory.registerCellEditorClass(BiasTextPainter.class, CellBiasTextPainterEditor.class);
ActionFactory.registerCellEditor(BufferedImage.class, new CellImageQuickEditor()); ActionFactory.registerCellEditorClass(BufferedImage.class, CellImageQuickEditor.class);
ActionFactory.registerChartCellEditorInEditor(new BasicChartQuickEditor()); ActionFactory.registerChartCellEditorInEditor(BasicChartQuickEditor.class);
Set<ElementUIProvider> providers = ExtraDesignClassManager.getInstance().getArray(ElementUIProvider.MARK_STRING); Set<ElementUIProvider> providers = ExtraDesignClassManager.getInstance().getArray(ElementUIProvider.MARK_STRING);
for (ElementUIProvider provider : providers) { for (ElementUIProvider provider : providers) {
try { try {
ActionFactory.registerCellEditor(provider.targetObjectClass(), provider.quickEditor().newInstance()); ActionFactory.registerCellEditorClass(provider.targetObjectClass(), provider.quickEditor());
} catch (Exception e) { } catch (Exception e) {
FRLogger.getLogger().error(e.getMessage(), e); FRLogger.getLogger().error(e.getMessage(), e);
} }
@ -173,13 +173,13 @@ public class DesignerModule extends DesignModule {
* kunnat: 注册悬浮选中Editor * kunnat: 注册悬浮选中Editor
*/ */
private void registerFloatEditor() { private void registerFloatEditor() {
ActionFactory.registerFloatEditor(String.class, new FloatStringQuickEditor());
ActionFactory.registerFloatEditor(Formula.class, new FloatStringQuickEditor());
ActionFactory.registerFloatEditor(Image.class, new FloatImageQuickEditor());
ActionFactory.registerFloatEditor(BufferedImage.class, new FloatImageQuickEditor());
ActionFactory.registerChartFloatEditorInEditor(new FloatChartQuickEditor()); ActionFactory.registerFloatEditorClass(String.class, FloatStringQuickEditor.class);
ActionFactory.registerFloatEditorClass(Formula.class, FloatStringQuickEditor.class);
ActionFactory.registerFloatEditorClass(Image.class, FloatImageQuickEditor.class);
ActionFactory.registerFloatEditorClass(BufferedImage.class, FloatImageQuickEditor.class);
ActionFactory.registerChartFloatEditorInEditor(FloatChartQuickEditor.class);
} }
/** /**

91
designer_base/src/com/fr/design/actions/core/ActionFactory.java

@ -30,15 +30,25 @@ import java.util.concurrent.ConcurrentMap;
public class ActionFactory { public class ActionFactory {
private static LinkedHashSet<Class<?>> actionClasses = new LinkedHashSet<>(); private static LinkedHashSet<Class<?>> actionClasses = new LinkedHashSet<>();
private static LinkedHashSet<Class<?>> floatActionClasses = new LinkedHashSet<>(); private static LinkedHashSet<Class<?>> floatActionClasses = new LinkedHashSet<>();
private static Class chartCollectionClass = null;
/** /**
* 悬浮元素编辑器 * 无需每次实例化的悬浮元素编辑器
*/ */
private static ConcurrentMap<Class, QuickEditor> floatEditor = new ConcurrentHashMap<>(); private static ConcurrentMap<Class, QuickEditor> floatEditor = new ConcurrentHashMap<>();
private static Class chartCollectionClass = null;
/** /**
* 单元格元素编辑器 * 无需每次实例化的单元格元素编辑器
*/ */
private static ConcurrentMap<Class, QuickEditor> cellEditor = new ConcurrentHashMap<>(); private static ConcurrentMap<Class, QuickEditor> cellEditor = new ConcurrentHashMap<>();
/**
* 需要每次实例化的悬浮元素编辑器
*/
private static ConcurrentMap<Class, Class<? extends QuickEditor>> floatEditorClass = new ConcurrentHashMap<>();
/**
* 需要每次实例化的单元格元素编辑器
*/
private static ConcurrentMap<Class, Class<? extends QuickEditor>> cellEditorClass = new ConcurrentHashMap<>();
private static UpdateAction chartPreStyleAction = null; private static UpdateAction chartPreStyleAction = null;
private static UpdateAction chartMapEditorAction = null; private static UpdateAction chartMapEditorAction = null;
@ -46,7 +56,7 @@ public class ActionFactory {
} }
/** /**
* 注册单元格编辑器 * 注册无需每次实例化的单元格元素编辑器
* *
* @param clazz 单元格属性类型 * @param clazz 单元格属性类型
* @param editor 单元格编辑器实例 * @param editor 单元格编辑器实例
@ -57,7 +67,7 @@ public class ActionFactory {
/** /**
* 注册悬浮元素编辑器 * 注册无需每次实例化的悬浮元素编辑器
* *
* @param clazz 悬浮元素类型 * @param clazz 悬浮元素类型
* @param editor 悬浮元素编辑器实例 * @param editor 悬浮元素编辑器实例
@ -66,6 +76,28 @@ public class ActionFactory {
floatEditor.put(clazz, editor); floatEditor.put(clazz, editor);
} }
/**
* 注册需要每次实例化的单元格元素编辑器
*
* @param clazz 单元格属性类型
* @param editorClass 单元格编辑器类
*/
public static void registerCellEditorClass(Class clazz, Class<? extends QuickEditor> editorClass) {
cellEditorClass.put(clazz, editorClass);
}
/**
* 注册需要每次实例化的悬浮元素编辑器
*
* @param clazz 悬浮元素类型
* @param editorClass 悬浮元素编辑器类
*/
public static void registerFloatEditorClass(Class clazz, Class<? extends QuickEditor> editorClass) {
floatEditorClass.put(clazz, editorClass);
}
/** /**
* kunsnat: 图表注册 悬浮元素编辑器 , 因为ChartCollecion和ChartQuickEditor一个在Chart,一个在Designer, 所以分开注册. * kunsnat: 图表注册 悬浮元素编辑器 , 因为ChartCollecion和ChartQuickEditor一个在Chart,一个在Designer, 所以分开注册.
* *
@ -97,22 +129,22 @@ public class ActionFactory {
/** /**
* kunsnat: 图表注册 悬浮元素编辑器 , 因为ChartCollection和ChartQuickEditor一个在Chart,一个在Designer, 所以分开注册. * kunsnat: 图表注册 悬浮元素编辑器 , 因为ChartCollection和ChartQuickEditor一个在Chart,一个在Designer, 所以分开注册.
* *
* @param editor 待说明 * @param editorClass 悬浮元素图表编辑器类
*/ */
public static void registerChartFloatEditorInEditor(QuickEditor editor) { public static void registerChartFloatEditorInEditor(Class<? extends QuickEditor> editorClass) {
if (chartCollectionClass != null) { if (chartCollectionClass != null) {
floatEditor.put(chartCollectionClass, editor); registerFloatEditorClass(chartCollectionClass, editorClass);
} }
} }
/** /**
* kunsnat: 图表注册 悬浮元素编辑器 , 因为ChartCollecion和ChartQuickEditor一个在Chart,一个在Designer, 所以分开注册. * kunsnat: 图表注册 单元格元素编辑器 , 因为ChartCollecion和ChartQuickEditor一个在Chart,一个在Designer, 所以分开注册.
* *
* @param editor 待说明 * @param editorClass 单元格元素图表编辑器类
*/ */
public static void registerChartCellEditorInEditor(QuickEditor editor) { public static void registerChartCellEditorInEditor(Class<? extends QuickEditor> editorClass) {
if (chartCollectionClass != null) { if (chartCollectionClass != null) {
cellEditor.put(chartCollectionClass, editor); registerCellEditorClass(chartCollectionClass, editorClass);
} }
} }
@ -153,7 +185,7 @@ public class ActionFactory {
* @return 编辑器实例 * @return 编辑器实例
*/ */
public static QuickEditor getFloatEditor(Class clazz) { public static QuickEditor getFloatEditor(Class clazz) {
return createEditor(clazz, floatEditor); return createEditor(clazz, floatEditor, floatEditorClass);
} }
/** /**
@ -163,7 +195,7 @@ public class ActionFactory {
* @return 编辑器实例 * @return 编辑器实例
*/ */
public static QuickEditor getCellEditor(Class clazz) { public static QuickEditor getCellEditor(Class clazz) {
return createEditor(clazz, cellEditor); return createEditor(clazz, cellEditor, cellEditorClass);
} }
public static UpdateAction createAction(Class clazz) { public static UpdateAction createAction(Class clazz) {
@ -299,17 +331,40 @@ public class ActionFactory {
return actions.toArray(new UpdateAction[actions.size()]); return actions.toArray(new UpdateAction[actions.size()]);
} }
private static QuickEditor createEditor(Class clazz, Map<Class, QuickEditor> editorMap) { private static QuickEditor createEditor(Class clazz, Map<Class, QuickEditor> editorMap, Map<Class, Class<? extends QuickEditor>> editorClassMap) {
QuickEditor c = findQuickEditorClass(clazz, editorMap); QuickEditor c = findQuickEditor(clazz, editorMap);
if (c == null) { if (c == null) {
FRLogger.getLogger().error("No Such Editor"); Class<? extends QuickEditor> cClazz = findQuickEditorClass(clazz, editorClassMap);
if (cClazz == null) {
FRLogger.getLogger().error("No Such Editor");
return null;
}
try {
Constructor<? extends QuickEditor> constructor = cClazz.getDeclaredConstructor();
constructor.setAccessible(true);
return constructor.newInstance();
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
}
return null; return null;
} }
return c; return c;
} }
private static QuickEditor findQuickEditorClass(Class clazz, Map<Class, QuickEditor> editorMap) { private static QuickEditor findQuickEditor(Class clazz, Map<Class, QuickEditor> editorMap) {
QuickEditor c = editorMap.get(clazz); QuickEditor c = editorMap.get(clazz);
if (c == null) {
Class superClazz = clazz.getSuperclass();
if (superClazz == null) {
return null;
}
return findQuickEditor(superClazz, editorMap);
}
return c;
}
private static Class<? extends QuickEditor> findQuickEditorClass(Class clazz, Map<Class, Class<? extends QuickEditor>> editorMap) {
Class<? extends QuickEditor> c = editorMap.get(clazz);
if (c == null) { if (c == null) {
Class superClazz = clazz.getSuperclass(); Class superClazz = clazz.getSuperclass();
if (superClazz == null) { if (superClazz == null) {

Loading…
Cancel
Save