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

Return to bug 84808