From 4af854aee97766c37a697adcfc3d0d71ad801bbe Mon Sep 17 00:00:00 2001 From: plough Date: Wed, 2 Aug 2017 16:44:18 +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?=E8=A1=A8=E5=8D=95=EF=BC=89=3D>bug=E8=A7=A3=E5=86=B3=EF=BC=9B?= =?UTF-8?q?=E6=95=88=E7=8E=87=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/controlpane/UIListControlPane.java | 2 +- .../properties/EventPropertyTable.java | 33 +++++++++++++------ .../src/com/fr/design/mainframe/JForm.java | 9 +++-- .../design/mainframe/WidgetPropertyPane.java | 16 +++++---- 4 files changed, 41 insertions(+), 19 deletions(-) diff --git a/designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java b/designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java index 1968dc6356..25369a550c 100644 --- a/designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java +++ b/designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java @@ -210,7 +210,7 @@ public abstract class UIListControlPane extends UIControlPane { listModel.addElement(new ListModelElement(aNameableArray)); } - if (listModel.size() > 0) { + if (listModel.size() > 0 || this.nameableList.getSelectedIndex() != 0) { this.nameableList.setSelectedIndex(0); } this.checkButtonEnabled(); diff --git a/designer_form/src/com/fr/design/designer/properties/EventPropertyTable.java b/designer_form/src/com/fr/design/designer/properties/EventPropertyTable.java index 97320585b3..a0a29fc4cb 100644 --- a/designer_form/src/com/fr/design/designer/properties/EventPropertyTable.java +++ b/designer_form/src/com/fr/design/designer/properties/EventPropertyTable.java @@ -204,7 +204,8 @@ public class EventPropertyTable extends UIListControlPane { * 刷新 */ public void refresh() { - isPopulating = true; +// isPopulating = true; + System.out.println("in refresh..."); int selectionSize = designer.getSelectionModel().getSelection().size(); if (selectionSize == 0 || selectionSize == 1) { this.creator = selectionSize == 0 ? designer.getRootComponent() : designer.getSelectionModel() @@ -232,21 +233,30 @@ public class EventPropertyTable extends UIListControlPane { populate(nameObjectList.toArray(new NameObject[widget.getListenerSize()])); checkButtonEnabled(); this.repaint(); - isPopulating = false; - } +// isPopulating = false; + System.out.println("out refresh..."); + } /** * 更新控件事件 * @param creator 控件 */ public void updateWidgetListener(XCreator creator, boolean isSaving) { - DefaultListModel listModel = (DefaultListModel) this.nameableList.getModel(); - (creator.toData()).clearListeners(); - for (int i = 0, len = listModel.getSize(); i < len; i++) { - NameObject nameObject = isSaving ? (NameObject)((ListModelElement) listModel.getElementAt(i)).wrapper : (NameObject)(listModel.getElementAt(i)); - (creator.toData()).addListener((Listener) nameObject.getObject()); - } - designer.fireTargetModified(); +// DefaultListModel listModel = (DefaultListModel) this.nameableList.getModel(); +// (creator.toData()).clearListeners(); +// for (int i = 0, len = listModel.getSize(); i < len; i++) { +// NameObject nameObject = isSaving ? (NameObject)((ListModelElement) listModel.getElementAt(i)).wrapper : (NameObject)(listModel.getElementAt(i)); +// (creator.toData()).addListener((Listener) nameObject.getObject()); +// } + + (creator.toData()).clearListeners(); + Nameable[] res = this.update(); + for (int i = 0; i < res.length; i++) { + NameObject nameObject = (NameObject)res[i]; + (creator.toData()).addListener((Listener) nameObject.getObject()); + } + + designer.fireTargetModified(); checkButtonEnabled(); } @@ -268,6 +278,9 @@ public class EventPropertyTable extends UIListControlPane { @Override public void saveSettings() { + if (isPopulating) { + return; + } updateWidgetListener(creator, true); } diff --git a/designer_form/src/com/fr/design/mainframe/JForm.java b/designer_form/src/com/fr/design/mainframe/JForm.java index 23299f30b1..439ebe9a66 100644 --- a/designer_form/src/com/fr/design/mainframe/JForm.java +++ b/designer_form/src/com/fr/design/mainframe/JForm.java @@ -221,14 +221,19 @@ public class JForm extends JTemplate implements BaseJForm { } }); formDesign.addDesignerEditListener(new DesignerEditListener() { - + private XComponent lastAffectedCreator; @Override public void fireCreatorModified(DesignerEvent evt) { if (evt.getCreatorEventID() == DesignerEvent.CREATOR_CUTED || evt.getCreatorEventID() == DesignerEvent.CREATOR_DELETED) { setPropertyPaneChange(formDesign.getRootComponent()); } else if (evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED) { - setPropertyPaneChange(evt.getAffectedCreator()); + // 防止多次触发 + if (lastAffectedCreator != null && lastAffectedCreator == evt.getAffectedCreator()) { + return; + } + lastAffectedCreator = evt.getAffectedCreator(); + setPropertyPaneChange(lastAffectedCreator); } } }); diff --git a/designer_form/src/com/fr/design/mainframe/WidgetPropertyPane.java b/designer_form/src/com/fr/design/mainframe/WidgetPropertyPane.java index 201ab203e4..40bdff39c5 100644 --- a/designer_form/src/com/fr/design/mainframe/WidgetPropertyPane.java +++ b/designer_form/src/com/fr/design/mainframe/WidgetPropertyPane.java @@ -4,10 +4,7 @@ import com.fr.base.BaseUtils; import com.fr.design.ExtraDesignClassManager; import com.fr.design.designer.beans.events.DesignerEditListener; import com.fr.design.designer.beans.events.DesignerEvent; -import com.fr.design.designer.creator.XCreator; -import com.fr.design.designer.creator.XCreatorUtils; -import com.fr.design.designer.creator.XLayoutContainer; -import com.fr.design.designer.creator.XWParameterLayout; +import com.fr.design.designer.creator.*; import com.fr.design.designer.properties.EventPropertyTable; import com.fr.design.designer.properties.WidgetPropertyTable; import com.fr.design.fun.WidgetPropertyUIProvider; @@ -314,6 +311,7 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper */ private class EventPropertyDesignerAdapter implements DesignerEditListener { EventPropertyTable propertyTable; + private XComponent lastAffectedCreator; EventPropertyDesignerAdapter(EventPropertyTable eventTable) { this.propertyTable = eventTable; @@ -321,8 +319,14 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper @Override public void fireCreatorModified(DesignerEvent evt) { - if (evt.getCreatorEventID() == DesignerEvent.CREATOR_EDITED - || evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED) { + if (evt.getCreatorEventID() == DesignerEvent.CREATOR_EDITED) { + propertyTable.refresh(); + } else if (evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED) { + // 防止多次触发 + if (lastAffectedCreator != null && lastAffectedCreator == evt.getAffectedCreator()) { + return; + } + lastAffectedCreator = evt.getAffectedCreator(); propertyTable.refresh(); } }