1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.g2d.element.handler;
\r
14 import java.util.Collection;
\r
16 import org.simantics.g2d.element.IElement;
\r
17 import org.simantics.g2d.element.ElementClass.Single;
\r
20 * A handler for retrieving the child elements of an element.
\r
22 * @author Tuukka Lehtonen
\r
25 public interface Children extends ElementHandler {
\r
27 public static class ChildEvent {
\r
28 public final IElement parent;
\r
29 public final Collection<IElement> removed;
\r
30 public final Collection<IElement> added;
\r
32 public ChildEvent(IElement parent, Collection<IElement> removed, Collection<IElement> added) {
\r
33 this.parent = parent;
\r
34 this.removed = removed;
\r
39 public String toString() {
\r
40 return getClass().getSimpleName() + "[parent=" + parent + ", removed=" + removed + ", added=" + added + "]";
\r
44 public interface ChildListener {
\r
45 void elementChildrenChanged(ChildEvent event);
\r
49 * @param element the element to check for child elements
\r
50 * @param result the collection to populate with the results or
\r
51 * <code>null</code> to allocate a new collection. The results shall
\r
52 * be appended to the provided collection.
\r
53 * @return all child elements of the specified IElement or <code>null</code>
\r
54 * if result was <code>null</code> and no children exist
\r
56 Collection<IElement> getChildren(IElement element, Collection<IElement> result);
\r
61 void addChildListener(IElement element, ChildListener listener);
\r
66 void removeChildListener(IElement element, ChildListener listener);
\r