KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > preferences > cleanup > CleanUpProfileVersioner


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  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.jdt.internal.ui.preferences.cleanup;
13
14 import java.util.Map JavaDoc;
15
16 import org.eclipse.jdt.internal.corext.fix.CleanUpConstants;
17
18 import org.eclipse.jdt.internal.ui.preferences.formatter.IProfileVersioner;
19 import org.eclipse.jdt.internal.ui.preferences.formatter.ProfileManager.CustomProfile;
20
21
22 public class CleanUpProfileVersioner implements IProfileVersioner {
23     
24     public static final String JavaDoc PROFILE_KIND= "CleanUpProfile"; //$NON-NLS-1$
25

26     private static final int VERSION_1= 1; // 3.3M2
27
private static final int VERSION_2= 2; // 3.3M3 Added ORGANIZE_IMPORTS
28

29     public static final int CURRENT_VERSION= VERSION_2;
30     
31     /* (non-Javadoc)
32      * @see org.eclipse.jdt.internal.ui.preferences.cleanup.IProfileVersioner#getFirstVersion()
33      */

34     public int getFirstVersion() {
35         return VERSION_1;
36     }
37
38     /* (non-Javadoc)
39      * @see org.eclipse.jdt.internal.ui.preferences.cleanup.IProfileVersioner#getCurrentVersion()
40      */

41     public int getCurrentVersion() {
42         return CURRENT_VERSION;
43     }
44
45     /* (non-Javadoc)
46      * @see org.eclipse.jdt.internal.ui.preferences.cleanup.IProfileVersioner#updateAndComplete(org.eclipse.jdt.internal.ui.preferences.cleanup.ProfileManager.CustomProfile)
47      */

48     public void update(CustomProfile profile) {
49         if (profile.getVersion() == VERSION_1)
50             updateFrom1To2(profile);
51         
52         profile.setVersion(CURRENT_VERSION);
53     }
54
55     /**
56      * {@inheritDoc}
57      */

58     public String JavaDoc getProfileKind() {
59         return PROFILE_KIND;
60     }
61     
62     private static void updateFrom1To2(CustomProfile profile) {
63         Map JavaDoc defaultSettings= CleanUpConstants.getEclipseDefaultSettings();
64         profile.getSettings().put(CleanUpConstants.ORGANIZE_IMPORTS, defaultSettings.get(CleanUpConstants.ORGANIZE_IMPORTS));
65     }
66     
67  }
68
Popular Tags