1
/*******************************************************************************
2
* Copyright (c) 2006 IBM Corporation.
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
9
* IBM Corporation - Jeff Briggs, Henry Hughes, Ryan Morse
10
*******************************************************************************/
12
package org.eclipse.linuxtools.internal.systemtap.ui.editor.actions;
14
import org.eclipse.jface.action.Action;
15
import org.eclipse.jface.action.IAction;
16
import org.eclipse.jface.viewers.ISelection;
17
import org.eclipse.ui.IEditorPart;
18
import org.eclipse.ui.IWorkbenchPage;
19
import org.eclipse.ui.IWorkbenchWindow;
20
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
21
import org.eclipse.ui.PlatformUI;
23
public abstract class EditorAction extends Action implements IWorkbenchWindowActionDelegate {
24
public EditorAction() {
29
public void init(IWorkbenchWindow window) {
33
protected void updateState() {
34
IEditorPart editor = getActiveEditor();
35
setEnabled(editor != null && editor.isDirty());
38
protected IWorkbenchWindow getWorkbenchWindow() {
39
return PlatformUI.getWorkbench().getActiveWorkbenchWindow();
42
protected IWorkbenchPage getActivePage() {
43
return getWorkbenchWindow().getActivePage();
46
protected IEditorPart getActiveEditor() {
47
return getActivePage().getActiveEditor();
50
public void selectionChanged(IAction act, ISelection select) {
52
buildEnablementChecks();
55
protected void buildEnablementChecks() {
59
protected void setEnablement(boolean enabled) {
60
action.setEnabled(enabled);
63
public void dispose() {
68
protected IWorkbenchWindow window;
69
protected IAction action;