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(final UIComponent uiComponent, final Integer oldTabIndex, final 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(final UIComponent uiComponent, final Object oldState, final Object newState) {
44      super(uiComponent);
45      setOldState(oldState);
46      setNewState(newState);
47    }
48  
49    @Override
50    public boolean isAppropriateListener(final FacesListener facesListener) {
51      return facesListener instanceof TabChangeListener;
52    }
53  
54    @Override
55    public void processListener(final FacesListener facesListener) {
56      if (facesListener instanceof TabChangeListener) {
57        ((TabChangeListener) facesListener).processTabChange(this);
58      }
59    }
60  
61    public int getOldTabIndex() {
62      return oldTabIndex;
63    }
64  
65    public int getNewTabIndex() {
66      return newTabIndex;
67    }
68  
69    /**
70     * @deprecated Please use {@link #getOldTabIndex()}
71     */
72    @Deprecated
73    public Object getOldState() {
74      return oldTabIndex;
75    }
76  
77    /**
78     * @deprecated Not supported anymore
79     */
80    @Deprecated
81    public void setOldState(final Object oldTabIndex) {
82      this.oldTabIndex = oldTabIndex instanceof Integer ? (Integer) oldTabIndex : -1;
83    }
84  
85    /**
86     * @deprecated Please use {@link #getNewTabIndex()}
87     */
88    @Deprecated
89    public Object getNewState() {
90      return newTabIndex;
91    }
92  
93    /**
94     * @deprecated Not supported anymore
95     */
96    @Deprecated
97    public void setNewState(final Object newTabIndex) {
98      this.newTabIndex = newTabIndex instanceof Integer ? (Integer) newTabIndex : -1;
99    }
100 }