Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 214696 | Differences between
and this patch

Collapse All | Expand All

(-)ui/org/eclipse/jdt/internal/debug/ui/snippeteditor/SnippetEditorPropertyPage.java (-2 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Remy Chi Jian Suen <remy.suen@gmail.com> - Bug 214696 Expose WorkingDirectoryBlock as API
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.internal.debug.ui.snippeteditor;
12
package org.eclipse.jdt.internal.debug.ui.snippeteditor;
12
13
Lines 20-25 Link Here
20
import org.eclipse.debug.ui.ILaunchConfigurationTab;
21
import org.eclipse.debug.ui.ILaunchConfigurationTab;
21
import org.eclipse.jdt.debug.ui.launchConfigurations.JavaJRETab;
22
import org.eclipse.jdt.debug.ui.launchConfigurations.JavaJRETab;
22
import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
23
import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
24
import org.eclipse.jdt.internal.debug.ui.launcher.JavaWorkingDirectoryBlock;
23
import org.eclipse.jdt.internal.debug.ui.launcher.VMArgumentsBlock;
25
import org.eclipse.jdt.internal.debug.ui.launcher.VMArgumentsBlock;
24
import org.eclipse.jdt.internal.debug.ui.launcher.WorkingDirectoryBlock;
26
import org.eclipse.jdt.internal.debug.ui.launcher.WorkingDirectoryBlock;
25
import org.eclipse.jface.operation.IRunnableWithProgress;
27
import org.eclipse.jface.operation.IRunnableWithProgress;
Lines 34-40 Link Here
34
 */
36
 */
35
public class SnippetEditorPropertyPage extends PropertyPage {
37
public class SnippetEditorPropertyPage extends PropertyPage {
36
	
38
	
37
	private WorkingDirectoryBlock fWorkingDirBlock = new WorkingDirectoryBlock();
39
	private WorkingDirectoryBlock fWorkingDirBlock = new JavaWorkingDirectoryBlock();
38
	
40
	
39
	private JavaJRETab fJRETab = new JavaJRETab();
41
	private JavaJRETab fJRETab = new JavaJRETab();
40
	
42
	
(-)ui/org/eclipse/jdt/internal/debug/ui/launcher/AppletWorkingDirectoryBlock.java (-2 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Remy Chi Jian Suen <remy.suen@gmail.com> - Bug 214696 Expose WorkingDirectoryBlock as API
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.internal.debug.ui.launcher;
12
package org.eclipse.jdt.internal.debug.ui.launcher;
12
13
Lines 14-20 Link Here
14
import org.eclipse.jdt.launching.JavaRuntime;
15
import org.eclipse.jdt.launching.JavaRuntime;
15
16
16
 
17
 
17
public class AppletWorkingDirectoryBlock extends WorkingDirectoryBlock {
18
public class AppletWorkingDirectoryBlock extends JavaWorkingDirectoryBlock {
18
19
19
	/**
20
	/**
20
	 * @see org.eclipse.jdt.internal.debug.ui.launcher.WorkingDirectoryBlock#setDefaultWorkingDir()
21
	 * @see org.eclipse.jdt.internal.debug.ui.launcher.WorkingDirectoryBlock#setDefaultWorkingDir()
(-)ui/org/eclipse/jdt/internal/debug/ui/launcher/WorkingDirectoryBlock.java (-20 / +77 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 7-18 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Remy Chi Jian Suen <remy.suen@gmail.com> - Bug 214696 Expose WorkingDirectoryBlock as API
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.internal.debug.ui.launcher;
12
package org.eclipse.jdt.internal.debug.ui.launcher;
12
13
13
import java.io.File;
14
import java.io.File;
14
15
15
import org.eclipse.core.resources.IContainer;
16
import org.eclipse.core.resources.IContainer;
17
import org.eclipse.core.resources.IProject;
16
import org.eclipse.core.resources.IResource;
18
import org.eclipse.core.resources.IResource;
17
import org.eclipse.core.resources.IWorkspaceRoot;
19
import org.eclipse.core.resources.IWorkspaceRoot;
18
import org.eclipse.core.resources.ResourcesPlugin;
20
import org.eclipse.core.resources.ResourcesPlugin;
Lines 23-36 Link Here
23
import org.eclipse.core.variables.VariablesPlugin;
25
import org.eclipse.core.variables.VariablesPlugin;
24
import org.eclipse.debug.core.ILaunchConfiguration;
26
import org.eclipse.debug.core.ILaunchConfiguration;
25
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
27
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
28
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
26
import org.eclipse.debug.ui.StringVariableSelectionDialog;
29
import org.eclipse.debug.ui.StringVariableSelectionDialog;
27
import org.eclipse.jdt.core.IJavaProject;
28
import org.eclipse.jdt.debug.ui.launchConfigurations.JavaLaunchTab;
29
import org.eclipse.jdt.internal.debug.ui.IJavaDebugHelpContextIds;
30
import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
31
import org.eclipse.jdt.internal.debug.ui.SWTFactory;
30
import org.eclipse.jdt.internal.debug.ui.SWTFactory;
32
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
33
import org.eclipse.jdt.launching.JavaRuntime;
34
import org.eclipse.swt.events.ModifyEvent;
31
import org.eclipse.swt.events.ModifyEvent;
35
import org.eclipse.swt.events.ModifyListener;
32
import org.eclipse.swt.events.ModifyListener;
36
import org.eclipse.swt.events.SelectionAdapter;
33
import org.eclipse.swt.events.SelectionAdapter;
Lines 50-56 Link Here
50
 * A control for setting the working directory associated with a launch
47
 * A control for setting the working directory associated with a launch
51
 * configuration.
48
 * configuration.
52
 */
49
 */
53
public class WorkingDirectoryBlock extends JavaLaunchTab {
50
public abstract class WorkingDirectoryBlock extends AbstractLaunchConfigurationTab {
54
			
51
			
55
	// Local directory
52
	// Local directory
56
	private Button fWorkspaceButton;
53
	private Button fWorkspaceButton;
Lines 103-108 Link Here
103
	
100
	
104
	private WidgetListener fListener = new WidgetListener();
101
	private WidgetListener fListener = new WidgetListener();
105
	
102
	
103
	/**
104
	 * The name of the launch configuration attribute that will be used to save
105
	 * the location of the working directory.
106
	 */
107
	private final String workingDirectoryAttribteName;
108
	
109
	/**
110
	 * The help context id to use to connect this working directory block
111
	 * to the help system.
112
	 */
113
	private final String helpContextId;
114
	
115
	/**
116
	 * Creates a new WorkingDirectoryBlock for setting a working directory.
117
	 * 
118
	 * @param workingDirectoryAttribteName the name of the launch configuration attribute to set the working directory's location
119
	 */
120
	public WorkingDirectoryBlock(String workingDirectoryAttribteName) {
121
		this(workingDirectoryAttribteName, null);
122
	}
123
	
124
	/**
125
	 * Creates a new WorkingDirectoryBlock for setting a working directory.
126
	 * 
127
	 * @param workingDirectoryAttribteName the name of the launch configuration attribute to set the working directory's location
128
	 * @param helpContextId the help context id to use to hook onto the help system
129
	 */
130
	public WorkingDirectoryBlock(String workingDirectoryAttribteName,
131
			String helpContextId) {
132
		this.workingDirectoryAttribteName = workingDirectoryAttribteName;
133
		this.helpContextId = helpContextId;
134
	}
135
	
106
	/* (non-Javadoc)
136
	/* (non-Javadoc)
107
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
137
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
108
	 */
138
	 */
Lines 110-116 Link Here
110
		Font font = parent.getFont();	
140
		Font font = parent.getFont();	
111
		Group group = SWTFactory.createGroup(parent, LauncherMessages.WorkingDirectoryBlock_12, 2, 1, GridData.FILL_HORIZONTAL);
141
		Group group = SWTFactory.createGroup(parent, LauncherMessages.WorkingDirectoryBlock_12, 2, 1, GridData.FILL_HORIZONTAL);
112
		setControl(group);
142
		setControl(group);
113
		PlatformUI.getWorkbench().getHelpSystem().setHelp(group, IJavaDebugHelpContextIds.WORKING_DIRECTORY_BLOCK);
143
		
144
		if (helpContextId != null) {
145
			PlatformUI.getWorkbench().getHelpSystem().setHelp(group, helpContextId);	
146
		}
147
		
114
	//default choice
148
	//default choice
115
		Composite comp = SWTFactory.createComposite(group, font, 2, 2, GridData.FILL_BOTH, 0, 0);
149
		Composite comp = SWTFactory.createComposite(group, font, 2, 2, GridData.FILL_BOTH, 0, 0);
116
		fUseDefaultDirButton = SWTFactory.createRadioButton(comp, LauncherMessages.WorkingDirectoryBlock_18);
150
		fUseDefaultDirButton = SWTFactory.createRadioButton(comp, LauncherMessages.WorkingDirectoryBlock_18);
Lines 192-198 Link Here
192
                        res = containers[0];
226
                        res = containers[0];
193
                    }
227
                    }
194
                } 
228
                } 
195
			    catch (CoreException e) {}
229
			    catch (CoreException e) {
230
			    	log(e);
231
			    }
196
			} 
232
			} 
197
		    else {	    
233
		    else {	    
198
				res = root.findMember(path);
234
				res = root.findMember(path);
Lines 247-262 Link Here
247
		try {
283
		try {
248
			ILaunchConfiguration config = getLaunchConfiguration();
284
			ILaunchConfiguration config = getLaunchConfiguration();
249
			if (config != null) {
285
			if (config != null) {
250
				IJavaProject javaProject = JavaRuntime.getJavaProject(config);
286
				IProject project = getProject(config);
251
				if (javaProject != null) {
287
				if (project != null) {
252
					setDefaultWorkingDirectoryText("${workspace_loc:" + javaProject.getPath().makeRelative().toOSString() + "}");  //$NON-NLS-1$//$NON-NLS-2$
288
					setDefaultWorkingDirectoryText("${workspace_loc:" + project.getFullPath().makeRelative().toOSString() + "}");  //$NON-NLS-1$//$NON-NLS-2$
253
					return;
289
					return;
254
				}
290
				}
255
			}
291
			}
256
		} 
292
		} 
257
		catch (CoreException ce) {}
293
		catch (CoreException ce) {
294
			log(ce);
295
		}
258
		setDefaultWorkingDirectoryText(System.getProperty("user.dir")); //$NON-NLS-1$
296
		setDefaultWorkingDirectoryText(System.getProperty("user.dir")); //$NON-NLS-1$
259
	}
297
	}
298
	
299
	/**
300
	 * Retrieves the project that is associated with the specified launch configuration.
301
	 * @param configuration the launch configuration that has been set to this working directory block
302
	 * @return the project specified by the launch configuration, or <tt>null</tt> if nothing has been set
303
	 * @throws CoreException if an error occurred while retrieving the project from the launch configuration
304
	 */
305
	protected abstract IProject getProject(ILaunchConfiguration configuration) throws CoreException;
260
306
261
	/* (non-Javadoc)
307
	/* (non-Javadoc)
262
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#isValid(org.eclipse.debug.core.ILaunchConfiguration)
308
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#isValid(org.eclipse.debug.core.ILaunchConfiguration)
Lines 273-278 Link Here
273
			}
319
			}
274
			catch (CoreException e) {
320
			catch (CoreException e) {
275
				setErrorMessage(e.getMessage());
321
				setErrorMessage(e.getMessage());
322
				log(e);
276
				return false;
323
				return false;
277
			}
324
			}
278
		} 
325
		} 
Lines 299-305 Link Here
299
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
346
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
300
	 */
347
	 */
301
	public void setDefaults(ILaunchConfigurationWorkingCopy config) {
348
	public void setDefaults(ILaunchConfigurationWorkingCopy config) {
302
		config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String)null);
349
		config.setAttribute(workingDirectoryAttribteName, (String)null);
303
	}
350
	}
304
351
305
	/* (non-Javadoc)
352
	/* (non-Javadoc)
Lines 308-322 Link Here
308
	public void initializeFrom(ILaunchConfiguration configuration) {
355
	public void initializeFrom(ILaunchConfiguration configuration) {
309
		setLaunchConfiguration(configuration);
356
		setLaunchConfiguration(configuration);
310
		try {			
357
		try {			
311
			String wd = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String)null);
358
			String wd = configuration.getAttribute(workingDirectoryAttribteName, (String)null);
312
			setDefaultWorkingDir();
359
			setDefaultWorkingDir();
313
			if (wd != null) {
360
			if (wd != null) {
314
				setOtherWorkingDirectoryText(wd);
361
				setOtherWorkingDirectoryText(wd);
315
			}
362
			}
316
		} 
363
		} 
317
		catch (CoreException e) {
364
		catch (CoreException e) {
318
			setErrorMessage(LauncherMessages.JavaArgumentsTab_Exception_occurred_reading_configuration___15 + e.getStatus().getMessage()); 
365
			setErrorMessage(LauncherMessages.JavaArgumentsTab_Exception_occurred_reading_configuration___15 + e.getStatus().getMessage());
319
			JDIDebugUIPlugin.log(e);
366
			log(e);
320
		}
367
		}
321
	}
368
	}
322
369
Lines 325-334 Link Here
325
	 */
372
	 */
326
	public void performApply(ILaunchConfigurationWorkingCopy configuration) {
373
	public void performApply(ILaunchConfigurationWorkingCopy configuration) {
327
		if(fUseDefaultDirButton.getSelection()) {
374
		if(fUseDefaultDirButton.getSelection()) {
328
			configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String)null);
375
			configuration.setAttribute(workingDirectoryAttribteName, (String)null);
329
		}
376
		}
330
		else {
377
		else {
331
			configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, getWorkingDirectoryText());
378
			configuration.setAttribute(workingDirectoryAttribteName, getWorkingDirectoryText());
332
		}
379
		}
333
	}
380
	}
334
	
381
	
Lines 340-345 Link Here
340
	}
387
	}
341
	
388
	
342
	/**
389
	/**
390
	 * Logs exceptions that have been caught by this working directory block.
391
	 * The default implementation does nothing. Subclasses should reimplement
392
	 * if they wish to monitor such exceptions.
393
	 * @param e the exception to log
394
	 */
395
	protected void log(CoreException e) {
396
		// do nothing
397
	}
398
	
399
	/**
343
	 * gets the path from the text box that is selected
400
	 * gets the path from the text box that is selected
344
	 * @return the working directory the user wishes to use
401
	 * @return the working directory the user wishes to use
345
	 * @since 3.2
402
	 * @since 3.2
(-)ui/org/eclipse/jdt/debug/ui/launchConfigurations/JavaArgumentsTab.java (-2 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 7-12 Link Here
7
 * 
7
 * 
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Remy Chi Jian Suen <remy.suen@gmail.com> - Bug 214696 Expose WorkingDirectoryBlock as API
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.debug.ui.launchConfigurations;
12
package org.eclipse.jdt.debug.ui.launchConfigurations;
12
13
Lines 20-25 Link Here
20
import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
21
import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
21
import org.eclipse.jdt.internal.debug.ui.JavaDebugImages;
22
import org.eclipse.jdt.internal.debug.ui.JavaDebugImages;
22
import org.eclipse.jdt.internal.debug.ui.actions.ControlAccessibleListener;
23
import org.eclipse.jdt.internal.debug.ui.actions.ControlAccessibleListener;
24
import org.eclipse.jdt.internal.debug.ui.launcher.JavaWorkingDirectoryBlock;
23
import org.eclipse.jdt.internal.debug.ui.launcher.LauncherMessages;
25
import org.eclipse.jdt.internal.debug.ui.launcher.LauncherMessages;
24
import org.eclipse.jdt.internal.debug.ui.launcher.VMArgumentsBlock;
26
import org.eclipse.jdt.internal.debug.ui.launcher.VMArgumentsBlock;
25
import org.eclipse.jdt.internal.debug.ui.launcher.WorkingDirectoryBlock;
27
import org.eclipse.jdt.internal.debug.ui.launcher.WorkingDirectoryBlock;
Lines 72-78 Link Here
72
	}
74
	}
73
	
75
	
74
	protected WorkingDirectoryBlock createWorkingDirBlock() {
76
	protected WorkingDirectoryBlock createWorkingDirBlock() {
75
		return new WorkingDirectoryBlock();
77
		return new JavaWorkingDirectoryBlock();
76
	}
78
	}
77
	
79
	
78
	/**
80
	/**
(-)ui/org/eclipse/jdt/internal/debug/ui/launcher/JavaWorkingDirectoryBlock.java (+38 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 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
 *     Remy Chi Jian Suen <remy.suen@gmail.com> - Bug 214696 Expose WorkingDirectoryBlock as API
11
 *******************************************************************************/
12
package org.eclipse.jdt.internal.debug.ui.launcher;
13
14
import org.eclipse.core.resources.IProject;
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.debug.core.ILaunchConfiguration;
17
import org.eclipse.jdt.internal.debug.ui.IJavaDebugHelpContextIds;
18
import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
19
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
20
import org.eclipse.jdt.launching.JavaRuntime;
21
22
public class JavaWorkingDirectoryBlock extends WorkingDirectoryBlock {
23
24
	public JavaWorkingDirectoryBlock() {
25
		super(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY,
26
				IJavaDebugHelpContextIds.WORKING_DIRECTORY_BLOCK);
27
	}
28
29
	protected IProject getProject(ILaunchConfiguration configuration)
30
			throws CoreException {
31
		return JavaRuntime.getJavaProject(configuration).getProject();
32
	}
33
34
	protected void log(CoreException e) {
35
		JDIDebugUIPlugin.log(e);
36
	}
37
38
}

Return to bug 214696