KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > compare > internal > BaseCompareAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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.compare.internal;
12
13 import org.eclipse.jface.action.IAction;
14 import org.eclipse.jface.viewers.ISelection;
15 import org.eclipse.ui.IActionDelegate;
16
17
18 public abstract class BaseCompareAction implements IActionDelegate {
19
20     private ISelection fSelection;
21     
22     /* (non-Javadoc)
23      * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
24      */

25     final public void run(IAction action) {
26         run(fSelection);
27     }
28
29     /* (non-Javadoc)
30      * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
31      */

32     final public void selectionChanged(IAction action, ISelection selection) {
33         fSelection= selection;
34         if (action != null)
35             action.setEnabled(isEnabled(fSelection));
36     }
37     
38     protected boolean isEnabled(ISelection selection) {
39         return false;
40     }
41     
42     abstract protected void run(ISelection selection);
43 }
44
Popular Tags