|
|
|
@ -5,13 +5,9 @@ package com.fr.design.designer.creator;
|
|
|
|
|
|
|
|
|
|
import com.fr.base.FRContext; |
|
|
|
|
import com.fr.design.ExtraDesignClassManager; |
|
|
|
|
import com.fr.design.designer.creator.cardlayout.XCardAddButton; |
|
|
|
|
import com.fr.design.designer.creator.cardlayout.XCardSwitchButton; |
|
|
|
|
import com.fr.design.designer.creator.cardlayout.XWCardLayout; |
|
|
|
|
import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; |
|
|
|
|
import com.fr.design.designer.creator.cardlayout.XWCardTagLayout; |
|
|
|
|
import com.fr.design.designer.creator.cardlayout.XWCardTitleLayout; |
|
|
|
|
import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; |
|
|
|
|
import com.fr.design.designer.creator.cardlayout.*; |
|
|
|
|
import com.fr.design.fun.FormWidgetOptionProvider; |
|
|
|
|
import com.fr.design.fun.ParameterWidgetOptionProvider; |
|
|
|
|
import com.fr.design.module.DesignModuleFactory; |
|
|
|
|
import com.fr.design.utils.gui.LayoutUtils; |
|
|
|
|
import com.fr.form.parameter.FormSubmitButton; |
|
|
|
@ -24,7 +20,13 @@ import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout;
|
|
|
|
|
import com.fr.form.ui.container.cardlayout.WCardTagLayout; |
|
|
|
|
import com.fr.form.ui.container.cardlayout.WCardTitleLayout; |
|
|
|
|
import com.fr.form.ui.container.cardlayout.WTabFitLayout; |
|
|
|
|
import com.fr.general.GeneralContext; |
|
|
|
|
import com.fr.general.IOUtils; |
|
|
|
|
import com.fr.plugin.context.PluginContext; |
|
|
|
|
import com.fr.plugin.injectable.PluginModule; |
|
|
|
|
import com.fr.plugin.manage.PluginFilter; |
|
|
|
|
import com.fr.plugin.observer.PluginEvent; |
|
|
|
|
import com.fr.plugin.observer.PluginEventListener; |
|
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
@ -38,11 +40,66 @@ import java.lang.reflect.Constructor;
|
|
|
|
|
* @since 6.5.3 |
|
|
|
|
*/ |
|
|
|
|
public class XCreatorUtils { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static java.util.Map<Class<? extends Widget>, Class<?>> objectMap = new java.util.HashMap<Class<? extends Widget>, Class<?>>(); |
|
|
|
|
|
|
|
|
|
private static java.util.Map<Class<? extends Widget>, Class<?>> extraObjectMap = new java.util.HashMap<Class<? extends Widget>, Class<?>>(); |
|
|
|
|
|
|
|
|
|
public static java.util.Map<Class<? extends Widget>, Class<?>> xLayoutMap = new java.util.HashMap<Class<? extends Widget>, Class<?>>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static { |
|
|
|
|
init(); |
|
|
|
|
GeneralContext.listenPluginRunningChanged(new PluginEventListener() { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void on(PluginEvent event) { |
|
|
|
|
|
|
|
|
|
reInitExtra(); |
|
|
|
|
} |
|
|
|
|
}, new PluginFilter() { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public boolean accept(PluginContext context) { |
|
|
|
|
|
|
|
|
|
return context.contain(PluginModule.ExtraDesign, ParameterWidgetOptionProvider.XML_TAG) |
|
|
|
|
|| context.contain(PluginModule.ExtraDesign, FormWidgetOptionProvider.XML_TAG); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static void init() { |
|
|
|
|
|
|
|
|
|
putDefault(); |
|
|
|
|
putExtraEditor(); |
|
|
|
|
putDefaultLayouts(); |
|
|
|
|
reInitExtra(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static void putDefaultLayouts() { |
|
|
|
|
|
|
|
|
|
xLayoutMap.put(WAbsoluteLayout.class, XWAbsoluteLayout.class); |
|
|
|
|
xLayoutMap.put(WParameterLayout.class, XWParameterLayout.class); |
|
|
|
|
xLayoutMap.put(WAbsoluteBodyLayout.class, XWAbsoluteBodyLayout.class); |
|
|
|
|
xLayoutMap.put(WAbsoluteLayout.class, XWAbsoluteLayout.class); |
|
|
|
|
xLayoutMap.put(WHorizontalBoxLayout.class, XWHorizontalBoxLayout.class); |
|
|
|
|
xLayoutMap.put(WBorderLayout.class, XWBorderLayout.class); |
|
|
|
|
xLayoutMap.put(WCardLayout.class, XWCardLayout.class); |
|
|
|
|
xLayoutMap.put(WVerticalBoxLayout.class, XWVerticalBoxLayout.class); |
|
|
|
|
xLayoutMap.put(WHorizontalSplitLayout.class, XWHorizontalSplitLayout.class); |
|
|
|
|
xLayoutMap.put(WVerticalSplitLayout.class, XWVerticalSplitLayout.class); |
|
|
|
|
xLayoutMap.put(WGridLayout.class, XWGridLayout.class); |
|
|
|
|
|
|
|
|
|
xLayoutMap.put(WFitLayout.class, XWFitLayout.class); |
|
|
|
|
xLayoutMap.put(WScaleLayout.class, XWScaleLayout.class); |
|
|
|
|
xLayoutMap.put(WTitleLayout.class, XWTitleLayout.class); |
|
|
|
|
xLayoutMap.put(WCardTagLayout.class, XWCardTagLayout.class); |
|
|
|
|
xLayoutMap.put(WCardTitleLayout.class, XWCardTitleLayout.class); |
|
|
|
|
xLayoutMap.put(WTabFitLayout.class, XWTabFitLayout.class); |
|
|
|
|
xLayoutMap.put(WCardMainBorderLayout.class, XWCardMainBorderLayout.class); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static void putDefault() { |
|
|
|
|
|
|
|
|
|
objectMap.put(TextEditor.class, XTextEditor.class); |
|
|
|
|
objectMap.put(TextArea.class, XTextArea.class); |
|
|
|
|
objectMap.put(NumberEditor.class, XNumberEditor.class); |
|
|
|
@ -73,40 +130,28 @@ public class XCreatorUtils {
|
|
|
|
|
objectMap.put(NameWidget.class, XNameWidget.class); |
|
|
|
|
objectMap.put(CardSwitchButton.class, XCardSwitchButton.class); |
|
|
|
|
objectMap.put(CardAddButton.class, XCardAddButton.class); |
|
|
|
|
putExtraEditor(); |
|
|
|
|
|
|
|
|
|
xLayoutMap.put(WAbsoluteLayout.class, XWAbsoluteLayout.class); |
|
|
|
|
xLayoutMap.put(WParameterLayout.class, XWParameterLayout.class); |
|
|
|
|
xLayoutMap.put(WAbsoluteBodyLayout.class, XWAbsoluteBodyLayout.class); |
|
|
|
|
xLayoutMap.put(WAbsoluteLayout.class, XWAbsoluteLayout.class); |
|
|
|
|
xLayoutMap.put(WHorizontalBoxLayout.class, XWHorizontalBoxLayout.class); |
|
|
|
|
xLayoutMap.put(WBorderLayout.class, XWBorderLayout.class); |
|
|
|
|
xLayoutMap.put(WCardLayout.class, XWCardLayout.class); |
|
|
|
|
xLayoutMap.put(WVerticalBoxLayout.class, XWVerticalBoxLayout.class); |
|
|
|
|
xLayoutMap.put(WHorizontalSplitLayout.class, XWHorizontalSplitLayout.class); |
|
|
|
|
xLayoutMap.put(WVerticalSplitLayout.class, XWVerticalSplitLayout.class); |
|
|
|
|
xLayoutMap.put(WGridLayout.class, XWGridLayout.class); |
|
|
|
|
|
|
|
|
|
xLayoutMap.put(WFitLayout.class, XWFitLayout.class); |
|
|
|
|
xLayoutMap.put(WScaleLayout.class, XWScaleLayout.class); |
|
|
|
|
xLayoutMap.put(WTitleLayout.class, XWTitleLayout.class); |
|
|
|
|
xLayoutMap.put(WCardTagLayout.class, XWCardTagLayout.class); |
|
|
|
|
xLayoutMap.put(WCardTitleLayout.class, XWCardTitleLayout.class); |
|
|
|
|
xLayoutMap.put(WTabFitLayout.class, XWTabFitLayout.class); |
|
|
|
|
xLayoutMap.put(WCardMainBorderLayout.class, XWCardMainBorderLayout.class); |
|
|
|
|
|
|
|
|
|
objectMap.putAll(ExtraDesignClassManager.getInstance().getParameterWidgetOptionsMap()); |
|
|
|
|
objectMap.putAll(ExtraDesignClassManager.getInstance().getFormWidgetOptionsMap()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static void reInitExtra() { |
|
|
|
|
|
|
|
|
|
extraObjectMap.clear(); |
|
|
|
|
extraObjectMap.putAll(ExtraDesignClassManager.getInstance().getParameterWidgetOptionsMap()); |
|
|
|
|
extraObjectMap.putAll(ExtraDesignClassManager.getInstance().getFormWidgetOptionsMap()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static void putExtraEditor() { |
|
|
|
|
if (DesignModuleFactory.getChartEditorClass() != null) { |
|
|
|
|
objectMap.put(DesignModuleFactory.getChartEditorClass(), XChartEditor.class); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
|
private static Class<? extends XCreator> searchXCreatorClass(Class<? extends Widget> clazz) { |
|
|
|
|
|
|
|
|
|
Class<? extends XCreator> xClazz = (Class<? extends XCreator>) objectMap.get(clazz); |
|
|
|
|
if (xClazz == null) { |
|
|
|
|
xClazz = (Class<? extends XCreator>) extraObjectMap.get(clazz); |
|
|
|
|
} |
|
|
|
|
if (xClazz == null) { |
|
|
|
|
xClazz = (Class<? extends XCreator>) xLayoutMap.get(clazz); |
|
|
|
|
} |
|
|
|
|