001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied. See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019
020 package org.apache.myfaces.tobago.event;
021
022 import javax.faces.component.UIComponent;
023 import javax.faces.event.FacesEvent;
024 import javax.faces.event.FacesListener;
025
026 /*
027 * User: weber
028 * Date: 13.12.2004
029 * Time: 16:25:03
030 */
031 public class TabChangeEvent extends FacesEvent {
032
033 private static final long serialVersionUID = 422186716954088729L;
034
035 private Integer oldTabIndex;
036 private Integer newTabIndex;
037
038 public TabChangeEvent(UIComponent uiComponent, Integer oldTabIndex, Integer newTabIndex) {
039 super(uiComponent);
040 this.oldTabIndex = oldTabIndex;
041 this.newTabIndex = newTabIndex;
042 }
043
044 @Deprecated
045 public TabChangeEvent(UIComponent uiComponent, Object oldState, Object newState) {
046 super(uiComponent);
047 setOldState(oldState);
048 setNewState(newState);
049 }
050
051 public boolean isAppropriateListener(FacesListener facesListener) {
052 return facesListener instanceof TabChangeListener;
053 }
054
055 public void processListener(FacesListener facesListener) {
056 if (facesListener instanceof TabChangeListener) {
057 ((TabChangeListener) facesListener).processTabChange(this);
058 }
059 }
060
061 public int getOldTabIndex() {
062 return oldTabIndex;
063 }
064
065 public int getNewTabIndex() {
066 return newTabIndex;
067 }
068
069 @Deprecated
070 public Object getOldState() {
071 return oldTabIndex;
072 }
073
074 @Deprecated
075 public void setOldState(Object oldTabIndex) {
076 this.oldTabIndex = oldTabIndex instanceof Integer ? (Integer) oldTabIndex : -1;
077 }
078
079 @Deprecated
080 public Object getNewState() {
081 return newTabIndex;
082 }
083
084 @Deprecated
085 public void setNewState(Object newTabIndex) {
086 this.newTabIndex = newTabIndex instanceof Integer ? (Integer) newTabIndex : -1;
087 }
088 }