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