1 package net.sourceforge.phpeclipse.overlaypages;
2 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
3 import net.sourceforge.phpeclipse.preferences.PHPMiscProjectPreferences;
4 import net.sourceforge.phpeclipse.preferences.PHPPreviewProjectPreferences;
6 import org.eclipse.core.resources.IProject;
7 import org.eclipse.core.resources.IResource;
8 import org.eclipse.core.runtime.CoreException;
9 import org.eclipse.core.runtime.QualifiedName;
12 public static String getMiscProjectsPreferenceValue(IResource resource, String key) {
13 return getOverlayedPrefProjectValue(resource,
14 PHPMiscProjectPreferences.PREF_ID, key);
16 public static String getOverlayedPrefProjectValue(IResource resource,
17 String pageId, String key) {
18 IProject project = resource.getProject();
20 if (useProjectSettings(project, pageId)) {
21 value = getProperty(resource, pageId, key);
25 return PHPeclipsePlugin.getDefault().getPreferenceStore().getString(key);
27 public static String getOverlayedPrefResourceValue(IResource resource,
28 String pageId, String key) {
30 if (useProjectSettings(resource, pageId)) {
31 value = getProperty(resource, pageId, key);
35 return PHPeclipsePlugin.getDefault().getPreferenceStore().getString(key);
37 public static boolean getPreviewBooleanValue(IResource resource, String key) {
38 return getOverlayedPrefResourceValue(resource,
39 PHPPreviewProjectPreferences.PREF_ID, key).equals("true");
41 public static String getPreviewStringValue(IResource resource, String key) {
42 return getOverlayedPrefResourceValue(resource,
43 PHPPreviewProjectPreferences.PREF_ID, key);
45 private static String getProperty(IResource resource, String pageId,
48 return resource.getPersistentProperty(new QualifiedName(pageId, key));
49 } catch (CoreException e) {
53 private static boolean useProjectSettings(IResource resource, String pageId) {
54 String use = getProperty(resource, pageId,
55 FieldEditorOverlayPage.USEPROJECTSETTINGS);
56 return "true".equals(use);