diff options
author | Joonas Lehtinen <joonas.lehtinen@itmill.com> | 2006-11-01 09:11:32 +0000 |
---|---|---|
committer | Joonas Lehtinen <joonas.lehtinen@itmill.com> | 2006-11-01 09:11:32 +0000 |
commit | 13af8cba414fbb6f02ef458a86c5afcad70c5275 (patch) | |
tree | 959ccae1696d9c208124ec3982f166bca6c28f0a /src/com/itmill/toolkit/ui/ComponentContainer.java | |
parent | de5565e87dc08be0a577c663bb2e009d0838c872 (diff) | |
download | vaadin-framework-13af8cba414fbb6f02ef458a86c5afcad70c5275.tar.gz vaadin-framework-13af8cba414fbb6f02ef458a86c5afcad70c5275.zip |
Refactoring: Enably -> IT Mill Toolkit
svn changeset:92/svn branch:toolkit
Diffstat (limited to 'src/com/itmill/toolkit/ui/ComponentContainer.java')
-rw-r--r-- | src/com/itmill/toolkit/ui/ComponentContainer.java | 173 |
1 files changed, 173 insertions, 0 deletions
diff --git a/src/com/itmill/toolkit/ui/ComponentContainer.java b/src/com/itmill/toolkit/ui/ComponentContainer.java new file mode 100644 index 0000000000..0ea1b9b9c4 --- /dev/null +++ b/src/com/itmill/toolkit/ui/ComponentContainer.java @@ -0,0 +1,173 @@ +/* ************************************************************************* + + IT Mill Toolkit + + Development of Browser User Intarfaces Made Easy + + Copyright (C) 2000-2006 IT Mill Ltd + + ************************************************************************* + + This product is distributed under commercial license that can be found + from the product package on license/license.txt. Use of this product might + require purchasing a commercial license from IT Mill Ltd. For guidelines + on usage, see license/licensing-guidelines.html + + ************************************************************************* + + For more information, contact: + + IT Mill Ltd phone: +358 2 4802 7180 + Ruukinkatu 2-4 fax: +358 2 4802 7181 + 20540, Turku email: info@itmill.com + Finland company www: www.itmill.com + + Primary source for information and releases: www.itmill.com + + ********************************************************************** */ + +package com.itmill.toolkit.ui; + +import java.util.Iterator; + +/** Extension to the {@link Component} interface which adds to it the capacity + * to contain other components. All UI elements that can have child elements + * implement this interface. + * + * @author IT Mill Ltd. + * @version @VERSION@ + * @since 3.0 + */ +public interface ComponentContainer extends Component { + + /** Adds a component into this container. + * + * @param c the component to be added + */ + public void addComponent(Component c); + + /** Removes a component from this container. + * + * @param c the component to be added + */ + public void removeComponent(Component c); + + /** Removes all components from this container. */ + public void removeAllComponents(); + + /** Replace a component in the container with another one without changing position. + * + * <p>This method replaces component with another one is such way that the new component + * overtakes the position of the old component. If the old component is not in the + * container, the new component is added to the container. If the both component are + * already in the container, their positions are swapped. + * Component attach and detach events should be taken care as with add and remove.</p> + * + * @param oldComponent The old component that will be replaced. + * @param newComponent The new component to be replaced + */ + public void replaceComponent(Component oldComponent, Component newComponent); + + /** Gets an iterator to the collection of contained components. Using + * this iterator it is possible to step through all components contained + * in this container. + * + * @return component iterator + */ + public Iterator getComponentIterator(); + + /** Moves all components from an another container into this container. + * The components are removed from <code>source</code>. + * + * @param source the container which contains the components that are to + * be moved to this container + */ + public void moveComponentsFrom(ComponentContainer source); + + /** Listen component attach events */ + public void addListener(ComponentAttachListener listener); + + /** Stop listening component attach events */ + public void removeListener(ComponentAttachListener listener); + + /** Listen component detach events */ + public void addListener(ComponentDetachListener listener); + + /** Stop listening component detach events */ + public void removeListener(ComponentDetachListener listener); + + /** Component attach listener interface. */ + public interface ComponentAttachListener { + + /** A new component is attached to container */ + public void componentAttachedToContainer(ComponentAttachEvent event); + } + + /** Component detach listener interface. */ + public interface ComponentDetachListener { + + /** A component has been detached from container */ + public void componentDetachedFromContainer(ComponentDetachEvent event); + } + + /** Component attach event sent when a component is attached to container */ + public class ComponentAttachEvent extends Component.Event { + + /** + * Serial generated by eclipse. + */ + private static final long serialVersionUID = 3257285812184692019L; + + private Component component; + + /** Create new attach event. + * @param container The component container the component has been detached to. + * @param attachedComponent The component that has been attached + */ + public ComponentAttachEvent(ComponentContainer container, Component attachedComponent) { + super(container); + this.component = attachedComponent; + } + + /** Get the component container */ + public ComponentContainer getContainer() { + return (ComponentContainer) getSource(); + } + + /** Get the attached component */ + public Component getAttachedComponent() { + return component; + } + } + + /** Component detach event sent when a component is detached from container */ + public class ComponentDetachEvent extends Component.Event { + + /** + * Serial generated by eclipse. + */ + private static final long serialVersionUID = 3618140052337930290L; + + private Component component; + + /** Create new detach event. + * @param container The component container the component has been detached from. + * @param detachedComponent The component that has been detached + */ + public ComponentDetachEvent(ComponentContainer container, Component detachedComponent) { + super(container); + this.component = detachedComponent; + } + + /** Get the component container */ + public ComponentContainer getContainer() { + return (ComponentContainer) getSource(); + } + + /** Get the detached component */ + public Component getDetachedComponent() { + return component; + } + } + +} |