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 84808 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/team/internal/ccvs/ui/CVSPreferencesPage.java (+2 lines)
Lines 375-380 Link Here
375
		new Checkbox(composite, ICVSUIConstants.PREF_DEBUG_PROTOCOL, CVSUIMessages.CVSPreferencesPage_17, IHelpContextIds.PREF_DEBUG_PROTOCOL);
375
		new Checkbox(composite, ICVSUIConstants.PREF_DEBUG_PROTOCOL, CVSUIMessages.CVSPreferencesPage_17, IHelpContextIds.PREF_DEBUG_PROTOCOL);
376
		new Checkbox(composite, ICVSUIConstants.PREF_AUTO_REFRESH_TAGS_IN_TAG_SELECTION_DIALOG, CVSUIMessages.CVSPreferencesPage_18, IHelpContextIds.PREF_AUTOREFRESH_TAG);
376
		new Checkbox(composite, ICVSUIConstants.PREF_AUTO_REFRESH_TAGS_IN_TAG_SELECTION_DIALOG, CVSUIMessages.CVSPreferencesPage_18, IHelpContextIds.PREF_AUTOREFRESH_TAG);
377
        new Checkbox(composite, ICVSUIConstants.PREF_AUTO_SHARE_ON_IMPORT, CVSUIMessages.CVSPreferencesPage_44, null);
377
        new Checkbox(composite, ICVSUIConstants.PREF_AUTO_SHARE_ON_IMPORT, CVSUIMessages.CVSPreferencesPage_44, null);
378
        new Checkbox(composite, ICVSUIConstants.PREF_USE_PROJECT_NAME_ON_CHECKOUT, CVSUIMessages.CVSPreferencesPage_45, null);
378
        
379
        
379
        final Composite textComposite= SWTUtils.createHFillComposite(composite, SWTUtils.MARGINS_NONE, 2);
380
        final Composite textComposite= SWTUtils.createHFillComposite(composite, SWTUtils.MARGINS_NONE, 2);
380
        new TextField(
381
        new TextField(
Lines 560-565 Link Here
560
		CVSProviderPlugin.getPlugin().setUsePlatformLineend(store.getBoolean(ICVSUIConstants.PREF_USE_PLATFORM_LINEEND));
561
		CVSProviderPlugin.getPlugin().setUsePlatformLineend(store.getBoolean(ICVSUIConstants.PREF_USE_PLATFORM_LINEEND));
561
		CVSProviderPlugin.getPlugin().setDetermineVersionEnabled(store.getBoolean(ICVSUIConstants.PREF_DETERMINE_SERVER_VERSION));
562
		CVSProviderPlugin.getPlugin().setDetermineVersionEnabled(store.getBoolean(ICVSUIConstants.PREF_DETERMINE_SERVER_VERSION));
562
        CVSProviderPlugin.getPlugin().setAutoshareOnImport(store.getBoolean(ICVSUIConstants.PREF_AUTO_SHARE_ON_IMPORT));
563
        CVSProviderPlugin.getPlugin().setAutoshareOnImport(store.getBoolean(ICVSUIConstants.PREF_AUTO_SHARE_ON_IMPORT));
564
        CVSProviderPlugin.getPlugin().setUseProjectNameOnCheckout(store.getBoolean(ICVSUIConstants.PREF_USE_PROJECT_NAME_ON_CHECKOUT));
563
		
565
		
564
		// changing the default keyword substitution mode for text files may affect
566
		// changing the default keyword substitution mode for text files may affect
565
		// information displayed in the decorators
567
		// information displayed in the decorators
(-)src/org/eclipse/team/internal/ccvs/ui/CVSUIMessages.java (-1 / +2 lines)
Lines 225-230 Link Here
225
	public static String CVSPreferencesPage_42;
225
	public static String CVSPreferencesPage_42;
226
	public static String CVSPreferencesPage_43;
226
	public static String CVSPreferencesPage_43;
227
    public static String CVSPreferencesPage_44;
227
    public static String CVSPreferencesPage_44;
228
    public static String CVSPreferencesPage_45;
228
	public static String CVSPropertiesPage_virtualModule;
229
	public static String CVSPropertiesPage_virtualModule;
229
230
230
231
Lines 796-802 Link Here
796
	public static String WorkspaceChangeSetCapability_7;
797
	public static String WorkspaceChangeSetCapability_7;
797
	public static String WorkspaceChangeSetCapability_8;
798
	public static String WorkspaceChangeSetCapability_8;
798
799
799
	public static String HasProjectMetaFile_taskName;
800
	public static String ProjectMetaFile_taskName;
800
	public static String TagFromWorkspace_taskName;
801
	public static String TagFromWorkspace_taskName;
801
	public static String TagFromRepository_taskName;
802
	public static String TagFromRepository_taskName;
802
	public static String UpdateOnlyMergeable_taskName;
803
	public static String UpdateOnlyMergeable_taskName;
(-)src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java (+2 lines)
Lines 531-536 Link Here
531
		store.setDefault(ICVSUIConstants.PREF_COMMIT_SET_DEFAULT_ENABLEMENT, false);
531
		store.setDefault(ICVSUIConstants.PREF_COMMIT_SET_DEFAULT_ENABLEMENT, false);
532
		store.setDefault(ICVSUIConstants.PREF_AUTO_REFRESH_TAGS_IN_TAG_SELECTION_DIALOG, false);
532
		store.setDefault(ICVSUIConstants.PREF_AUTO_REFRESH_TAGS_IN_TAG_SELECTION_DIALOG, false);
533
        store.setDefault(ICVSUIConstants.PREF_AUTO_SHARE_ON_IMPORT, true);
533
        store.setDefault(ICVSUIConstants.PREF_AUTO_SHARE_ON_IMPORT, true);
534
        store.setDefault(ICVSUIConstants.PREF_USE_PROJECT_NAME_ON_CHECKOUT, false);
534
        store.setDefault(ICVSUIConstants.PREF_COMMIT_FILES_DISPLAY_THRESHOLD, 1000);
535
        store.setDefault(ICVSUIConstants.PREF_COMMIT_FILES_DISPLAY_THRESHOLD, 1000);
535
		
536
		
536
		PreferenceConverter.setDefault(store, ICVSUIConstants.PREF_CONSOLE_COMMAND_COLOR, new RGB(0, 0, 0));
537
		PreferenceConverter.setDefault(store, ICVSUIConstants.PREF_CONSOLE_COMMAND_COLOR, new RGB(0, 0, 0));
Lines 587-592 Link Here
587
		CVSProviderPlugin.getPlugin().setDetermineVersionEnabled(store.getBoolean(ICVSUIConstants.PREF_DETERMINE_SERVER_VERSION));
588
		CVSProviderPlugin.getPlugin().setDetermineVersionEnabled(store.getBoolean(ICVSUIConstants.PREF_DETERMINE_SERVER_VERSION));
588
		CVSProviderPlugin.getPlugin().setDebugProtocol(CVSProviderPlugin.getPlugin().isDebugProtocol() || store.getBoolean(ICVSUIConstants.PREF_DEBUG_PROTOCOL));
589
		CVSProviderPlugin.getPlugin().setDebugProtocol(CVSProviderPlugin.getPlugin().isDebugProtocol() || store.getBoolean(ICVSUIConstants.PREF_DEBUG_PROTOCOL));
589
        CVSProviderPlugin.getPlugin().setAutoshareOnImport(store.getBoolean(ICVSUIConstants.PREF_AUTO_SHARE_ON_IMPORT));
590
        CVSProviderPlugin.getPlugin().setAutoshareOnImport(store.getBoolean(ICVSUIConstants.PREF_AUTO_SHARE_ON_IMPORT));
591
        CVSProviderPlugin.getPlugin().setUseProjectNameOnCheckout(store.getBoolean(ICVSUIConstants.PREF_USE_PROJECT_NAME_ON_CHECKOUT));
590
	}
592
	}
591
	
593
	
592
	/**
594
	/**
(-)src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java (+1 lines)
Lines 95-100 Link Here
95
	public final String PREF_AUTO_REFRESH_TAGS_IN_TAG_SELECTION_DIALOG = "pref_auto_refresh_tags_in_tag_selection_dialog"; //$NON-NLS-1$
95
	public final String PREF_AUTO_REFRESH_TAGS_IN_TAG_SELECTION_DIALOG = "pref_auto_refresh_tags_in_tag_selection_dialog"; //$NON-NLS-1$
96
    public final String PREF_COMMIT_FILES_DISPLAY_THRESHOLD = "pref_commit_files_display_threshold"; //$NON-NLS-1$
96
    public final String PREF_COMMIT_FILES_DISPLAY_THRESHOLD = "pref_commit_files_display_threshold"; //$NON-NLS-1$
97
    public final String PREF_AUTO_SHARE_ON_IMPORT = "pref_auto_share_on_import"; //$NON-NLS-1$
97
    public final String PREF_AUTO_SHARE_ON_IMPORT = "pref_auto_share_on_import"; //$NON-NLS-1$
98
    public final String PREF_USE_PROJECT_NAME_ON_CHECKOUT = "pref_use_project_name_on_checkout"; //$NON-NLS-1$
98
	
99
	
99
	// console preferences
100
	// console preferences
100
	public final String PREF_CONSOLE_COMMAND_COLOR = "pref_console_command_color"; //$NON-NLS-1$
101
	public final String PREF_CONSOLE_COMMAND_COLOR = "pref_console_command_color"; //$NON-NLS-1$
(-)src/org/eclipse/team/internal/ccvs/ui/messages.properties (-1 / +2 lines)
Lines 220-225 Link Here
220
CVSPreferencesPage_42=&Open perspective after a 'Show Annotations' operation
220
CVSPreferencesPage_42=&Open perspective after a 'Show Annotations' operation
221
CVSPreferencesPage_43=D&efault perspective for 'Show Annotations':
221
CVSPreferencesPage_43=D&efault perspective for 'Show Annotations':
222
CVSPreferencesPage_44=Aut&omatically share projects containing CVS meta information
222
CVSPreferencesPage_44=Aut&omatically share projects containing CVS meta information
223
CVSPreferencesPage_45=Use .project &project name instead of module name on check out
223
CVSPropertiesPage_virtualModule=<no corresponding remote folder>
224
CVSPropertiesPage_virtualModule=<no corresponding remote folder>
224
225
225
226
Lines 834-840 Link Here
834
WorkspaceChangeSetCapability_8=Edit the name and comment for the change set
835
WorkspaceChangeSetCapability_8=Edit the name and comment for the change set
835
836
836
837
837
HasProjectMetaFile_taskName=Looking for a remote meta file
838
ProjectMetaFile_taskName=Looking for a remote meta file
838
TagFromWorkspace_taskName=Tagging from workspace
839
TagFromWorkspace_taskName=Tagging from workspace
839
TagFromRepository_taskName=Tagging from repository
840
TagFromRepository_taskName=Tagging from repository
840
UpdateOnlyMergeable_taskName=Updating mergeable changes
841
UpdateOnlyMergeable_taskName=Updating mergeable changes
(-)src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAction.java (-1 / +17 lines)
Lines 14-22 Link Here
14
14
15
import org.eclipse.jface.action.IAction;
15
import org.eclipse.jface.action.IAction;
16
import org.eclipse.team.core.TeamException;
16
import org.eclipse.team.core.TeamException;
17
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
17
import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
18
import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
18
import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
19
import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
19
import org.eclipse.team.internal.ccvs.ui.operations.CheckoutMultipleProjectsOperation;
20
import org.eclipse.team.internal.ccvs.ui.operations.CheckoutMultipleProjectsOperation;
21
import org.eclipse.team.internal.ccvs.ui.operations.ProjectMetaFileOperation;
20
22
21
/**
23
/**
22
 * Checkout a remote module into the workspace ensuring that the user is prompted for
24
 * Checkout a remote module into the workspace ensuring that the user is prompted for
Lines 28-34 Link Here
28
	 * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#execute(org.eclipse.jface.action.IAction)
30
	 * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#execute(org.eclipse.jface.action.IAction)
29
	 */
31
	 */
30
	protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
32
	protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
31
		new CheckoutMultipleProjectsOperation(getTargetPart(), getSelectedRemoteFolders(), null)
33
		new CheckoutMultipleProjectsOperation(getTargetPart(), getSelectedRemoteFoldersWithProjectName(), null)
32
			.run();
34
			.run();
33
	}
35
	}
34
	
36
	
Lines 48-51 Link Here
48
	   }
50
	   }
49
	   return true;
51
	   return true;
50
   }
52
   }
53
54
	/**
55
	 * Get selected CVS remote folders, and add Project Description 
56
	 * from metafile if available based on preferences settings
57
	 * @throws InterruptedException 
58
	 * @throws InvocationTargetException 
59
	 */
60
	private ICVSRemoteFolder[] getSelectedRemoteFoldersWithProjectName() throws InvocationTargetException, InterruptedException {
61
		ICVSRemoteFolder[] folders = getSelectedRemoteFolders();
62
		if (CVSProviderPlugin.getPlugin().isUseProjectNameOnCheckout()){
63
			folders = ProjectMetaFileOperation.updateFoldersWithProjectName(getTargetPart(), folders);
64
		}
65
		return folders;
66
	}
51
}
67
}
(-)src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAsAction.java (-12 / +14 lines)
Lines 15-22 Link Here
15
import org.eclipse.jface.action.IAction;
15
import org.eclipse.jface.action.IAction;
16
import org.eclipse.jface.wizard.WizardDialog;
16
import org.eclipse.jface.wizard.WizardDialog;
17
import org.eclipse.team.core.TeamException;
17
import org.eclipse.team.core.TeamException;
18
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
18
import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
19
import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
19
import org.eclipse.team.internal.ccvs.ui.operations.HasProjectMetaFileOperation;
20
import org.eclipse.team.internal.ccvs.ui.operations.ProjectMetaFileOperation;
20
import org.eclipse.team.internal.ccvs.ui.wizards.CheckoutAsWizard;
21
import org.eclipse.team.internal.ccvs.ui.wizards.CheckoutAsWizard;
21
22
22
public class CheckoutAsAction extends CVSAction {
23
public class CheckoutAsAction extends CVSAction {
Lines 26-46 Link Here
26
	 */
27
	 */
27
	public void execute(IAction action) throws InvocationTargetException, InterruptedException {
28
	public void execute(IAction action) throws InvocationTargetException, InterruptedException {
28
		ICVSRemoteFolder[] folders = getSelectedRemoteFolders();
29
		ICVSRemoteFolder[] folders = getSelectedRemoteFolders();
29
		CheckoutAsWizard wizard = new CheckoutAsWizard(getTargetPart(), folders, allowProjectConfiguration(folders));
30
		boolean withName = CVSProviderPlugin.getPlugin().isUseProjectNameOnCheckout();
31
		ProjectMetaFileOperation op = new ProjectMetaFileOperation(getTargetPart(), folders, withName);
32
		op.run();
33
		
34
		// project configuration allowed only if single folder without metafile
35
		boolean allowProjectConfig = (folders.length == 1 && !op.metaFileExists());
36
		
37
		if (withName) {
38
			folders = op.getUpdatedFolders();
39
		}
40
		
41
		CheckoutAsWizard wizard = new CheckoutAsWizard(getTargetPart(), folders, allowProjectConfig);
30
		WizardDialog dialog = new WizardDialog(shell, wizard);
42
		WizardDialog dialog = new WizardDialog(shell, wizard);
31
		dialog.open();
43
		dialog.open();
32
	}
44
	}
33
	
45
	
34
	/*
35
	 * Return true if the remote project does not have a .project file
36
	 * so that the checkout wizard will give the option to launch
37
	 * the New Project wizard
38
	 */
39
	protected boolean allowProjectConfiguration(ICVSRemoteFolder[] folders) throws InvocationTargetException, InterruptedException {
40
		if (folders.length != 1) return false;
41
		return !HasProjectMetaFileOperation.hasMetaFile(getTargetPart(), folders[0]);	
42
	}
43
	
44
	/* (non-Javadoc)
46
	/* (non-Javadoc)
45
	 * @see org.eclipse.team.internal.ui.actions.TeamAction#isEnabled()
47
	 * @see org.eclipse.team.internal.ui.actions.TeamAction#isEnabled()
46
	 */
48
	 */
(-)src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutProjectOperation.java (+13 lines)
Lines 124-129 Link Here
124
				project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
124
				project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
125
			}
125
			}
126
			
126
			
127
			// Check to see if using remote metafile project description name is preferred
128
			if (project == null 
129
					&& CVSProviderPlugin.getPlugin().isUseProjectNameOnCheckout() 
130
					&& resource.getProjectName() != null) {
131
				// no project was specified but we need to attempt the creation of one 
132
				// based on the metafile project name 
133
				project = ResourcesPlugin.getWorkspace().getRoot().getProject(resource.getProjectName());
134
			}
135
			
127
			// Determine the local target projects (either the project provider or the module expansions)
136
			// Determine the local target projects (either the project provider or the module expansions)
128
			// Note: Module expansions can be run over the same connection as a checkout
137
			// Note: Module expansions can be run over the same connection as a checkout
129
			final IProject[] targetProjects = determineProjects(session, resource, project, Policy.subMonitorFor(pm, 5));
138
			final IProject[] targetProjects = determineProjects(session, resource, project, Policy.subMonitorFor(pm, 5));
Lines 286-291 Link Here
286
			if (expansions.length == 1 && expansions[0].equals(moduleName)) {
295
			if (expansions.length == 1 && expansions[0].equals(moduleName)) {
287
				// For a remote folder, use the last segment as the project to be created
296
				// For a remote folder, use the last segment as the project to be created
288
				String lastSegment = new Path(null, expansions[0]).lastSegment();
297
				String lastSegment = new Path(null, expansions[0]).lastSegment();
298
				// if using metafile project name is preferred, use it
299
				if (CVSProviderPlugin.getPlugin().isUseProjectNameOnCheckout() && remoteFolder.getProjectName() != null) {
300
					lastSegment = remoteFolder.getProjectName();
301
				} 
289
				targetProjectSet.add(ResourcesPlugin.getWorkspace().getRoot().getProject(lastSegment));
302
				targetProjectSet.add(ResourcesPlugin.getWorkspace().getRoot().getProject(lastSegment));
290
			} else {
303
			} else {
291
				for (int j = 0; j < expansions.length; j++) {
304
				for (int j = 0; j < expansions.length; j++) {
(-)src/org/eclipse/team/internal/ccvs/ui/operations/HasProjectMetaFileOperation.java (-96 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2004 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.team.internal.ccvs.ui.operations;
12
13
import java.lang.reflect.InvocationTargetException;
14
15
import org.eclipse.core.runtime.IProgressMonitor;
16
import org.eclipse.team.core.TeamException;
17
import org.eclipse.team.internal.ccvs.core.CVSException;
18
import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
19
import org.eclipse.team.internal.ccvs.ui.CVSUIMessages;
20
import org.eclipse.ui.IWorkbenchPart;
21
22
/**
23
 * Operation which checks for the existance of the .project file
24
 * in a remote folder. The operation can be run using the <code>hasMetaFile</code>
25
 * static method of by executing the operation and then checking <code>metaFileExists</code>
26
 */
27
public class HasProjectMetaFileOperation extends CVSOperation {
28
29
	private ICVSRemoteFolder remoteFolder;
30
	private boolean metaFileExists;
31
	
32
	public static boolean hasMetaFile(IWorkbenchPart part, ICVSRemoteFolder remoteFolder) throws InvocationTargetException, InterruptedException {
33
		HasProjectMetaFileOperation op = new HasProjectMetaFileOperation(part, remoteFolder);
34
		op.run();
35
		return op.metaFileExists();
36
	}
37
	
38
	public HasProjectMetaFileOperation(IWorkbenchPart part, ICVSRemoteFolder remoteFolder) {
39
		super(part);
40
		this.remoteFolder = remoteFolder;
41
	}
42
	
43
	/*
44
	 * Return true if the provided remote folder contains a valid meta-file 
45
	 * (i.e. .project file).
46
	 */
47
	private boolean hasMetaFile(ICVSRemoteFolder folder, IProgressMonitor monitor) throws CVSException {
48
		
49
		// make a copy of the folder so that we will not effect the original folder when we refetch the members
50
		// TODO: this is a strange thing to need to do. We shold fix this.
51
		folder = (ICVSRemoteFolder)folder.forTag(remoteFolder.getTag());
52
53
		try {
54
			folder.members(monitor);
55
		} catch (TeamException e) {
56
			throw CVSException.wrapException(e);
57
		}
58
		// Check for the existance of the .project file
59
		try {
60
			folder.getFile(".project"); //$NON-NLS-1$
61
			return true;
62
		} catch (TeamException e) {
63
			// We couldn't retrieve the meta file so assume it doesn't exist
64
		}
65
		return false;
66
	}
67
68
	/* (non-Javadoc)
69
	 * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
70
	 */
71
	public void execute(IProgressMonitor monitor) throws CVSException, InterruptedException {
72
		metaFileExists = hasMetaFile(remoteFolder, monitor);
73
	}
74
	
75
	/**
76
	 * Return true if the meta file exists remotely. This method should only be invoked
77
	 * after the operation has been executed;
78
	 * @return
79
	 */
80
	public boolean metaFileExists() {
81
		return metaFileExists;
82
	}
83
84
	protected String getTaskName() {
85
		return CVSUIMessages.HasProjectMetaFile_taskName; //$NON-NLS-1$
86
	}
87
	
88
	/* (non-Javadoc)
89
	 * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#canRunAsJob()
90
	 */
91
	public boolean canRunAsJob() {
92
		// This operation should never be run in the background.
93
		return false;
94
	}
95
96
}
(-)src/org/eclipse/team/internal/ccvs/ui/wizards/CVSWizardPage.java (+15 lines)
Lines 24-29 Link Here
24
import org.eclipse.swt.layout.GridData;
24
import org.eclipse.swt.layout.GridData;
25
import org.eclipse.swt.layout.GridLayout;
25
import org.eclipse.swt.layout.GridLayout;
26
import org.eclipse.swt.widgets.*;
26
import org.eclipse.swt.widgets.*;
27
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
28
import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
27
import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
29
import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
28
import org.eclipse.ui.model.WorkbenchContentProvider;
30
import org.eclipse.ui.model.WorkbenchContentProvider;
29
import org.eclipse.ui.model.WorkbenchLabelProvider;
31
import org.eclipse.ui.model.WorkbenchLabelProvider;
Lines 310-313 Link Here
310
		}
312
		}
311
		return super.canFlipToNextPage();
313
		return super.canFlipToNextPage();
312
	}
314
	}
315
316
	/**
317
	 * Utility method to get a folder name based on preferences.
318
	 * Returns the folder name or the project name retrieved from the project metafile 
319
	 * @param the CVS remote folder
320
	 * @return a project name
321
	 */
322
	static protected String getPreferredFolderName(ICVSRemoteFolder folder) {
323
		if (CVSProviderPlugin.getPlugin().isUseProjectNameOnCheckout() && folder.getProjectName() != null) {
324
			return folder.getProjectName();
325
		}
326
		return folder.getName();
327
	}
313
}
328
}
(-)src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsLocationSelectionPage.java (-2 / +2 lines)
Lines 105-111 Link Here
105
	
105
	
106
	private IProject getSingleProject() {
106
	private IProject getSingleProject() {
107
		if (singleProject == null) {
107
		if (singleProject == null) {
108
			setProjectName(remoteFolders[0].getName());
108
			setProjectName(getPreferredFolderName(remoteFolders[0]));
109
		}
109
		}
110
		return singleProject;
110
		return singleProject;
111
	}
111
	}
Lines 295-301 Link Here
295
					return locationStatus.getMessage();
295
					return locationStatus.getMessage();
296
			} else {
296
			} else {
297
				for (int i = 0; i < remoteFolders.length; i++) {
297
				for (int i = 0; i < remoteFolders.length; i++) {
298
					String projectName = remoteFolders[i].getName();
298
					String projectName = getPreferredFolderName(remoteFolders[i]);
299
					IStatus locationStatus = ResourcesPlugin.getWorkspace().validateProjectLocation(
299
					IStatus locationStatus = ResourcesPlugin.getWorkspace().validateProjectLocation(
300
						ResourcesPlugin.getWorkspace().getRoot().getProject(projectName),
300
						ResourcesPlugin.getWorkspace().getRoot().getProject(projectName),
301
						new Path(targetLocation).append(projectName));
301
						new Path(targetLocation).append(projectName));
(-)src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsMainPage.java (-1 / +1 lines)
Lines 87-93 Link Here
87
	 * For the single folder case, return the name of the folder
87
	 * For the single folder case, return the name of the folder
88
	 */
88
	 */
89
	private String getFolderName() {
89
	private String getFolderName() {
90
		String name = folders[0].getName();
90
		String name = getPreferredFolderName(folders[0]);
91
		if (name .equals(".")) { //$NON-NLS-1$
91
		if (name .equals(".")) { //$NON-NLS-1$
92
			name = new Path(null, folders[0].getRepository().getRootDirectory()).lastSegment();
92
			name = new Path(null, folders[0].getRepository().getRootDirectory()).lastSegment();
93
		}
93
		}
(-)src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsProjectSelectionPage.java (-1 / +1 lines)
Lines 73-79 Link Here
73
	 * For the single folder case, return the name of the folder
73
	 * For the single folder case, return the name of the folder
74
	 */
74
	 */
75
	private String getInputFolderName() {
75
	private String getInputFolderName() {
76
		return remoteFolders[0].getName();
76
		return getPreferredFolderName(remoteFolders[0]);
77
	}
77
	}
78
	
78
	
79
	private String getRepository() throws CVSException {
79
	private String getRepository() throws CVSException {
(-)src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsWizard.java (-1 / +13 lines)
Lines 227-232 Link Here
227
		return folders;
227
		return folders;
228
	}
228
	}
229
229
230
	/*
231
	 * Return the remote folders to be checked out with 
232
	 * Folder description if available based on preferrences settings
233
	 */
234
	private ICVSRemoteFolder[] getRemoteFoldersWithProjectDescriptions() throws InvocationTargetException, InterruptedException {
235
		ICVSRemoteFolder[] folders = getRemoteFolders();
236
		if (CVSProviderPlugin.getPlugin().isUseProjectNameOnCheckout()) {
237
			folders = ProjectMetaFileOperation.updateFoldersWithProjectName(part, folders);
238
		}
239
		return folders;
240
	}
241
230
	private CVSTag getSelectedTag() {
242
	private CVSTag getSelectedTag() {
231
		return tagSelectionPage.getSelectedTag();
243
		return tagSelectionPage.getSelectedTag();
232
	}
244
	}
Lines 247-253 Link Here
247
	private boolean performMultipleCheckoutAs() throws InvocationTargetException, InterruptedException {
259
	private boolean performMultipleCheckoutAs() throws InvocationTargetException, InterruptedException {
248
		String targetLocation = locationSelectionPage.getTargetLocation();
260
		String targetLocation = locationSelectionPage.getTargetLocation();
249
		// Run the checkout in the background
261
		// Run the checkout in the background
250
		new CheckoutMultipleProjectsOperation(part, getRemoteFolders(), targetLocation).run();
262
		new CheckoutMultipleProjectsOperation(part, getRemoteFoldersWithProjectDescriptions(), targetLocation).run();
251
		return true;
263
		return true;
252
	}
264
	}
253
265
(-)src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutWizard.java (-15 / +20 lines)
Lines 24-30 Link Here
24
import org.eclipse.team.internal.ccvs.core.util.KnownRepositories;
24
import org.eclipse.team.internal.ccvs.core.util.KnownRepositories;
25
import org.eclipse.team.internal.ccvs.ui.*;
25
import org.eclipse.team.internal.ccvs.ui.*;
26
import org.eclipse.team.internal.ccvs.ui.operations.CheckoutMultipleProjectsOperation;
26
import org.eclipse.team.internal.ccvs.ui.operations.CheckoutMultipleProjectsOperation;
27
import org.eclipse.team.internal.ccvs.ui.operations.HasProjectMetaFileOperation;
27
import org.eclipse.team.internal.ccvs.ui.operations.ProjectMetaFileOperation;
28
import org.eclipse.ui.*;
28
import org.eclipse.ui.*;
29
29
30
/**
30
/**
Lines 187-194 Link Here
187
				try {
187
				try {
188
					boolean hasMetafile = true;
188
					boolean hasMetafile = true;
189
					if (selectedModules.length == 1) {
189
					if (selectedModules.length == 1) {
190
						// Only allow configuration if one module is selected
190
						final ICVSRemoteFolder[] folders = new ICVSRemoteFolder[] {selectedModules[0]};
191
						hasMetafile = hasProjectMetafile(selectedModules[0]);
191
						final boolean withName = CVSProviderPlugin.getPlugin().isUseProjectNameOnCheckout();
192
193
						// attempt to retrieve the project description depending on preferences
194
						// this is a bit circumvoluted to batch the metafile check and retrieval in one op
195
						final ICVSRemoteFolder[] folderResult = new ICVSRemoteFolder [1];
196
						final boolean[] booleanResult = new boolean[] { true };
197
						
198
						getContainer().run(true, true, new IRunnableWithProgress() {
199
							public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
200
								ProjectMetaFileOperation op = new ProjectMetaFileOperation(getPart(), new ICVSRemoteFolder[] {folders[0]}, withName);
201
								op.run(monitor);
202
								folderResult[0] = op.getUpdatedFolders()[0];
203
								booleanResult[0] = op.metaFileExists();
204
							}
205
						});
206
						hasMetafile = booleanResult[0];
207
						if (withName && hasMetafile)
208
							selectedModules[0] = folderResult[0];
192
					}
209
					}
193
					resetSubwizard();
210
					resetSubwizard();
194
					wizard = new CheckoutAsWizard(getPart(), selectedModules, ! hasMetafile /* allow configuration */);
211
					wizard = new CheckoutAsWizard(getPart(), selectedModules, ! hasMetafile /* allow configuration */);
Lines 215-232 Link Here
215
		return null;
232
		return null;
216
	}
233
	}
217
234
218
	private boolean hasProjectMetafile(final ICVSRemoteFolder selectedModule) throws InvocationTargetException, InterruptedException {
219
		final boolean[] result = new boolean[] { true };
220
		getContainer().run(true, true, new IRunnableWithProgress() {
221
			public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
222
				HasProjectMetaFileOperation op = new HasProjectMetaFileOperation(getPart(), selectedModule);
223
				op.run(monitor);
224
				result[0] = op.metaFileExists();
225
			}
226
		});
227
		return result[0];
228
	}
229
230
	private ICVSRemoteFolder[] getSelectedModules() {
235
	private ICVSRemoteFolder[] getSelectedModules() {
231
		if (modulePage == null) return null;
236
		if (modulePage == null) return null;
232
		return modulePage.getSelectedModules();
237
		return modulePage.getSelectedModules();
(-)src/org/eclipse/team/internal/ccvs/ui/operations/ProjectMetaFileOperation.java (+171 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2004 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.team.internal.ccvs.ui.operations;
12
13
import java.io.IOException;
14
import java.io.InputStream;
15
import java.lang.reflect.InvocationTargetException;
16
17
import org.eclipse.core.resources.IProjectDescription;
18
import org.eclipse.core.resources.IWorkspace;
19
import org.eclipse.core.resources.ResourcesPlugin;
20
import org.eclipse.core.runtime.CoreException;
21
import org.eclipse.core.runtime.IProgressMonitor;
22
import org.eclipse.team.core.TeamException;
23
import org.eclipse.team.internal.ccvs.core.CVSException;
24
import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile;
25
import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
26
import org.eclipse.team.internal.ccvs.ui.CVSUIMessages;
27
import org.eclipse.ui.IWorkbenchPart;
28
29
/**
30
 * Operation which checks for the existence of the .project file
31
 * in a remote folder, or to retrieve the project name for one or more
32
 * folders based on what is in the .project file.
33
 * 
34
 * To check for meta file exitence, the operation can be run 
35
 * by executing the operation and then checking <code>metaFileExists</code>
36
 * Use the retrieveContent as false in the constructor, to avoid the 
37
 * overhead of retrieving the file content too.
38
 * 
39
 * To update the folders with project names, the operation can be run
40
 * by calling the static method <code>updateFoldersWithProjectName</code> 
41
 * or by executing the operation and then checking <code>getUpdatedFolders</code>
42
 * to retrieve updated folders.
43
 * Use the retrieveContent as true in the constructor to retrive the content.
44
 * 
45
 * The <code>metaFileExists</code> flag is always updated regardless of the
46
 * retrieveContent constructor argument value
47
 */
48
public class ProjectMetaFileOperation extends CVSOperation {
49
50
	private ICVSRemoteFolder[] remoteFolders;
51
	private boolean metaFileExists;
52
	private boolean retrieveContent;
53
	
54
	/*
55
	 * Update a list of folders with their project names
56
	 * for those folders that have one.
57
	 */
58
	public static ICVSRemoteFolder[] updateFoldersWithProjectName(IWorkbenchPart part, ICVSRemoteFolder[] folders)
59
			throws InvocationTargetException, InterruptedException {
60
		ProjectMetaFileOperation op = new ProjectMetaFileOperation(part, folders, true /*retrieve metafile content*/);
61
		op.run();
62
		return op.getUpdatedFolders();
63
	}
64
65
	public ProjectMetaFileOperation(IWorkbenchPart part, ICVSRemoteFolder[] remoteFolders, boolean retrieveContent) {
66
		super(part);
67
		this.remoteFolders = remoteFolders;
68
		this.retrieveContent = retrieveContent;
69
	}
70
	
71
	/*
72
	 * Update the folders with a project name if the provided remote folder contains a non empty project name
73
	 * in its meta-file (i.e. .project file) 
74
	 * Set the metafile existence to true as needed
75
	 */
76
	private void checkForMetafileAndUpdateFoldersWithRemoteProjectName(ICVSRemoteFolder[] folders, IProgressMonitor monitor) throws CVSException {
77
		metaFileExists = false;
78
		for (int i = 0; i < folders.length; i++) {
79
			
80
			// make a copy of the folder so that we will not effect the original
81
			// folder when we refetch the members
82
			// TODO: this is a strange thing to need to do. We should fix this.
83
			ICVSRemoteFolder folder = (ICVSRemoteFolder) folders[i].forTag(folders[i].getTag());
84
		
85
			try {
86
				folder.members(monitor);
87
			} catch (TeamException e) {
88
				throw CVSException.wrapException(e);
89
			}
90
			// Check for the existance of the .project file
91
			// and attempt to create an IProjectDescription of it
92
			// and extract the project name
93
			InputStream in = null;
94
			try {
95
				ICVSRemoteFile remote = (ICVSRemoteFile) folder.getFile(".project"); //$NON-NLS-1$
96
				//if we have gone so far, then a metafile exists.
97
				metaFileExists = true;
98
				// retrieve the file content optionally, if requested
99
				if (retrieveContent) {
100
					in = remote.getContents(monitor);
101
					if (in == null || monitor.isCanceled()) {
102
						break;
103
					}
104
					IWorkspace workspace = ResourcesPlugin.getWorkspace();
105
					IProjectDescription projectDesc = workspace.loadProjectDescription(in);
106
					folder.setProjectName(projectDesc.getName());
107
					// let's update back our folder
108
					folders[i] = folder;
109
				}
110
			} catch (TeamException e) {
111
				// We couldn't retrieve the project meta file so assume it doesn't
112
				// exist
113
			} catch (CoreException e) {
114
				// We couldn't read the project description, so assume the
115
				// metafile is not a metafile, or is incorrect
116
				// which is as if it does not exist
117
			} finally {
118
				try {
119
					if (in != null) {
120
						in.close();
121
					}
122
				} catch (IOException e) {
123
					// ignore : we cannot read the file, so it's like it is not there
124
				}
125
			}
126
		}
127
	}
128
129
	
130
	/* (non-Javadoc)
131
	 * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
132
	 */
133
	public void execute(IProgressMonitor monitor) throws CVSException, InterruptedException {
134
		checkForMetafileAndUpdateFoldersWithRemoteProjectName(remoteFolders, monitor);
135
	}
136
	
137
	/**
138
	 * Return true if the meta file exists remotely. This method should only be invoked
139
	 * after the operation has been executed;
140
	 * @return
141
	 */
142
	public boolean metaFileExists() {
143
		return metaFileExists;
144
	}
145
146
	/**
147
	 * @return the updated folders with project name from the remote project meta
148
	 *         information if the .project file was properly retrieved or the
149
	 *         unmodified folders if retrieval failed. This method should only be
150
	 *         invoked after the operation has been executed;
151
	 */
152
	public ICVSRemoteFolder[] getUpdatedFolders() {
153
		return remoteFolders;
154
	}
155
156
	/* (non-Javadoc)
157
	 * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName()
158
	 */
159
	protected String getTaskName() {
160
		return CVSUIMessages.ProjectMetaFile_taskName; //$NON-NLS-1$
161
	}
162
	
163
	/* (non-Javadoc)
164
	 * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#canRunAsJob()
165
	 */
166
	public boolean canRunAsJob() {
167
		// This operation should never be run in the background.
168
		return false;
169
	}
170
171
}

Return to bug 84808