KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > internal > resources > ResourcesCompatibility


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
12 package org.eclipse.core.internal.resources;
13
14 import org.eclipse.core.filesystem.EFS;
15 import org.eclipse.core.filesystem.IFileStore;
16 import org.eclipse.core.internal.localstore.*;
17 import org.eclipse.core.internal.properties.*;
18 import org.eclipse.core.internal.utils.Policy;
19 import org.eclipse.core.resources.ResourcesPlugin;
20 import org.eclipse.core.runtime.IPath;
21 import org.eclipse.core.runtime.IStatus;
22
23 /**
24  * This class provides the entry point to the backward compatibility fragment.
25  *
26  * @see ResourcesCompatibilityHelper
27  */

28 public class ResourcesCompatibility {
29     /**
30      * Creates a new history store.
31      *
32      * @param location the base location for the history store
33      * @param limit the number of buckets in the blob store
34      * @param newImpl whether should use the new implementation
35      * @param convert whether should convert the existing state (ignored if newImpl is false)
36      * @param rename whether should rename the existing index file after converting (ignored if newImpl or convert are false)
37      * @return a history store
38      */

39     public static IHistoryStore createHistoryStore(IPath location, int limit, boolean newImpl, boolean convert, boolean rename) {
40         Workspace workspace = (Workspace) ResourcesPlugin.getWorkspace();
41         if (!newImpl)
42             // keep using the old history store
43
return new HistoryStore(workspace, location, limit);
44         IFileStore store = EFS.getLocalFileSystem().getStore(location);
45         HistoryStore2 newHistoryStore = new HistoryStore2(workspace, store, limit);
46         if (!convert)
47             // do not try to convert - return as it is
48
return newHistoryStore;
49         IStatus result = new HistoryStoreConverter().convertHistory(workspace, location, limit, newHistoryStore, rename);
50         // if we do anything (either we fail or succeed converting), a non-OK status is returned
51
if (result.getSeverity() != IStatus.OK)
52             Policy.log(result);
53         return newHistoryStore;
54     }
55     /**
56      * Creates a new property manager.
57      *
58      * @param newImpl whether should use the new implementation
59      * @param convert whether should convert the existing state (ignored if newImpl is false)
60      * @return a history store
61      */

62     public static IPropertyManager createPropertyManager(boolean newImpl, boolean convert) {
63         Workspace workspace = (Workspace) ResourcesPlugin.getWorkspace();
64         if (!newImpl)
65             // keep using the old history store
66
return new PropertyManager(workspace);
67         PropertyManager2 newPropertyManager = new PropertyManager2(workspace);
68         if (!convert)
69             // do not try to convert - return as it is
70
return newPropertyManager;
71         // try to convert the existing data now
72
IStatus result = new PropertyStoreConverter().convertProperties(workspace, newPropertyManager);
73         if (result.getSeverity() != IStatus.OK)
74             // if we do anything (either we fail or succeed converting), a non-OK status is returned
75
Policy.log(result);
76         return newPropertyManager;
77     }
78 }
79
Popular Tags