KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > compare > JavaHistoryAction


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.jdt.internal.ui.compare;
12
13 import org.eclipse.core.runtime.Assert;
14
15 import org.eclipse.jface.action.Action;
16 import org.eclipse.jface.action.IAction;
17 import org.eclipse.jface.viewers.ISelection;
18 import org.eclipse.ui.IActionDelegate;
19 import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
20
21 /**
22  * A delegate for JavaHistoryActionImpls.
23  */

24 public abstract class JavaHistoryAction extends Action implements IActionDelegate {
25     
26     private JavaHistoryActionImpl fDelegate;
27     private JavaEditor fEditor;
28     private String JavaDoc fTitle;
29     private String JavaDoc fMessage;
30     
31     JavaHistoryAction() {
32     }
33     
34     private JavaHistoryActionImpl getDelegate() {
35         if (fDelegate == null) {
36             fDelegate= createDelegate();
37             if (fEditor != null && fTitle != null && fMessage != null)
38                 fDelegate.init(fEditor, fTitle, fMessage);
39         }
40         return fDelegate;
41     }
42     
43     protected abstract JavaHistoryActionImpl createDelegate();
44     
45     final void init(JavaEditor editor, String JavaDoc text, String JavaDoc title, String JavaDoc message) {
46         Assert.isNotNull(editor);
47         Assert.isNotNull(title);
48         Assert.isNotNull(message);
49         fEditor= editor;
50         fTitle= title;
51         fMessage= message;
52         //getDelegate().init(editor, text, title, message);
53
setText(text);
54         //setEnabled(getDelegate().checkEnabled());
55
}
56     
57     /**
58      * Executes this action with the given selection.
59      */

60     public final void run(ISelection selection) {
61         getDelegate().run(selection);
62     }
63
64     public final void run() {
65         getDelegate().runFromEditor(this);
66     }
67
68     final void update() {
69         getDelegate().update(this);
70     }
71     
72     //---- IActionDelegate
73

74     public final void selectionChanged(IAction uiProxy, ISelection selection) {
75         getDelegate().selectionChanged(uiProxy, selection);
76     }
77     
78     public final void run(IAction action) {
79         getDelegate().run(action);
80     }
81 }
82
Popular Tags