All prefs administrated in external tools plugin.
[phpeclipse.git] / net.sourceforge.phpeclipse.externaltools / src / net / sourceforge / phpdt / externaltools / actions / PHPExternalParserAction.java
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
7
8 Contributors:
9     IBM Corporation - Initial implementation
10     www.phpeclipse.de
11 **********************************************************************/
12 package net.sourceforge.phpdt.externaltools.actions;
13
14 import java.util.Iterator;
15
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;
25
26
27 public class PHPExternalParserAction implements IObjectActionDelegate {
28
29   private IWorkbenchPart workbenchPart;
30   /**
31    * Constructor for Action1.
32    */
33   public PHPExternalParserAction() {
34     super();
35   }
36
37   /**
38    * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
39    */
40   public void setActivePart(IAction action, IWorkbenchPart targetPart) {
41     workbenchPart = targetPart;
42   }
43
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());
48   //    } else {
49   //      showMessage(shell, dialogTitle, ActionMessages.getString("OpenBrowserUtil.help_not_available"), false); //$NON-NLS-1$
50   //    }
51   //  }
52
53   public void run(IAction action) {
54     ISelectionProvider selectionProvider = null;
55     selectionProvider = workbenchPart.getSite().getSelectionProvider();
56
57     StructuredSelection selection = null;
58     selection = (StructuredSelection) selectionProvider.getSelection();
59
60     //Shell shell = null;
61     Iterator iterator = null;
62     iterator = selection.iterator();
63     while (iterator.hasNext()) {
64       //  obj => selected object in the view
65       Object obj = iterator.next();
66
67       // is it a resource
68       if (obj instanceof IResource) {
69         IResource resource = (IResource) obj;
70
71         // check if it's a file resource
72         switch (resource.getType()) {
73  
74           case IResource.FILE :
75             // single file:
76           ExternalPHPParser parser = new ExternalPHPParser((IFile)resource);
77           parser.phpExternalParse();
78         }
79       }
80     }
81   }
82
83   /**
84    * @see IActionDelegate#selectionChanged(IAction, ISelection)
85    */
86   public void selectionChanged(IAction action, ISelection selection) {
87   }
88
89 }