Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 25641 Details for
Bug 84808
(PatchAttached) Read project name from .project file in CVS checkout wizard
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch 2 or 2 for team.cvs.ui
o.e.team.cvs.ui-patch-to-fetch-project-name-from-metadata-2005-08-03.patch (text/plain), 33.97 KB, created by
Philippe Ombredanne
on 2005-08-03 17:15:46 EDT
(
hide
)
Description:
Patch 2 or 2 for team.cvs.ui
Filename:
MIME Type:
Creator:
Philippe Ombredanne
Created:
2005-08-03 17:15:46 EDT
Size:
33.97 KB
patch
obsolete
>Index: src/org/eclipse/team/internal/ccvs/ui/CVSPreferencesPage.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPreferencesPage.java,v >retrieving revision 1.60 >diff -u -r1.60 CVSPreferencesPage.java >--- src/org/eclipse/team/internal/ccvs/ui/CVSPreferencesPage.java 3 Jun 2005 15:41:17 -0000 1.60 >+++ src/org/eclipse/team/internal/ccvs/ui/CVSPreferencesPage.java 3 Aug 2005 21:10:57 -0000 >@@ -375,6 +375,7 @@ > new Checkbox(composite, ICVSUIConstants.PREF_DEBUG_PROTOCOL, CVSUIMessages.CVSPreferencesPage_17, IHelpContextIds.PREF_DEBUG_PROTOCOL); > new Checkbox(composite, ICVSUIConstants.PREF_AUTO_REFRESH_TAGS_IN_TAG_SELECTION_DIALOG, CVSUIMessages.CVSPreferencesPage_18, IHelpContextIds.PREF_AUTOREFRESH_TAG); > new Checkbox(composite, ICVSUIConstants.PREF_AUTO_SHARE_ON_IMPORT, CVSUIMessages.CVSPreferencesPage_44, null); >+ new Checkbox(composite, ICVSUIConstants.PREF_USE_PROJECT_NAME_ON_CHECKOUT, CVSUIMessages.CVSPreferencesPage_45, null); > > final Composite textComposite= SWTUtils.createHFillComposite(composite, SWTUtils.MARGINS_NONE, 2); > new TextField( >@@ -560,6 +561,7 @@ > CVSProviderPlugin.getPlugin().setUsePlatformLineend(store.getBoolean(ICVSUIConstants.PREF_USE_PLATFORM_LINEEND)); > CVSProviderPlugin.getPlugin().setDetermineVersionEnabled(store.getBoolean(ICVSUIConstants.PREF_DETERMINE_SERVER_VERSION)); > CVSProviderPlugin.getPlugin().setAutoshareOnImport(store.getBoolean(ICVSUIConstants.PREF_AUTO_SHARE_ON_IMPORT)); >+ CVSProviderPlugin.getPlugin().setUseProjectNameOnCheckout(store.getBoolean(ICVSUIConstants.PREF_USE_PROJECT_NAME_ON_CHECKOUT)); > > // changing the default keyword substitution mode for text files may affect > // information displayed in the decorators >Index: src/org/eclipse/team/internal/ccvs/ui/CVSUIMessages.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIMessages.java,v >retrieving revision 1.12 >diff -u -r1.12 CVSUIMessages.java >--- src/org/eclipse/team/internal/ccvs/ui/CVSUIMessages.java 18 Jul 2005 14:58:00 -0000 1.12 >+++ src/org/eclipse/team/internal/ccvs/ui/CVSUIMessages.java 3 Aug 2005 21:10:57 -0000 >@@ -225,6 +225,7 @@ > public static String CVSPreferencesPage_42; > public static String CVSPreferencesPage_43; > public static String CVSPreferencesPage_44; >+ public static String CVSPreferencesPage_45; > public static String CVSPropertiesPage_virtualModule; > > >@@ -796,7 +797,7 @@ > public static String WorkspaceChangeSetCapability_7; > public static String WorkspaceChangeSetCapability_8; > >- public static String HasProjectMetaFile_taskName; >+ public static String ProjectMetaFile_taskName; > public static String TagFromWorkspace_taskName; > public static String TagFromRepository_taskName; > public static String UpdateOnlyMergeable_taskName; >Index: src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java,v >retrieving revision 1.170 >diff -u -r1.170 CVSUIPlugin.java >--- src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java 3 Aug 2005 15:55:41 -0000 1.170 >+++ src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java 3 Aug 2005 21:10:58 -0000 >@@ -531,6 +531,7 @@ > store.setDefault(ICVSUIConstants.PREF_COMMIT_SET_DEFAULT_ENABLEMENT, false); > store.setDefault(ICVSUIConstants.PREF_AUTO_REFRESH_TAGS_IN_TAG_SELECTION_DIALOG, false); > store.setDefault(ICVSUIConstants.PREF_AUTO_SHARE_ON_IMPORT, true); >+ store.setDefault(ICVSUIConstants.PREF_USE_PROJECT_NAME_ON_CHECKOUT, false); > store.setDefault(ICVSUIConstants.PREF_COMMIT_FILES_DISPLAY_THRESHOLD, 1000); > > PreferenceConverter.setDefault(store, ICVSUIConstants.PREF_CONSOLE_COMMAND_COLOR, new RGB(0, 0, 0)); >@@ -587,6 +588,7 @@ > CVSProviderPlugin.getPlugin().setDetermineVersionEnabled(store.getBoolean(ICVSUIConstants.PREF_DETERMINE_SERVER_VERSION)); > CVSProviderPlugin.getPlugin().setDebugProtocol(CVSProviderPlugin.getPlugin().isDebugProtocol() || store.getBoolean(ICVSUIConstants.PREF_DEBUG_PROTOCOL)); > CVSProviderPlugin.getPlugin().setAutoshareOnImport(store.getBoolean(ICVSUIConstants.PREF_AUTO_SHARE_ON_IMPORT)); >+ CVSProviderPlugin.getPlugin().setUseProjectNameOnCheckout(store.getBoolean(ICVSUIConstants.PREF_USE_PROJECT_NAME_ON_CHECKOUT)); > } > > /** >Index: src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java,v >retrieving revision 1.90 >diff -u -r1.90 ICVSUIConstants.java >--- src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java 18 Jul 2005 14:58:00 -0000 1.90 >+++ src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java 3 Aug 2005 21:10:58 -0000 >@@ -95,6 +95,7 @@ > public final String PREF_AUTO_REFRESH_TAGS_IN_TAG_SELECTION_DIALOG = "pref_auto_refresh_tags_in_tag_selection_dialog"; //$NON-NLS-1$ > public final String PREF_COMMIT_FILES_DISPLAY_THRESHOLD = "pref_commit_files_display_threshold"; //$NON-NLS-1$ > public final String PREF_AUTO_SHARE_ON_IMPORT = "pref_auto_share_on_import"; //$NON-NLS-1$ >+ public final String PREF_USE_PROJECT_NAME_ON_CHECKOUT = "pref_use_project_name_on_checkout"; //$NON-NLS-1$ > > // console preferences > public final String PREF_CONSOLE_COMMAND_COLOR = "pref_console_command_color"; //$NON-NLS-1$ >Index: src/org/eclipse/team/internal/ccvs/ui/messages.properties >=================================================================== >RCS file: /home/eclipse/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties,v >retrieving revision 1.438 >diff -u -r1.438 messages.properties >--- src/org/eclipse/team/internal/ccvs/ui/messages.properties 18 Jul 2005 14:58:00 -0000 1.438 >+++ src/org/eclipse/team/internal/ccvs/ui/messages.properties 3 Aug 2005 21:10:58 -0000 >@@ -220,6 +220,7 @@ > CVSPreferencesPage_42=&Open perspective after a 'Show Annotations' operation > CVSPreferencesPage_43=D&efault perspective for 'Show Annotations': > CVSPreferencesPage_44=Aut&omatically share projects containing CVS meta information >+CVSPreferencesPage_45=Use .project &project name instead of module name on check out > CVSPropertiesPage_virtualModule=<no corresponding remote folder> > > >@@ -834,7 +835,7 @@ > WorkspaceChangeSetCapability_8=Edit the name and comment for the change set > > >-HasProjectMetaFile_taskName=Looking for a remote meta file >+ProjectMetaFile_taskName=Looking for a remote meta file > TagFromWorkspace_taskName=Tagging from workspace > TagFromRepository_taskName=Tagging from repository > UpdateOnlyMergeable_taskName=Updating mergeable changes >Index: src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAction.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAction.java,v >retrieving revision 1.17 >diff -u -r1.17 CheckoutAction.java >--- src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAction.java 22 Feb 2005 19:46:31 -0000 1.17 >+++ src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAction.java 3 Aug 2005 21:10:58 -0000 >@@ -14,9 +14,11 @@ > > import org.eclipse.jface.action.IAction; > import org.eclipse.team.core.TeamException; >+import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; > import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder; > import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; > import org.eclipse.team.internal.ccvs.ui.operations.CheckoutMultipleProjectsOperation; >+import org.eclipse.team.internal.ccvs.ui.operations.ProjectMetaFileOperation; > > /** > * Checkout a remote module into the workspace ensuring that the user is prompted for >@@ -28,7 +30,7 @@ > * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#execute(org.eclipse.jface.action.IAction) > */ > protected void execute(IAction action) throws InvocationTargetException, InterruptedException { >- new CheckoutMultipleProjectsOperation(getTargetPart(), getSelectedRemoteFolders(), null) >+ new CheckoutMultipleProjectsOperation(getTargetPart(), getSelectedRemoteFoldersWithProjectName(), null) > .run(); > } > >@@ -48,4 +50,18 @@ > } > return true; > } >+ >+ /** >+ * Get selected CVS remote folders, and add Project Description >+ * from metafile if available based on preferences settings >+ * @throws InterruptedException >+ * @throws InvocationTargetException >+ */ >+ private ICVSRemoteFolder[] getSelectedRemoteFoldersWithProjectName() throws InvocationTargetException, InterruptedException { >+ ICVSRemoteFolder[] folders = getSelectedRemoteFolders(); >+ if (CVSProviderPlugin.getPlugin().isUseProjectNameOnCheckout()){ >+ folders = ProjectMetaFileOperation.updateFoldersWithProjectName(getTargetPart(), folders); >+ } >+ return folders; >+ } > } >Index: src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAsAction.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAsAction.java,v >retrieving revision 1.35 >diff -u -r1.35 CheckoutAsAction.java >--- src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAsAction.java 22 Feb 2005 19:46:31 -0000 1.35 >+++ src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAsAction.java 3 Aug 2005 21:10:58 -0000 >@@ -15,8 +15,9 @@ > import org.eclipse.jface.action.IAction; > import org.eclipse.jface.wizard.WizardDialog; > import org.eclipse.team.core.TeamException; >+import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; > import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder; >-import org.eclipse.team.internal.ccvs.ui.operations.HasProjectMetaFileOperation; >+import org.eclipse.team.internal.ccvs.ui.operations.ProjectMetaFileOperation; > import org.eclipse.team.internal.ccvs.ui.wizards.CheckoutAsWizard; > > public class CheckoutAsAction extends CVSAction { >@@ -26,21 +27,22 @@ > */ > public void execute(IAction action) throws InvocationTargetException, InterruptedException { > ICVSRemoteFolder[] folders = getSelectedRemoteFolders(); >- CheckoutAsWizard wizard = new CheckoutAsWizard(getTargetPart(), folders, allowProjectConfiguration(folders)); >+ boolean withName = CVSProviderPlugin.getPlugin().isUseProjectNameOnCheckout(); >+ ProjectMetaFileOperation op = new ProjectMetaFileOperation(getTargetPart(), folders, withName); >+ op.run(); >+ >+ // project configuration allowed only if single folder without metafile >+ boolean allowProjectConfig = (folders.length == 1 && !op.metaFileExists()); >+ >+ if (withName) { >+ folders = op.getUpdatedFolders(); >+ } >+ >+ CheckoutAsWizard wizard = new CheckoutAsWizard(getTargetPart(), folders, allowProjectConfig); > WizardDialog dialog = new WizardDialog(shell, wizard); > dialog.open(); > } > >- /* >- * Return true if the remote project does not have a .project file >- * so that the checkout wizard will give the option to launch >- * the New Project wizard >- */ >- protected boolean allowProjectConfiguration(ICVSRemoteFolder[] folders) throws InvocationTargetException, InterruptedException { >- if (folders.length != 1) return false; >- return !HasProjectMetaFileOperation.hasMetaFile(getTargetPart(), folders[0]); >- } >- > /* (non-Javadoc) > * @see org.eclipse.team.internal.ui.actions.TeamAction#isEnabled() > */ >Index: src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutProjectOperation.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutProjectOperation.java,v >retrieving revision 1.32 >diff -u -r1.32 CheckoutProjectOperation.java >--- src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutProjectOperation.java 17 May 2005 20:48:54 -0000 1.32 >+++ src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutProjectOperation.java 3 Aug 2005 21:10:58 -0000 >@@ -124,6 +124,15 @@ > project = ResourcesPlugin.getWorkspace().getRoot().getProject(name); > } > >+ // Check to see if using remote metafile project description name is preferred >+ if (project == null >+ && CVSProviderPlugin.getPlugin().isUseProjectNameOnCheckout() >+ && resource.getProjectName() != null) { >+ // no project was specified but we need to attempt the creation of one >+ // based on the metafile project name >+ project = ResourcesPlugin.getWorkspace().getRoot().getProject(resource.getProjectName()); >+ } >+ > // Determine the local target projects (either the project provider or the module expansions) > // Note: Module expansions can be run over the same connection as a checkout > final IProject[] targetProjects = determineProjects(session, resource, project, Policy.subMonitorFor(pm, 5)); >@@ -286,6 +295,10 @@ > if (expansions.length == 1 && expansions[0].equals(moduleName)) { > // For a remote folder, use the last segment as the project to be created > String lastSegment = new Path(null, expansions[0]).lastSegment(); >+ // if using metafile project name is preferred, use it >+ if (CVSProviderPlugin.getPlugin().isUseProjectNameOnCheckout() && remoteFolder.getProjectName() != null) { >+ lastSegment = remoteFolder.getProjectName(); >+ } > targetProjectSet.add(ResourcesPlugin.getWorkspace().getRoot().getProject(lastSegment)); > } else { > for (int j = 0; j < expansions.length; j++) { >Index: src/org/eclipse/team/internal/ccvs/ui/operations/HasProjectMetaFileOperation.java >=================================================================== >RCS file: src/org/eclipse/team/internal/ccvs/ui/operations/HasProjectMetaFileOperation.java >diff -N src/org/eclipse/team/internal/ccvs/ui/operations/HasProjectMetaFileOperation.java >--- src/org/eclipse/team/internal/ccvs/ui/operations/HasProjectMetaFileOperation.java 5 Apr 2005 20:52:46 -0000 1.10 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,96 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2000, 2004 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.team.internal.ccvs.ui.operations; >- >-import java.lang.reflect.InvocationTargetException; >- >-import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.team.core.TeamException; >-import org.eclipse.team.internal.ccvs.core.CVSException; >-import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder; >-import org.eclipse.team.internal.ccvs.ui.CVSUIMessages; >-import org.eclipse.ui.IWorkbenchPart; >- >-/** >- * Operation which checks for the existance of the .project file >- * in a remote folder. The operation can be run using the <code>hasMetaFile</code> >- * static method of by executing the operation and then checking <code>metaFileExists</code> >- */ >-public class HasProjectMetaFileOperation extends CVSOperation { >- >- private ICVSRemoteFolder remoteFolder; >- private boolean metaFileExists; >- >- public static boolean hasMetaFile(IWorkbenchPart part, ICVSRemoteFolder remoteFolder) throws InvocationTargetException, InterruptedException { >- HasProjectMetaFileOperation op = new HasProjectMetaFileOperation(part, remoteFolder); >- op.run(); >- return op.metaFileExists(); >- } >- >- public HasProjectMetaFileOperation(IWorkbenchPart part, ICVSRemoteFolder remoteFolder) { >- super(part); >- this.remoteFolder = remoteFolder; >- } >- >- /* >- * Return true if the provided remote folder contains a valid meta-file >- * (i.e. .project file). >- */ >- private boolean hasMetaFile(ICVSRemoteFolder folder, IProgressMonitor monitor) throws CVSException { >- >- // make a copy of the folder so that we will not effect the original folder when we refetch the members >- // TODO: this is a strange thing to need to do. We shold fix this. >- folder = (ICVSRemoteFolder)folder.forTag(remoteFolder.getTag()); >- >- try { >- folder.members(monitor); >- } catch (TeamException e) { >- throw CVSException.wrapException(e); >- } >- // Check for the existance of the .project file >- try { >- folder.getFile(".project"); //$NON-NLS-1$ >- return true; >- } catch (TeamException e) { >- // We couldn't retrieve the meta file so assume it doesn't exist >- } >- return false; >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#execute(org.eclipse.core.runtime.IProgressMonitor) >- */ >- public void execute(IProgressMonitor monitor) throws CVSException, InterruptedException { >- metaFileExists = hasMetaFile(remoteFolder, monitor); >- } >- >- /** >- * Return true if the meta file exists remotely. This method should only be invoked >- * after the operation has been executed; >- * @return >- */ >- public boolean metaFileExists() { >- return metaFileExists; >- } >- >- protected String getTaskName() { >- return CVSUIMessages.HasProjectMetaFile_taskName; //$NON-NLS-1$ >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#canRunAsJob() >- */ >- public boolean canRunAsJob() { >- // This operation should never be run in the background. >- return false; >- } >- >-} >Index: src/org/eclipse/team/internal/ccvs/ui/wizards/CVSWizardPage.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CVSWizardPage.java,v >retrieving revision 1.20 >diff -u -r1.20 CVSWizardPage.java >--- src/org/eclipse/team/internal/ccvs/ui/wizards/CVSWizardPage.java 18 Mar 2005 20:25:40 -0000 1.20 >+++ src/org/eclipse/team/internal/ccvs/ui/wizards/CVSWizardPage.java 3 Aug 2005 21:10:58 -0000 >@@ -24,6 +24,8 @@ > import org.eclipse.swt.layout.GridData; > import org.eclipse.swt.layout.GridLayout; > import org.eclipse.swt.widgets.*; >+import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; >+import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder; > import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; > import org.eclipse.ui.model.WorkbenchContentProvider; > import org.eclipse.ui.model.WorkbenchLabelProvider; >@@ -310,4 +312,17 @@ > } > return super.canFlipToNextPage(); > } >+ >+ /** >+ * Utility method to get a folder name based on preferences. >+ * Returns the folder name or the project name retrieved from the project metafile >+ * @param the CVS remote folder >+ * @return a project name >+ */ >+ static protected String getPreferredFolderName(ICVSRemoteFolder folder) { >+ if (CVSProviderPlugin.getPlugin().isUseProjectNameOnCheckout() && folder.getProjectName() != null) { >+ return folder.getProjectName(); >+ } >+ return folder.getName(); >+ } > } >Index: src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsLocationSelectionPage.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsLocationSelectionPage.java,v >retrieving revision 1.12 >diff -u -r1.12 CheckoutAsLocationSelectionPage.java >--- src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsLocationSelectionPage.java 30 Jun 2005 19:50:49 -0000 1.12 >+++ src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsLocationSelectionPage.java 3 Aug 2005 21:10:59 -0000 >@@ -105,7 +105,7 @@ > > private IProject getSingleProject() { > if (singleProject == null) { >- setProjectName(remoteFolders[0].getName()); >+ setProjectName(getPreferredFolderName(remoteFolders[0])); > } > return singleProject; > } >@@ -295,7 +295,7 @@ > return locationStatus.getMessage(); > } else { > for (int i = 0; i < remoteFolders.length; i++) { >- String projectName = remoteFolders[i].getName(); >+ String projectName = getPreferredFolderName(remoteFolders[i]); > IStatus locationStatus = ResourcesPlugin.getWorkspace().validateProjectLocation( > ResourcesPlugin.getWorkspace().getRoot().getProject(projectName), > new Path(targetLocation).append(projectName)); >Index: src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsMainPage.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsMainPage.java,v >retrieving revision 1.14 >diff -u -r1.14 CheckoutAsMainPage.java >--- src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsMainPage.java 31 May 2005 15:16:52 -0000 1.14 >+++ src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsMainPage.java 3 Aug 2005 21:10:59 -0000 >@@ -87,7 +87,7 @@ > * For the single folder case, return the name of the folder > */ > private String getFolderName() { >- String name = folders[0].getName(); >+ String name = getPreferredFolderName(folders[0]); > if (name .equals(".")) { //$NON-NLS-1$ > name = new Path(null, folders[0].getRepository().getRootDirectory()).lastSegment(); > } >Index: src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsProjectSelectionPage.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsProjectSelectionPage.java,v >retrieving revision 1.14 >diff -u -r1.14 CheckoutAsProjectSelectionPage.java >--- src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsProjectSelectionPage.java 31 May 2005 15:16:52 -0000 1.14 >+++ src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsProjectSelectionPage.java 3 Aug 2005 21:10:59 -0000 >@@ -73,7 +73,7 @@ > * For the single folder case, return the name of the folder > */ > private String getInputFolderName() { >- return remoteFolders[0].getName(); >+ return getPreferredFolderName(remoteFolders[0]); > } > > private String getRepository() throws CVSException { >Index: src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsWizard.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsWizard.java,v >retrieving revision 1.15 >diff -u -r1.15 CheckoutAsWizard.java >--- src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsWizard.java 30 Jun 2005 19:50:49 -0000 1.15 >+++ src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsWizard.java 3 Aug 2005 21:10:59 -0000 >@@ -227,6 +227,18 @@ > return folders; > } > >+ /* >+ * Return the remote folders to be checked out with >+ * Folder description if available based on preferrences settings >+ */ >+ private ICVSRemoteFolder[] getRemoteFoldersWithProjectDescriptions() throws InvocationTargetException, InterruptedException { >+ ICVSRemoteFolder[] folders = getRemoteFolders(); >+ if (CVSProviderPlugin.getPlugin().isUseProjectNameOnCheckout()) { >+ folders = ProjectMetaFileOperation.updateFoldersWithProjectName(part, folders); >+ } >+ return folders; >+ } >+ > private CVSTag getSelectedTag() { > return tagSelectionPage.getSelectedTag(); > } >@@ -247,7 +259,7 @@ > private boolean performMultipleCheckoutAs() throws InvocationTargetException, InterruptedException { > String targetLocation = locationSelectionPage.getTargetLocation(); > // Run the checkout in the background >- new CheckoutMultipleProjectsOperation(part, getRemoteFolders(), targetLocation).run(); >+ new CheckoutMultipleProjectsOperation(part, getRemoteFoldersWithProjectDescriptions(), targetLocation).run(); > return true; > } > >Index: src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutWizard.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutWizard.java,v >retrieving revision 1.19 >diff -u -r1.19 CheckoutWizard.java >--- src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutWizard.java 5 Apr 2005 20:52:46 -0000 1.19 >+++ src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutWizard.java 3 Aug 2005 21:10:59 -0000 >@@ -24,7 +24,7 @@ > import org.eclipse.team.internal.ccvs.core.util.KnownRepositories; > import org.eclipse.team.internal.ccvs.ui.*; > import org.eclipse.team.internal.ccvs.ui.operations.CheckoutMultipleProjectsOperation; >-import org.eclipse.team.internal.ccvs.ui.operations.HasProjectMetaFileOperation; >+import org.eclipse.team.internal.ccvs.ui.operations.ProjectMetaFileOperation; > import org.eclipse.ui.*; > > /** >@@ -187,8 +187,25 @@ > try { > boolean hasMetafile = true; > if (selectedModules.length == 1) { >- // Only allow configuration if one module is selected >- hasMetafile = hasProjectMetafile(selectedModules[0]); >+ final ICVSRemoteFolder[] folders = new ICVSRemoteFolder[] {selectedModules[0]}; >+ final boolean withName = CVSProviderPlugin.getPlugin().isUseProjectNameOnCheckout(); >+ >+ // attempt to retrieve the project description depending on preferences >+ // this is a bit circumvoluted to batch the metafile check and retrieval in one op >+ final ICVSRemoteFolder[] folderResult = new ICVSRemoteFolder [1]; >+ final boolean[] booleanResult = new boolean[] { true }; >+ >+ getContainer().run(true, true, new IRunnableWithProgress() { >+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { >+ ProjectMetaFileOperation op = new ProjectMetaFileOperation(getPart(), new ICVSRemoteFolder[] {folders[0]}, withName); >+ op.run(monitor); >+ folderResult[0] = op.getUpdatedFolders()[0]; >+ booleanResult[0] = op.metaFileExists(); >+ } >+ }); >+ hasMetafile = booleanResult[0]; >+ if (withName && hasMetafile) >+ selectedModules[0] = folderResult[0]; > } > resetSubwizard(); > wizard = new CheckoutAsWizard(getPart(), selectedModules, ! hasMetafile /* allow configuration */); >@@ -215,18 +232,6 @@ > return null; > } > >- private boolean hasProjectMetafile(final ICVSRemoteFolder selectedModule) throws InvocationTargetException, InterruptedException { >- final boolean[] result = new boolean[] { true }; >- getContainer().run(true, true, new IRunnableWithProgress() { >- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { >- HasProjectMetaFileOperation op = new HasProjectMetaFileOperation(getPart(), selectedModule); >- op.run(monitor); >- result[0] = op.metaFileExists(); >- } >- }); >- return result[0]; >- } >- > private ICVSRemoteFolder[] getSelectedModules() { > if (modulePage == null) return null; > return modulePage.getSelectedModules(); >Index: src/org/eclipse/team/internal/ccvs/ui/operations/ProjectMetaFileOperation.java >=================================================================== >RCS file: src/org/eclipse/team/internal/ccvs/ui/operations/ProjectMetaFileOperation.java >diff -N src/org/eclipse/team/internal/ccvs/ui/operations/ProjectMetaFileOperation.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/team/internal/ccvs/ui/operations/ProjectMetaFileOperation.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,171 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2004 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.team.internal.ccvs.ui.operations; >+ >+import java.io.IOException; >+import java.io.InputStream; >+import java.lang.reflect.InvocationTargetException; >+ >+import org.eclipse.core.resources.IProjectDescription; >+import org.eclipse.core.resources.IWorkspace; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.team.core.TeamException; >+import org.eclipse.team.internal.ccvs.core.CVSException; >+import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile; >+import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder; >+import org.eclipse.team.internal.ccvs.ui.CVSUIMessages; >+import org.eclipse.ui.IWorkbenchPart; >+ >+/** >+ * Operation which checks for the existence of the .project file >+ * in a remote folder, or to retrieve the project name for one or more >+ * folders based on what is in the .project file. >+ * >+ * To check for meta file exitence, the operation can be run >+ * by executing the operation and then checking <code>metaFileExists</code> >+ * Use the retrieveContent as false in the constructor, to avoid the >+ * overhead of retrieving the file content too. >+ * >+ * To update the folders with project names, the operation can be run >+ * by calling the static method <code>updateFoldersWithProjectName</code> >+ * or by executing the operation and then checking <code>getUpdatedFolders</code> >+ * to retrieve updated folders. >+ * Use the retrieveContent as true in the constructor to retrive the content. >+ * >+ * The <code>metaFileExists</code> flag is always updated regardless of the >+ * retrieveContent constructor argument value >+ */ >+public class ProjectMetaFileOperation extends CVSOperation { >+ >+ private ICVSRemoteFolder[] remoteFolders; >+ private boolean metaFileExists; >+ private boolean retrieveContent; >+ >+ /* >+ * Update a list of folders with their project names >+ * for those folders that have one. >+ */ >+ public static ICVSRemoteFolder[] updateFoldersWithProjectName(IWorkbenchPart part, ICVSRemoteFolder[] folders) >+ throws InvocationTargetException, InterruptedException { >+ ProjectMetaFileOperation op = new ProjectMetaFileOperation(part, folders, true /*retrieve metafile content*/); >+ op.run(); >+ return op.getUpdatedFolders(); >+ } >+ >+ public ProjectMetaFileOperation(IWorkbenchPart part, ICVSRemoteFolder[] remoteFolders, boolean retrieveContent) { >+ super(part); >+ this.remoteFolders = remoteFolders; >+ this.retrieveContent = retrieveContent; >+ } >+ >+ /* >+ * Update the folders with a project name if the provided remote folder contains a non empty project name >+ * in its meta-file (i.e. .project file) >+ * Set the metafile existence to true as needed >+ */ >+ private void checkForMetafileAndUpdateFoldersWithRemoteProjectName(ICVSRemoteFolder[] folders, IProgressMonitor monitor) throws CVSException { >+ metaFileExists = false; >+ for (int i = 0; i < folders.length; i++) { >+ >+ // make a copy of the folder so that we will not effect the original >+ // folder when we refetch the members >+ // TODO: this is a strange thing to need to do. We should fix this. >+ ICVSRemoteFolder folder = (ICVSRemoteFolder) folders[i].forTag(folders[i].getTag()); >+ >+ try { >+ folder.members(monitor); >+ } catch (TeamException e) { >+ throw CVSException.wrapException(e); >+ } >+ // Check for the existance of the .project file >+ // and attempt to create an IProjectDescription of it >+ // and extract the project name >+ InputStream in = null; >+ try { >+ ICVSRemoteFile remote = (ICVSRemoteFile) folder.getFile(".project"); //$NON-NLS-1$ >+ //if we have gone so far, then a metafile exists. >+ metaFileExists = true; >+ // retrieve the file content optionally, if requested >+ if (retrieveContent) { >+ in = remote.getContents(monitor); >+ if (in == null || monitor.isCanceled()) { >+ break; >+ } >+ IWorkspace workspace = ResourcesPlugin.getWorkspace(); >+ IProjectDescription projectDesc = workspace.loadProjectDescription(in); >+ folder.setProjectName(projectDesc.getName()); >+ // let's update back our folder >+ folders[i] = folder; >+ } >+ } catch (TeamException e) { >+ // We couldn't retrieve the project meta file so assume it doesn't >+ // exist >+ } catch (CoreException e) { >+ // We couldn't read the project description, so assume the >+ // metafile is not a metafile, or is incorrect >+ // which is as if it does not exist >+ } finally { >+ try { >+ if (in != null) { >+ in.close(); >+ } >+ } catch (IOException e) { >+ // ignore : we cannot read the file, so it's like it is not there >+ } >+ } >+ } >+ } >+ >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#execute(org.eclipse.core.runtime.IProgressMonitor) >+ */ >+ public void execute(IProgressMonitor monitor) throws CVSException, InterruptedException { >+ checkForMetafileAndUpdateFoldersWithRemoteProjectName(remoteFolders, monitor); >+ } >+ >+ /** >+ * Return true if the meta file exists remotely. This method should only be invoked >+ * after the operation has been executed; >+ * @return >+ */ >+ public boolean metaFileExists() { >+ return metaFileExists; >+ } >+ >+ /** >+ * @return the updated folders with project name from the remote project meta >+ * information if the .project file was properly retrieved or the >+ * unmodified folders if retrieval failed. This method should only be >+ * invoked after the operation has been executed; >+ */ >+ public ICVSRemoteFolder[] getUpdatedFolders() { >+ return remoteFolders; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName() >+ */ >+ protected String getTaskName() { >+ return CVSUIMessages.ProjectMetaFile_taskName; //$NON-NLS-1$ >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#canRunAsJob() >+ */ >+ public boolean canRunAsJob() { >+ // This operation should never be run in the background. >+ return false; >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 84808
:
25145
|
25640
|
25641
|
26058