Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkmoore2011-10-20 16:03:03 +0000
committerkmoore2011-10-20 16:03:03 +0000
commitbdc0d3b9e11186c0e2c0257f9cab39b4ddb18c55 (patch)
tree74062b48752f026959e96ed9aa060ca977142062 /common/plugins
parent45d2456f8acce590bbbcf3d78951a8e0fa85356f (diff)
downloadwebtools.dali-bdc0d3b9e11186c0e2c0257f9cab39b4ddb18c55.tar.gz
webtools.dali-bdc0d3b9e11186c0e2c0257f9cab39b4ddb18c55.tar.xz
webtools.dali-bdc0d3b9e11186c0e2c0257f9cab39b4ddb18c55.zip
bug 310720 - fixing IndexOutOfBoundsException with Override Default check boxes. fire an itemsReplaced event instead of a listChanged events
Diffstat (limited to 'common/plugins')
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/SingleAspectChangeSupport.java2
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ItemPropertyListValueModelAdapter.java42
2 files changed, 42 insertions, 2 deletions
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/SingleAspectChangeSupport.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/SingleAspectChangeSupport.java
index ef13a67927..f4641d1253 100644
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/SingleAspectChangeSupport.java
+++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/SingleAspectChangeSupport.java
@@ -84,7 +84,7 @@ public class SingleAspectChangeSupport
}
}
- private void check(Class<? extends EventListener> listenerClass, String aspectName) {
+ protected void check(Class<? extends EventListener> listenerClass, String aspectName) {
this.check(listenerClass);
if ( ! aspectName.equals(this.validAspectName)) {
throw new IllegalArgumentException(
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ItemPropertyListValueModelAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ItemPropertyListValueModelAdapter.java
index 870a36590f..e464360242 100644
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ItemPropertyListValueModelAdapter.java
+++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ItemPropertyListValueModelAdapter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2011 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -10,8 +10,15 @@
package org.eclipse.jpt.common.utility.internal.model.value;
import java.util.Arrays;
+import java.util.EventListener;
+import java.util.EventObject;
+import org.eclipse.jpt.common.utility.internal.CollectionTools;
+import org.eclipse.jpt.common.utility.internal.model.ChangeSupport;
+import org.eclipse.jpt.common.utility.internal.model.SingleAspectChangeSupport;
import org.eclipse.jpt.common.utility.model.Model;
+import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
+import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
import org.eclipse.jpt.common.utility.model.value.ListValueModel;
@@ -81,4 +88,37 @@ public class ItemPropertyListValueModelAdapter<E>
}
}
+ /**
+ * bug 310720
+ * Override to just fire an itemReplaced event instead of a listChanged event.
+ * An aspect of the item as changed, so no reason to say that the entire list has changed.
+ * Added a LocalChangeSupport so that I can fire a ListReplacedEvent for an old list
+ * and new list containing the same item.
+ */
+ @Override
+ protected void itemAspectChanged(EventObject event) {
+ Object item = event.getSource();
+ this.getChangeSupport().fireItemsReplaced(
+ new ListReplaceEvent(this, LIST_VALUES, CollectionTools.indexOf(this.listHolder, item), item, item));
+ }
+
+ @Override
+ protected ChangeSupport buildChangeSupport() {
+ return new LocalChangeSupport(this, ListChangeListener.class, ListValueModel.LIST_VALUES);
+ }
+
+ private class LocalChangeSupport extends SingleAspectChangeSupport {
+ public LocalChangeSupport(Model source, Class<? extends EventListener> validListenerClass, String validAspectName) {
+ super(source, validListenerClass, validAspectName);
+ }
+ @Override
+ public boolean fireItemsReplaced(ListReplaceEvent event) {
+ this.check(LIST_CHANGE_LISTENER_CLASS, event.getListName());
+ if (event.getItemsSize() != 0) {
+ this.fireItemsReplaced_(event);
+ return true;
+ }
+ return false;
+ }
+ }
}

Back to the top