|
Lines 12-17
Link Here
|
| 12 |
|
12 |
|
| 13 |
import java.io.File; |
13 |
import java.io.File; |
| 14 |
import org.eclipse.core.runtime.CoreException; |
14 |
import org.eclipse.core.runtime.CoreException; |
|
|
15 |
import org.eclipse.core.variables.VariablesPlugin; |
| 15 |
import org.eclipse.debug.core.ILaunchConfiguration; |
16 |
import org.eclipse.debug.core.ILaunchConfiguration; |
| 16 |
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; |
17 |
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; |
| 17 |
import org.eclipse.pde.internal.launching.IPDEConstants; |
18 |
import org.eclipse.pde.internal.launching.IPDEConstants; |
|
Lines 34-39
Link Here
|
| 34 |
private Button fClearWorkspaceLogRadio; |
35 |
private Button fClearWorkspaceLogRadio; |
| 35 |
|
36 |
|
| 36 |
private String fLastKnownName; |
37 |
private String fLastKnownName; |
|
|
38 |
private String fLastKnownLocation; |
| 37 |
|
39 |
|
| 38 |
public WorkspaceDataBlock(AbstractLauncherTab tab) { |
40 |
public WorkspaceDataBlock(AbstractLauncherTab tab) { |
| 39 |
super(tab); |
41 |
super(tab); |
|
Lines 97-113
Link Here
|
| 97 |
} |
99 |
} |
| 98 |
|
100 |
|
| 99 |
public void performApply(ILaunchConfigurationWorkingCopy config, boolean isJUnit) { |
101 |
public void performApply(ILaunchConfigurationWorkingCopy config, boolean isJUnit) { |
|
|
102 |
/* |
| 103 |
* Goals: |
| 104 |
* - Update the workspace location when the configuration name changes and ... |
| 105 |
* - the workspace location matches the default location |
| 106 |
* - the workspace location doesn't exist on the file system |
| 107 |
* - Renaming the config should not set the workspace location to an already existing location |
| 108 |
*/ |
| 100 |
String currentLocation = getLocation(); |
109 |
String currentLocation = getLocation(); |
| 101 |
String currentName = config.getName(); |
110 |
String currentName = config.getName(); |
| 102 |
if (fLastKnownName != null && !fLastKnownName.equals(currentName)) { |
111 |
if (fLastKnownName != null && !fLastKnownName.equals(currentName)) { |
| 103 |
String lastDefaultLocation = LaunchArgumentsHelper.getDefaultWorkspaceLocation(fLastKnownName, isJUnit); |
112 |
if (currentLocation.equals(fLastKnownLocation)) { |
| 104 |
if (lastDefaultLocation.equals(currentLocation)) { |
|
|
| 105 |
try { |
113 |
try { |
| 106 |
File workspaceDir = new File(LaunchArgumentsHelper.getWorkspaceLocation(config)); |
114 |
File workspaceDir = new File(LaunchArgumentsHelper.getWorkspaceLocation(config)); |
| 107 |
if (!workspaceDir.exists()) { |
115 |
if (!workspaceDir.exists()) { |
| 108 |
currentLocation = LaunchArgumentsHelper.getDefaultWorkspaceLocation(currentName, isJUnit); |
116 |
currentLocation = getUnusedWorkspaceLocation(currentName, isJUnit); |
| 109 |
fLocationText.setText(currentLocation); |
117 |
fLocationText.setText(currentLocation); |
| 110 |
fLastKnownName = currentName; |
118 |
fLastKnownName = currentName; |
|
|
119 |
fLastKnownLocation = currentLocation; |
| 111 |
} |
120 |
} |
| 112 |
} catch (CoreException e) { |
121 |
} catch (CoreException e) { |
| 113 |
// don't change workspace location |
122 |
// don't change workspace location |
|
Lines 120-128
Link Here
|
| 120 |
config.setAttribute(IPDEConstants.DOCLEARLOG, fClearWorkspaceLogRadio.getSelection()); |
129 |
config.setAttribute(IPDEConstants.DOCLEARLOG, fClearWorkspaceLogRadio.getSelection()); |
| 121 |
} |
130 |
} |
| 122 |
|
131 |
|
|
|
132 |
private String getUnusedWorkspaceLocation(String name, boolean isJUnit) { |
| 133 |
String location = LaunchArgumentsHelper.getDefaultWorkspaceLocation(name, isJUnit); |
| 134 |
String resolvedLocation; |
| 135 |
try { |
| 136 |
resolvedLocation = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(location); |
| 137 |
} catch (CoreException e) { |
| 138 |
return location; |
| 139 |
} |
| 140 |
File workspaceDir = new File(resolvedLocation); |
| 141 |
if (!workspaceDir.exists()) |
| 142 |
return location; |
| 143 |
|
| 144 |
String resolvedLocation2; |
| 145 |
int i = 1; |
| 146 |
do { |
| 147 |
i++; |
| 148 |
resolvedLocation2 = resolvedLocation + '-' + i; |
| 149 |
} while (new File(resolvedLocation2).exists()); |
| 150 |
return location + '-' + i; |
| 151 |
} |
| 152 |
|
| 123 |
public void initializeFrom(ILaunchConfiguration configuration) throws CoreException { |
153 |
public void initializeFrom(ILaunchConfiguration configuration) throws CoreException { |
| 124 |
fLastKnownName = configuration.getName(); |
154 |
fLastKnownName = configuration.getName(); |
| 125 |
fLocationText.setText(configuration.getAttribute(IPDELauncherConstants.LOCATION, LaunchArgumentsHelper.getDefaultWorkspaceLocation(fLastKnownName))); |
155 |
fLastKnownLocation = configuration.getAttribute(IPDELauncherConstants.LOCATION, LaunchArgumentsHelper.getDefaultWorkspaceLocation(fLastKnownName)); |
|
|
156 |
fLocationText.setText(fLastKnownLocation); |
| 126 |
fClearWorkspaceCheck.setSelection(configuration.getAttribute(IPDELauncherConstants.DOCLEAR, false)); |
157 |
fClearWorkspaceCheck.setSelection(configuration.getAttribute(IPDELauncherConstants.DOCLEAR, false)); |
| 127 |
fAskClearCheck.setSelection(configuration.getAttribute(IPDELauncherConstants.ASKCLEAR, true)); |
158 |
fAskClearCheck.setSelection(configuration.getAttribute(IPDELauncherConstants.ASKCLEAR, true)); |
| 128 |
fAskClearCheck.setEnabled(fClearWorkspaceCheck.getSelection()); |
159 |
fAskClearCheck.setEnabled(fClearWorkspaceCheck.getSelection()); |
|
Lines 134-140
Link Here
|
| 134 |
|
165 |
|
| 135 |
public void setDefaults(ILaunchConfigurationWorkingCopy configuration, boolean isJUnit) { |
166 |
public void setDefaults(ILaunchConfigurationWorkingCopy configuration, boolean isJUnit) { |
| 136 |
fLastKnownName = configuration.getName(); |
167 |
fLastKnownName = configuration.getName(); |
| 137 |
configuration.setAttribute(IPDELauncherConstants.LOCATION, LaunchArgumentsHelper.getDefaultWorkspaceLocation(fLastKnownName, isJUnit)); |
168 |
fLastKnownLocation = LaunchArgumentsHelper.getDefaultWorkspaceLocation(fLastKnownName, isJUnit); |
|
|
169 |
configuration.setAttribute(IPDELauncherConstants.LOCATION, fLastKnownLocation); |
| 138 |
configuration.setAttribute(IPDELauncherConstants.DOCLEAR, isJUnit); |
170 |
configuration.setAttribute(IPDELauncherConstants.DOCLEAR, isJUnit); |
| 139 |
configuration.setAttribute(IPDELauncherConstants.ASKCLEAR, !isJUnit); |
171 |
configuration.setAttribute(IPDELauncherConstants.ASKCLEAR, !isJUnit); |
| 140 |
configuration.setAttribute(IPDEConstants.DOCLEARLOG, false); |
172 |
configuration.setAttribute(IPDEConstants.DOCLEARLOG, false); |