KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > debug > ui > monitors > ToggleViewAction


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

11 package org.eclipse.jdt.internal.debug.ui.monitors;
12
13
14 import org.eclipse.jface.action.IAction;
15 import org.eclipse.jface.viewers.ISelection;
16 import org.eclipse.ui.IViewActionDelegate;
17 import org.eclipse.ui.IViewPart;
18 import org.eclipse.ui.texteditor.IUpdate;
19
20 public abstract class ToggleViewAction implements IViewActionDelegate, IUpdate {
21
22     protected MonitorsView fMonitorsView;
23     protected IAction fAction;
24     
25     /**
26      * @see org.eclipse.ui.IViewActionDelegate#init(IViewPart)
27      */

28     public void init(IViewPart view) {
29         if (view instanceof MonitorsView) {
30             fMonitorsView= (MonitorsView)view;
31             fMonitorsView.add(this);
32         }
33     }
34     
35     /**
36      * @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection)
37      */

38     public void selectionChanged(IAction action, ISelection selection) {
39         fAction= action;
40     }
41     
42     /**
43      * @see org.eclipse.ui.texteditor.IUpdate#update()
44      */

45     public void update() {
46         if (fMonitorsView.getViewId() != getViewId()) {
47             fAction.setChecked(false);
48         }
49     }
50     
51     /**
52      * @see org.eclipse.ui.IActionDelegate#run(IAction)
53      */

54     public void run(IAction action) {
55         fMonitorsView.setViewId(getViewId());
56         fMonitorsView.updateObjects();
57     }
58     
59     protected abstract int getViewId();
60 }
61
Popular Tags