Lines 18-23
Link Here
|
18 |
import org.eclipse.core.resources.*; |
18 |
import org.eclipse.core.resources.*; |
19 |
import org.eclipse.core.runtime.*; |
19 |
import org.eclipse.core.runtime.*; |
20 |
import org.eclipse.core.runtime.jobs.*; |
20 |
import org.eclipse.core.runtime.jobs.*; |
|
|
21 |
import org.eclipse.jface.dialogs.MessageDialogWithToggle; |
22 |
import org.eclipse.jface.preference.IPreferenceStore; |
21 |
import org.eclipse.osgi.util.NLS; |
23 |
import org.eclipse.osgi.util.NLS; |
22 |
import org.eclipse.team.core.RepositoryProvider; |
24 |
import org.eclipse.team.core.RepositoryProvider; |
23 |
import org.eclipse.team.core.TeamException; |
25 |
import org.eclipse.team.core.TeamException; |
Lines 29-36
Link Here
|
29 |
import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; |
31 |
import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; |
30 |
import org.eclipse.team.internal.ccvs.ui.*; |
32 |
import org.eclipse.team.internal.ccvs.ui.*; |
31 |
import org.eclipse.team.internal.ccvs.ui.Policy; |
33 |
import org.eclipse.team.internal.ccvs.ui.Policy; |
|
|
34 |
import org.eclipse.team.internal.ccvs.ui.wizards.NewProjectListener; |
32 |
import org.eclipse.team.internal.ui.wizards.WorkingSetsDialog; |
35 |
import org.eclipse.team.internal.ui.wizards.WorkingSetsDialog; |
33 |
import org.eclipse.ui.*; |
36 |
import org.eclipse.ui.*; |
|
|
37 |
import org.eclipse.ui.actions.NewProjectAction; |
34 |
/** |
38 |
/** |
35 |
* This class acts as an abstract class for checkout operations. |
39 |
* This class acts as an abstract class for checkout operations. |
36 |
* It provides a few common methods. |
40 |
* It provides a few common methods. |
Lines 38-47
Link Here
|
38 |
public abstract class CheckoutProjectOperation extends CheckoutOperation { |
42 |
public abstract class CheckoutProjectOperation extends CheckoutOperation { |
39 |
|
43 |
|
40 |
private String targetLocation; |
44 |
private String targetLocation; |
|
|
45 |
|
46 |
private boolean scrubProject = true; |
47 |
private boolean configureProjectsWithoutMetaFile; |
41 |
|
48 |
|
42 |
public CheckoutProjectOperation(IWorkbenchPart part, ICVSRemoteFolder[] remoteFolders, String targetLocation) { |
49 |
public CheckoutProjectOperation(IWorkbenchPart part, ICVSRemoteFolder[] remoteFolders, String targetLocation) { |
|
|
50 |
this(part, remoteFolders, targetLocation, false); |
51 |
} |
52 |
|
53 |
public CheckoutProjectOperation(IWorkbenchPart part, ICVSRemoteFolder[] remoteFolders, String targetLocation, boolean configureProjectWithoutMetaFile) { |
43 |
super(part, remoteFolders); |
54 |
super(part, remoteFolders); |
44 |
this.targetLocation = targetLocation; |
55 |
this.targetLocation = targetLocation; |
|
|
56 |
this.configureProjectsWithoutMetaFile = configureProjectWithoutMetaFile; |
45 |
} |
57 |
} |
46 |
|
58 |
|
47 |
/** |
59 |
/** |
Lines 148-154
Link Here
|
148 |
return OK; |
160 |
return OK; |
149 |
} |
161 |
} |
150 |
|
162 |
|
151 |
final boolean sendModuleName = project != null; |
163 |
final boolean[] sendModuleName = new boolean[]{project != null}; |
|
|
164 |
|
165 |
if(configureProjectsWithoutMetaFile){ |
166 |
boolean canContinue = configureProject(resource, pm, targetProjects, sendModuleName); |
167 |
if(!canContinue){ |
168 |
return OK; //cancelled, but no error |
169 |
} |
170 |
} |
171 |
|
152 |
final IStatus[] result = new IStatus[] { null }; |
172 |
final IStatus[] result = new IStatus[] { null }; |
153 |
final ISchedulingRule schedulingRule = getSchedulingRule(targetProjects); |
173 |
final ISchedulingRule schedulingRule = getSchedulingRule(targetProjects); |
154 |
if (schedulingRule instanceof IResource && ((IResource)schedulingRule).getType() == IResource.ROOT) { |
174 |
if (schedulingRule instanceof IResource && ((IResource)schedulingRule).getType() == IResource.ROOT) { |
Lines 159-165
Link Here
|
159 |
// Still use the projects as the inner rule so we get the proper batching of sync info write |
179 |
// Still use the projects as the inner rule so we get the proper batching of sync info write |
160 |
EclipseSynchronizer.getInstance().run(MultiRule.combine(targetProjects), new ICVSRunnable() { |
180 |
EclipseSynchronizer.getInstance().run(MultiRule.combine(targetProjects), new ICVSRunnable() { |
161 |
public void run(IProgressMonitor monitor) throws CVSException { |
181 |
public void run(IProgressMonitor monitor) throws CVSException { |
162 |
result[0] = performCheckout(session, resource, targetProjects, sendModuleName, monitor); |
182 |
result[0] = performCheckout(session, resource, targetProjects, sendModuleName[0], monitor); |
163 |
} |
183 |
} |
164 |
}, Policy.subMonitorFor(pm, 90)); |
184 |
}, Policy.subMonitorFor(pm, 90)); |
165 |
} finally { |
185 |
} finally { |
Lines 168-174
Link Here
|
168 |
} else { |
188 |
} else { |
169 |
EclipseSynchronizer.getInstance().run(schedulingRule, new ICVSRunnable() { |
189 |
EclipseSynchronizer.getInstance().run(schedulingRule, new ICVSRunnable() { |
170 |
public void run(IProgressMonitor monitor) throws CVSException { |
190 |
public void run(IProgressMonitor monitor) throws CVSException { |
171 |
result[0] = performCheckout(session, resource, targetProjects, sendModuleName, monitor); |
191 |
result[0] = performCheckout(session, resource, targetProjects, sendModuleName[0], monitor); |
172 |
} |
192 |
} |
173 |
}, Policy.subMonitorFor(pm, 90)); |
193 |
}, Policy.subMonitorFor(pm, 90)); |
174 |
} |
194 |
} |
Lines 182-193
Link Here
|
182 |
// Since we were able to make a connection, return the status so the |
202 |
// Since we were able to make a connection, return the status so the |
183 |
// checkout of any other modules can proceed |
203 |
// checkout of any other modules can proceed |
184 |
return new CVSStatus(e.getStatus().getSeverity(), NLS.bind(CVSUIMessages.CheckoutProjectOperation_1, new String[] {resource.getRepositoryRelativePath(), e.getMessage()}), e); |
204 |
return new CVSStatus(e.getStatus().getSeverity(), NLS.bind(CVSUIMessages.CheckoutProjectOperation_1, new String[] {resource.getRepositoryRelativePath(), e.getMessage()}), e); |
|
|
205 |
} catch (InterruptedException e) { |
206 |
/* ignore cancellation */ |
207 |
return OK; |
185 |
} finally { |
208 |
} finally { |
186 |
session.close(); |
209 |
session.close(); |
187 |
pm.done(); |
210 |
pm.done(); |
188 |
} |
211 |
} |
189 |
} |
212 |
} |
190 |
|
213 |
|
|
|
214 |
private boolean configureProject(final ICVSRemoteFolder resource, |
215 |
IProgressMonitor pm, final IProject[] targetProjects, |
216 |
final boolean[] sendModuleName) throws CVSException, |
217 |
InterruptedException { |
218 |
ProjectMetaFileOperation metafileOp = new ProjectMetaFileOperation(getPart(), new ICVSRemoteFolder[]{resource}, false); |
219 |
metafileOp.execute(pm); |
220 |
boolean metaFileExists = metafileOp.metaFileExists(); |
221 |
boolean shouldConfigure = false; //default simple checkout |
222 |
if( !metaFileExists){ |
223 |
shouldConfigure = shouldConfigureProjectsWithoutMetaFile(targetProjects[0]); |
224 |
} |
225 |
if(shouldConfigure){ |
226 |
final NewProjectListener listener = new NewProjectListener(); |
227 |
getShell().getDisplay().syncExec(new Runnable(){ |
228 |
public void run() { |
229 |
ResourcesPlugin.getWorkspace().addResourceChangeListener(listener, IResourceChangeEvent.POST_CHANGE); |
230 |
(new NewProjectAction(PlatformUI.getWorkbench().getActiveWorkbenchWindow())).run(); |
231 |
targetProjects[0] = listener.getNewProject(); |
232 |
} |
233 |
}); |
234 |
if(targetProjects[0] == null){ |
235 |
return false; |
236 |
} |
237 |
ResourcesPlugin.getWorkspace().removeResourceChangeListener(listener); |
238 |
scrubProject = false; |
239 |
sendModuleName[0] = true; |
240 |
} |
241 |
return true; |
242 |
} |
243 |
|
191 |
private ISchedulingRule getSchedulingRule(IProject[] projects) { |
244 |
private ISchedulingRule getSchedulingRule(IProject[] projects) { |
192 |
if (projects.length == 1) { |
245 |
if (projects.length == 1) { |
193 |
return ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(projects[0]); |
246 |
return ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(projects[0]); |
Lines 283-288
Link Here
|
283 |
pm.done(); |
336 |
pm.done(); |
284 |
} |
337 |
} |
285 |
} |
338 |
} |
|
|
339 |
|
340 |
private boolean shouldConfigureProjectsWithoutMetaFile(final IProject project){ |
341 |
final IPreferenceStore store = CVSUIPlugin.getPlugin().getPreferenceStore(); |
342 |
if(MessageDialogWithToggle.NEVER.equals(store.getString(ICVSUIConstants.PREF_PROMPT_ON_PROJECT_WITHOUT_METAFILE))){ |
343 |
return false; |
344 |
} |
345 |
if(MessageDialogWithToggle.ALWAYS.equals(store.getString(ICVSUIConstants.PREF_PROMPT_ON_PROJECT_WITHOUT_METAFILE))) { |
346 |
return true; |
347 |
} |
348 |
final boolean[] result = new boolean[]{false}; |
349 |
getShell().getDisplay().syncExec(new Runnable(){ |
350 |
|
351 |
public void run() { |
352 |
MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(getShell(), |
353 |
CVSUIMessages.CheckoutProjectOperation_ConfigurationPromptTitle, |
354 |
NLS.bind(CVSUIMessages.CheckoutProjectOperation_ConfigurationPromptMessage, project.getName()), |
355 |
CVSUIMessages.CheckoutProjectOperation_ConfigurationPromptToogle, |
356 |
false, store, |
357 |
ICVSUIConstants.PREF_PROMPT_ON_PROJECT_WITHOUT_METAFILE); |
358 |
result[0] = dialog.getReturnCode() == 2; |
359 |
} |
360 |
|
361 |
}); |
362 |
|
363 |
return result[0]; |
364 |
} |
286 |
|
365 |
|
287 |
protected boolean isRecursive() { |
366 |
protected boolean isRecursive() { |
288 |
return true; |
367 |
return true; |
Lines 343-349
Link Here
|
343 |
* Default is to scrub the projects. Can be overridden by subclasses. |
422 |
* Default is to scrub the projects. Can be overridden by subclasses. |
344 |
*/ |
423 |
*/ |
345 |
protected boolean performScrubProjects() { |
424 |
protected boolean performScrubProjects() { |
346 |
return true; |
425 |
return scrubProject; |
347 |
} |
426 |
} |
348 |
|
427 |
|
349 |
/* |
428 |
/* |