KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > javadocexport > CreateJavadocActionDelegate


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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.javadocexport;
12
13 import org.eclipse.core.resources.IFile;
14
15 import org.eclipse.swt.widgets.Shell;
16
17 import org.eclipse.jface.action.IAction;
18 import org.eclipse.jface.viewers.ISelection;
19 import org.eclipse.jface.viewers.IStructuredSelection;
20
21 import org.eclipse.ui.IObjectActionDelegate;
22 import org.eclipse.ui.IWorkbenchPart;
23
24 public class CreateJavadocActionDelegate implements IObjectActionDelegate {
25
26     private ISelection fCurrentSelection;
27     private Shell fCurrentShell;
28
29     /*
30      * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
31      */

32     public void setActivePart(IAction action, IWorkbenchPart targetPart) {
33         fCurrentShell= targetPart.getSite().getShell();
34     }
35
36     /*
37      * @see IActionDelegate#run(IAction)
38      */

39     public void run(IAction action) {
40         if (fCurrentSelection instanceof IStructuredSelection) {
41             IStructuredSelection structuredSelection= (IStructuredSelection) fCurrentSelection;
42             Object JavaDoc first= structuredSelection.getFirstElement();
43             if (first instanceof IFile) {
44                 JavadocWizard wizard= new JavadocWizard((IFile) first);
45                 JavadocWizard.openJavadocWizard(wizard, fCurrentShell, structuredSelection);
46             }
47         }
48     }
49
50     /*
51      * @see IActionDelegate#selectionChanged(IAction, ISelection)
52      */

53     public void selectionChanged(IAction action, ISelection selection) {
54         fCurrentSelection= selection;
55     }
56
57 }
58
Popular Tags