blob: 9620ac1120fdd8b1c0fb20da06607150264678b8 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2000, 2005 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.ui.javadocexport;
import org.eclipse.core.resources.IFile;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
public class CreateJavadocActionDelegate implements IObjectActionDelegate {
private ISelection fCurrentSelection;
private Shell fCurrentShell;
/*
* @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
*/
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
fCurrentShell= targetPart.getSite().getShell();
}
/*
* @see IActionDelegate#run(IAction)
*/
public void run(IAction action) {
if (fCurrentSelection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection= (IStructuredSelection) fCurrentSelection;
Object first= structuredSelection.getFirstElement();
if (first instanceof IFile) {
JavadocWizard wizard= new JavadocWizard((IFile) first);
JavadocWizard.openJavadocWizard(wizard, fCurrentShell, structuredSelection);
}
}
}
/*
* @see IActionDelegate#selectionChanged(IAction, ISelection)
*/
public void selectionChanged(IAction action, ISelection selection) {
fCurrentSelection= selection;
}
}