diff options
Diffstat (limited to 'common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event')
20 files changed, 0 insertions, 1834 deletions
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ChangeEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ChangeEvent.java deleted file mode 100644 index 22247ecfdc..0000000000 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ChangeEvent.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.common.utility.model.event; - -import java.util.EventObject; -import org.eclipse.jpt.common.utility.internal.StringTools; -import org.eclipse.jpt.common.utility.model.Model; - -/** - * Abstract class for all the change events that can be fired by models. - * <p> - * Provisional API: This class is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public abstract class ChangeEvent extends EventObject { - - private static final long serialVersionUID = 1L; - - - /** - * Construct a new change event. - * - * @param source The object on which the event initially occurred. - */ - protected ChangeEvent(Model source) { - super(source); - } - - /** - * Covariant override. - */ - @Override - public Model getSource() { - return (Model) super.getSource(); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - StringTools.appendSimpleToString(sb, this); - sb.append('('); - int len = sb.length(); - this.toString(sb); - if (sb.length() == len) { - sb.deleteCharAt(len - 1); - } else { - sb.append(')'); - } - return sb.toString(); - } - - protected void toString(@SuppressWarnings("unused") StringBuilder sb) { - // subclasses should override this to do something a bit more helpful - } - -} diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/CollectionAddEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/CollectionAddEvent.java deleted file mode 100644 index c2a2e7bc9c..0000000000 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/CollectionAddEvent.java +++ /dev/null @@ -1,124 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.common.utility.model.event; - -import java.util.Collection; - -import org.eclipse.jpt.common.utility.internal.StringTools; -import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable; -import org.eclipse.jpt.common.utility.model.Model; - -/** - * A "collection add" event gets delivered whenever a model adds items to a - * "bound" or "constrained" collection. A <code>CollectionAddEvent</code> is sent as an - * argument to the {@link org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener}. - * <p> - * Provisional API: This class is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -/* - * Design options: - * - create a collection to wrap a single added or removed item - * (this is the option we implemented below and in collaborating code) - * since there is no way to optimize downstream code for - * single items, we take another performance hit by building - * a collection each time (@see Collections#singleton(Object)) - * and forcing downstream code to use an iterator every time - * - * - fire a separate event for each item added or removed - * eliminates any potential for optimizations to downstream code - * - * - add protocol to support both single items and collections - * adds conditional logic to downstream code - */ -public final class CollectionAddEvent extends CollectionEvent { - - /** The items added to the collection. */ - private final Object[] items; - - private static final long serialVersionUID = 1L; - - - // ********** constructors ********** - - /** - * Construct a new collection add event. - * - * @param source The object on which the event initially occurred. - * @param collectionName The programmatic name of the collection that was changed. - * @param item The item added to the collection. - */ - public CollectionAddEvent(Model source, String collectionName, Object item) { - this(source, collectionName, new Object[] {item}); - } - - /** - * Construct a new collection add event. - * - * @param source The object on which the event initially occurred. - * @param collectionName The programmatic name of the collection that was changed. - * @param items The items added to the collection. - */ - public CollectionAddEvent(Model source, String collectionName, Collection<?> items) { - this(source, collectionName, items.toArray()); // NPE if 'items' is null - } - - private CollectionAddEvent(Model source, String collectionName, Object[] items) { - super(source, collectionName); - this.items = items; - } - - - // ********** standard state ********** - - /** - * Return the items added to the collection. - */ - public Iterable<?> getItems() { - return new ArrayIterable<Object>(this.items); - } - - /** - * Return the number of items added to the collection. - */ - public int getItemsSize() { - return this.items.length; - } - - @Override - protected void toString(StringBuilder sb) { - super.toString(sb); - sb.append(": "); //$NON-NLS-1$ - StringTools.append(sb, this.items); - } - - - // ********** cloning ********** - - /** - * Return a copy of the event with the specified source - * replacing the current source. - */ - public CollectionAddEvent clone(Model newSource) { - return this.clone(newSource, this.collectionName); - } - - /** - * Return a copy of the event with the specified source and collection name - * replacing the current source and collection name. - */ - public CollectionAddEvent clone(Model newSource, String newCollectionName) { - return new CollectionAddEvent(newSource, newCollectionName, this.items); - } - -} diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/CollectionChangeEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/CollectionChangeEvent.java deleted file mode 100644 index 5c2c75903c..0000000000 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/CollectionChangeEvent.java +++ /dev/null @@ -1,105 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.common.utility.model.event; - -import java.util.Collection; - -import org.eclipse.jpt.common.utility.internal.StringTools; -import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable; -import org.eclipse.jpt.common.utility.model.Model; - -/** - * A "collection change" event gets delivered whenever a model changes a "bound" - * or "constrained" collection in a manner that is not easily characterized by - * the other collection events. - * A <code>CollectionChangeEvent</code> is sent as an - * argument to the {@link org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener}. - * A <code>CollectionChangeEvent</code> is accompanied by the collection name and - * the current state of the collection. - * <p> - * Provisional API: This class is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public final class CollectionChangeEvent extends CollectionEvent { - - /** - * The the collection in its current state. - * Clients will need to calculate the necessary changes to synchronize - * with the collection. - */ - private final Object[] collection; - - private static final long serialVersionUID = 1L; - - - // ********** constructors ********** - - /** - * Construct a new collection change event. - * - * @param source The object on which the event initially occurred. - * @param collectionName The programmatic name of the collection that was changed. - */ - public CollectionChangeEvent(Model source, String collectionName, Collection<?> collection) { - this(source, collectionName, collection.toArray()); // NPE if 'collection' is null - } - - private CollectionChangeEvent(Model source, String collectionName, Object[] collection) { - super(source, collectionName); - this.collection = collection; - } - - - // ********** standard state ********** - - /** - * Return the current state of the collection. - */ - public Iterable<?> getCollection() { - return new ArrayIterable<Object>(this.collection); - } - - /** - * Return the number of items in the current state of the collection. - */ - public int getCollectionSize() { - return this.collection.length; - } - - @Override - protected void toString(StringBuilder sb) { - super.toString(sb); - sb.append(": "); //$NON-NLS-1$ - StringTools.append(sb, this.collection); - } - - - // ********** cloning ********** - - /** - * Return a copy of the event with the specified source - * replacing the current source. - */ - public CollectionChangeEvent clone(Model newSource) { - return this.clone(newSource, this.collectionName); - } - - /** - * Return a copy of the event with the specified source and collection name - * replacing the current source and collection name. - */ - public CollectionChangeEvent clone(Model newSource, String newCollectionName) { - return new CollectionChangeEvent(newSource, newCollectionName, this.collection); - } - -} diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/CollectionClearEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/CollectionClearEvent.java deleted file mode 100644 index 0fb2adce58..0000000000 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/CollectionClearEvent.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.common.utility.model.event; - -import org.eclipse.jpt.common.utility.model.Model; - -/** - * A "collection clear" event gets delivered whenever a model clears - * a "bound" or "constrained" collection. A <code>CollectionClearEvent</code> is sent - * as an argument to the {@link org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener}. - * <p> - * Provisional API: This class is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public final class CollectionClearEvent extends CollectionEvent { - - private static final long serialVersionUID = 1L; - - - // ********** constructors ********** - - /** - * Construct a new collection clear event. - * - * @param source The object on which the event initially occurred. - * @param collectionName The programmatic name of the collection that was changed. - */ - public CollectionClearEvent(Model source, String collectionName) { - super(source, collectionName); - } - - - // ********** cloning ********** - - /** - * Return a copy of the event with the specified source - * replacing the current source. - */ - public CollectionClearEvent clone(Model newSource) { - return this.clone(newSource, this.collectionName); - } - - /** - * Return a copy of the event with the specified source and collection name - * replacing the current source and collection name. - */ - public CollectionClearEvent clone(Model newSource, String newCollectionName) { - return new CollectionClearEvent(newSource, newCollectionName); - } - -} diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/CollectionEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/CollectionEvent.java deleted file mode 100644 index d3e0bda965..0000000000 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/CollectionEvent.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.common.utility.model.event; - -import org.eclipse.jpt.common.utility.model.Model; -// TODO add "item/original/nested event" for item changed? -/** - * A "collection" event gets delivered whenever a model changes a "bound" - * or "constrained" collection. A <code>CollectionEvent</code> is sent as an - * argument to the {@link org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener}. - * The intent is that any listener - * can keep itself synchronized with the model's collection via the collection - * events it receives and need not maintain a reference to the original - * collection. - * <p> - * Provisional API: This class is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public abstract class CollectionEvent extends ChangeEvent { - - /** Name of the collection that changed. */ - final String collectionName; - - private static final long serialVersionUID = 1L; - - - /** - * Construct a new collection event. - * - * @param source The object on which the event initially occurred. - * @param collectionName The programmatic name of the collection that was changed. - */ - public CollectionEvent(Model source, String collectionName) { - super(source); - if (collectionName == null) { - throw new NullPointerException(); - } - this.collectionName = collectionName; - } - - /** - * Return the programmatic name of the collection that was changed. - */ - public String getCollectionName() { - return this.collectionName; - } - - @Override - protected void toString(StringBuilder sb) { - sb.append(this.collectionName); - } - -} diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/CollectionRemoveEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/CollectionRemoveEvent.java deleted file mode 100644 index a12218d9b3..0000000000 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/CollectionRemoveEvent.java +++ /dev/null @@ -1,112 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.common.utility.model.event; - -import java.util.Collection; - -import org.eclipse.jpt.common.utility.internal.StringTools; -import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable; -import org.eclipse.jpt.common.utility.model.Model; - -/** - * A "collection remove" event gets delivered whenever a model removes items - * from a "bound" or "constrained" collection. A <code>CollectionRemoveEvent</code> is sent - * as an argument to the {@link org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener}. - * <p> - * Provisional API: This class is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -/* - * See design discussion in CollectionAddEvent - */ -public final class CollectionRemoveEvent extends CollectionEvent { - - /** The items removed from the collection. */ - private final Object[] items; - - private static final long serialVersionUID = 1L; - - - // ********** constructors ********** - - /** - * Construct a new collection remove event. - * - * @param source The object on which the event initially occurred. - * @param collectionName The programmatic name of the collection that was changed. - * @param item The item removed from the collection. - */ - public CollectionRemoveEvent(Model source, String collectionName, Object item) { - this(source, collectionName, new Object[] {item}); - } - - /** - * Construct a new collection remove event. - * - * @param source The object on which the event initially occurred. - * @param collectionName The programmatic name of the collection that was changed. - * @param items The items removed from the collection. - */ - public CollectionRemoveEvent(Model source, String collectionName, Collection<?> items) { - this(source, collectionName, items.toArray()); // NPE if 'items' is null - } - - private CollectionRemoveEvent(Model source, String collectionName, Object[] items) { - super(source, collectionName); - this.items = items; - } - - - // ********** standard state ********** - - /** - * Return the items removed from the collection. - */ - public Iterable<?> getItems() { - return new ArrayIterable<Object>(this.items); - } - - /** - * Return the number of items removed from the collection. - */ - public int getItemsSize() { - return this.items.length; - } - - @Override - protected void toString(StringBuilder sb) { - super.toString(sb); - sb.append(": "); //$NON-NLS-1$ - StringTools.append(sb, this.items); - } - - - // ********** cloning ********** - - /** - * Return a copy of the event with the specified source - * replacing the current source. - */ - public CollectionRemoveEvent clone(Model newSource) { - return this.clone(newSource, this.collectionName); - } - - /** - * Return a copy of the event with the specified source and collection name - * replacing the current source and collection name. - */ - public CollectionRemoveEvent clone(Model newSource, String newCollectionName) { - return new CollectionRemoveEvent(newSource, newCollectionName, this.items); - } - -} diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListAddEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListAddEvent.java deleted file mode 100644 index 900740add7..0000000000 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListAddEvent.java +++ /dev/null @@ -1,134 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.common.utility.model.event; - -import java.util.List; - -import org.eclipse.jpt.common.utility.internal.StringTools; -import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable; -import org.eclipse.jpt.common.utility.model.Model; - -/** - * A "list add" event gets delivered whenever a model adds items to a - * "bound" or "constrained" list. A <code>ListAddEvent</code> is sent as an - * argument to the {@link org.eclipse.jpt.common.utility.model.listener.ListChangeListener}. - * <p> - * Provisional API: This class is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -/* - * See design discussion in CollectionAddEvent - */ -public final class ListAddEvent extends ListEvent { - - /** The index at which the items were added. */ - private final int index; - - /** The items added to the list. */ - private final Object[] items; - - private static final long serialVersionUID = 1L; - - - // ********** constructors ********** - - /** - * Construct a new list add event. - * - * @param source The object on which the event initially occurred. - * @param listName The programmatic name of the list that was changed. - * @param index The index at which the items were added. - * @param item The item added to the list. - */ - public ListAddEvent(Model source, String listName, int index, Object item) { - this(source, listName, index, new Object[] {item}); - } - - /** - * Construct a new list add event. - * - * @param source The object on which the event initially occurred. - * @param listName The programmatic name of the list that was changed. - * @param index The index at which the items were added. - * @param items The items added to the list. - */ - public ListAddEvent(Model source, String listName, int index, List<?> items) { - this(source, listName, index, items.toArray()); // NPE if 'items' is null - } - - private ListAddEvent(Model source, String listName, int index, Object[] items) { - super(source, listName); - this.index = index; - this.items = items; - } - - - // ********** standard state ********** - - /** - * Return the index at which the items were added to the list. - */ - public int getIndex() { - return this.index; - } - - /** - * Return the items added to the list. - */ - public Iterable<?> getItems() { - return new ArrayIterable<Object>(this.items); - } - - /** - * Return the number of items added to the list. - */ - public int getItemsSize() { - return this.items.length; - } - - @Override - protected void toString(StringBuilder sb) { - super.toString(sb); - sb.append(": "); //$NON-NLS-1$ - StringTools.append(sb, this.items); - } - - - // ********** cloning ********** - - /** - * Return a copy of the event with the specified source - * replacing the current source. - */ - public ListAddEvent clone(Model newSource) { - return this.clone(newSource, this.listName); - } - - /** - * Return a copy of the event with the specified source and list name - * replacing the current source and list name. - */ - public ListAddEvent clone(Model newSource, String newListName) { - return this.clone(newSource, newListName, 0); - } - - /** - * Return a copy of the event with the specified source and list name - * replacing the current source and list name and displacing - * the index by the specified amount. - */ - public ListAddEvent clone(Model newSource, String newListName, int offset) { - return new ListAddEvent(newSource, newListName, this.index + offset, this.items); - } - -} diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListChangeEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListChangeEvent.java deleted file mode 100644 index ebcf2919c6..0000000000 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListChangeEvent.java +++ /dev/null @@ -1,105 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.common.utility.model.event; - -import java.util.List; - -import org.eclipse.jpt.common.utility.internal.StringTools; -import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable; -import org.eclipse.jpt.common.utility.model.Model; - -/** - * A "list change" event gets delivered whenever a model changes a "bound" - * or "constrained" list in a manner that is not easily characterized by - * the other list events. - * A <code>ListChangeEvent</code> is sent as an - * argument to the {@link org.eclipse.jpt.common.utility.model.listener.ListChangeListener}. - * A <code>ListChangeEvent</code> is accompanied by the list name and - * the current state of the list. - * <p> - * Provisional API: This class is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public final class ListChangeEvent extends ListEvent { - - /** - * The the list in its current state. - * Clients will need to calculate the necessary changes to synchronize - * with the list. - */ - private final Object[] list; - - private static final long serialVersionUID = 1L; - - - // ********** constructors ********** - - /** - * Construct a new list change event. - * - * @param source The object on which the event initially occurred. - * @param listName The programmatic name of the list that was changed. - */ - public ListChangeEvent(Model source, String listName, List<?> list) { - this(source, listName, list.toArray()); // NPE if 'list' is null - } - - private ListChangeEvent(Model source, String listName, Object[] list) { - super(source, listName); - this.list = list; - } - - - // ********** standard state ********** - - /** - * Return the current state of the list. - */ - public Iterable<?> getList() { - return new ArrayIterable<Object>(this.list); - } - - /** - * Return the number of items in the current state of the list. - */ - public int getListSize() { - return this.list.length; - } - - @Override - protected void toString(StringBuilder sb) { - super.toString(sb); - sb.append(": "); //$NON-NLS-1$ - StringTools.append(sb, this.list); - } - - - // ********** cloning ********** - - /** - * Return a copy of the event with the specified source - * replacing the current source. - */ - public ListChangeEvent clone(Model newSource) { - return this.clone(newSource, this.listName); - } - - /** - * Return a copy of the event with the specified source and list name - * replacing the current source and list name. - */ - public ListChangeEvent clone(Model newSource, String newListName) { - return new ListChangeEvent(newSource, newListName, this.list); - } - -} diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListClearEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListClearEvent.java deleted file mode 100644 index 8faf558131..0000000000 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListClearEvent.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.common.utility.model.event; - -import org.eclipse.jpt.common.utility.model.Model; - -/** - * A "list clear" event gets delivered whenever a model clears - * a "bound" or "constrained" list. A <code>ListClearEvent</code> is sent - * as an argument to the {@link org.eclipse.jpt.common.utility.model.listener.ListChangeListener}. - * <p> - * Provisional API: This class is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public final class ListClearEvent extends ListEvent { - - private static final long serialVersionUID = 1L; - - - // ********** constructor ********** - - /** - * Construct a new list clear event. - * - * @param source The object on which the event initially occurred. - * @param listName The programmatic name of the list that was changed. - */ - public ListClearEvent(Model source, String listName) { - super(source, listName); - } - - - // ********** cloning ********** - - /** - * Return a copy of the event with the specified source - * replacing the current source. - */ - public ListClearEvent clone(Model newSource) { - return this.clone(newSource, this.listName); - } - - /** - * Return a copy of the event with the specified source and list name - * replacing the current source and list name. - */ - public ListClearEvent clone(Model newSource, String newListName) { - return new ListClearEvent(newSource, newListName); - } - -} diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListEvent.java deleted file mode 100644 index acd345845c..0000000000 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListEvent.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.common.utility.model.event; - -import org.eclipse.jpt.common.utility.model.Model; - -// TODO add "item/original/nested event" for item changed? -/** - * A "list" event gets delivered whenever a model changes a "bound" - * or "constrained" list. A <code>ListEvent</code> is sent as an - * argument to the {@link org.eclipse.jpt.common.utility.model.listener.ListChangeListener}. - * The intent is that any listener - * can keep itself synchronized with the model's list via the list - * events it receives and need not maintain a reference to the original - * list. - * <p> - * Provisional API: This class is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public class ListEvent extends ChangeEvent { - - /** Name of the list that changed. */ - final String listName; - - private static final long serialVersionUID = 1L; - - - /** - * Construct a new list event. - * - * @param source The object on which the event initially occurred. - * @param listName The programmatic name of the list that was changed. - */ - public ListEvent(Model source, String listName) { - super(source); - if (listName == null) { - throw new NullPointerException(); - } - this.listName = listName; - } - - /** - * Return the programmatic name of the list that was changed. - */ - public String getListName() { - return this.listName; - } - - @Override - protected void toString(StringBuilder sb) { - sb.append(this.listName); - } - -} diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListMoveEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListMoveEvent.java deleted file mode 100644 index 4627edb5b3..0000000000 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListMoveEvent.java +++ /dev/null @@ -1,120 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.common.utility.model.event; - -import org.eclipse.jpt.common.utility.model.Model; - -/** - * A "list move" event gets delivered whenever a model moves the elements in - * a "bound" or "constrained" list. A <code>ListMoveEvent</code> is sent - * as an argument to the {@link org.eclipse.jpt.common.utility.model.listener.ListChangeListener}. - * <p> - * Provisional API: This class is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public final class ListMoveEvent extends ListEvent { - - /** The index to which the items were moved. */ - private final int targetIndex; - - /** The index from which the items were moved. */ - private final int sourceIndex; - - /** The number of items moved. */ - private final int length; - - private static final long serialVersionUID = 1L; - - - // ********** constructor ********** - - /** - * Construct a new list move event. - * - * @param source The object on which the event initially occurred. - * @param listName The programmatic name of the list that was changed. - * @param targetIndex The index to which the items were moved. - * @param sourceIndex The index from which the items were moved. - * @param length The number of items moved. - */ - public ListMoveEvent(Model source, String listName, int targetIndex, int sourceIndex, int length) { - super(source, listName); - this.targetIndex = targetIndex; - this.sourceIndex = sourceIndex; - this.length = length; - } - - - // ********** standard state ********** - - /** - * Return the index to which the items were moved. - */ - public int getTargetIndex() { - return this.targetIndex; - } - - /** - * Return the index from which the items were moved. - */ - public int getSourceIndex() { - return this.sourceIndex; - } - - /** - * Return the number of items moved. - */ - public int getLength() { - return this.length; - } - - @Override - protected void toString(StringBuilder sb) { - super.toString(sb); - sb.append(": "); //$NON-NLS-1$ - sb.append(this.sourceIndex); - sb.append(" => "); //$NON-NLS-1$ - sb.append(this.targetIndex); - sb.append(" length="); //$NON-NLS-1$ - sb.append(this.length); - } - - - // ********** cloning ********** - - /** - * Return a copy of the event with the specified source - * replacing the current source. - */ - public ListMoveEvent clone(Model newSource) { - return this.clone(newSource, this.listName); - } - - /** - * Return a copy of the event with the specified source and list name - * replacing the current source and list name. - */ - public ListMoveEvent clone(Model newSource, String newListName) { - return this.clone(newSource, newListName, 0); - } - - /** - * Return a copy of the event with the specified source and list name - * replacing the current source and list name and displacing - * the index by the specified amount. - */ - public ListMoveEvent clone(Model newSource, String newListName, int offset) { - return new ListMoveEvent(newSource, newListName, this.targetIndex + offset, this.sourceIndex + offset, this.length); - } - -} diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListRemoveEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListRemoveEvent.java deleted file mode 100644 index 41b82d8ca6..0000000000 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListRemoveEvent.java +++ /dev/null @@ -1,134 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.common.utility.model.event; - -import java.util.Collection; - -import org.eclipse.jpt.common.utility.internal.StringTools; -import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable; -import org.eclipse.jpt.common.utility.model.Model; - -/** - * A "list remove" event gets delivered whenever a model removes items - * from a "bound" or "constrained" list. A <code>ListRemoveEvent</code> is sent - * as an argument to the {@link org.eclipse.jpt.common.utility.model.listener.ListChangeListener}. - * <p> - * Provisional API: This class is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -/* - * See design discussion in CollectionAddEvent - */ -public final class ListRemoveEvent extends ListEvent { - - /** The index at which the items were removed. */ - private final int index; - - /** The items removed from the list. */ - private final Object[] items; - - private static final long serialVersionUID = 1L; - - - // ********** constructors ********** - - /** - * Construct a new list remove event. - * - * @param source The object on which the event initially occurred. - * @param collectionName The programmatic name of the list that was changed. - * @param index The index at which the items were removed. - * @param item The item removed from the list. - */ - public ListRemoveEvent(Model source, String listName, int index, Object item) { - this(source, listName, index, new Object[] {item}); - } - - /** - * Construct a new list remove event. - * - * @param source The object on which the event initially occurred. - * @param collectionName The programmatic name of the list that was changed. - * @param index The index at which the items were removed. - * @param items The items removed from the list. - */ - public ListRemoveEvent(Model source, String listName, int index, Collection<?> items) { - this(source, listName, index, items.toArray()); // NPE if 'items' is null - } - - private ListRemoveEvent(Model source, String listName, int index, Object[] items) { - super(source, listName); - this.index = index; - this.items = items; - } - - - // ********** standard state ********** - - /** - * Return the index at which the items were removed from the list. - */ - public int getIndex() { - return this.index; - } - - /** - * Return the items removed from the list. - */ - public Iterable<?> getItems() { - return new ArrayIterable<Object>(this.items); - } - - /** - * Return the number of items removed from the list. - */ - public int getItemsSize() { - return this.items.length; - } - - @Override - protected void toString(StringBuilder sb) { - super.toString(sb); - sb.append(": "); //$NON-NLS-1$ - StringTools.append(sb, this.items); - } - - - // ********** cloning ********** - - /** - * Return a copy of the event with the specified source - * replacing the current source. - */ - public ListRemoveEvent clone(Model newSource) { - return this.clone(newSource, this.listName); - } - - /** - * Return a copy of the event with the specified source and list name - * replacing the current source and list name. - */ - public ListRemoveEvent clone(Model newSource, String newListName) { - return this.clone(newSource, newListName, 0); - } - - /** - * Return a copy of the event with the specified source and list name - * replacing the current source and list name and displacing - * the index by the specified amount. - */ - public ListRemoveEvent clone(Model newSource, String newListName, int offset) { - return new ListRemoveEvent(newSource, newListName, this.index + offset, this.items); - } - -} diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListReplaceEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListReplaceEvent.java deleted file mode 100644 index dd6f3760e0..0000000000 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListReplaceEvent.java +++ /dev/null @@ -1,150 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.common.utility.model.event; - -import java.util.List; - -import org.eclipse.jpt.common.utility.internal.StringTools; -import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable; -import org.eclipse.jpt.common.utility.model.Model; - -/** - * A "list replace" event gets delivered whenever a model replaces items in a - * "bound" or "constrained" list. A <code>ListReplaceEvent</code> is sent as an - * argument to the {@link org.eclipse.jpt.common.utility.model.listener.ListChangeListener}. - * <p> - * Provisional API: This class is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public final class ListReplaceEvent extends ListEvent { - - /** The index at which the items were replaced. */ - private final int index; - - /** The new items that replaced the old items in the list. */ - private final Object[] newItems; - - /** The old items that were replaced by the new items in the list. */ - private final Object[] oldItems; - - private static final long serialVersionUID = 1L; - - - // ********** constructors ********** - - /** - * Construct a new list replace event for a list of replaced items. - * - * @param source The object on which the event initially occurred. - * @param listName The programmatic name of the list that was changed. - * @param index The index at which the item in the list was replaced. - * @param newItem The new item in the list. - * @param oldItem The old item in the list that were replaced. - */ - public ListReplaceEvent(Model source, String listName, int index, Object newItem, Object oldItem) { - this(source, listName, index, new Object[] {newItem}, new Object[] {oldItem}); - } - - /** - * Construct a new list replace event for a list of replaced items. - * - * @param source The object on which the event initially occurred. - * @param listName The programmatic name of the list that was changed. - * @param index The index at which the items in the list were replaced. - * @param newItems The new items in the list. - * @param oldItems The old items in the list that were replaced. - */ - public ListReplaceEvent(Model source, String listName, int index, List<?> newItems, List<?> oldItems) { - this(source, listName, index, newItems.toArray(), oldItems.toArray()); // NPE if either 'newItems' or 'oldItems' is null - } - - private ListReplaceEvent(Model source, String listName, int index, Object[] newItems, Object[] oldItems) { - super(source, listName); - if (newItems.length != oldItems.length) { - throw new IllegalArgumentException("sizes must match - new items size: " + newItems.length //$NON-NLS-1$ - + " old items size: " + oldItems.length); //$NON-NLS-1$ - } - this.index = index; - this.newItems = newItems; - this.oldItems = oldItems; - } - - - // ********** standard state ********** - - /** - * Return the index at which the items were replaced in the list. - */ - public int getIndex() { - return this.index; - } - - /** - * Return the new items that replaced the old items in the list. - */ - public Iterable<?> getNewItems() { - return new ArrayIterable<Object>(this.newItems); - } - - /** - * Return the old items that were replaced by the new items in the list. - */ - public Iterable<?> getOldItems() { - return new ArrayIterable<Object>(this.oldItems); - } - - /** - * Return the number of items that were replaced. - */ - public int getItemsSize() { - return this.newItems.length; - } - - @Override - protected void toString(StringBuilder sb) { - super.toString(sb); - sb.append(": "); //$NON-NLS-1$ - StringTools.append(sb, this.oldItems); - sb.append(" => "); //$NON-NLS-1$ - StringTools.append(sb, this.newItems); - } - - - // ********** cloning ********** - - /** - * Return a copy of the event with the specified source - * replacing the current source. - */ - public ListReplaceEvent clone(Model newSource) { - return this.clone(newSource, this.listName); - } - - /** - * Return a copy of the event with the specified source and list name - * replacing the current source and list name. - */ - public ListReplaceEvent clone(Model newSource, String newListName) { - return this.clone(newSource, newListName, 0); - } - - /** - * Return a copy of the event with the specified source and list name - * replacing the current source and list name and displacing - * the index by the specified amount. - */ - public ListReplaceEvent clone(Model newSource, String newListName, int offset) { - return new ListReplaceEvent(newSource, newListName, this.index + offset, this.newItems, this.oldItems); - } - -} diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/PropertyChangeEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/PropertyChangeEvent.java deleted file mode 100644 index 55c7475e85..0000000000 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/PropertyChangeEvent.java +++ /dev/null @@ -1,109 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.common.utility.model.event; - -import org.eclipse.jpt.common.utility.model.Model; - -/** - * A "property change" event gets delivered whenever a model changes a "bound" - * or "constrained" property. A <code>PropertyChangeEvent</code> is sent as an - * argument to the {@link org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener}. - * A <code>PropertyChangeEvent</code> is accompanied by the old and new values - * of the property. - * <p> - * Provisional API: This class is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public final class PropertyChangeEvent extends ChangeEvent { - - /** Name of the property that changed. */ - private final String propertyName; - - /** The property's old value, before the change. */ - private final Object oldValue; - - /** The property's new value, after the change. */ - private final Object newValue; - - private static final long serialVersionUID = 1L; - - - // ********** constructors ********** - - /** - * Construct a new property change event. - * - * @param source The object on which the event initially occurred. - * @param propertyName The programmatic name of the property that was changed. - * @param oldValue The old value of the property. - * @param newValue The new value of the property. - */ - public PropertyChangeEvent(Model source, String propertyName, Object oldValue, Object newValue) { - super(source); - if (propertyName == null) { - throw new NullPointerException(); - } - this.propertyName = propertyName; - this.oldValue = oldValue; - this.newValue = newValue; - } - - - // ********** standard state ********** - - /** - * Return the programmatic name of the property that was changed. - */ - public String getPropertyName() { - return this.propertyName; - } - - /** - * Return the old value of the property. - */ - public Object getOldValue() { - return this.oldValue; - } - - /** - * Return the new value of the property. - */ - public Object getNewValue() { - return this.newValue; - } - - @Override - protected void toString(StringBuilder sb) { - sb.append(this.propertyName); - sb.append(": "); //$NON-NLS-1$ - sb.append(this.oldValue); - sb.append(" => "); //$NON-NLS-1$ - sb.append(this.newValue); - } - - - // ********** cloning ********** - - public PropertyChangeEvent clone(Model newSource) { - return new PropertyChangeEvent(newSource, this.propertyName, this.oldValue, this.newValue); - } - - /** - * Return a copy of the event with the specified source and property name - * replacing the current source and property name. - */ - public PropertyChangeEvent clone(Model newSource, String newPropertyName) { - return new PropertyChangeEvent(newSource, newPropertyName, this.oldValue, this.newValue); - } - -} diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/StateChangeEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/StateChangeEvent.java deleted file mode 100644 index fdac399c4b..0000000000 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/StateChangeEvent.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.common.utility.model.event; - -import org.eclipse.jpt.common.utility.model.Model; - -/** - * A generic "state change" event gets delivered whenever a model changes to - * such extent that it cannot be delineated all aspects of it that have changed. - * Any listener can synchronize with the model as necessary since the model is - * available as the event's 'source'. - * A <code>StateChangeEvent</code> is sent as an argument to the - * {@link org.eclipse.jpt.common.utility.model.listener.StateChangeListener}. - * <p> - * Provisional API: This class is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public final class StateChangeEvent extends ChangeEvent { - - private static final long serialVersionUID = 1L; - - - // ********** constructors ********** - - /** - * Construct a new state change event. - * - * @param source The object on which the event initially occurred. - */ - public StateChangeEvent(Model source) { - super(source); - } - - - // ********** cloning ********** - - public StateChangeEvent clone(Model newSource) { - return new StateChangeEvent(newSource); - } - -} diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/TreeAddEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/TreeAddEvent.java deleted file mode 100644 index 0550271a5d..0000000000 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/TreeAddEvent.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.common.utility.model.event; - -import java.util.List; - -import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable; -import org.eclipse.jpt.common.utility.model.Model; - -/** - * A "tree add" event gets delivered whenever a model adds a node to a "bound" - * or "constrained" tree. A <code>TreeChangeEvent</code> is sent as an - * argument to the {@link org.eclipse.jpt.common.utility.model.listener.TreeChangeListener}. - * <p> - * Provisional API: This class is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public final class TreeAddEvent extends TreeEvent { - - /** - * Path to the node added to the tree. - */ - protected final Object[] path; - - private static final long serialVersionUID = 1L; - - - // ********** constructors ********** - - /** - * Construct a new tree add event. - * - * @param source The object on which the event initially occurred. - * @param treeName The programmatic name of the tree that was changed. - * @param path The path to the part of the tree that was added. - */ - public TreeAddEvent(Model source, String treeName, List<?> path) { - this(source, treeName, path.toArray()); // NPE if 'path' is null - } - - private TreeAddEvent(Model source, String treeName, Object[] path) { - super(source, treeName); - this.path = path; - } - - - // ********** standard state ********** - - /** - * Return the path to the part of the tree that was added. - */ - public Iterable<?> getPath() { - return new ArrayIterable<Object>(this.path); - } - - - // ********** cloning ********** - - public TreeAddEvent clone(Model newSource) { - return this.clone(newSource, this.treeName); - } - - /** - * Return a copy of the event with the specified source and tree name - * replacing the current source and tree name. - */ - public TreeAddEvent clone(Model newSource, String newTreeName) { - return new TreeAddEvent(newSource, newTreeName, this.path); - } - -} diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/TreeChangeEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/TreeChangeEvent.java deleted file mode 100644 index 7ad7e03db5..0000000000 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/TreeChangeEvent.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.common.utility.model.event; - -import java.util.Collection; - -import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable; -import org.eclipse.jpt.common.utility.model.Model; - -/** - * A "tree change" event gets delivered whenever a model changes a "bound" - * or "constrained" tree in a manner that is not easily characterized by - * the other tree events. - * A <code>TreeChangeEvent</code> is sent as an - * argument to the {@link org.eclipse.jpt.common.utility.model.listener.TreeChangeListener}. - * <p> - * Provisional API: This class is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public final class TreeChangeEvent extends TreeEvent { - - /** - * The current nodes in the changed tree. - */ - protected final Object[] nodes; - - private static final long serialVersionUID = 1L; - - - // ********** constructor ********** - - /** - * Construct a new tree change event. - * - * @param source The object on which the event initially occurred. - * @param treeName The programmatic name of the tree that was changed. - * @param nodes The current nodes in the changed tree. - */ - public TreeChangeEvent(Model source, String treeName, Collection<?> nodes) { - this(source, treeName, nodes.toArray()); // NPE if 'nodes' is null - } - - private TreeChangeEvent(Model source, String treeName, Object[] nodes) { - super(source, treeName); - this.nodes = nodes; - } - - - // ********** standard state ********** - - /** - * Return the current nodes in the changed tree. - */ - public Iterable<?> getNodes() { - return new ArrayIterable<Object>(this.nodes); - } - - /** - * Return the current nodes in the changed tree. - */ - public int getNodesSize() { - return this.nodes.length; - } - - - // ********** cloning ********** - - public TreeChangeEvent clone(Model newSource) { - return this.clone(newSource, this.treeName); - } - - /** - * Return a copy of the event with the specified source and tree name - * replacing the current source and tree name. - */ - public TreeChangeEvent clone(Model newSource, String newTreeName) { - return new TreeChangeEvent(newSource, newTreeName, this.nodes); - } - -} diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/TreeClearEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/TreeClearEvent.java deleted file mode 100644 index 6d96568a7f..0000000000 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/TreeClearEvent.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.common.utility.model.event; - -import org.eclipse.jpt.common.utility.model.Model; - -/** - * A "tree clear" event gets delivered whenever a model clears - * a "bound" or "constrained" tree. A <code>TreeClearEvent</code> is sent - * as an argument to the {@link org.eclipse.jpt.common.utility.model.listener.TreeChangeListener}. - * <p> - * Provisional API: This class is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public final class TreeClearEvent extends TreeEvent { - - private static final long serialVersionUID = 1L; - - - // ********** constructors ********** - - /** - * Construct a new tree clear event. - * - * @param source The object on which the event initially occurred. - * @param collectionName The programmatic name of the tree that was changed. - */ - public TreeClearEvent(Model source, String treeName) { - super(source, treeName); - } - - - // ********** cloning ********** - - /** - * Return a copy of the event with the specified source - * replacing the current source. - */ - public TreeClearEvent clone(Model newSource) { - return this.clone(newSource, this.treeName); - } - - /** - * Return a copy of the event with the specified source and collection name - * replacing the current source and collection name. - */ - public TreeClearEvent clone(Model newSource, String newCollectionName) { - return new TreeClearEvent(newSource, newCollectionName); - } - -} diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/TreeEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/TreeEvent.java deleted file mode 100644 index e57777aef1..0000000000 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/TreeEvent.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.common.utility.model.event; - -import org.eclipse.jpt.common.utility.model.Model; - -/** - * A "tree" event gets delivered whenever a model changes a "bound" - * or "constrained" tree. A <code>TreeEvent</code> is sent as an - * argument to the {@link org.eclipse.jpt.common.utility.model.listener.TreeChangeListener}. - * The intent is that any listener - * can keep itself synchronized with the model's tree via the tree events - * it receives and need not maintain a reference to the original tree. - * <p> - * Provisional API: This class is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public abstract class TreeEvent extends ChangeEvent { - - /** Name of the tree that changed. */ - final String treeName; - - private static final long serialVersionUID = 1L; - - - /** - * Construct a new tree event. - * - * @param source The object on which the event initially occurred. - * @param treeName The programmatic name of the tree that was changed. - */ - public TreeEvent(Model source, String treeName) { - super(source); - if (treeName == null) { - throw new NullPointerException(); - } - this.treeName = treeName; - } - - /** - * Return the programmatic name of the tree that was changed. - */ - public String getTreeName() { - return this.treeName; - } - - @Override - protected void toString(StringBuilder sb) { - sb.append(this.treeName); - } - -} diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/TreeRemoveEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/TreeRemoveEvent.java deleted file mode 100644 index afa3157678..0000000000 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/TreeRemoveEvent.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.common.utility.model.event; - -import java.util.List; - -import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable; -import org.eclipse.jpt.common.utility.model.Model; - -/** - * A "tree remove" event gets delivered whenever a model removes a node rom a - * "bound" or "constrained" tree. A <code>TreeChangeEvent</code> is sent as an - * argument to the {@link org.eclipse.jpt.common.utility.model.listener.TreeChangeListener}. - * <p> - * Provisional API: This class is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public final class TreeRemoveEvent extends TreeEvent { - - /** - * Path to the node removed from the tree. - */ - protected final Object[] path; - - private static final long serialVersionUID = 1L; - - - // ********** constructors ********** - - /** - * Construct a new tree remove event. - * - * @param source The object on which the event initially occurred. - * @param treeName The programmatic name of the tree that was changed. - * @param path The path to the part of the tree that was removed. - */ - public TreeRemoveEvent(Model source, String treeName, List<?> path) { - this(source, treeName, path.toArray()); // NPE if 'path' is null - } - - private TreeRemoveEvent(Model source, String treeName, Object[] path) { - super(source, treeName); - this.path = path; - } - - - // ********** standard state ********** - - /** - * Return the path to the part of the tree that was removed. - */ - public Iterable<?> getPath() { - return new ArrayIterable<Object>(this.path); - } - - - // ********** cloning ********** - - public TreeRemoveEvent clone(Model newSource) { - return this.clone(newSource, this.treeName); - } - - /** - * Return a copy of the event with the specified source and tree name - * replacing the current source and tree name. - */ - public TreeRemoveEvent clone(Model newSource, String newTreeName) { - return new TreeRemoveEvent(newSource, newTreeName, this.path); - } - -} |