diff options
author | Michael Valenta | 2003-04-30 20:38:52 +0000 |
---|---|---|
committer | Michael Valenta | 2003-04-30 20:38:52 +0000 |
commit | 34cbad0266417ada38b708238f7385c7e80b5d7d (patch) | |
tree | 6090bd2641b718ae2250611ccbbf3108006652e4 | |
parent | 85da8d8c846223f050fa36a2bc8751caf6661190 (diff) | |
download | eclipse.platform.team-34cbad0266417ada38b708238f7385c7e80b5d7d.tar.gz eclipse.platform.team-34cbad0266417ada38b708238f7385c7e80b5d7d.tar.xz eclipse.platform.team-34cbad0266417ada38b708238f7385c7e80b5d7d.zip |
*** empty log message ***
6 files changed, 54 insertions, 244 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CVSOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CVSOperation.java index 6a64e0d6f..2b650a727 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CVSOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CVSOperation.java @@ -83,6 +83,10 @@ public abstract class CVSOperation implements IRunnableWithProgress { } } + public void executeWithProgress() throws CVSException, InterruptedException { + execute(new ProgressMonitorDialog(getShell())); + } + /** * Execute the operation in the runnable context that has been assigned to the operation. * If a context has not been assigned, the workbench window is used. diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutOperation.java index b2c150cc7..0eb63d6a3 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutOperation.java @@ -86,10 +86,10 @@ public abstract class CheckoutOperation extends CVSOperation { /** * @return */ - protected IProject[] getTargetProjects(ICVSRemoteFolder[] remoteFolders) { + protected IProject[] getTargetProjects(ICVSRemoteFolder[] folders) { IProject[] projects = new IProject[remoteFolders.length]; for (int i = 0; i < projects.length; i++) { - projects[i] = ResourcesPlugin.getWorkspace().getRoot().getProject(remoteFolders[i].getName()); + projects[i] = ResourcesPlugin.getWorkspace().getRoot().getProject(folders[i].getName()); } return projects; } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/HasProjectMetaFileOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/HasProjectMetaFileOperation.java index 998ec3f79..463c354ea 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/HasProjectMetaFileOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/HasProjectMetaFileOperation.java @@ -45,27 +45,27 @@ public class HasProjectMetaFileOperation extends CVSOperation { * Return true if the provided remote folder contains a valid meta-file * (i.e. .project or the older .vcm_meta file). */ - private boolean hasMetaFile(ICVSRemoteFolder remoteFolder, IProgressMonitor monitor) throws CVSException { + 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 strang thing to need to do. We shold fix this. - remoteFolder = (ICVSRemoteFolder)remoteFolder.forTag(remoteFolder.getTag()); + folder = (ICVSRemoteFolder)folder.forTag(remoteFolder.getTag()); try { - remoteFolder.members(monitor); + folder.members(monitor); } catch (TeamException e) { throw CVSException.wrapException(e); } // Check for the existance of the .project file try { - remoteFolder.getFile(".project"); //$NON-NLS-1$ + folder.getFile(".project"); //$NON-NLS-1$ return true; } catch (TeamException e) { // We couldn't retrieve the meta file so assume it doesn't exist } // If the above failed, look for the old .vcm_meta file try { - remoteFolder.getFile(".vcm_meta"); //$NON-NLS-1$ + folder.getFile(".vcm_meta"); //$NON-NLS-1$ return true; } catch (TeamException e) { // We couldn't retrieve the meta file so assume it doesn't exist diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsLocationSelectionPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsLocationSelectionPage.java index 0d0d5c518..6254834a1 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsLocationSelectionPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsLocationSelectionPage.java @@ -13,7 +13,6 @@ package org.eclipse.team.internal.ccvs.ui.wizards; import java.io.File; import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; @@ -289,37 +288,17 @@ public class CheckoutAsLocationSelectionPage extends CVSWizardPage { } /** - * Return the project descriptions containing the custom location for - * each project or null if no custom location was specified. - * In this case, the custom location is the parent of all projects - * being created. - */ - public IProjectDescription[] getProjectDescriptions() { - // create the project descriptions for each project - IProjectDescription[] descriptions = new IProjectDescription[remoteFolders.length]; - for (int i = 0; i < remoteFolders.length; i++) { - String projectName = remoteFolders[i].getName(); - descriptions[i] = ResourcesPlugin.getWorkspace().newProjectDescription(projectName); - descriptions[i].setLocation(new Path(targetLocation).append(projectName)); - } - return descriptions; - } - - /** * Return the custom location for a single project. In this case, the specified * location is used as the location of the project. * * @param project * @return */ - public IProjectDescription getProjectDescription(IProject project) { - if (isCustomLocationSpecified()) { - IProjectDescription description = ResourcesPlugin.getWorkspace().newProjectDescription(project.getName()); - description.setLocation(new Path(targetLocation)); - return description; - } else { + public String getTargetLocation() { + if (isCustomLocationSpecified()) + return targetLocation; + else return null; - } } /** diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsProjectSelectionPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsProjectSelectionPage.java index b2a77e443..47674b6b8 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsProjectSelectionPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsProjectSelectionPage.java @@ -47,10 +47,8 @@ import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; import org.eclipse.team.internal.ccvs.ui.Policy; /** - * @author Administrator - * - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>Code and Comments + * This page allows the user to select the target parent container for + * the folders being checked out. */ public class CheckoutAsProjectSelectionPage extends CVSWizardPage { @@ -175,11 +173,11 @@ public class CheckoutAsProjectSelectionPage extends CVSWizardPage { } private void handleResourceSelection(SelectionChangedEvent event) { - ISelection selection = event.getSelection(); - if (selection.isEmpty()) { + ISelection sel = event.getSelection(); + if (sel.isEmpty()) { this.selection = null; } else if (selection instanceof IStructuredSelection) { - this.selection = (IResource)((IStructuredSelection)selection).getFirstElement(); + this.selection = (IResource)((IStructuredSelection)sel).getFirstElement(); } updateWidgetEnablements(); } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsWizard.java index e740f23e9..c4f7dc4aa 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsWizard.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsWizard.java @@ -10,33 +10,24 @@ *******************************************************************************/ package org.eclipse.team.internal.ccvs.ui.wizards; -import java.io.File; -import java.lang.reflect.InvocationTargetException; - import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResourceChangeEvent; import org.eclipse.core.resources.IResourceChangeListener; import org.eclipse.core.resources.IResourceDelta; import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.wizard.IWizardPage; import org.eclipse.jface.wizard.Wizard; -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.core.resources.CVSWorkspaceRoot; import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants; import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ui.IPromptCondition; -import org.eclipse.team.internal.ui.PromptingDialog; +import org.eclipse.team.internal.ccvs.ui.operations.CheckoutMultipleProjectsOperation; +import org.eclipse.team.internal.ccvs.ui.operations.CheckoutSingleProjectOperation; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.actions.NewProjectAction; -import org.eclipse.ui.actions.WorkspaceModifyOperation; /** * @author Administrator @@ -103,16 +94,23 @@ public class CheckoutAsWizard extends Wizard { * @see org.eclipse.jface.wizard.IWizard#performFinish() */ public boolean performFinish() { - if (mainPage.isPerformConfigure()) { - return performConfigureAndCheckout(); - } else if (mainPage.isPerformCheckoutAs()) { - if (isSingleFolder()) { - return performSingleCheckoutAs(); - } else { - return performMultipleCheckoutAs(); + try { + if (mainPage.isPerformConfigure()) { + return performConfigureAndCheckout(); + } else if (mainPage.isPerformCheckoutAs()) { + if (isSingleFolder()) { + return performSingleCheckoutAs(); + } else { + return performMultipleCheckoutAs(); + } + } else if (mainPage.isPerformCheckoutInto()) { + return performCheckoutInto(); } - } else if (mainPage.isPerformCheckoutInto()) { - return performCheckoutInto(); + } catch (CVSException e) { + handle(e); + // drop through + } catch (InterruptedException e) { + // drop through } return false; } @@ -160,18 +158,6 @@ public class CheckoutAsWizard extends Wizard { if (page == mainPage) return null; return mainPage; } - - private boolean run(WorkspaceModifyOperation operation) { - try { - getContainer().run(true, true, operation); - return true; - } catch (InvocationTargetException e) { - handle(e); - return false; - } catch (InterruptedException e) { - return false; - } - } private void handle(Throwable e) { CVSUIPlugin.openError(getShell(), Policy.bind("CheckoutAsWizard.error"), null, e); //$NON-NLS-1$ @@ -181,68 +167,34 @@ public class CheckoutAsWizard extends Wizard { * Configure a local project and checkout the selected remote folder into the project. * This only occurs for single folders. */ - private boolean performConfigureAndCheckout() { - final IProject newProject = getNewProject(); + private boolean performConfigureAndCheckout() throws CVSException, InterruptedException { + IProject newProject = getNewProject(); if (newProject == null) return false; - return run(new WorkspaceModifyOperation() { - public void execute(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - checkoutProject(newProject, null, monitor); - } catch (TeamException e) { - throw new InvocationTargetException(e); - } - } - }); + new CheckoutSingleProjectOperation(getShell(), remoteFolders[0], newProject, null, true) + .executeWithProgress(); + return true; } /** * */ - private boolean performSingleCheckoutAs() { - final IProject newProject = ResourcesPlugin.getWorkspace().getRoot().getProject(mainPage.getProjectName()); - final IProjectDescription desc = locationSelectionPage.getProjectDescription(newProject); - if (!promptToOverwrite(new IProject[] {newProject}, new IProjectDescription[] {desc})) return false; - return run(new WorkspaceModifyOperation() { - public void execute(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - checkoutProject(newProject, desc, monitor); - } catch (TeamException e) { - throw new InvocationTargetException(e); - } - } - }); + private boolean performSingleCheckoutAs() throws CVSException, InterruptedException { + IProject newProject = ResourcesPlugin.getWorkspace().getRoot().getProject(mainPage.getProjectName()); + String targetLocation = locationSelectionPage.getTargetLocation(); + new CheckoutSingleProjectOperation(getShell(), remoteFolders[0], newProject, targetLocation, false) + .executeWithProgress(); + return true; } /** * Check out multiple folders to the workspace using a custom location if one is * specified. */ - private boolean performMultipleCheckoutAs() { - final IProject[] newProjects = getTargetProjects(); - final IProjectDescription[] descs = locationSelectionPage.getProjectDescriptions(); - if (!promptToOverwrite(newProjects, descs)) return false; - return run(new WorkspaceModifyOperation() { - public void execute(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - checkoutProjects(newProjects, descs, monitor); - } catch (TeamException e) { - throw new InvocationTargetException(e); - } - } - }); - } - - /** - * Answer the list of target projects for the remote folders - */ - private IProject[] getTargetProjects() { - // create the target project handles - IProject[] targetProjects = new IProject[remoteFolders.length]; - for (int i = 0; i < remoteFolders.length; i++) { - ICVSRemoteFolder remoteFolder = remoteFolders[i]; - targetProjects[i] = ResourcesPlugin.getWorkspace().getRoot().getProject(remoteFolder.getName()); - } - return targetProjects; + private boolean performMultipleCheckoutAs() throws CVSException, InterruptedException { + String targetLocation = locationSelectionPage.getTargetLocation(); + new CheckoutMultipleProjectsOperation(getShell(), remoteFolders, targetLocation) + .executeWithProgress(); + return true; } /** @@ -252,80 +204,7 @@ public class CheckoutAsWizard extends Wizard { // TODO Auto-generated method stub return false; } - - /** - * @param projects - * @param descs - * @return - */ - private boolean promptToOverwrite(IProject[] projects, IProjectDescription[] descs) { - PromptingDialog prompt = new PromptingDialog(getShell(), projects, - getOverwriteLocalAndFileSystemPrompt(descs), - Policy.bind("ReplaceWithAction.confirmOverwrite"), - true /* all or nothing */);//$NON-NLS-1$ - try { - return (prompt.promptForMultiple().length == projects.length); - } catch (InterruptedException e) { - return false; - } - } - - protected IPromptCondition getOverwriteLocalAndFileSystemPrompt(final IProjectDescription[] descriptions) { - return new IPromptCondition() { - // prompt if resource in workspace exists or exists in local file system - public boolean needsPrompt(IResource resource) { - - // First, check the description location - IProjectDescription desc = findDescription(descriptions, resource); - if (desc != null) { - File localLocation = desc.getLocation().toFile(); - return localLocation.exists(); - } - - // Next, check if the resource itself exists - if (resource.exists()) return true; - - // Finally, check if the location in the workspace exists; - File localLocation = getFileLocation(resource); - if (localLocation.exists()) return true; - - // The target doesn't exist - return false; - } - public String promptMessage(IResource resource) { - IProjectDescription desc = findDescription(descriptions, resource); - if (desc != null) { - return Policy.bind("AddToWorkspaceAction.thisExternalFileExists", desc.getLocation().toString());//$NON-NLS-1$ - } else if(resource.exists()) { - return Policy.bind("AddToWorkspaceAction.thisResourceExists", resource.getName());//$NON-NLS-1$ - } else { - File localLocation = getFileLocation(resource); - return Policy.bind("AddToWorkspaceAction.thisExternalFileExists", localLocation.toString());//$NON-NLS-1$ - } - } - private File getFileLocation(IResource resource) { - return new File(resource.getParent().getLocation().toFile(), resource.getName()); - } - }; - } - /** - * @param newProject - * @param monitor - */ - protected void checkoutProject(IProject newProject, IProjectDescription desc, IProgressMonitor monitor) throws TeamException { - monitor.beginTask(null, 100); - createAndOpenProject(newProject, desc, Policy.subMonitorFor(monitor, 10)); - checkoutProjects(remoteFolders, new IProject[] {newProject}, Policy.subMonitorFor(monitor, 90)); - monitor.done(); - } - protected void checkoutProjects(IProject[] newProjects, IProjectDescription[] descs, IProgressMonitor monitor) throws TeamException { - monitor.beginTask(null, 100); - createAndOpenProjects(newProjects, descs, Policy.subMonitorFor(monitor, 10)); - checkoutProjects(remoteFolders, newProjects, Policy.subMonitorFor(monitor, 90)); - monitor.done(); - - } /** * Get a new project that is configured by the new project wizard. * This is currently the only way to do this. @@ -338,55 +217,5 @@ public class CheckoutAsWizard extends Wizard { IProject project = listener.getNewProject(); return project; } - - private void createAndOpenProject(IProject project, IProjectDescription desc, IProgressMonitor monitor) throws CVSException { - try { - monitor.beginTask(null, 5); - if (project.exists()) { - if (desc != null) { - project.move(desc, true, Policy.subMonitorFor(monitor, 3)); - } - } else { - if (desc == null) { - // create in default location - project.create(Policy.subMonitorFor(monitor, 3)); - } else { - // create in some other location - project.create(desc, Policy.subMonitorFor(monitor, 3)); - } - } - if (!project.isOpen()) { - project.open(Policy.subMonitorFor(monitor, 2)); - } - } catch (CoreException e) { - throw CVSException.wrapException(e); - } finally { - monitor.done(); - } - } - - private void createAndOpenProjects(IProject[] projects, IProjectDescription[] descriptions, IProgressMonitor monitor) throws CVSException { - monitor.beginTask(null, projects.length* 100); - for (int i = 0; i < projects.length; i++) { - IProject project = projects[i]; - IProjectDescription desc = findDescription(descriptions, project); - createAndOpenProject(project, desc, Policy.subMonitorFor(monitor, 100)); - } - monitor.done(); - } - - private IProjectDescription findDescription(IProjectDescription[] descriptions, IResource resource) { - IProject project = resource.getProject(); - for (int i = 0; i < descriptions.length; i++) { - IProjectDescription description = descriptions[i]; - if (description != null && description.getName().equals(project.getName())) - return description; - } - return null; - } - - private void checkoutProjects(ICVSRemoteFolder[] folders, IProject[] projects, IProgressMonitor monitor) throws TeamException { - CVSWorkspaceRoot.checkout(folders, projects, monitor); - } } |