KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > core > ProjectSetSerializationContext


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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  * Dan Rubel - initial API and implementation
10  * IBM Corporation - ongoing maintenance
11  *******************************************************************************/

12
13 package org.eclipse.team.core;
14
15 import java.util.HashMap JavaDoc;
16 import java.util.Map JavaDoc;
17
18 import org.eclipse.core.resources.IProject;
19
20 /**
21  * The context in which project serialization occurs.
22  * The class may be subclassed to represent different serialization contexts.
23  *
24  * @since 3.0
25  */

26 public class ProjectSetSerializationContext {
27     
28     private final String JavaDoc filename;
29     private final Map JavaDoc properties = new HashMap JavaDoc();
30
31     /**
32      * Create a serialization context with no filename
33      */

34     public ProjectSetSerializationContext() {
35         this(null);
36     }
37     
38     /**
39      * Create a serialization context and set the filename of the file
40      * that does or is to contain the project set.
41      * @param filename a filename or <code>null</code>
42      */

43     public ProjectSetSerializationContext(String JavaDoc filename) {
44         this.filename = filename;
45     }
46     
47     /**
48      * Given an array of projects that currently exist in the workspace
49      * determine which of those projects should be overwritten.
50      * <p>
51      * This default implementation always returns an empty array
52      * indicating that no existing projects should be overwritten.
53      * Subclasses may override this as appropriate.
54      *
55      * @param projects
56      * an array of projects currently existing in the workspace
57      * that are desired to be overwritten.
58      * (not <code>null</code>, contains no <code>null</code>s)
59      * @return
60      * an array of zero or more projects that should be overwritten
61      * or <code>null</code> if the operation is to be canceled
62      * @throws TeamException
63      */

64     public IProject[] confirmOverwrite(IProject[] projects) throws TeamException {
65         return new IProject[0];
66     }
67
68     /**
69      * Return a org.eclipse.swt.Shell if there is a UI context
70      * or <code>null</code> if executing headless.
71      *
72      * @return the shell or <code>null</code>
73      */

74     public Object JavaDoc getShell() {
75         return null;
76     }
77     
78     /**
79      * Return the name of the file to or from which the project set is being loaded or saved.
80      * This may be <code>null</code>.
81      * @return the filename or <code>null</code>
82      */

83     public String JavaDoc getFilename() {
84         return filename;
85     }
86     
87     /**
88      * Set a property of this context.
89      * @since 3.3
90      * @param key the property key
91      * @param value the property value
92      */

93     public void setProperty(String JavaDoc key, Object JavaDoc value) {
94         properties.put(key, value);
95     }
96     
97     /**
98      * Return the property for the given key or <code>null</code>
99      * if the property is not set.
100      * @param key the property key
101      * @return the property value
102      * @since 3.3
103      */

104     public Object JavaDoc getProperty(String JavaDoc key) {
105         return properties.get(key);
106     }
107 }
108
Popular Tags