Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 87364 Details for
Bug 214696
refactor WorkingDirectoryBlock
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch to remove "most" of the JDT Debug dependencies on the WorkingDirectoryBlock class.
patch.txt (text/plain), 16.36 KB, created by
Remy Suen
on 2008-01-20 17:50:12 EST
(
hide
)
Description:
Patch to remove "most" of the JDT Debug dependencies on the WorkingDirectoryBlock class.
Filename:
MIME Type:
Creator:
Remy Suen
Created:
2008-01-20 17:50:12 EST
Size:
16.36 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.debug.ui >Index: ui/org/eclipse/jdt/internal/debug/ui/snippeteditor/SnippetEditorPropertyPage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/snippeteditor/SnippetEditorPropertyPage.java,v >retrieving revision 1.25 >diff -u -r1.25 SnippetEditorPropertyPage.java >--- ui/org/eclipse/jdt/internal/debug/ui/snippeteditor/SnippetEditorPropertyPage.java 27 Apr 2007 18:24:48 -0000 1.25 >+++ ui/org/eclipse/jdt/internal/debug/ui/snippeteditor/SnippetEditorPropertyPage.java 20 Jan 2008 22:48:44 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Remy Chi Jian Suen <remy.suen@gmail.com> - Bug 214696 Expose WorkingDirectoryBlock as API > *******************************************************************************/ > package org.eclipse.jdt.internal.debug.ui.snippeteditor; > >@@ -20,6 +21,7 @@ > import org.eclipse.debug.ui.ILaunchConfigurationTab; > import org.eclipse.jdt.debug.ui.launchConfigurations.JavaJRETab; > import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; >+import org.eclipse.jdt.internal.debug.ui.launcher.JavaWorkingDirectoryBlock; > import org.eclipse.jdt.internal.debug.ui.launcher.VMArgumentsBlock; > import org.eclipse.jdt.internal.debug.ui.launcher.WorkingDirectoryBlock; > import org.eclipse.jface.operation.IRunnableWithProgress; >@@ -34,7 +36,7 @@ > */ > public class SnippetEditorPropertyPage extends PropertyPage { > >- private WorkingDirectoryBlock fWorkingDirBlock = new WorkingDirectoryBlock(); >+ private WorkingDirectoryBlock fWorkingDirBlock = new JavaWorkingDirectoryBlock(); > > private JavaJRETab fJRETab = new JavaJRETab(); > >Index: ui/org/eclipse/jdt/internal/debug/ui/launcher/AppletWorkingDirectoryBlock.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/launcher/AppletWorkingDirectoryBlock.java,v >retrieving revision 1.8 >diff -u -r1.8 AppletWorkingDirectoryBlock.java >--- ui/org/eclipse/jdt/internal/debug/ui/launcher/AppletWorkingDirectoryBlock.java 8 May 2006 20:35:08 -0000 1.8 >+++ ui/org/eclipse/jdt/internal/debug/ui/launcher/AppletWorkingDirectoryBlock.java 20 Jan 2008 22:48:44 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2006 IBM Corporation and others. >+ * Copyright (c) 2000, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Remy Chi Jian Suen <remy.suen@gmail.com> - Bug 214696 Expose WorkingDirectoryBlock as API > *******************************************************************************/ > package org.eclipse.jdt.internal.debug.ui.launcher; > >@@ -14,7 +15,7 @@ > import org.eclipse.jdt.launching.JavaRuntime; > > >-public class AppletWorkingDirectoryBlock extends WorkingDirectoryBlock { >+public class AppletWorkingDirectoryBlock extends JavaWorkingDirectoryBlock { > > /** > * @see org.eclipse.jdt.internal.debug.ui.launcher.WorkingDirectoryBlock#setDefaultWorkingDir() >Index: ui/org/eclipse/jdt/internal/debug/ui/launcher/WorkingDirectoryBlock.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/launcher/WorkingDirectoryBlock.java,v >retrieving revision 1.36 >diff -u -r1.36 WorkingDirectoryBlock.java >--- ui/org/eclipse/jdt/internal/debug/ui/launcher/WorkingDirectoryBlock.java 27 Mar 2007 02:35:58 -0000 1.36 >+++ ui/org/eclipse/jdt/internal/debug/ui/launcher/WorkingDirectoryBlock.java 20 Jan 2008 22:48:44 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,12 +7,14 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Remy Chi Jian Suen <remy.suen@gmail.com> - Bug 214696 Expose WorkingDirectoryBlock as API > *******************************************************************************/ > package org.eclipse.jdt.internal.debug.ui.launcher; > > import java.io.File; > > import org.eclipse.core.resources.IContainer; >+import org.eclipse.core.resources.IProject; > import org.eclipse.core.resources.IResource; > import org.eclipse.core.resources.IWorkspaceRoot; > import org.eclipse.core.resources.ResourcesPlugin; >@@ -23,14 +25,9 @@ > import org.eclipse.core.variables.VariablesPlugin; > import org.eclipse.debug.core.ILaunchConfiguration; > import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; >+import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; > import org.eclipse.debug.ui.StringVariableSelectionDialog; >-import org.eclipse.jdt.core.IJavaProject; >-import org.eclipse.jdt.debug.ui.launchConfigurations.JavaLaunchTab; >-import org.eclipse.jdt.internal.debug.ui.IJavaDebugHelpContextIds; >-import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; > import org.eclipse.jdt.internal.debug.ui.SWTFactory; >-import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; >-import org.eclipse.jdt.launching.JavaRuntime; > import org.eclipse.swt.events.ModifyEvent; > import org.eclipse.swt.events.ModifyListener; > import org.eclipse.swt.events.SelectionAdapter; >@@ -50,7 +47,7 @@ > * A control for setting the working directory associated with a launch > * configuration. > */ >-public class WorkingDirectoryBlock extends JavaLaunchTab { >+public abstract class WorkingDirectoryBlock extends AbstractLaunchConfigurationTab { > > // Local directory > private Button fWorkspaceButton; >@@ -103,6 +100,39 @@ > > private WidgetListener fListener = new WidgetListener(); > >+ /** >+ * The name of the launch configuration attribute that will be used to save >+ * the location of the working directory. >+ */ >+ private final String workingDirectoryAttribteName; >+ >+ /** >+ * The help context id to use to connect this working directory block >+ * to the help system. >+ */ >+ private final String helpContextId; >+ >+ /** >+ * Creates a new WorkingDirectoryBlock for setting a working directory. >+ * >+ * @param workingDirectoryAttribteName the name of the launch configuration attribute to set the working directory's location >+ */ >+ public WorkingDirectoryBlock(String workingDirectoryAttribteName) { >+ this(workingDirectoryAttribteName, null); >+ } >+ >+ /** >+ * Creates a new WorkingDirectoryBlock for setting a working directory. >+ * >+ * @param workingDirectoryAttribteName the name of the launch configuration attribute to set the working directory's location >+ * @param helpContextId the help context id to use to hook onto the help system >+ */ >+ public WorkingDirectoryBlock(String workingDirectoryAttribteName, >+ String helpContextId) { >+ this.workingDirectoryAttribteName = workingDirectoryAttribteName; >+ this.helpContextId = helpContextId; >+ } >+ > /* (non-Javadoc) > * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite) > */ >@@ -110,7 +140,11 @@ > Font font = parent.getFont(); > Group group = SWTFactory.createGroup(parent, LauncherMessages.WorkingDirectoryBlock_12, 2, 1, GridData.FILL_HORIZONTAL); > setControl(group); >- PlatformUI.getWorkbench().getHelpSystem().setHelp(group, IJavaDebugHelpContextIds.WORKING_DIRECTORY_BLOCK); >+ >+ if (helpContextId != null) { >+ PlatformUI.getWorkbench().getHelpSystem().setHelp(group, helpContextId); >+ } >+ > //default choice > Composite comp = SWTFactory.createComposite(group, font, 2, 2, GridData.FILL_BOTH, 0, 0); > fUseDefaultDirButton = SWTFactory.createRadioButton(comp, LauncherMessages.WorkingDirectoryBlock_18); >@@ -192,7 +226,9 @@ > res = containers[0]; > } > } >- catch (CoreException e) {} >+ catch (CoreException e) { >+ log(e); >+ } > } > else { > res = root.findMember(path); >@@ -247,16 +283,26 @@ > try { > ILaunchConfiguration config = getLaunchConfiguration(); > if (config != null) { >- IJavaProject javaProject = JavaRuntime.getJavaProject(config); >- if (javaProject != null) { >- setDefaultWorkingDirectoryText("${workspace_loc:" + javaProject.getPath().makeRelative().toOSString() + "}"); //$NON-NLS-1$//$NON-NLS-2$ >+ IProject project = getProject(config); >+ if (project != null) { >+ setDefaultWorkingDirectoryText("${workspace_loc:" + project.getFullPath().makeRelative().toOSString() + "}"); //$NON-NLS-1$//$NON-NLS-2$ > return; > } > } > } >- catch (CoreException ce) {} >+ catch (CoreException ce) { >+ log(ce); >+ } > setDefaultWorkingDirectoryText(System.getProperty("user.dir")); //$NON-NLS-1$ > } >+ >+ /** >+ * Retrieves the project that is associated with the specified launch configuration. >+ * @param configuration the launch configuration that has been set to this working directory block >+ * @return the project specified by the launch configuration, or <tt>null</tt> if nothing has been set >+ * @throws CoreException if an error occurred while retrieving the project from the launch configuration >+ */ >+ protected abstract IProject getProject(ILaunchConfiguration configuration) throws CoreException; > > /* (non-Javadoc) > * @see org.eclipse.debug.ui.ILaunchConfigurationTab#isValid(org.eclipse.debug.core.ILaunchConfiguration) >@@ -273,6 +319,7 @@ > } > catch (CoreException e) { > setErrorMessage(e.getMessage()); >+ log(e); > return false; > } > } >@@ -299,7 +346,7 @@ > * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) > */ > public void setDefaults(ILaunchConfigurationWorkingCopy config) { >- config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String)null); >+ config.setAttribute(workingDirectoryAttribteName, (String)null); > } > > /* (non-Javadoc) >@@ -308,15 +355,15 @@ > public void initializeFrom(ILaunchConfiguration configuration) { > setLaunchConfiguration(configuration); > try { >- String wd = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String)null); >+ String wd = configuration.getAttribute(workingDirectoryAttribteName, (String)null); > setDefaultWorkingDir(); > if (wd != null) { > setOtherWorkingDirectoryText(wd); > } > } > catch (CoreException e) { >- setErrorMessage(LauncherMessages.JavaArgumentsTab_Exception_occurred_reading_configuration___15 + e.getStatus().getMessage()); >- JDIDebugUIPlugin.log(e); >+ setErrorMessage(LauncherMessages.JavaArgumentsTab_Exception_occurred_reading_configuration___15 + e.getStatus().getMessage()); >+ log(e); > } > } > >@@ -325,10 +372,10 @@ > */ > public void performApply(ILaunchConfigurationWorkingCopy configuration) { > if(fUseDefaultDirButton.getSelection()) { >- configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String)null); >+ configuration.setAttribute(workingDirectoryAttribteName, (String)null); > } > else { >- configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, getWorkingDirectoryText()); >+ configuration.setAttribute(workingDirectoryAttribteName, getWorkingDirectoryText()); > } > } > >@@ -340,6 +387,16 @@ > } > > /** >+ * Logs exceptions that have been caught by this working directory block. >+ * The default implementation does nothing. Subclasses should reimplement >+ * if they wish to monitor such exceptions. >+ * @param e the exception to log >+ */ >+ protected void log(CoreException e) { >+ // do nothing >+ } >+ >+ /** > * gets the path from the text box that is selected > * @return the working directory the user wishes to use > * @since 3.2 >Index: ui/org/eclipse/jdt/debug/ui/launchConfigurations/JavaArgumentsTab.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/debug/ui/launchConfigurations/JavaArgumentsTab.java,v >retrieving revision 1.37 >diff -u -r1.37 JavaArgumentsTab.java >--- ui/org/eclipse/jdt/debug/ui/launchConfigurations/JavaArgumentsTab.java 12 Sep 2007 15:24:18 -0000 1.37 >+++ ui/org/eclipse/jdt/debug/ui/launchConfigurations/JavaArgumentsTab.java 20 Jan 2008 22:48:44 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2006 IBM Corporation and others. >+ * Copyright (c) 2000, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Remy Chi Jian Suen <remy.suen@gmail.com> - Bug 214696 Expose WorkingDirectoryBlock as API > *******************************************************************************/ > package org.eclipse.jdt.debug.ui.launchConfigurations; > >@@ -20,6 +21,7 @@ > import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; > import org.eclipse.jdt.internal.debug.ui.JavaDebugImages; > import org.eclipse.jdt.internal.debug.ui.actions.ControlAccessibleListener; >+import org.eclipse.jdt.internal.debug.ui.launcher.JavaWorkingDirectoryBlock; > import org.eclipse.jdt.internal.debug.ui.launcher.LauncherMessages; > import org.eclipse.jdt.internal.debug.ui.launcher.VMArgumentsBlock; > import org.eclipse.jdt.internal.debug.ui.launcher.WorkingDirectoryBlock; >@@ -72,7 +74,7 @@ > } > > protected WorkingDirectoryBlock createWorkingDirBlock() { >- return new WorkingDirectoryBlock(); >+ return new JavaWorkingDirectoryBlock(); > } > > /** >Index: ui/org/eclipse/jdt/internal/debug/ui/launcher/JavaWorkingDirectoryBlock.java >=================================================================== >RCS file: ui/org/eclipse/jdt/internal/debug/ui/launcher/JavaWorkingDirectoryBlock.java >diff -N ui/org/eclipse/jdt/internal/debug/ui/launcher/JavaWorkingDirectoryBlock.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/jdt/internal/debug/ui/launcher/JavaWorkingDirectoryBlock.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,38 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Remy Chi Jian Suen <remy.suen@gmail.com> - Bug 214696 Expose WorkingDirectoryBlock as API >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.debug.ui.launcher; >+ >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.jdt.internal.debug.ui.IJavaDebugHelpContextIds; >+import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; >+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; >+import org.eclipse.jdt.launching.JavaRuntime; >+ >+public class JavaWorkingDirectoryBlock extends WorkingDirectoryBlock { >+ >+ public JavaWorkingDirectoryBlock() { >+ super(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, >+ IJavaDebugHelpContextIds.WORKING_DIRECTORY_BLOCK); >+ } >+ >+ protected IProject getProject(ILaunchConfiguration configuration) >+ throws CoreException { >+ return JavaRuntime.getJavaProject(configuration).getProject(); >+ } >+ >+ protected void log(CoreException e) { >+ JDIDebugUIPlugin.log(e); >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 214696
:
87364
|
87556
|
87717