KickJava   Java API By Example, From Geeks To Geeks.

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


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 package org.eclipse.jdt.internal.ui.preferences.cleanup;
12
13 import java.util.ArrayList JavaDoc;
14 import java.util.List JavaDoc;
15
16 import org.eclipse.core.runtime.preferences.IEclipsePreferences;
17 import org.eclipse.core.runtime.preferences.IScopeContext;
18
19 import org.eclipse.jdt.internal.corext.fix.CleanUpConstants;
20
21 import org.eclipse.jdt.ui.JavaUI;
22
23 import org.eclipse.jdt.internal.ui.preferences.PreferencesAccess;
24 import org.eclipse.jdt.internal.ui.preferences.formatter.IProfileVersioner;
25 import org.eclipse.jdt.internal.ui.preferences.formatter.ProfileManager;
26
27 public class CleanUpProfileManager extends ProfileManager {
28     
29     public static KeySet[] KEY_SETS= {
30         new KeySet(JavaUI.ID_PLUGIN, new ArrayList JavaDoc(CleanUpConstants.getEclipseDefaultSettings().keySet()))
31     };
32     
33     private final PreferencesAccess fPreferencesAccess;
34
35     public CleanUpProfileManager(List JavaDoc profiles, IScopeContext context, PreferencesAccess preferencesAccess, IProfileVersioner profileVersioner) {
36         super(profiles, context, preferencesAccess, profileVersioner, KEY_SETS, CleanUpConstants.CLEANUP_PROFILE, CleanUpConstants.CLEANUP_SETTINGS_VERSION_KEY);
37         fPreferencesAccess= preferencesAccess;
38     }
39     
40     /* (non-Javadoc)
41      * @see org.eclipse.jdt.internal.ui.preferences.cleanup.ProfileManager#getDefaultProfile()
42      */

43     public Profile getDefaultProfile() {
44         return getProfile(CleanUpConstants.DEFAULT_PROFILE);
45     }
46     
47     /**
48      * {@inheritDoc}
49      */

50     protected void updateProfilesWithName(String JavaDoc oldName, Profile newProfile, boolean applySettings) {
51         super.updateProfilesWithName(oldName, newProfile, applySettings);
52         
53         IEclipsePreferences node= fPreferencesAccess.getInstanceScope().getNode(JavaUI.ID_PLUGIN);
54         String JavaDoc name= node.get(CleanUpConstants.CLEANUP_ON_SAVE_PROFILE, null);
55         if (name != null && name.equals(oldName)) {
56             if (newProfile == null) {
57                 node.remove(CleanUpConstants.CLEANUP_ON_SAVE_PROFILE);
58             } else {
59                 node.put(CleanUpConstants.CLEANUP_ON_SAVE_PROFILE, newProfile.getID());
60             }
61         }
62     }
63
64 }
65
Popular Tags