KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > views > framelist > FrameAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.views.framelist;
12
13 import org.eclipse.jface.action.Action;
14 import org.eclipse.jface.util.IPropertyChangeListener;
15 import org.eclipse.jface.util.PropertyChangeEvent;
16
17 /**
18  * Abstract superclass for actions dealing with frames or a frame list.
19  * This listens for changes to the frame list and updates itself
20  * accordingly.
21  */

22 public abstract class FrameAction extends Action {
23     private FrameList frameList;
24     
25     private IPropertyChangeListener propertyChangeListener = new IPropertyChangeListener() {
26         public void propertyChange(PropertyChangeEvent event) {
27             FrameAction.this.handlePropertyChange(event);
28         }
29     };
30
31     /**
32      * Constructs a new action for the specified frame list.
33      * and adds a property change listener on it.
34      *
35      * @param frameList the frame list
36      */

37     protected FrameAction(FrameList frameList) {
38         this.frameList = frameList;
39         frameList.addPropertyChangeListener(propertyChangeListener);
40     }
41
42     /**
43      * Disposes this frame action.
44      * This implementation removes the property change listener from the frame list.
45      */

46     public void dispose() {
47         frameList.removePropertyChangeListener(propertyChangeListener);
48     }
49
50     /**
51      * Returns the frame list.
52      */

53     public FrameList getFrameList() {
54         return frameList;
55     }
56
57     /**
58      * Handles a property change event from the frame list.
59      * This implementation calls <code>update()</code>.
60      */

61     protected void handlePropertyChange(PropertyChangeEvent event) {
62         update();
63     }
64
65     /**
66      * Updates this action. This implementation does nothing.
67      * Most implementations will override this method.
68      */

69     public void update() {
70     }
71
72 }
73
Popular Tags