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

Collapse All | Expand All

(-)org/eclipse/team/internal/ui/wizards/ProjectSetExportWizard.java (-4 / +5 lines)
Lines 32-46 Link Here
32
import org.eclipse.jface.viewers.IStructuredSelection;
32
import org.eclipse.jface.viewers.IStructuredSelection;
33
import org.eclipse.jface.wizard.Wizard;
33
import org.eclipse.jface.wizard.Wizard;
34
import org.eclipse.swt.widgets.Shell;
34
import org.eclipse.swt.widgets.Shell;
35
import org.eclipse.team.core.IProjectSetSerializer;
36
import org.eclipse.team.core.ProjectSetCapability;
35
import org.eclipse.team.core.ProjectSetCapability;
36
import org.eclipse.team.core.ProjectSetSerializer;
37
import org.eclipse.team.core.RepositoryProvider;
37
import org.eclipse.team.core.RepositoryProvider;
38
import org.eclipse.team.core.RepositoryProviderType;
38
import org.eclipse.team.core.RepositoryProviderType;
39
import org.eclipse.team.core.Team;
40
import org.eclipse.team.core.TeamException;
39
import org.eclipse.team.core.TeamException;
41
import org.eclipse.team.internal.ui.Policy;
40
import org.eclipse.team.internal.ui.Policy;
42
import org.eclipse.team.internal.ui.TeamUIPlugin;
41
import org.eclipse.team.internal.ui.TeamUIPlugin;
43
import org.eclipse.team.ui.ISharedImages;
42
import org.eclipse.team.ui.ISharedImages;
43
import org.eclipse.team.ui.UIProjectSetSerializationContext;
44
import org.eclipse.ui.IExportWizard;
44
import org.eclipse.ui.IExportWizard;
45
import org.eclipse.ui.IWorkbench;
45
import org.eclipse.ui.IWorkbench;
46
46
Lines 123-128 Link Here
123
						writer.newLine();
123
						writer.newLine();
124
						
124
						
125
						// For each provider id, do the writing
125
						// For each provider id, do the writing
126
						UIProjectSetSerializationContext context = new UIProjectSetSerializationContext(getShell());
126
						Iterator it = map.keySet().iterator();
127
						Iterator it = map.keySet().iterator();
127
						monitor.beginTask(null, 1000 * map.keySet().size());
128
						monitor.beginTask(null, 1000 * map.keySet().size());
128
						while (it.hasNext()) {
129
						while (it.hasNext()) {
Lines 133-141 Link Here
133
							writer.newLine();
134
							writer.newLine();
134
							List list = (List)map.get(id);
135
							List list = (List)map.get(id);
135
							IProject[] projectArray = (IProject[])list.toArray(new IProject[list.size()]);
136
							IProject[] projectArray = (IProject[])list.toArray(new IProject[list.size()]);
136
							IProjectSetSerializer serializer = Team.getProjectSetSerializer(id);
137
							ProjectSetSerializer serializer = RepositoryProviderType.getProviderType(id).getProjectSetSerializer();
137
							if (serializer != null) {
138
							if (serializer != null) {
138
								String[] references = serializer.asReference(projectArray, shell, new SubProgressMonitor(monitor, 990));
139
								String[] references = serializer.asReference(projectArray, context, new SubProgressMonitor(monitor, 990));
139
								for (int i = 0; i < references.length; i++) {
140
								for (int i = 0; i < references.length; i++) {
140
									writer.write("\t\t<project reference=\""); //$NON-NLS-1$
141
									writer.write("\t\t<project reference=\""); //$NON-NLS-1$
141
									writer.write(references[i]);
142
									writer.write(references[i]);
(-)org/eclipse/team/internal/ui/wizards/ProjectSetImportWizard.java (-2 / +6 lines)
Lines 28-39 Link Here
28
import org.eclipse.jface.viewers.IStructuredSelection;
28
import org.eclipse.jface.viewers.IStructuredSelection;
29
import org.eclipse.jface.wizard.Wizard;
29
import org.eclipse.jface.wizard.Wizard;
30
import org.eclipse.team.core.IProjectSetSerializer;
30
import org.eclipse.team.core.IProjectSetSerializer;
31
import org.eclipse.team.core.ProjectSetSerializer;
32
import org.eclipse.team.core.RepositoryProviderType;
31
import org.eclipse.team.core.Team;
33
import org.eclipse.team.core.Team;
32
import org.eclipse.team.core.TeamException;
34
import org.eclipse.team.core.TeamException;
33
import org.eclipse.team.internal.ui.Policy;
35
import org.eclipse.team.internal.ui.Policy;
34
import org.eclipse.team.internal.ui.ProjectSetContentHandler;
36
import org.eclipse.team.internal.ui.ProjectSetContentHandler;
35
import org.eclipse.team.internal.ui.TeamUIPlugin;
37
import org.eclipse.team.internal.ui.TeamUIPlugin;
36
import org.eclipse.team.ui.ISharedImages;
38
import org.eclipse.team.ui.ISharedImages;
39
import org.eclipse.team.ui.UIProjectSetSerializationContext;
37
import org.eclipse.ui.IImportWizard;
40
import org.eclipse.ui.IImportWizard;
38
import org.eclipse.ui.IWorkbench;
41
import org.eclipse.ui.IWorkbench;
39
import org.eclipse.ui.IWorkingSet;
42
import org.eclipse.ui.IWorkingSet;
Lines 93-105 Link Here
93
									newProjects.addAll(Arrays.asList(projects));
96
									newProjects.addAll(Arrays.asList(projects));
94
							}
97
							}
95
						} else {
98
						} else {
99
							UIProjectSetSerializationContext context = new UIProjectSetSerializationContext(getShell());
96
							Iterator it = map.keySet().iterator();
100
							Iterator it = map.keySet().iterator();
97
							while (it.hasNext()) {
101
							while (it.hasNext()) {
98
								String id = (String)it.next();
102
								String id = (String)it.next();
99
								List references = (List)map.get(id);
103
								List references = (List)map.get(id);
100
								IProjectSetSerializer serializer = Team.getProjectSetSerializer(id);
104
								ProjectSetSerializer serializer = RepositoryProviderType.getProviderType(id).getProjectSetSerializer();
101
								if (serializer != null) {
105
								if (serializer != null) {
102
									IProject[] projects = serializer.addToWorkspace((String[])references.toArray(new String[references.size()]), filename, getShell(), monitor);
106
									IProject[] projects = serializer.addToWorkspace((String[])references.toArray(new String[references.size()]), context, monitor);
103
									if (projects != null)
107
									if (projects != null)
104
										newProjects.addAll(Arrays.asList(projects));
108
										newProjects.addAll(Arrays.asList(projects));
105
								}
109
								}
(-)src/org/eclipse/team/ui/UIProjectSetSerializationContext.java (+111 lines)
Added Link Here
1
package org.eclipse.team.ui;
2
3
import java.util.Arrays;
4
import java.util.List;
5
6
import org.eclipse.core.resources.IProject;
7
import org.eclipse.core.resources.IResource;
8
import org.eclipse.jface.util.Assert;
9
import org.eclipse.swt.widgets.Shell;
10
import org.eclipse.team.core.ProjectSetSerializationContext;
11
import org.eclipse.team.core.TeamException;
12
import org.eclipse.team.internal.ui.dialogs.IPromptCondition;
13
import org.eclipse.team.internal.ui.dialogs.PromptingDialog;
14
15
/**
16
 * The UI based context in which project serialization occurs.
17
 * The class may be subclasses to represent different UI based serialization contexts.
18
 * It is recommended that all UI based serialization contexts
19
 * use this class directly or indirectly as their superclass. 
20
 * 
21
 * @since 3.0
22
 */
23
public class UIProjectSetSerializationContext extends ProjectSetSerializationContext {
24
25
	/**
26
	 * The parent shell for this UI context
27
	 */
28
	private final Shell shell;
29
30
	/**
31
	 * Construct a new instance
32
	 * 
33
	 * @param shell The parent shell for this UI context
34
	 */
35
	public UIProjectSetSerializationContext(Shell shell) {
36
		Assert.isNotNull(shell);
37
		this.shell = shell;
38
	}
39
40
	/**
41
	 * Answer the shell associated with this UI context.
42
	 * 
43
	 * @return the shell (not <code>null</code>)
44
	 */
45
	public Shell getShell() {
46
		return shell;
47
	}
48
49
	/**
50
	 * Answer the shell associated with this UI context.
51
	 * 
52
	 * @return the shell (not <code>null</code>)
53
	 * 
54
	 * @see ProjectSetSerializationContext#getIProjectSetSerializerContext()
55
	 * 
56
	 * @deprecated 
57
	 * 		This method exist solely for backward compatibility
58
	 * 		with the {@link IProjectSetSerializer} interface
59
	 * 		and should not be used for any other purpose.
60
	 */
61
	public Object getIProjectSetSerializerContext() {
62
		return getShell();
63
	}
64
	
65
	/**
66
	 * Given an array of projects that currently exist in the workspace
67
	 * prompt the user to determine which of those projects should be overwritten.
68
	 * <p>
69
	 * This default implementation prompts the user
70
	 * to determine which projects should be overwritten.
71
	 * Subclasses may override this as appropriate.
72
	 * 
73
	 * @param projects 
74
	 * 		an array of projects currently existing in the workspace
75
	 * 		that are desired to be overwritten.
76
	 * 		(not <code>null</code>, contains no <code>null</code>s)
77
	 * @return
78
	 * 		an array of zero or more projects that should be overwritten
79
	 * 		or <code>null</code> if the operation is to be canceled
80
	 * 
81
	 * @see org.eclipse.team.core.ProjectSetSerializationContext#confirmOverwrite(org.eclipse.core.resources.IProject[])
82
	 */
83
	public IProject[] confirmOverwrite(final IProject[] projects) throws TeamException {
84
		IPromptCondition prompt = new IPromptCondition() {
85
			List resources = Arrays.asList(projects);
86
			public boolean needsPrompt(IResource resource) {
87
				return resources.contains(resource);
88
			}
89
			public String promptMessage(IResource resource) {
90
				return "Overwrite " + resource.getName();
91
			}
92
		};
93
		PromptingDialog dialog =
94
			new PromptingDialog(
95
				getShell(),
96
				projects,
97
				prompt,
98
				"Overwrite projects?");
99
		IResource[] resourcesToOverwrite;
100
		try {
101
			resourcesToOverwrite = dialog.promptForMultiple();
102
		} catch (InterruptedException e) {
103
			// Return null indicating that the user canceled the operation
104
			return null;
105
		}
106
		IProject[] projectsToOverwrite = new IProject[resourcesToOverwrite.length];
107
		System.arraycopy(resourcesToOverwrite, 0, projectsToOverwrite, 0, resourcesToOverwrite.length);
108
		return projectsToOverwrite;
109
	}
110
111
}

Return to bug 38048