1 /**********************************************************************
2 Copyright (c) 2000, 2002 IBM Corp. and others.
3 All rights reserved. This program and the accompanying materials
4 are made available under the terms of the Common Public License v1.0
5 which accompanies this distribution, and is available at
6 http://www.eclipse.org/legal/cpl-v10.html
9 IBM Corporation - Initial implementation
10 Klaus Hartlage - www.eclipseproject.de
11 **********************************************************************/
12 package net.sourceforge.phpeclipse.actions;
14 import java.util.Iterator;
16 import net.sourceforge.phpdt.externaltools.launchConfigurations.ExternalToolsUtil;
17 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
19 import org.eclipse.core.resources.IProject;
20 import org.eclipse.core.resources.IResource;
21 import org.eclipse.jface.action.IAction;
22 import org.eclipse.jface.preference.IPreferenceStore;
23 import org.eclipse.jface.viewers.ISelection;
24 import org.eclipse.jface.viewers.ISelectionProvider;
25 import org.eclipse.jface.viewers.StructuredSelection;
26 import org.eclipse.ui.IObjectActionDelegate;
27 import org.eclipse.ui.IWorkbenchPart;
29 public class PHPDocumentorAction implements IObjectActionDelegate {
31 private IWorkbenchPart workbenchPart;
33 * Constructor for Action1.
35 public PHPDocumentorAction() {
40 * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
42 public void setActivePart(IAction action, IWorkbenchPart targetPart) {
43 workbenchPart = targetPart;
46 // public static void open(final URL url, final Shell shell, final String dialogTitle) {
47 // IHelp help= WorkbenchHelp.getHelpSupport();
48 // if (help != null) {
49 // WorkbenchHelp.getHelpSupport().displayHelpResource(url.toExternalForm());
51 // showMessage(shell, dialogTitle, ActionMessages.getString("OpenBrowserUtil.help_not_available"), false); //$NON-NLS-1$
55 public void run(IAction action) {
56 ISelectionProvider selectionProvider = null;
57 selectionProvider = workbenchPart.getSite().getSelectionProvider();
59 StructuredSelection selection = null;
60 selection = (StructuredSelection) selectionProvider.getSelection();
62 final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
63 final String phpExecutable = store.getString(PHPeclipsePlugin.PHP_RUN_PREF);
66 Iterator iterator = null;
67 iterator = selection.iterator();
68 while (iterator.hasNext()) {
69 // obj => selected object in the view
70 Object obj = iterator.next();
73 if (obj instanceof IResource) {
74 IResource resource = (IResource) obj;
77 switch (resource.getType()) {
78 case IResource.PROJECT :
79 IProject project = (IProject) resource;
80 String projectName = project.getLocation().toString();
81 String targetDirectory = projectName + "/phpdoc";
83 // C:\>php.exe "C:\Path\To\phpdoc" -t targetdir -o HTML:default:default -d parsedir
85 "\"C:\\php\\phpDocumentor\\phpdoc\" -t " + targetDirectory + " -o HTML:default:default -d " + projectName;
86 ExternalToolsUtil.execute("phpdocumentor", phpExecutable, argument, true);
88 // case IResource.FILE :
90 // IFile file = (IFile) resource;
91 // PHPParserSuperclass.phpExternalParse(file);
98 * @see IActionDelegate#selectionChanged(IAction, ISelection)
100 public void selectionChanged(IAction action, ISelection selection) {