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;
26 public class PHPExternalParserAction implements IObjectActionDelegate {
28 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
46 // IHelp help= WorkbenchHelp.getHelpSupport();
47 // if (help != null) {
48 // WorkbenchHelp.getHelpSupport().displayHelpResource(url.toExternalForm());
50 // showMessage(shell, dialogTitle,
51 // ActionMessages.getString("OpenBrowserUtil.help_not_available"), false);
56 public void run(IAction action) {
57 ISelectionProvider selectionProvider = null;
58 selectionProvider = workbenchPart.getSite().getSelectionProvider();
60 StructuredSelection selection = null;
61 selection = (StructuredSelection) selectionProvider.getSelection();
63 // Shell shell = null;
64 Iterator iterator = null;
65 iterator = selection.iterator();
66 while (iterator.hasNext()) {
67 // obj => selected object in the view
68 Object obj = iterator.next();
71 if (obj instanceof IResource) {
72 IResource resource = (IResource) obj;
74 // check if it's a file resource
75 switch (resource.getType()) {
79 ExternalPHPParser parser = new ExternalPHPParser(
81 parser.phpExternalParse();
88 * @see IActionDelegate#selectionChanged(IAction, ISelection)
90 public void selectionChanged(IAction action, ISelection selection) {