From 7d76f7d6f23ff4a1a150a5964b8f01b1e39d5819 Mon Sep 17 00:00:00 2001 From: plough Date: Tue, 1 Aug 2017 11:23:13 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-3163=20=E5=90=88=E4=BD=9C=E5=BC=80?= =?UTF-8?q?=E5=8F=919.0=E8=AE=BE=E8=AE=A1=E5=99=A8=3D>=E6=8E=A7=E4=BB=B6?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=BA=8B=E4=BB=B6=E7=BC=96=E8=BE=91=EF=BC=88?= =?UTF-8?q?=E6=8A=A5=E8=A1=A8=EF=BC=89=E5=88=9D=E6=AD=A5=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/widget/WidgetEventPane.java | 12 ++-- .../gui/controlpane/ObjectUIControlPane.java | 72 +++++++++++++++++++ .../design/gui/controlpane/UIControlPane.java | 11 ++- 3 files changed, 90 insertions(+), 5 deletions(-) create mode 100644 designer_base/src/com/fr/design/gui/controlpane/ObjectUIControlPane.java diff --git a/designer/src/com/fr/design/widget/WidgetEventPane.java b/designer/src/com/fr/design/widget/WidgetEventPane.java index 2665057b3..5d9845c3c 100644 --- a/designer/src/com/fr/design/widget/WidgetEventPane.java +++ b/designer/src/com/fr/design/widget/WidgetEventPane.java @@ -4,10 +4,10 @@ package com.fr.design.widget; import java.util.ArrayList; import java.util.List; +import com.fr.design.gui.controlpane.ObjectUIControlPane; import com.fr.design.write.submit.DBManipulationPane; import com.fr.design.write.submit.SmartInsertDBManipulationInWidgetEventPane; import com.fr.design.gui.controlpane.NameableCreator; -import com.fr.design.gui.controlpane.ObjectJControlPane; import com.fr.design.gui.frpane.ListenerUpdatePane; import com.fr.design.javascript.JavaScriptActionPane; import com.fr.design.mainframe.DesignerContext; @@ -19,7 +19,7 @@ import com.fr.general.Inter; import com.fr.general.NameObject; import com.fr.stable.Nameable; -public class WidgetEventPane extends ObjectJControlPane { +public class WidgetEventPane extends ObjectUIControlPane { public WidgetEventPane() { this(null); @@ -38,8 +38,12 @@ public class WidgetEventPane extends ObjectJControlPane { EventCreator.STATECHANGE }; } - - @Override + + @Override + public void saveSettings() { + } + + @Override protected String title4PopupWindow() { return Inter.getLocText("Event"); } diff --git a/designer_base/src/com/fr/design/gui/controlpane/ObjectUIControlPane.java b/designer_base/src/com/fr/design/gui/controlpane/ObjectUIControlPane.java new file mode 100644 index 000000000..46b41d020 --- /dev/null +++ b/designer_base/src/com/fr/design/gui/controlpane/ObjectUIControlPane.java @@ -0,0 +1,72 @@ +package com.fr.design.gui.controlpane; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import com.fr.design.beans.BasicBeanPane; + +/** + * Created by plough on 2017/8/1. + */ +public abstract class ObjectUIControlPane extends UIListControlPane { + private Object object; + + public ObjectUIControlPane() { + this(null); + } + + public ObjectUIControlPane(Object object) { + super(); + this.object = object; + } + + @Override + protected BasicBeanPane createPaneByCreators(NameableCreator creator) { + try { + if (object == null) { + return super.createPaneByCreators(creator); + } else if (object.getClass().isArray()) { + return creator.getUpdatePane().getConstructor(object.getClass()).newInstance(object); + } else { + Constructor constructor = getConstructor(creator.getUpdatePane(), object.getClass()); + return constructor == null ? super.createPaneByCreators(creator) : constructor.newInstance(object); + } + } catch (InstantiationException e) { + throw new RuntimeException(e); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } catch (IllegalArgumentException e) { + throw new RuntimeException(e); + } catch (SecurityException e) { + throw new RuntimeException(e); + } catch (InvocationTargetException e) { + throw new RuntimeException(e); + } catch (NoSuchMethodException e) { + throw new RuntimeException(e); + } + } + + /** + * 传进BasicBeanPane的构造函数的参数,可能是 + * + * @param clazz + * @param cls + * @return + */ + private Constructor getConstructor(Class clazz, Class cls) { + Constructor constructor = null; + try { + constructor = clazz.getConstructor(cls); + } catch (SecurityException e) { + } catch (NoSuchMethodException e) { + } + if (constructor != null) { + return constructor; + } else { + if (cls.getName() == Object.class.getName()) { + return null; + } + return getConstructor(clazz, cls.getSuperclass()); + } + } + +} \ No newline at end of file diff --git a/designer_base/src/com/fr/design/gui/controlpane/UIControlPane.java b/designer_base/src/com/fr/design/gui/controlpane/UIControlPane.java index 42d7e97bd..02273477b 100644 --- a/designer_base/src/com/fr/design/gui/controlpane/UIControlPane.java +++ b/designer_base/src/com/fr/design/gui/controlpane/UIControlPane.java @@ -28,6 +28,7 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH private ToolBarDef toolbarDef; private UIToolbar toolBar; + private UIToolbar topToolBar; protected PopupEditDialog popupEditDialog; // peter:这是整体的一个cardLayout Pane protected CardLayout cardLayout; @@ -146,7 +147,7 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH // leftContentPane.setBorder(BorderFactory.createLineBorder(new Color(201, 198, 184))); // 顶部标签及add按钮 - UIToolbar topToolBar = new UIToolbar(); + topToolBar = new UIToolbar(); topToolBar.setLayout(new BorderLayout()); ShortCut addItem = addItemShortCut().getShortCut(); addItem.intoJToolBar(topToolBar); @@ -246,6 +247,14 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH toolbarDef.updateToolBar(toolBar); toolBar.validate(); toolBar.repaint(); + + + // 顶部按钮 + topToolBar.removeAll(); + ShortCut addItem = addItemShortCut().getShortCut(); + addItem.intoJToolBar(topToolBar); + topToolBar.validate(); + this.repaint(); }