Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: b6826213cbb075d5bd4b161dd969b331f9a43216 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*******************************************************************************
 * Copyright (c) 2000, 2006 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:
 *     Dan Rubel - initial API and implementation
 *     IBM Corporation - ongoing maintenance
 *******************************************************************************/

package org.eclipse.team.core;

import java.util.HashMap;
import java.util.Map;

import org.eclipse.core.resources.IProject;

/**
 * The context in which project serialization occurs.
 * The class may be subclassed to represent different serialization contexts.
 * 
 * @since 3.0
 */
public class ProjectSetSerializationContext {
	
	private final String filename;
	private final Map properties = new HashMap();

	/**
	 * Create a serialization context with no filename
	 */
	public ProjectSetSerializationContext() {
		this(null);
	}
	
	/**
	 * Create a serialization context and set the filename of the file 
	 * that does or is to contain the project set.
	 * @param filename a filename or <code>null</code>
	 */
	public ProjectSetSerializationContext(String filename) {
		this.filename = filename;
	}
	
	/**
	 * Given an array of projects that currently exist in the workspace
	 * determine which of those projects should be overwritten.
	 * <p>
	 * This default implementation always returns an empty array
	 * indicating that no existing projects should be overwritten.
	 * Subclasses may override this as appropriate.
	 * 
	 * @param projects 
	 * 		an array of projects currently existing in the workspace
	 * 		that are desired to be overwritten.
	 * 		(not <code>null</code>, contains no <code>null</code>s)
	 * @return
	 * 		an array of zero or more projects that should be overwritten
	 * 		or <code>null</code> if the operation is to be canceled
	 * @throws TeamException 
	 */
	public IProject[] confirmOverwrite(IProject[] projects) throws TeamException {
		return new IProject[0];
	}

	/**
	 * Return a org.eclipse.swt.Shell if there is a UI context 
	 * or <code>null</code> if executing headless.
	 *
	 * @return the shell or <code>null</code>
	 */
	public Object getShell() {
		return null;
	}
	
	/**
	 * Return the name of the file to or from which the project set is being loaded or saved. 
	 * This may be <code>null</code>.
	 * @return the filename or <code>null</code>
	 */
	public String getFilename() {
		return filename;
	}
	
	/**
	 * Set a property of this context.
	 * @since 3.3
	 * @param key the property key
	 * @param value the property value
	 */
	public void setProperty(String key, Object value) {
		properties.put(key, value);
	}
	
	/**
	 * Return the property for the given key or <code>null</code>
	 * if the property is not set.
	 * @param key the property key
	 * @return the property value
	 * @since 3.3
	 */
	public Object getProperty(String key) {
		return properties.get(key);
	}
}

Back to the top