From a349fb16d4adc6f271429221a82dccfc652b3784 Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Fri, 9 Jun 2017 09:52:30 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E7=9B=91=E5=90=AC=E5=8C=85=E5=90=ABFormPar?= =?UTF-8?q?aWidgetPane=E6=8E=A5=E5=8F=A3=E7=9A=84=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../designer/creator/XCreatorUtils.java | 69 ++++++++++++++----- .../design/mainframe/FormParaWidgetPane.java | 31 ++++++++- 2 files changed, 82 insertions(+), 18 deletions(-) diff --git a/designer_form/src/com/fr/design/designer/creator/XCreatorUtils.java b/designer_form/src/com/fr/design/designer/creator/XCreatorUtils.java index 3c58e2f19..726c16178 100644 --- a/designer_form/src/com/fr/design/designer/creator/XCreatorUtils.java +++ b/designer_form/src/com/fr/design/designer/creator/XCreatorUtils.java @@ -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,35 @@ import java.lang.reflect.Constructor; * @since 6.5.3 */ public class XCreatorUtils { - + public static java.util.Map, Class> objectMap = new java.util.HashMap, Class>(); + + private static java.util.Map, Class> extraObjectMap = new java.util.HashMap, Class>(); + public static java.util.Map, Class> xLayoutMap = new java.util.HashMap, 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() { + objectMap.put(TextEditor.class, XTextEditor.class); objectMap.put(TextArea.class, XTextArea.class); objectMap.put(NumberEditor.class, XNumberEditor.class); @@ -74,7 +100,7 @@ public class XCreatorUtils { 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); @@ -86,7 +112,7 @@ public class XCreatorUtils { 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); @@ -94,19 +120,30 @@ public class XCreatorUtils { 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()); + + reInitExtra(); } - + + 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 searchXCreatorClass(Class clazz) { + Class xClazz = (Class) objectMap.get(clazz); + if (xClazz == null) { + xClazz = (Class) extraObjectMap.get(clazz); + } if (xClazz == null) { xClazz = (Class) xLayoutMap.get(clazz); } diff --git a/designer_form/src/com/fr/design/mainframe/FormParaWidgetPane.java b/designer_form/src/com/fr/design/mainframe/FormParaWidgetPane.java index 6187bbd48..c3855c3c9 100644 --- a/designer_form/src/com/fr/design/mainframe/FormParaWidgetPane.java +++ b/designer_form/src/com/fr/design/mainframe/FormParaWidgetPane.java @@ -6,6 +6,7 @@ import com.fr.design.constants.UIConstants; import com.fr.design.designer.beans.events.DesignerEditListener; import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.creator.XCreatorUtils; +import com.fr.design.fun.FormWidgetOptionProvider; import com.fr.design.gui.core.FormWidgetOption; import com.fr.design.gui.core.UserDefinedWidgetOption; import com.fr.design.gui.core.WidgetOption; @@ -16,7 +17,13 @@ import com.fr.design.module.DesignModuleFactory; import com.fr.design.utils.gui.LayoutUtils; import com.fr.form.ui.*; import com.fr.general.ComparatorUtils; +import com.fr.general.GeneralContext; import com.fr.general.Inter; +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.ArrayUtils; import javax.swing.*; @@ -55,8 +62,28 @@ public class FormParaWidgetPane extends JPanel { private UILabel paraLabel; private FormDesigner designer; - - public static final FormParaWidgetPane getInstance(FormDesigner designer) { + + static { + GeneralContext.listenPluginRunningChanged(new PluginEventListener() { + + @Override + public void on(PluginEvent event) { + + synchronized (FormParaWidgetPane.class) { + THIS = null; + } + } + }, new PluginFilter() { + + @Override + public boolean accept(PluginContext context) { + + return context.contain(PluginModule.ExtraDesign, FormWidgetOptionProvider.XML_TAG); + } + }); + } + + public static synchronized final FormParaWidgetPane getInstance(FormDesigner designer) { if (THIS == null) { THIS = new FormParaWidgetPane(); } From 7195e9f19b2811cad3515576734ecf91b192a6e3 Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Fri, 9 Jun 2017 09:54:53 +0800 Subject: [PATCH 2/3] fix --- .../designer/creator/XCreatorUtils.java | 54 +++++++++++-------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/designer_form/src/com/fr/design/designer/creator/XCreatorUtils.java b/designer_form/src/com/fr/design/designer/creator/XCreatorUtils.java index 726c16178..4b6b4240a 100644 --- a/designer_form/src/com/fr/design/designer/creator/XCreatorUtils.java +++ b/designer_form/src/com/fr/design/designer/creator/XCreatorUtils.java @@ -69,6 +69,37 @@ public class XCreatorUtils { 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); @@ -99,29 +130,6 @@ 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); - - reInitExtra(); } private static void reInitExtra() { From 016a70ee471d74aa3ea5b9a9f8498108fada5180 Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Fri, 9 Jun 2017 16:00:35 +0800 Subject: [PATCH 3/3] fix --- .../design/gui/frpane/HyperlinkGroupPane.java | 13 -- .../src/com/fr/plugin/PluginManager.java | 128 ------------------ 2 files changed, 141 deletions(-) delete mode 100644 designer_base/src/com/fr/plugin/PluginManager.java diff --git a/designer_base/src/com/fr/design/gui/frpane/HyperlinkGroupPane.java b/designer_base/src/com/fr/design/gui/frpane/HyperlinkGroupPane.java index 99fc5948e..3408bf371 100644 --- a/designer_base/src/com/fr/design/gui/frpane/HyperlinkGroupPane.java +++ b/designer_base/src/com/fr/design/gui/frpane/HyperlinkGroupPane.java @@ -1,8 +1,6 @@ package com.fr.design.gui.frpane; import com.fr.design.ExtraDesignClassManager; -import com.fr.design.actions.HyperlinkPluginAction; -import com.fr.design.actions.UpdateAction; import com.fr.design.fun.HyperlinkProvider; import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.NameableCreator; @@ -12,14 +10,12 @@ import com.fr.general.NameObject; import com.fr.js.JavaScript; import com.fr.js.NameJavaScript; import com.fr.js.NameJavaScriptGroup; -import com.fr.plugin.PluginManager; import com.fr.stable.ListMap; import com.fr.stable.Nameable; import java.util.ArrayList; import java.util.Map; import java.util.Set; -import java.util.TreeMap; /** * 超级链接 界面. @@ -40,15 +36,6 @@ public class HyperlinkGroupPane extends JListControlPane { for (NameableCreator creator : creators) { nameCreators.put(creator.menuName(), creator); } - PluginManager.getInstance().setExtensionPoint(HyperlinkPluginAction.XML_TAG); - ArrayList templateArrayLisy = PluginManager.getInstance().getResultList(); -// if (templateArrayLisy.isEmpty()) { -// return creators; -// } - for (int i = 0; i < templateArrayLisy.size(); i++) { - NameableCreator nameableCreator = ((HyperlinkPluginAction) templateArrayLisy.get(i)).getHyperlinkCreator(); - nameCreators.put(nameableCreator.menuName(), nameableCreator); - } Set providers = ExtraDesignClassManager.getInstance().getArray(HyperlinkProvider.XML_TAG); for (HyperlinkProvider provider : providers) { NameableCreator nc = provider.createHyperlinkCreator(); diff --git a/designer_base/src/com/fr/plugin/PluginManager.java b/designer_base/src/com/fr/plugin/PluginManager.java deleted file mode 100644 index c539db874..000000000 --- a/designer_base/src/com/fr/plugin/PluginManager.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.fr.plugin; - -import com.fr.design.actions.UpdateAction; -import com.fr.file.XMLFileManager; -import com.fr.general.ComparatorUtils; -import com.fr.general.FRLogger; -import com.fr.general.GeneralUtils; -import com.fr.stable.StringUtils; -import com.fr.stable.xml.XMLPrintWriter; -import com.fr.stable.xml.XMLReadable; -import com.fr.stable.xml.XMLableReader; - -import java.util.ArrayList; - -/** - * Created by IntelliJ IDEA. - * Author : daisy - * Version: 6.5.6 - * Date: 13-12-20 - * Time: 下午5:05 - */ -public class PluginManager extends XMLFileManager { - - private static PluginManager pluginManager = null; - - private String extensionPoint = StringUtils.EMPTY; - - private ArrayList resultList = new ArrayList(); - - - public synchronized static PluginManager getInstance() { - if (pluginManager == null) { - pluginManager = new PluginManager(); - } - return pluginManager; - } - - - public PluginManager() { - - } - - /** - * 文件名 - * @return 文件名 - */ - public String fileName() { - return "plugin.xml"; - } - - - public void setExtensionPoint(String point) { - extensionPoint = point; - resultList.clear(); - pluginManager.readXMLFile(); - } - - - @Override - public void readXML(XMLableReader reader) { - if (extensionPoint == StringUtils.EMPTY) { - return; - } - if (reader.getTagName().equals("PluginManager")) { - reader.readXMLObject(new XMLReadable() { - @Override - public void readXML(XMLableReader reader) { - readExtension(reader); - } - }); - } - - - } - - private void readExtension(XMLableReader reader) { - if (reader.isChildNode()) { - if (reader.getTagName().equals("Extension")) { - String name = null, tmpVal = null; - if ((tmpVal = reader.getAttrAsString("position", null)) != null) { - name = tmpVal; - } - if (!ComparatorUtils.equals(name, extensionPoint)) { - return; - } - reader.readXMLObject(new XMLReadable() { - @Override - public void readXML(XMLableReader reader) { - readActions(reader); - } - }); - - } - } - } - - private void readActions(XMLableReader reader) { - if (reader.isChildNode()) { - if (reader.getTagName().equals("Action")) { - String name = null, tmpVal = null; - if ((tmpVal = reader.getAttrAsString("class", null)) != null) { - name = tmpVal; - } - //读取模板数据集菜单 - if (name.isEmpty()) { - return; - } - try { - UpdateAction action = (UpdateAction) GeneralUtils.classForName(name).newInstance(); - PluginManager.this.resultList.add(action); - } catch (Exception exp) { - FRLogger.getLogger().error(exp.getMessage(), exp); - } - } - } - - } - - - public ArrayList getResultList() { - return resultList; - } - - @Override - public void writeXML(XMLPrintWriter writer) { - } - -} \ No newline at end of file