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