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 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.IObjectActionDelegate;
23 import org.eclipse.ui.IWorkbenchPart;
26 public class PHPExternalParserAction implements IObjectActionDelegate {
28 private IWorkbenchPart workbenchPart;
30 * Constructor for Action1.
32 public PHPExternalParserAction() {
37 * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
39 public void setActivePart(IAction action, IWorkbenchPart targetPart) {
40 workbenchPart = targetPart;
43 // public static void open(final URL url, final Shell shell, final String dialogTitle) {
44 // IHelp help= WorkbenchHelp.getHelpSupport();
45 // if (help != null) {
46 // WorkbenchHelp.getHelpSupport().displayHelpResource(url.toExternalForm());
48 // showMessage(shell, dialogTitle, ActionMessages.getString("OpenBrowserUtil.help_not_available"), false); //$NON-NLS-1$
52 public void run(IAction action) {
53 ISelectionProvider selectionProvider = null;
54 selectionProvider = workbenchPart.getSite().getSelectionProvider();
56 StructuredSelection selection = null;
57 selection = (StructuredSelection) selectionProvider.getSelection();
60 Iterator iterator = null;
61 iterator = selection.iterator();
62 while (iterator.hasNext()) {
63 // obj => selected object in the view
64 Object obj = iterator.next();
67 if (obj instanceof IResource) {
68 IResource resource = (IResource) obj;
70 // check if it's a file resource
71 switch (resource.getType()) {
75 ExternalPHPParser parser = new ExternalPHPParser((IFile)resource);
76 parser.phpExternalParse();
83 * @see IActionDelegate#selectionChanged(IAction, ISelection)
85 public void selectionChanged(IAction action, ISelection selection) {