KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > stringsubstitution > ResourceSelector


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.debug.internal.ui.stringsubstitution;
12
13 import org.eclipse.core.resources.IResource;
14 import org.eclipse.core.resources.ResourcesPlugin;
15 import org.eclipse.core.variables.IStringVariable;
16 import org.eclipse.jface.window.Window;
17 import org.eclipse.swt.widgets.Shell;
18 import org.eclipse.ui.dialogs.ResourceListSelectionDialog;
19
20 /**
21  * Selects a resource argument for a string substitution variable
22  */

23 public class ResourceSelector implements IArgumentSelector {
24
25     /* (non-Javadoc)
26      * @see org.eclipse.debug.internal.ui.stringsubstitution.IArgumentSelector#selectArgument(org.eclipse.debug.internal.core.stringsubstitution.IStringVariable)
27      */

28     public String JavaDoc selectArgument(IStringVariable variable, Shell shell) {
29         ResourceListSelectionDialog dialog = new ResourceListSelectionDialog(shell, ResourcesPlugin.getWorkspace().getRoot(), IResource.FILE | IResource.FOLDER | IResource.PROJECT);
30         dialog.setTitle(StringSubstitutionMessages.ResourceSelector_0);
31         if (dialog.open() == Window.OK) {
32             Object JavaDoc[] objects = dialog.getResult();
33             if (objects.length == 1) {
34                 return ((IResource)objects[0]).getFullPath().toString();
35             }
36         }
37         return null;
38     }
39
40 }
41
Popular Tags