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 result format.
20 * This class is not intended to be extended by clients.
23 public class WorkingSetExpander implements IVariableResourceExpander {
28 public WorkingSetExpander() {
33 * (non-Javadoc) Method declared on IVariableResourceExpander.
35 public IResource[] getResources(String varTag, String varValue,
36 ExpandVariableContext context) {
37 if (varValue == null || varValue.length() == 0)
40 IWorkingSet set = PlatformUI.getWorkbench().getWorkingSetManager()
41 .getWorkingSet(varValue);
45 IAdaptable[] elements = set.getElements();
46 IResource[] resources = new IResource[elements.length];
47 for (int i = 0; i < elements.length; i++) {
48 IAdaptable adaptable = elements[i];
49 if (adaptable instanceof IResource)
50 resources[i] = (IResource) adaptable;
52 resources[i] = (IResource) adaptable
53 .getAdapter(IResource.class);