KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > actions > GenerateJavadocAction


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.actions;
12
13 import org.eclipse.swt.widgets.Shell;
14
15 import org.eclipse.jface.action.IAction;
16 import org.eclipse.jface.viewers.ISelection;
17 import org.eclipse.jface.viewers.IStructuredSelection;
18 import org.eclipse.jface.viewers.StructuredSelection;
19
20 import org.eclipse.ui.IWorkbenchWindow;
21 import org.eclipse.ui.IWorkbenchWindowActionDelegate;
22
23 import org.eclipse.jdt.internal.ui.javadocexport.JavadocWizard;
24
25 public class GenerateJavadocAction implements IWorkbenchWindowActionDelegate {
26
27     private ISelection fSelection;
28     private Shell fCurrentShell;
29
30     public void dispose() {
31     }
32
33     public void init(IWorkbenchWindow window) {
34         fCurrentShell= window.getShell();
35     }
36
37     public void run(IAction action) {
38         JavadocWizard wizard= new JavadocWizard();
39         IStructuredSelection selection= null;
40         if (fSelection instanceof IStructuredSelection) {
41             selection= (IStructuredSelection)fSelection;
42         } else {
43             selection= new StructuredSelection();
44         }
45         JavadocWizard.openJavadocWizard(wizard, fCurrentShell, selection);
46     }
47
48     public void selectionChanged(IAction action, ISelection selection) {
49         fSelection= selection;
50     }
51 }
52
Popular Tags