KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > myfaces > custom > tree > event > TreeSelectionEvent


1 /*
2  * Copyright 2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.myfaces.custom.tree.event;
17
18 import javax.faces.event.FacesEvent;
19 import javax.faces.event.FacesListener;
20 import javax.faces.component.UIComponent;
21
22 import org.apache.myfaces.custom.tree.model.TreePath;
23
24
25 /**
26  * Event fired by {@link org.apache.myfaces.custom.tree.HtmlTree} on selection changes.
27  *
28  * @author <a HREF="mailto:oliver@rossmueller.com">Oliver Rossmueller</a>
29  * @version $Revision: 1.4 $ $Date: 2004/10/13 11:50:58 $
30  * $Log: TreeSelectionEvent.java,v $
31  * Revision 1.4 2004/10/13 11:50:58 matze
32  * renamed packages to org.apache
33  *
34  * Revision 1.3 2004/07/01 21:53:08 mwessendorf
35  * ASF switch
36  *
37  * Revision 1.2 2004/04/23 19:09:34 o_rossmueller
38  * state transition magic
39  *
40  * Revision 1.1 2004/04/22 21:14:54 o_rossmueller
41  * TreeSelectionListener support
42  *
43  */

44 public class TreeSelectionEvent extends FacesEvent
45 {
46
47     private TreePath oldSelectionPath;
48     private TreePath newSelectionPath;
49
50
51     /**
52      * Construct an event.
53      *
54      * @param uiComponent event source
55      * @param oldSelectionPath path of the old selection, null if no node was selected before
56      * @param newSelectionPath path of the current selection
57      */

58     public TreeSelectionEvent(UIComponent uiComponent, TreePath oldSelectionPath, TreePath newSelectionPath)
59     {
60         super(uiComponent);
61         this.oldSelectionPath = oldSelectionPath;
62         this.newSelectionPath = newSelectionPath;
63     }
64
65
66     /**
67      * Answer the path of the old selection.
68      *
69      * @return path of previous (old) selection, null if no node was selected before
70      */

71     public TreePath getOldSelectionPath()
72     {
73         return oldSelectionPath;
74     }
75
76
77     /**
78      * Answer the path of the current (new) selection.
79      *
80      * @return path of the new selected node
81      */

82     public TreePath getNewSelectionPath()
83     {
84         return newSelectionPath;
85     }
86
87
88     public boolean isAppropriateListener(FacesListener faceslistener)
89     {
90         return faceslistener instanceof TreeSelectionListener;
91     }
92
93
94     public void processListener(FacesListener faceslistener)
95     {
96         ((TreeSelectionListener) faceslistener).valueChanged(this);
97     }
98 }
99
Popular Tags