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.ArrayList;
13: import java.util.List;
14:
15: import org.eclipse.core.runtime.preferences.IEclipsePreferences;
16: import org.eclipse.core.runtime.preferences.IScopeContext;
17:
18: import org.eclipse.jdt.internal.corext.fix.CleanUpConstants;
19:
20: import org.eclipse.jdt.ui.JavaUI;
21:
22: import org.eclipse.jdt.internal.ui.preferences.PreferencesAccess;
23: import org.eclipse.jdt.internal.ui.preferences.formatter.IProfileVersioner;
24: import org.eclipse.jdt.internal.ui.preferences.formatter.ProfileManager;
25:
26: public class CleanUpProfileManager extends ProfileManager {
27:
28: public static KeySet[] KEY_SETS = { new KeySet(JavaUI.ID_PLUGIN,
29: new ArrayList(CleanUpConstants.getEclipseDefaultSettings()
30: .keySet())) };
31:
32: private final PreferencesAccess fPreferencesAccess;
33:
34: public CleanUpProfileManager(List profiles, IScopeContext context,
35: PreferencesAccess preferencesAccess,
36: IProfileVersioner profileVersioner) {
37: super (profiles, context, preferencesAccess, profileVersioner,
38: KEY_SETS, CleanUpConstants.CLEANUP_PROFILE,
39: CleanUpConstants.CLEANUP_SETTINGS_VERSION_KEY);
40: fPreferencesAccess = preferencesAccess;
41: }
42:
43: /* (non-Javadoc)
44: * @see org.eclipse.jdt.internal.ui.preferences.cleanup.ProfileManager#getDefaultProfile()
45: */
46: public Profile getDefaultProfile() {
47: return getProfile(CleanUpConstants.DEFAULT_PROFILE);
48: }
49:
50: /**
51: * {@inheritDoc}
52: */
53: protected void updateProfilesWithName(String oldName,
54: Profile newProfile, boolean applySettings) {
55: super
56: .updateProfilesWithName(oldName, newProfile,
57: applySettings);
58:
59: IEclipsePreferences node = fPreferencesAccess
60: .getInstanceScope().getNode(JavaUI.ID_PLUGIN);
61: String name = node.get(
62: CleanUpConstants.CLEANUP_ON_SAVE_PROFILE, null);
63: if (name != null && name.equals(oldName)) {
64: if (newProfile == null) {
65: node.remove(CleanUpConstants.CLEANUP_ON_SAVE_PROFILE);
66: } else {
67: node.put(CleanUpConstants.CLEANUP_ON_SAVE_PROFILE,
68: newProfile.getID());
69: }
70: }
71: }
72:
73: }
|