View | Details | Raw Unified | Return to bug 154984 | Differences between
and this patch

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/UserLibraryManager.java (-21 / +30 lines)
Lines 41-47 Link Here
41
	public final static String CP_USERLIBRARY_PREFERENCES_PREFIX = JavaCore.PLUGIN_ID+".userLibrary."; //$NON-NLS-1$
41
	public final static String CP_USERLIBRARY_PREFERENCES_PREFIX = JavaCore.PLUGIN_ID+".userLibrary."; //$NON-NLS-1$
42
	public final static String CP_ENTRY_IGNORE = "##<cp entry ignore>##"; //$NON-NLS-1$
42
	public final static String CP_ENTRY_IGNORE = "##<cp entry ignore>##"; //$NON-NLS-1$
43
43
44
	private static Map userLibraries;
44
	private static Map UserLibraries;
45
	private static ThreadLocal InitializingLibraries = new ThreadLocal();
45
	private static final boolean logProblems= false;
46
	private static final boolean logProblems= false;
46
	private static IEclipsePreferences.IPreferenceChangeListener listener= new IEclipsePreferences.IPreferenceChangeListener() {
47
	private static IEclipsePreferences.IPreferenceChangeListener listener= new IEclipsePreferences.IPreferenceChangeListener() {
47
48
Lines 122-153 Link Here
122
	}
123
	}
123
	
124
	
124
	static Map getLibraryMap() {
125
	static Map getLibraryMap() {
125
		if (userLibraries == null) {
126
		if (UserLibraries == null) {
126
			userLibraries= new HashMap();
127
			HashMap libraries = (HashMap) InitializingLibraries.get();
127
			// load variables and containers from preferences into cache
128
			if (libraries != null)
128
			IEclipsePreferences instancePreferences = JavaModelManager.getJavaModelManager().getInstancePreferences();
129
				return libraries;
129
			instancePreferences.addPreferenceChangeListener(listener);
130
131
			// only get variable from preferences not set to their default
132
			try {
130
			try {
133
				String[] propertyNames = instancePreferences.keys();
131
				InitializingLibraries.set(libraries = new HashMap());
134
				for (int i = 0; i < propertyNames.length; i++) {
132
				// load variables and containers from preferences into cache
135
					String propertyName = propertyNames[i];
133
				IEclipsePreferences instancePreferences = JavaModelManager.getJavaModelManager().getInstancePreferences();
136
					if (propertyName.startsWith(CP_USERLIBRARY_PREFERENCES_PREFIX)) {
134
				instancePreferences.addPreferenceChangeListener(listener);
137
						try {
135
	
138
							String propertyValue = instancePreferences.get(propertyName, null);
136
				// only get variable from preferences not set to their default
139
							if (propertyValue != null)
137
				try {
140
								recreatePersistedUserLibraryEntry(propertyName,propertyValue, false, false);
138
					String[] propertyNames = instancePreferences.keys();
141
						} catch (JavaModelException e) {
139
					for (int i = 0; i < propertyNames.length; i++) {
142
							// won't happen: no rebinding
140
						String propertyName = propertyNames[i];
141
						if (propertyName.startsWith(CP_USERLIBRARY_PREFERENCES_PREFIX)) {
142
							try {
143
								String propertyValue = instancePreferences.get(propertyName, null);
144
								if (propertyValue != null)
145
									recreatePersistedUserLibraryEntry(propertyName,propertyValue, false, false);
146
							} catch (JavaModelException e) {
147
								// won't happen: no rebinding
148
							}
143
						}
149
						}
144
					}
150
					}
151
				} catch (BackingStoreException e) {
152
					// nothing to do in this case
145
				}
153
				}
146
			} catch (BackingStoreException e) {
154
				UserLibraries = libraries;
147
				// nothing to do in this case
155
			} finally {
156
				InitializingLibraries.set(null);
148
			}
157
			}
149
		}
158
		}
150
		return userLibraries;
159
		return UserLibraries;
151
	}
160
	}
152
	
161
	
153
	static void recreatePersistedUserLibraryEntry(String propertyName, String savedString, boolean save, boolean rebind) throws JavaModelException {
162
	static void recreatePersistedUserLibraryEntry(String propertyName, String savedString, boolean save, boolean rebind) throws JavaModelException {

Return to bug 154984