From c55a0f68c9cb1e690e4f73bad0cf2db3338d1410 Mon Sep 17 00:00:00 2001 From: zack Date: Thu, 12 May 2016 12:00:58 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E6=8E=A7=E4=BB=B6=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E4=BC=A0=E9=80=92=E6=8F=92=E4=BB=B6=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/widget/WidgetPane.java | 17 ++++++++++++++ .../fr/design/ExtraDesignClassManager.java | 12 ++++++++++ .../fr/design/fun/WidgetDesignHandler.java | 22 +++++++++++++++++++ .../fun/impl/AbstractWidgetDesignHandler.java | 16 ++++++++++++++ 4 files changed, 67 insertions(+) create mode 100644 designer_base/src/com/fr/design/fun/WidgetDesignHandler.java create mode 100644 designer_base/src/com/fr/design/fun/impl/AbstractWidgetDesignHandler.java diff --git a/designer/src/com/fr/design/widget/WidgetPane.java b/designer/src/com/fr/design/widget/WidgetPane.java index 83cde65561..2efdaebbb9 100644 --- a/designer/src/com/fr/design/widget/WidgetPane.java +++ b/designer/src/com/fr/design/widget/WidgetPane.java @@ -1,6 +1,7 @@ package com.fr.design.widget; import com.fr.design.ExtraDesignClassManager; +import com.fr.design.fun.WidgetDesignHandler; import com.fr.design.gui.core.WidgetOption; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBoxRenderer; @@ -30,6 +31,7 @@ public class WidgetPane extends BasicPane implements ItemListener { private CellWidgetCardPane cellEditorCardPane; private boolean shouldFireSelectedEvent; protected JPanel northPane; + private Widget oldWidget;//记录一下上次编辑的插件 public WidgetPane() { this(null); @@ -42,6 +44,14 @@ public class WidgetPane extends BasicPane implements ItemListener { this.initComponents(pane); } + public Widget getOldWidget() { + return oldWidget; + } + + public void setOldWidget(Widget oldWidget) { + this.oldWidget = oldWidget; + } + protected void initComponents(ElementCasePane pane) { this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); @@ -66,11 +76,17 @@ public class WidgetPane extends BasicPane implements ItemListener { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { if (e.getItem() instanceof Item && ((Item) e.getItem()).getValue() instanceof WidgetConfig) { + Widget newWidget = editorTypeComboBox.getCellWidget(); + populate(editorTypeComboBox.getCellWidget()); return; } if (shouldFireSelectedEvent) { Widget selectedItem = editorTypeComboBox.getCellWidget(); + WidgetDesignHandler handler = ExtraDesignClassManager.getInstance().getWidgetDesignHandler(); + if (handler != null) { + selectedItem = handler.dealWithWidget(getOldWidget(), selectedItem); + } populateWidgetConfig(selectedItem); } } @@ -82,6 +98,7 @@ public class WidgetPane extends BasicPane implements ItemListener { } public void populate(Widget widget) { + setOldWidget(widget); if (widget == null) { widget = new TextEditor(); } diff --git a/designer_base/src/com/fr/design/ExtraDesignClassManager.java b/designer_base/src/com/fr/design/ExtraDesignClassManager.java index a861772c9a..81a2ed01dc 100644 --- a/designer_base/src/com/fr/design/ExtraDesignClassManager.java +++ b/designer_base/src/com/fr/design/ExtraDesignClassManager.java @@ -132,6 +132,16 @@ public class ExtraDesignClassManager extends XMLFileManager implements ExtraDesi private Set widgetAttrProviders; + private WidgetDesignHandler widgetDesignHandler; + + public WidgetDesignHandler getWidgetDesignHandler() { + return widgetDesignHandler; + } + + public void setWidgetDesignHandler(Level level, PluginSimplify simplify) throws Exception { + widgetDesignHandler = (WidgetDesignHandler) level; + } + public TableDataTreePaneProcessor getTableDataTreePaneProcessor() { return tableDataTreePaneProcessor; } @@ -847,6 +857,8 @@ public class ExtraDesignClassManager extends XMLFileManager implements ExtraDesi addElementUIProvider(impl, simplify); } else if (tagName.equals(WidgetAttrProvider.XML_TAG)) { addWidgetAttrProvider(impl, simplify); + } else if (tagName.equals(WidgetDesignHandler.XML_TAG)) { + setWidgetDesignHandler(impl, simplify); } } catch (PluginInvalidLevelException e) { PluginMessage.remindUpdate(e.getMessage()); diff --git a/designer_base/src/com/fr/design/fun/WidgetDesignHandler.java b/designer_base/src/com/fr/design/fun/WidgetDesignHandler.java new file mode 100644 index 0000000000..0f4b52bf92 --- /dev/null +++ b/designer_base/src/com/fr/design/fun/WidgetDesignHandler.java @@ -0,0 +1,22 @@ +package com.fr.design.fun; + +import com.fr.form.ui.Widget; +import com.fr.stable.fun.Level; + +/** + * Coder: zack + * Date: 2016/5/12 + * Time: 10:37 + */ +public interface WidgetDesignHandler extends Level { + String XML_TAG = "WidgetDesignHandler"; + int CURRENT_LEVEL = 1; + /** + * 控件设置的时候对原控件和新控件的一些特殊处理(比如属性的传递,默认属性的设置等) + * + * @param oldWidget 老控件 + * @param newWidget 新控件 + * @return 处理后的控件 + */ + Widget dealWithWidget(Widget oldWidget, Widget newWidget); +} diff --git a/designer_base/src/com/fr/design/fun/impl/AbstractWidgetDesignHandler.java b/designer_base/src/com/fr/design/fun/impl/AbstractWidgetDesignHandler.java new file mode 100644 index 0000000000..1bf331c694 --- /dev/null +++ b/designer_base/src/com/fr/design/fun/impl/AbstractWidgetDesignHandler.java @@ -0,0 +1,16 @@ +package com.fr.design.fun.impl; + +import com.fr.design.fun.WidgetDesignHandler; +import com.fr.form.ui.Widget; + +/** + * Coder: zack + * Date: 2016/5/12 + * Time: 10:41 + */ +public abstract class AbstractWidgetDesignHandler implements WidgetDesignHandler { + @Override + public Widget dealWithWidget(Widget oldWidget, Widget newWidget) { + return newWidget; + } +} From 652c0d21aecd4c25e7914abf7bd6cab2a6910e7e Mon Sep 17 00:00:00 2001 From: zack Date: Thu, 12 May 2016 12:52:35 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer/src/com/fr/design/widget/WidgetPane.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/designer/src/com/fr/design/widget/WidgetPane.java b/designer/src/com/fr/design/widget/WidgetPane.java index 2efdaebbb9..a29014c55d 100644 --- a/designer/src/com/fr/design/widget/WidgetPane.java +++ b/designer/src/com/fr/design/widget/WidgetPane.java @@ -75,18 +75,17 @@ public class WidgetPane extends BasicPane implements ItemListener { */ public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { + setOldWidget(update()); + Widget selectedItem = editorTypeComboBox.getCellWidget(); + WidgetDesignHandler handler = ExtraDesignClassManager.getInstance().getWidgetDesignHandler(); + if (handler != null) { + selectedItem = handler.dealWithWidget(getOldWidget(), selectedItem); + } if (e.getItem() instanceof Item && ((Item) e.getItem()).getValue() instanceof WidgetConfig) { - Widget newWidget = editorTypeComboBox.getCellWidget(); - - populate(editorTypeComboBox.getCellWidget()); + populate(selectedItem); return; } if (shouldFireSelectedEvent) { - Widget selectedItem = editorTypeComboBox.getCellWidget(); - WidgetDesignHandler handler = ExtraDesignClassManager.getInstance().getWidgetDesignHandler(); - if (handler != null) { - selectedItem = handler.dealWithWidget(getOldWidget(), selectedItem); - } populateWidgetConfig(selectedItem); } } From a83f87101534aefedc36ecae5f15421843374a82 Mon Sep 17 00:00:00 2001 From: zack Date: Thu, 12 May 2016 12:56:23 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=B8=8D=E9=9C=80?= =?UTF-8?q?=E8=A6=81=E7=9A=84=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer/src/com/fr/design/widget/WidgetPane.java | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/designer/src/com/fr/design/widget/WidgetPane.java b/designer/src/com/fr/design/widget/WidgetPane.java index a29014c55d..13797a5758 100644 --- a/designer/src/com/fr/design/widget/WidgetPane.java +++ b/designer/src/com/fr/design/widget/WidgetPane.java @@ -31,7 +31,6 @@ public class WidgetPane extends BasicPane implements ItemListener { private CellWidgetCardPane cellEditorCardPane; private boolean shouldFireSelectedEvent; protected JPanel northPane; - private Widget oldWidget;//记录一下上次编辑的插件 public WidgetPane() { this(null); @@ -44,14 +43,6 @@ public class WidgetPane extends BasicPane implements ItemListener { this.initComponents(pane); } - public Widget getOldWidget() { - return oldWidget; - } - - public void setOldWidget(Widget oldWidget) { - this.oldWidget = oldWidget; - } - protected void initComponents(ElementCasePane pane) { this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); @@ -75,11 +66,11 @@ public class WidgetPane extends BasicPane implements ItemListener { */ public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { - setOldWidget(update()); + Widget oldWidget = update(); Widget selectedItem = editorTypeComboBox.getCellWidget(); WidgetDesignHandler handler = ExtraDesignClassManager.getInstance().getWidgetDesignHandler(); if (handler != null) { - selectedItem = handler.dealWithWidget(getOldWidget(), selectedItem); + selectedItem = handler.dealWithWidget(oldWidget, selectedItem); } if (e.getItem() instanceof Item && ((Item) e.getItem()).getValue() instanceof WidgetConfig) { populate(selectedItem); @@ -97,7 +88,6 @@ public class WidgetPane extends BasicPane implements ItemListener { } public void populate(Widget widget) { - setOldWidget(widget); if (widget == null) { widget = new TextEditor(); } From e06b655ed6c93df8991bfcdd9b57f6f2fe295e89 Mon Sep 17 00:00:00 2001 From: zack Date: Thu, 12 May 2016 12:56:59 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96=E4=B8=80?= =?UTF-8?q?=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer/src/com/fr/design/widget/WidgetPane.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/designer/src/com/fr/design/widget/WidgetPane.java b/designer/src/com/fr/design/widget/WidgetPane.java index 13797a5758..f2e5ce30a1 100644 --- a/designer/src/com/fr/design/widget/WidgetPane.java +++ b/designer/src/com/fr/design/widget/WidgetPane.java @@ -1,6 +1,7 @@ package com.fr.design.widget; import com.fr.design.ExtraDesignClassManager; +import com.fr.design.dialog.BasicPane; import com.fr.design.fun.WidgetDesignHandler; import com.fr.design.gui.core.WidgetOption; import com.fr.design.gui.icombobox.UIComboBox; @@ -8,13 +9,12 @@ import com.fr.design.gui.icombobox.UIComboBoxRenderer; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.ElementCasePane; -import com.fr.design.dialog.BasicPane; +import com.fr.design.widget.btn.ButtonConstants; import com.fr.form.ui.Button; import com.fr.form.ui.*; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; import com.fr.stable.ArrayUtils; -import com.fr.design.widget.btn.ButtonConstants; import javax.swing.*; import java.awt.*; @@ -62,6 +62,7 @@ public class WidgetPane extends BasicPane implements ItemListener { /** * 状态改变 + * * @param e 事件对象 */ public void itemStateChanged(ItemEvent e) { @@ -115,9 +116,9 @@ public class WidgetPane extends BasicPane implements ItemListener { public Widget update() { return cellEditorCardPane.update(); } - + protected void populateWidgetConfig(Widget widget) { - cellEditorCardPane.populate(widget); + cellEditorCardPane.populate(widget); } @@ -196,12 +197,13 @@ public class WidgetPane extends BasicPane implements ItemListener { } private WidgetOption[] getWidgetOptions() { - return (WidgetOption[])ArrayUtils.addAll(WidgetOption.getReportWidgetInstance(), ExtraDesignClassManager.getInstance().getCellWidgetOptions()); + return (WidgetOption[]) ArrayUtils.addAll(WidgetOption.getReportWidgetInstance(), ExtraDesignClassManager.getInstance().getCellWidgetOptions()); } } /** * 校验 + * * @throws Exception 抛出异常 */ public void checkValid() throws Exception { @@ -228,6 +230,7 @@ public class WidgetPane extends BasicPane implements ItemListener { /** * 转化成字符串形式 + * * @return 返回字符串 */ public String toString() { From 280a1ec62bc2f036af09ac4a982ba9cf381c2de4 Mon Sep 17 00:00:00 2001 From: zack Date: Thu, 12 May 2016 13:49:43 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer/src/com/fr/design/widget/WidgetPane.java | 2 +- designer_base/src/com/fr/design/fun/WidgetDesignHandler.java | 2 +- .../com/fr/design/fun/impl/AbstractWidgetDesignHandler.java | 5 ----- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/designer/src/com/fr/design/widget/WidgetPane.java b/designer/src/com/fr/design/widget/WidgetPane.java index f2e5ce30a1..57ff668c8a 100644 --- a/designer/src/com/fr/design/widget/WidgetPane.java +++ b/designer/src/com/fr/design/widget/WidgetPane.java @@ -71,7 +71,7 @@ public class WidgetPane extends BasicPane implements ItemListener { Widget selectedItem = editorTypeComboBox.getCellWidget(); WidgetDesignHandler handler = ExtraDesignClassManager.getInstance().getWidgetDesignHandler(); if (handler != null) { - selectedItem = handler.dealWithWidget(oldWidget, selectedItem); + handler.dealWithWidget(oldWidget, selectedItem); } if (e.getItem() instanceof Item && ((Item) e.getItem()).getValue() instanceof WidgetConfig) { populate(selectedItem); diff --git a/designer_base/src/com/fr/design/fun/WidgetDesignHandler.java b/designer_base/src/com/fr/design/fun/WidgetDesignHandler.java index 0f4b52bf92..20a0dec0ea 100644 --- a/designer_base/src/com/fr/design/fun/WidgetDesignHandler.java +++ b/designer_base/src/com/fr/design/fun/WidgetDesignHandler.java @@ -18,5 +18,5 @@ public interface WidgetDesignHandler extends Level { * @param newWidget 新控件 * @return 处理后的控件 */ - Widget dealWithWidget(Widget oldWidget, Widget newWidget); + void dealWithWidget(Widget oldWidget, Widget newWidget); } diff --git a/designer_base/src/com/fr/design/fun/impl/AbstractWidgetDesignHandler.java b/designer_base/src/com/fr/design/fun/impl/AbstractWidgetDesignHandler.java index 1bf331c694..63659de215 100644 --- a/designer_base/src/com/fr/design/fun/impl/AbstractWidgetDesignHandler.java +++ b/designer_base/src/com/fr/design/fun/impl/AbstractWidgetDesignHandler.java @@ -1,7 +1,6 @@ package com.fr.design.fun.impl; import com.fr.design.fun.WidgetDesignHandler; -import com.fr.form.ui.Widget; /** * Coder: zack @@ -9,8 +8,4 @@ import com.fr.form.ui.Widget; * Time: 10:41 */ public abstract class AbstractWidgetDesignHandler implements WidgetDesignHandler { - @Override - public Widget dealWithWidget(Widget oldWidget, Widget newWidget) { - return newWidget; - } } From 47f779ac70e6533140a33f1be080fc2690554de2 Mon Sep 17 00:00:00 2001 From: zack Date: Thu, 12 May 2016 13:52:43 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer/src/com/fr/design/widget/WidgetPane.java | 2 +- .../src/com/fr/design/fun/WidgetDesignHandler.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/designer/src/com/fr/design/widget/WidgetPane.java b/designer/src/com/fr/design/widget/WidgetPane.java index 57ff668c8a..d14f2da946 100644 --- a/designer/src/com/fr/design/widget/WidgetPane.java +++ b/designer/src/com/fr/design/widget/WidgetPane.java @@ -71,7 +71,7 @@ public class WidgetPane extends BasicPane implements ItemListener { Widget selectedItem = editorTypeComboBox.getCellWidget(); WidgetDesignHandler handler = ExtraDesignClassManager.getInstance().getWidgetDesignHandler(); if (handler != null) { - handler.dealWithWidget(oldWidget, selectedItem); + handler.transferWidgetProperties(oldWidget, selectedItem); } if (e.getItem() instanceof Item && ((Item) e.getItem()).getValue() instanceof WidgetConfig) { populate(selectedItem); diff --git a/designer_base/src/com/fr/design/fun/WidgetDesignHandler.java b/designer_base/src/com/fr/design/fun/WidgetDesignHandler.java index 20a0dec0ea..db8e568ed9 100644 --- a/designer_base/src/com/fr/design/fun/WidgetDesignHandler.java +++ b/designer_base/src/com/fr/design/fun/WidgetDesignHandler.java @@ -11,12 +11,12 @@ import com.fr.stable.fun.Level; public interface WidgetDesignHandler extends Level { String XML_TAG = "WidgetDesignHandler"; int CURRENT_LEVEL = 1; + /** - * 控件设置的时候对原控件和新控件的一些特殊处理(比如属性的传递,默认属性的设置等) + * 传递控件共有属性 * * @param oldWidget 老控件 * @param newWidget 新控件 - * @return 处理后的控件 */ - void dealWithWidget(Widget oldWidget, Widget newWidget); + void transferWidgetProperties(Widget oldWidget, Widget newWidget); }