Browse Source

REPORT-5668 单元格元素与悬浮元素图表配置问题

master
yaoh.wu 7 years ago
parent
commit
ed78a57558
  1. 4
      designer/src/com/fr/design/module/DesignerModule.java
  2. 89
      designer_base/src/com/fr/design/actions/core/ActionFactory.java

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

@ -151,7 +151,7 @@ public class DesignerModule extends DesignModule {
ActionFactory.registerCellEditor(BiasTextPainter.class, new CellBiasTextPainterEditor());
ActionFactory.registerCellEditor(BufferedImage.class, new CellImageQuickEditor());
ActionFactory.registerChartCellEditorInEditor(new BasicChartQuickEditor());
ActionFactory.registerChartCellEditorInEditor(BasicChartQuickEditor.class);
Set<ElementUIProvider> providers = ExtraDesignClassManager.getInstance().getArray(ElementUIProvider.MARK_STRING);
for (ElementUIProvider provider : providers) {
@ -179,7 +179,7 @@ public class DesignerModule extends DesignModule {
ActionFactory.registerFloatEditor(Image.class, new FloatImageQuickEditor());
ActionFactory.registerFloatEditor(BufferedImage.class, new FloatImageQuickEditor());
ActionFactory.registerChartFloatEditorInEditor(new FloatChartQuickEditor());
ActionFactory.registerChartFloatEditorInEditor(FloatChartQuickEditor.class);
}
/**

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

@ -30,15 +30,25 @@ import java.util.concurrent.ConcurrentMap;
public class ActionFactory {
private static LinkedHashSet<Class<?>> actionClasses = new LinkedHashSet<>();
private static LinkedHashSet<Class<?>> floatActionClasses = new LinkedHashSet<>();
private static Class chartCollectionClass = null;
/**
* 悬浮元素编辑器
* 无需每次实例化的悬浮元素编辑器
*/
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, Class<? extends QuickEditor>> floatEditorClass = new ConcurrentHashMap<>();
/**
* 需要每次实例化的单元格元素编辑器
*/
private static ConcurrentMap<Class, Class<? extends QuickEditor>> cellEditorClass = new ConcurrentHashMap<>();
private static UpdateAction chartPreStyleAction = null;
private static UpdateAction chartMapEditorAction = null;
@ -46,7 +56,7 @@ public class ActionFactory {
}
/**
* 注册单元格编辑器
* 注册无需每次实例化的单元格元素编辑器
*
* @param clazz 单元格属性类型
* @param editor 单元格编辑器实例
@ -57,7 +67,7 @@ public class ActionFactory {
/**
* 注册悬浮元素编辑器
* 注册无需每次实例化的悬浮元素编辑器
*
* @param clazz 悬浮元素类型
* @param editor 悬浮元素编辑器实例
@ -66,6 +76,28 @@ public class ActionFactory {
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, 所以分开注册.
*
@ -97,22 +129,22 @@ public class ActionFactory {
/**
* 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) {
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) {
cellEditor.put(chartCollectionClass, editor);
registerCellEditorClass(chartCollectionClass, editorClass);
}
}
@ -153,7 +185,7 @@ public class ActionFactory {
* @return 编辑器实例
*/
public static QuickEditor getFloatEditor(Class clazz) {
return createEditor(clazz, floatEditor);
return createEditor(clazz, floatEditor, floatEditorClass);
}
/**
@ -163,7 +195,7 @@ public class ActionFactory {
* @return 编辑器实例
*/
public static QuickEditor getCellEditor(Class clazz) {
return createEditor(clazz, cellEditor);
return createEditor(clazz, cellEditor, cellEditorClass);
}
public static UpdateAction createAction(Class clazz) {
@ -299,17 +331,40 @@ public class ActionFactory {
return actions.toArray(new UpdateAction[actions.size()]);
}
private static QuickEditor createEditor(Class clazz, Map<Class, QuickEditor> editorMap) {
QuickEditor c = findQuickEditorClass(clazz, editorMap);
private static QuickEditor createEditor(Class clazz, Map<Class, QuickEditor> editorMap, Map<Class, Class<? extends QuickEditor>> editorClassMap) {
QuickEditor c = findQuickEditor(clazz, editorMap);
if (c == null) {
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 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);
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) {
Class superClazz = clazz.getSuperclass();
if (superClazz == null) {

Loading…
Cancel
Save