Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 84a583065fe8481695d7151f25a7288d40798f64 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*******************************************************************************
 * Copyright (c) 2000, 2005 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.cdt.internal.ui.cview;

import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.actions.SelectionProviderAction;

/**
 * Superclass of all actions provided by the cview.
 */
public abstract class CViewAction extends SelectionProviderAction {
	
	private CView cview;

	/**
	 * Creates a new instance of the class.
	 */
	public CViewAction(CView cview, String label) {
		super(cview.getViewer(), label);
		this.cview = cview;
	}

	/**
	 * Returns the cview for which this action was created.
	 */
	public CView getCView() {
		return cview;
	}

	/**
	 * Returns the viewer
	 */
	protected Viewer getViewer() {
		return getCView().getViewer();
	}

	/**
	 * Returns the shell to use within actions.
	 */
	protected Shell getShell() {
		return getCView().getSite().getShell();
	}

	/**
	 * Returns the workbench.
	 */
	protected IWorkbench getWorkbench() {
		return CUIPlugin.getDefault().getWorkbench();
	}

	/**
	 * Returns the workbench window.
	 */
	protected IWorkbenchWindow getWorkbenchWindow() {
		return getCView().getSite().getWorkbenchWindow();
	}
}

Back to the top