01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.internal.ui.preferences.cleanup;
11:
12: import java.util.Map;
13:
14: import org.eclipse.jdt.internal.corext.fix.CleanUpConstants;
15:
16: import org.eclipse.jdt.internal.ui.preferences.formatter.IProfileVersioner;
17: import org.eclipse.jdt.internal.ui.preferences.formatter.ProfileManager.CustomProfile;
18:
19: public class CleanUpProfileVersioner implements IProfileVersioner {
20:
21: public static final String PROFILE_KIND = "CleanUpProfile"; //$NON-NLS-1$
22:
23: private static final int VERSION_1 = 1; // 3.3M2
24: private static final int VERSION_2 = 2; // 3.3M3 Added ORGANIZE_IMPORTS
25:
26: public static final int CURRENT_VERSION = VERSION_2;
27:
28: /* (non-Javadoc)
29: * @see org.eclipse.jdt.internal.ui.preferences.cleanup.IProfileVersioner#getFirstVersion()
30: */
31: public int getFirstVersion() {
32: return VERSION_1;
33: }
34:
35: /* (non-Javadoc)
36: * @see org.eclipse.jdt.internal.ui.preferences.cleanup.IProfileVersioner#getCurrentVersion()
37: */
38: public int getCurrentVersion() {
39: return CURRENT_VERSION;
40: }
41:
42: /* (non-Javadoc)
43: * @see org.eclipse.jdt.internal.ui.preferences.cleanup.IProfileVersioner#updateAndComplete(org.eclipse.jdt.internal.ui.preferences.cleanup.ProfileManager.CustomProfile)
44: */
45: public void update(CustomProfile profile) {
46: if (profile.getVersion() == VERSION_1)
47: updateFrom1To2(profile);
48:
49: profile.setVersion(CURRENT_VERSION);
50: }
51:
52: /**
53: * {@inheritDoc}
54: */
55: public String getProfileKind() {
56: return PROFILE_KIND;
57: }
58:
59: private static void updateFrom1To2(CustomProfile profile) {
60: Map defaultSettings = CleanUpConstants
61: .getEclipseDefaultSettings();
62: profile.getSettings().put(CleanUpConstants.ORGANIZE_IMPORTS,
63: defaultSettings.get(CleanUpConstants.ORGANIZE_IMPORTS));
64: }
65:
66: }
|