View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  
20  package org.apache.myfaces.tobago.event;
21  
22  import javax.faces.component.UIComponent;
23  import javax.faces.event.ActionEvent;
24  import javax.faces.event.FacesListener;
25  
26  public class TabChangeEvent extends ActionEvent {
27  
28    private static final long serialVersionUID = 422186716954088729L;
29  
30    private Integer oldTabIndex;
31    private Integer newTabIndex;
32  
33    public TabChangeEvent(UIComponent uiComponent, Integer oldTabIndex, Integer newTabIndex) {
34      super(uiComponent);
35      this.oldTabIndex = oldTabIndex;
36      this.newTabIndex = newTabIndex;
37    }
38    
39    /**
40     * @deprecated Please use {@link TabChangeEvent(UIComponent, Integer, Integer)}
41     */
42    @Deprecated
43    public TabChangeEvent(UIComponent uiComponent, Object oldState, Object newState) {
44      super(uiComponent);
45      setOldState(oldState);
46      setNewState(newState);
47    }
48  
49    public boolean isAppropriateListener(FacesListener facesListener) {
50      return facesListener instanceof TabChangeListener;
51    }
52  
53    public void processListener(FacesListener facesListener) {
54      if (facesListener instanceof TabChangeListener) {
55        ((TabChangeListener) facesListener).processTabChange(this);
56      }
57    }
58  
59    public int getOldTabIndex() {
60      return oldTabIndex;
61    }
62  
63    public int getNewTabIndex() {
64      return newTabIndex;
65    }
66  
67    /**
68     * @deprecated Please use {@link #getOldTabIndex()}
69     */
70    @Deprecated
71    public Object getOldState() {
72      return oldTabIndex;
73    }
74  
75    /**
76     * @deprecated Not supported anymore
77     */
78    @Deprecated
79    public void setOldState(Object oldTabIndex) {
80      this.oldTabIndex = oldTabIndex instanceof Integer ? (Integer) oldTabIndex : -1;
81    }
82  
83    /**
84     * @deprecated Please use {@link #getNewTabIndex()}
85     */
86    @Deprecated
87    public Object getNewState() {
88      return newTabIndex;
89    }
90  
91    /**
92     * @deprecated Not supported anymore
93     */
94    @Deprecated
95    public void setNewState(Object newTabIndex) {
96      this.newTabIndex = newTabIndex instanceof Integer ? (Integer) newTabIndex : -1;
97    }
98  }