KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > compare > patch > WorkspacePatcherUI


1 /*******************************************************************************
2  * Copyright (c) 2005, 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  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.compare.patch;
12
13 import org.eclipse.compare.internal.patch.PatchReader;
14 import org.eclipse.core.resources.IProject;
15
16 /**
17  * Provides the headers required to create a workspace patch.
18  * @since 3.2
19  */

20 public class WorkspacePatcherUI {
21     /**
22      * Returns a string that must be the first line of a workspace patch (a multi-project patch
23      * that is understood by the Apply Patch wizard). Each project to be included in the patch
24      * must be prefixed by the line obtained from the <code>getWorkspacePatchProjectHeader()</code>.
25      * This snippet outlines how the a workspace patch is to be created:
26      * <pre>
27      * //Write out workspace patch header
28      * stream.println(CompareUI.getWorkspacePatchHeader());
29      * for (int i=0; i<projects.length; i++){
30      * //Write out project header
31      * stream.println(CompareUI.getWorkspacePatchProjectHeader(projects[i]);
32      * //Write out patches in Unified Diff format
33      * }
34      * </pre>
35      * @return String
36      * @see WorkspacePatcherUI#getWorkspacePatchProjectHeader(IProject)
37      * @since 3.2
38      */

39     public static String JavaDoc getWorkspacePatchHeader() {
40         return PatchReader.MULTIPROJECTPATCH_HEADER+" "+PatchReader.MULTIPROJECTPATCH_VERSION; //$NON-NLS-1$
41
}
42
43     /**
44      * Returns the project header that must appear before any patches that apply to that
45      * project. All patches that are encountered after this header and before the next header
46      * are understood to belong the the project.
47      * @param project project to be patched
48      * @return String
49      * @see WorkspacePatcherUI#getWorkspacePatchHeader()
50      * @since 3.2
51      */

52     public static String JavaDoc getWorkspacePatchProjectHeader(IProject project) {
53         return PatchReader.MULTIPROJECTPATCH_PROJECT+" "+ project.getName(); //$NON-NLS-1$
54
}
55 }
56
Popular Tags