1 package net.sourceforge.phpdt.externaltools.variable;
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
10 **********************************************************************/
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;
18 * Expands a working set type variable into the desired
21 * This class is not intended to be extended by clients.
24 public class WorkingSetExpander implements IVariableResourceExpander {
29 public WorkingSetExpander() {
34 * Method declared on IVariableResourceExpander.
36 public IResource[] getResources(String varTag, String varValue, ExpandVariableContext context) {
37 if (varValue == null || varValue.length() == 0)
40 IWorkingSet set = PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(varValue);
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;
51 resources[i] = (IResource) adaptable.getAdapter(IResource.class);