01: /*******************************************************************************
02: * Copyright (c) 2000, 2005 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.views.framelist;
11:
12: import org.eclipse.jface.action.Action;
13: import org.eclipse.jface.util.IPropertyChangeListener;
14: import org.eclipse.jface.util.PropertyChangeEvent;
15:
16: /**
17: * Abstract superclass for actions dealing with frames or a frame list.
18: * This listens for changes to the frame list and updates itself
19: * accordingly.
20: */
21: public abstract class FrameAction extends Action {
22: private FrameList frameList;
23:
24: private IPropertyChangeListener propertyChangeListener = new IPropertyChangeListener() {
25: public void propertyChange(PropertyChangeEvent event) {
26: FrameAction.this .handlePropertyChange(event);
27: }
28: };
29:
30: /**
31: * Constructs a new action for the specified frame list.
32: * and adds a property change listener on it.
33: *
34: * @param frameList the frame list
35: */
36: protected FrameAction(FrameList frameList) {
37: this .frameList = frameList;
38: frameList.addPropertyChangeListener(propertyChangeListener);
39: }
40:
41: /**
42: * Disposes this frame action.
43: * This implementation removes the property change listener from the frame list.
44: */
45: public void dispose() {
46: frameList.removePropertyChangeListener(propertyChangeListener);
47: }
48:
49: /**
50: * Returns the frame list.
51: */
52: public FrameList getFrameList() {
53: return frameList;
54: }
55:
56: /**
57: * Handles a property change event from the frame list.
58: * This implementation calls <code>update()</code>.
59: */
60: protected void handlePropertyChange(PropertyChangeEvent event) {
61: update();
62: }
63:
64: /**
65: * Updates this action. This implementation does nothing.
66: * Most implementations will override this method.
67: */
68: public void update() {
69: }
70:
71: }
|