All prefs for xampp administrated in external tools plugin.
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / externaltools / variable / WorkingSetExpander.java
1 package net.sourceforge.phpdt.externaltools.variable;
2
3 /**********************************************************************
4 Copyright (c) 2002 IBM Corp. and others. All rights reserved.
5 This file is made available under the terms of the Common Public License v1.0
6 which accompanies this distribution, and is available at
7 http://www.eclipse.org/legal/cpl-v10.html
8  
9 Contributors:
10 **********************************************************************/
11
12 import org.eclipse.core.resources.IResource;
13 import org.eclipse.core.runtime.IAdaptable;
14 import org.eclipse.ui.IWorkingSet;
15 import org.eclipse.ui.PlatformUI;
16
17 /**
18  * Expands a working set type variable into the desired
19  * result format.
20  * <p>
21  * This class is not intended to be extended by clients.
22  * </p>
23  */
24 public class WorkingSetExpander implements IVariableResourceExpander {
25
26         /**
27          * Create an instance
28          */
29         public WorkingSetExpander() {
30                 super();
31         }
32
33         /* (non-Javadoc)
34          * Method declared on IVariableResourceExpander.
35          */
36         public IResource[] getResources(String varTag, String varValue, ExpandVariableContext context) {
37                 if (varValue == null || varValue.length() == 0)
38                         return null;
39
40                 IWorkingSet set = PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(varValue);
41                 if (set == null)
42                         return null;
43                         
44                 IAdaptable[] elements = set.getElements();
45                 IResource[] resources = new IResource[elements.length];
46                 for (int i = 0; i < elements.length; i++) {
47                         IAdaptable adaptable = elements[i];
48                         if (adaptable instanceof IResource)
49                                 resources[i] = (IResource) adaptable;
50                         else
51                                 resources[i] = (IResource) adaptable.getAdapter(IResource.class);
52                 }
53                 
54                 return resources;
55         }
56 }