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(); } }