KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > wings > event > SContainerEvent


1 /*
2  * $Id: SContainerEvent.java,v 1.3 2004/12/01 07:54:07 hengels Exp $
3  * Copyright 2000,2005 wingS development team.
4  *
5  * This file is part of wingS (http://www.j-wings.org).
6  *
7  * wingS is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License
9  * as published by the Free Software Foundation; either version 2.1
10  * of the License, or (at your option) any later version.
11  *
12  * Please see COPYING for the complete licence.
13  */

14 package org.wings.event;
15
16 import org.wings.SComponent;
17 import org.wings.SContainer;
18
19 /**
20  * A container event, that is issued, whenever a
21  * component is added or removed from an container.
22  *
23  * @author <a HREF="mailto:H.Zeller@acm.org">Henner Zeller</a>
24  * @see org.wings.SContainer#addContainerListener(SContainerListener)
25  */

26 public class SContainerEvent extends SComponentEvent {
27     /**
28      * The first number of used IDs for container events.
29      */

30     public static final int CONTAINER_FIRST = 11000;
31
32     /**
33      * An event with this ID indicates, that a component was added to
34      * the container.
35      */

36     public static final int COMPONENT_ADDED = CONTAINER_FIRST;
37
38     /**
39      * An event with this ID indicates, that a component was removed from
40      * the container.
41      */

42     public static final int COMPONENT_REMOVED = CONTAINER_FIRST + 1;
43
44     /**
45      * The last number of used IDs for container events.
46      */

47     public static final int CONTAINER_LAST = COMPONENT_REMOVED;
48
49     /**
50      * the child component that has been added or removed.
51      */

52     private final SComponent child;
53
54     /**
55      * create a new container event issued by 'source' and affecting
56      * 'child'.
57      *
58      * @param source the Container issuing this event
59      * @param id the integer ID describing the action; one of
60      * <code>COMPONENT_ADDED</code>
61      * or <code>COMPONENT_REMOVED</code>.
62      * @param child the component that is affected by this event, i.e. that
63      * is added or removed.
64      */

65     public SContainerEvent(SContainer source, int id, SComponent child) {
66         super(source, id);
67         this.child = child;
68     }
69
70     /**
71      * returns the source container, this event origins from.
72      */

73     public SContainer getContainer() {
74         return (SContainer) source;
75     }
76
77     /**
78      * returns the child component, whose new status in the container
79      * is reported by this event.
80      */

81     public SComponent getChild() {
82         return child;
83     }
84
85     public String JavaDoc paramString() {
86         switch (id) {
87             case COMPONENT_ADDED:
88                 return "COMPONENT_ADDED";
89             case COMPONENT_REMOVED:
90                 return "COMPONENT_REMOVED";
91             default:
92                 return super.paramString();
93         }
94     }
95
96     public String JavaDoc toString() {
97         return "ContainerEvent[container=" + source + "; " + paramString() +
98                 "child=" + child + "]";
99     }
100 }
101
102
103
Popular Tags