KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > externaltools > internal > program > launchConfigurations > ProgramMainTab


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.ui.externaltools.internal.program.launchConfigurations;
12
13
14 import org.eclipse.core.resources.IFile;
15 import org.eclipse.core.resources.ResourcesPlugin;
16 import org.eclipse.jface.viewers.IStructuredSelection;
17 import org.eclipse.swt.widgets.Composite;
18 import org.eclipse.ui.PlatformUI;
19 import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsMainTab;
20 import org.eclipse.ui.externaltools.internal.model.IExternalToolsHelpContextIds;
21 import org.eclipse.ui.externaltools.internal.ui.FileSelectionDialog;
22
23 public class ProgramMainTab extends ExternalToolsMainTab {
24
25     /**
26      * Prompts the user for a program location within the workspace and sets the
27      * location as a String containing the workspace_loc variable or
28      * <code>null</code> if no location was obtained from the user.
29      */

30     protected void handleWorkspaceLocationButtonSelected() {
31         FileSelectionDialog dialog;
32         dialog = new FileSelectionDialog(getShell(), ResourcesPlugin.getWorkspace().getRoot(), ExternalToolsProgramMessages.ProgramMainTab_Select);
33         dialog.open();
34         IStructuredSelection result = dialog.getResult();
35         if (result == null) {
36             return;
37         }
38         Object JavaDoc file= result.getFirstElement();
39         if (file instanceof IFile) {
40             StringBuffer JavaDoc expression = new StringBuffer JavaDoc();
41             expression.append("${workspace_loc:"); //$NON-NLS-1$
42
expression.append(((IFile)file).getFullPath().toString());
43             expression.append("}"); //$NON-NLS-1$
44
locationField.setText(expression.toString());
45         }
46     }
47     
48     
49     /* (non-Javadoc)
50      * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
51      */

52     public void createControl(Composite parent) {
53         super.createControl(parent);
54         PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IExternalToolsHelpContextIds.EXTERNAL_TOOLS_LAUNCH_CONFIGURATION_DIALOG_PROGRAM_MAIN_TAB);
55     }
56 }
57
Popular Tags