KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > guiframework > view > event > BeforeCreateEvent


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.tools.guiframework.view.event;
25
26 import com.sun.enterprise.tools.guiframework.view.DescriptorContainerView;
27 import com.sun.enterprise.tools.guiframework.view.descriptors.ViewDescriptor;
28
29 import java.util.EventObject JavaDoc;
30
31
32 /**
33  * This event object will be created and used prior to any child being
34  * created. This provides a place to initialize things that may be needed for
35  * object creation (such as populating a Model). The source for this event
36  * will be the parent container, or the ViewDescriptor if there is no parent
37  * container (I know this is inconsistent, however, null is not allowed). The
38  * parent container should always be an instanceof DescriptorContainerView.
39  */

40 public class BeforeCreateEvent extends EventObject JavaDoc {
41
42     /**
43      * This is the constructor for a BeforeCreateEvent. You must specify the
44      * ViewDescriptor (the ViewDescriptor of the View that is about to be
45      * created). You should specify the container unless this is a ViewBean,
46      * in which case null may be passed in. If null is passed, the source
47      * event source will be the descriptor instead of the null View (this is
48      * because null is not allowed as a source).
49      *
50      * @param src The containing DescriptorContainerView
51      * @param desc The ViewDescriptor for the View to be created
52      */

53     public BeforeCreateEvent(DescriptorContainerView src, ViewDescriptor desc) {
54     super((src == null) ? (Object JavaDoc)desc : (Object JavaDoc)src);
55     setViewDescriptor(desc);
56     }
57
58
59     /**
60      * This method sets the ViewDescriptor for the object that is about to be
61      * created.
62      *
63      * @param viewDesc The ViewDescriptor of the View to be created.
64      */

65     protected void setViewDescriptor(ViewDescriptor viewDesc) {
66     if (viewDesc == null) {
67         throw new IllegalArgumentException JavaDoc(
68         "You must specify a ViewDescriptor when creating a "+
69         "BeforeCreateEvent object!");
70     }
71     _viewDesc = viewDesc;
72     }
73
74
75     /**
76      * This method retrieves the ViewDescriptor of the View that is about to
77      * be created. The ViewDescriptor may have necessary information in order
78      * to do what you have to do before the View is created.
79      *
80      * @return The ViewDescriptor for the View about to be created.
81      */

82     public ViewDescriptor getViewDescriptor() {
83     return _viewDesc;
84     }
85
86
87     /**
88      * This method returns the name of the View that is about to be created.
89      *
90      * @return The name of the view to be created.
91      */

92     public String JavaDoc getName() {
93     return getViewDescriptor().getName();
94     }
95
96
97     private ViewDescriptor _viewDesc = null;
98 }
99
Popular Tags