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
11 **********************************************************************/
12 package net.sourceforge.phpdt.externaltools.actions;
14 import java.util.Iterator;
16 import org.eclipse.core.resources.IFile;
17 import org.eclipse.core.resources.IResource;
18 import org.eclipse.jface.action.IAction;
19 import org.eclipse.jface.viewers.ISelection;
20 import org.eclipse.jface.viewers.ISelectionProvider;
21 import org.eclipse.jface.viewers.StructuredSelection;
22 import org.eclipse.ui.IActionDelegate;
23 import org.eclipse.ui.IObjectActionDelegate;
24 import org.eclipse.ui.IWorkbenchPart;
27 public class PHPExternalParserAction implements IObjectActionDelegate {
29 private IWorkbenchPart workbenchPart;
31 * Constructor for Action1.
33 public PHPExternalParserAction() {
38 * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
40 public void setActivePart(IAction action, IWorkbenchPart targetPart) {
41 workbenchPart = targetPart;
44 // public static void open(final URL url, final Shell shell, final String dialogTitle) {
45 // IHelp help= WorkbenchHelp.getHelpSupport();
46 // if (help != null) {
47 // WorkbenchHelp.getHelpSupport().displayHelpResource(url.toExternalForm());
49 // showMessage(shell, dialogTitle, ActionMessages.getString("OpenBrowserUtil.help_not_available"), false); //$NON-NLS-1$
53 public void run(IAction action) {
54 ISelectionProvider selectionProvider = null;
55 selectionProvider = workbenchPart.getSite().getSelectionProvider();
57 StructuredSelection selection = null;
58 selection = (StructuredSelection) selectionProvider.getSelection();
61 Iterator iterator = null;
62 iterator = selection.iterator();
63 while (iterator.hasNext()) {
64 // obj => selected object in the view
65 Object obj = iterator.next();
68 if (obj instanceof IResource) {
69 IResource resource = (IResource) obj;
71 // check if it's a file resource
72 switch (resource.getType()) {
76 ExternalPHPParser parser = new ExternalPHPParser((IFile)resource);
77 parser.phpExternalParse();
84 * @see IActionDelegate#selectionChanged(IAction, ISelection)
86 public void selectionChanged(IAction action, ISelection selection) {