From 1183851d6ccf76aca63a246ef43f52629ac853cf Mon Sep 17 00:00:00 2001
From: axelcl <axelcl>
Date: Wed, 29 Dec 2004 21:45:23 +0000
Subject: [PATCH] misc

---
 net.sourceforge.phpeclipse.smarty.ui/plugin.xml    |    2 +-
 net.sourceforge.phpeclipse.ui/plugin.xml           |    2 +-
 .../phpeclipse/ui/IPreferenceConstants.java        |    3 +-
 .../ui/editor/ShowExternalPreviewAction.java       |   33 +++-----
 .../ui/overlaypages/ProjectPrefUtil.java           |   85 ++++++++++++++++++++
 .../phpeclipse/ui/overlaypages/Util.java           |   58 -------------
 .../ui/preferences/PHPMiscProjectPreferences.java  |   11 ++-
 .../preferences/PHPPreferencesMessages.properties  |    5 +-
 .../ui/text/rules/AbstractPartitioner.java         |    4 +-
 9 files changed, 114 insertions(+), 89 deletions(-)
 create mode 100644 net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/overlaypages/ProjectPrefUtil.java
 delete mode 100644 net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/overlaypages/Util.java

diff --git a/net.sourceforge.phpeclipse.smarty.ui/plugin.xml b/net.sourceforge.phpeclipse.smarty.ui/plugin.xml
index 8222123..480bf45 100644
--- a/net.sourceforge.phpeclipse.smarty.ui/plugin.xml
+++ b/net.sourceforge.phpeclipse.smarty.ui/plugin.xml
@@ -3,7 +3,7 @@
 <plugin
    id="net.sourceforge.phpdt.smarty.ui"
    name="PHPeclipse Smarty UI"
-   version="1.1.1"
+   version="1.1.2"
    provider-name="PHPeclipse.de"
    class="net.sourceforge.phpdt.smarty.ui.SmartyUI">
    
diff --git a/net.sourceforge.phpeclipse.ui/plugin.xml b/net.sourceforge.phpeclipse.ui/plugin.xml
index 654db25..4cba6c8 100644
--- a/net.sourceforge.phpeclipse.ui/plugin.xml
+++ b/net.sourceforge.phpeclipse.ui/plugin.xml
@@ -3,7 +3,7 @@
 <plugin
    id="net.sourceforge.phpeclipse.ui"
    name="%pluginName"
-   version="1.1.1"
+   version="1.1.2"
    provider-name="%providerName"
    class="net.sourceforge.phpeclipse.ui.WebUI">
 
diff --git a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/IPreferenceConstants.java b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/IPreferenceConstants.java
index dcc49d1..2378a96 100644
--- a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/IPreferenceConstants.java
+++ b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/IPreferenceConstants.java
@@ -6,7 +6,8 @@ public interface IPreferenceConstants {
   public static final String PHP_BOOKMARK_DEFAULT = "_php_bookmark_default";
   public static final String PHP_LOCALHOST_PREF = "_php_localhost";
   public static final String PHP_DOCUMENTROOT_PREF = "_php_documentroot";
-
+  public static final String PHP_INCLUDE_PATHS = "_php_include_paths";
+  
   public static final String PHP_AUTO_PREVIEW_DEFAULT = "_auto_preview";
   public static final String PHP_BRING_TO_TOP_PREVIEW_DEFAULT = "_bring_to_top_preview";
   public static final String PHP_SHOW_HTML_FILES_LOCAL = "_show_html_files_local";
diff --git a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/editor/ShowExternalPreviewAction.java b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/editor/ShowExternalPreviewAction.java
index 776e992..5cfaeb7 100644
--- a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/editor/ShowExternalPreviewAction.java
+++ b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/editor/ShowExternalPreviewAction.java
@@ -1,20 +1,12 @@
 package net.sourceforge.phpeclipse.ui.editor;
 
-/*******************************************************************************
- * Copyright (c) 2000, 2002 IBM Corp. and others. All rights reserved. This
- * program and the accompanying materials are made available under the terms of
- * the Common Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/cpl-v10.html
- * 
- * Contributors: IBM Corporation - Initial implementation Klaus Hartlage -
- * www.eclipseproject.de
- ******************************************************************************/
 import net.sourceforge.phpeclipse.ui.IPreferenceConstants;
 import net.sourceforge.phpeclipse.ui.WebUI;
-import net.sourceforge.phpeclipse.ui.overlaypages.Util;
+import net.sourceforge.phpeclipse.ui.overlaypages.ProjectPrefUtil;
 import net.sourceforge.phpeclipse.webbrowser.views.BrowserView;
 
 import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IPath;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IFileEditorInput;
@@ -63,10 +55,10 @@ public class ShowExternalPreviewAction extends TextEditorAction {
       return;
     }
     String extension = previewFile.getFileExtension().toLowerCase();
-    boolean autoPreview = Util.getPreviewBooleanValue(previewFile, IPreferenceConstants.PHP_AUTO_PREVIEW_DEFAULT);
-    boolean bringToTopPreview = Util.getPreviewBooleanValue(previewFile, IPreferenceConstants.PHP_BRING_TO_TOP_PREVIEW_DEFAULT);
-    boolean showHTMLFilesLocal = Util.getPreviewBooleanValue(previewFile, IPreferenceConstants.PHP_SHOW_HTML_FILES_LOCAL);
-    boolean showXMLFilesLocal = Util.getPreviewBooleanValue(previewFile, IPreferenceConstants.PHP_SHOW_XML_FILES_LOCAL);
+    boolean autoPreview = ProjectPrefUtil.getPreviewBooleanValue(previewFile, IPreferenceConstants.PHP_AUTO_PREVIEW_DEFAULT);
+    boolean bringToTopPreview = ProjectPrefUtil.getPreviewBooleanValue(previewFile, IPreferenceConstants.PHP_BRING_TO_TOP_PREVIEW_DEFAULT);
+    boolean showHTMLFilesLocal = ProjectPrefUtil.getPreviewBooleanValue(previewFile, IPreferenceConstants.PHP_SHOW_HTML_FILES_LOCAL);
+    boolean showXMLFilesLocal = ProjectPrefUtil.getPreviewBooleanValue(previewFile, IPreferenceConstants.PHP_SHOW_XML_FILES_LOCAL);
     boolean isHTMLFileName = "html".equals(extension) || "htm".equals(extension) || "xhtml".equals(extension);
     boolean isXMLFileName = "xml".equals(extension) || "xsd".equals(extension) || "dtd".equals(extension);
 
@@ -103,8 +95,8 @@ public class ShowExternalPreviewAction extends TextEditorAction {
       // should never happen
       return;
     }
-    boolean autoPreview = Util.getPreviewBooleanValue(fileToParse, IPreferenceConstants.PHP_AUTO_PREVIEW_DEFAULT);
-    boolean bringToTopPreview = Util.getPreviewBooleanValue(fileToParse, IPreferenceConstants.PHP_BRING_TO_TOP_PREVIEW_DEFAULT);
+    boolean autoPreview = ProjectPrefUtil.getPreviewBooleanValue(fileToParse, IPreferenceConstants.PHP_AUTO_PREVIEW_DEFAULT);
+    boolean bringToTopPreview = ProjectPrefUtil.getPreviewBooleanValue(fileToParse, IPreferenceConstants.PHP_BRING_TO_TOP_PREVIEW_DEFAULT);
 
     if (autoPreview) {
       IWorkbenchPage page = WebUI.getActivePage();
@@ -149,17 +141,14 @@ public class ShowExternalPreviewAction extends TextEditorAction {
     String localhostURL = file.getLocation().toString();
     String lowerCaseFileName = localhostURL.toLowerCase();
     //  String documentRoot = store.getString(PHPeclipsePlugin.DOCUMENTROOT_PREF);
-    String documentRoot = Util.getMiscProjectsPreferenceValue(file.getProject(), IPreferenceConstants.PHP_DOCUMENTROOT_PREF);
-
-    documentRoot = documentRoot.replace('\\', '/');
-    documentRoot = documentRoot.toLowerCase();
-
+    IPath documentRootPath = ProjectPrefUtil.getDocumentRoot(file.getProject());
+    String documentRoot = documentRootPath.toString().toLowerCase();
     if (lowerCaseFileName.startsWith(documentRoot)) {
       localhostURL = localhostURL.substring(documentRoot.length());
     } else {
       return null;
     }
     //    return store.getString(PHPeclipsePlugin.LOCALHOST_PREF) + localhostURL;
-    return Util.getMiscProjectsPreferenceValue(file.getProject(), IPreferenceConstants.PHP_LOCALHOST_PREF) + localhostURL;
+    return ProjectPrefUtil.getMiscProjectsPreferenceValue(file.getProject(), IPreferenceConstants.PHP_LOCALHOST_PREF) + localhostURL;
   }
 }
\ No newline at end of file
diff --git a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/overlaypages/ProjectPrefUtil.java b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/overlaypages/ProjectPrefUtil.java
new file mode 100644
index 0000000..e292e31
--- /dev/null
+++ b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/overlaypages/ProjectPrefUtil.java
@@ -0,0 +1,85 @@
+package net.sourceforge.phpeclipse.ui.overlaypages;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import net.sourceforge.phpeclipse.ui.IPreferenceConstants;
+import net.sourceforge.phpeclipse.ui.WebUI;
+import net.sourceforge.phpeclipse.ui.preferences.PHPMiscProjectPreferences;
+import net.sourceforge.phpeclipse.ui.preferences.PHPPreviewProjectPreferences;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.QualifiedName;
+
+public class ProjectPrefUtil {
+  public static String getMiscProjectsPreferenceValue(IResource resource, String key) {
+    return getOverlayedPrefProjectValue(resource, PHPMiscProjectPreferences.PREF_ID, key);
+  }
+
+  public static List getIncludePaths(IResource resource) {
+    String includePaths = getMiscProjectsPreferenceValue(resource, IPreferenceConstants.PHP_INCLUDE_PATHS);
+    ArrayList list = new ArrayList();
+    if (includePaths != null) {
+      StringTokenizer st = new StringTokenizer(includePaths, File.pathSeparator + "\n\r");//$NON-NLS-1$
+      while (st.hasMoreElements()) {
+        list.add(st.nextElement());
+      }
+    }
+    return list;
+  }
+
+  public static IPath getDocumentRoot(IResource resource) {
+    String documentRoot = getMiscProjectsPreferenceValue(resource, IPreferenceConstants.PHP_DOCUMENTROOT_PREF);
+    IPath path = new Path(documentRoot);
+    //    documentRoot = documentRoot.replace('\\', '/');
+    return path;
+  }
+
+  public static String getOverlayedPrefProjectValue(IResource resource, String pageId, String key) {
+    IProject project = resource.getProject();
+    String value = null;
+    if (useProjectSettings(project, pageId)) {
+      value = getProperty(resource, pageId, key);
+    }
+    if (value != null)
+      return value;
+    return WebUI.getDefault().getPreferenceStore().getString(key);
+  }
+
+  public static String getOverlayedPrefResourceValue(IResource resource, String pageId, String key) {
+    String value = null;
+    if (useProjectSettings(resource, pageId)) {
+      value = getProperty(resource, pageId, key);
+    }
+    if (value != null)
+      return value;
+    return WebUI.getDefault().getPreferenceStore().getString(key);
+  }
+
+  public static boolean getPreviewBooleanValue(IResource resource, String key) {
+    return getOverlayedPrefResourceValue(resource, PHPPreviewProjectPreferences.PREF_ID, key).equals("true");
+  }
+
+  public static String getPreviewStringValue(IResource resource, String key) {
+    return getOverlayedPrefResourceValue(resource, PHPPreviewProjectPreferences.PREF_ID, key);
+  }
+
+  private static String getProperty(IResource resource, String pageId, String key) {
+    try {
+      return resource.getPersistentProperty(new QualifiedName(pageId, key));
+    } catch (CoreException e) {
+    }
+    return null;
+  }
+
+  private static boolean useProjectSettings(IResource resource, String pageId) {
+    String use = getProperty(resource, pageId, FieldEditorOverlayPage.USEPROJECTSETTINGS);
+    return "true".equals(use);
+  }
+}
\ No newline at end of file
diff --git a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/overlaypages/Util.java b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/overlaypages/Util.java
deleted file mode 100644
index 79a1bfc..0000000
--- a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/overlaypages/Util.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package net.sourceforge.phpeclipse.ui.overlaypages;
-
-import net.sourceforge.phpeclipse.ui.WebUI;
-import net.sourceforge.phpeclipse.ui.preferences.PHPMiscProjectPreferences;
-import net.sourceforge.phpeclipse.ui.preferences.PHPPreviewProjectPreferences;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.QualifiedName;
-
-public class Util {
-  public static String getMiscProjectsPreferenceValue(IResource resource, String key) {
-    return getOverlayedPrefProjectValue(resource, PHPMiscProjectPreferences.PREF_ID, key);
-  }
-
-  public static String getOverlayedPrefProjectValue(IResource resource, String pageId, String key) {
-    IProject project = resource.getProject();
-    String value = null;
-    if (useProjectSettings(project, pageId)) {
-      value = getProperty(resource, pageId, key);
-    }
-    if (value != null)
-      return value;
-    return WebUI.getDefault().getPreferenceStore().getString(key);
-  }
-
-  public static String getOverlayedPrefResourceValue(IResource resource, String pageId, String key) {
-    String value = null;
-    if (useProjectSettings(resource, pageId)) {
-      value = getProperty(resource, pageId, key);
-    }
-    if (value != null)
-      return value;
-    return WebUI.getDefault().getPreferenceStore().getString(key);
-  }
-
-  public static boolean getPreviewBooleanValue(IResource resource, String key) {
-    return getOverlayedPrefResourceValue(resource, PHPPreviewProjectPreferences.PREF_ID, key).equals("true");
-  }
-
-  public static String getPreviewStringValue(IResource resource, String key) {
-    return getOverlayedPrefResourceValue(resource, PHPPreviewProjectPreferences.PREF_ID, key);
-  }
-
-  private static String getProperty(IResource resource, String pageId, String key) {
-    try {
-      return resource.getPersistentProperty(new QualifiedName(pageId, key));
-    } catch (CoreException e) {
-    }
-    return null;
-  }
-
-  private static boolean useProjectSettings(IResource resource, String pageId) {
-    String use = getProperty(resource, pageId, FieldEditorOverlayPage.USEPROJECTSETTINGS);
-    return "true".equals(use);
-  }
-}
\ No newline at end of file
diff --git a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/preferences/PHPMiscProjectPreferences.java b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/preferences/PHPMiscProjectPreferences.java
index 7759fd0..c8b8145 100644
--- a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/preferences/PHPMiscProjectPreferences.java
+++ b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/preferences/PHPMiscProjectPreferences.java
@@ -4,6 +4,7 @@ import net.sourceforge.phpeclipse.ui.WebUI;
 import net.sourceforge.phpeclipse.ui.overlaypages.FieldEditorOverlayPage;
 
 import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PathEditor;
 import org.eclipse.jface.preference.StringFieldEditor;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.ui.IWorkbench;
@@ -37,11 +38,15 @@ public class PHPMiscProjectPreferences extends FieldEditorOverlayPage
     addField(new StringFieldEditor(IPreferenceConstants.PHP_LOCALHOST_PREF,
         PHPPreferencesMessages.getString("PHPMiscProjectPreferences.localhost"),
         composite));
+    addField(new StringFieldEditor(IPreferenceConstants.PHP_BOOKMARK_DEFAULT,
+        PHPPreferencesMessages.getString("PHPMiscProjectPreferences.bookmark"),
+        composite));
     addField(new StringFieldEditor(IPreferenceConstants.PHP_DOCUMENTROOT_PREF,
         PHPPreferencesMessages.getString("PHPMiscProjectPreferences.documentroot"),
         composite)); 
-    addField(new StringFieldEditor(IPreferenceConstants.PHP_BOOKMARK_DEFAULT,
-        PHPPreferencesMessages.getString("PHPMiscProjectPreferences.bookmark"),
+    addField(new PathEditor(IPreferenceConstants.PHP_INCLUDE_PATHS,
+        PHPPreferencesMessages.getString("PHPMiscProjectPreferences.include_paths"),
+        "Choose Path...",
         composite));
     //if (!isPropertyPage)) {
     //  
@@ -57,6 +62,6 @@ public class PHPMiscProjectPreferences extends FieldEditorOverlayPage
    * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
    */
   public void init(IWorkbench workbench) {
-    setDescription("Default entries for misc project settings.");
+    setDescription("Default entries for PHP projects.");
   }
 }
\ No newline at end of file
diff --git a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/preferences/PHPPreferencesMessages.properties b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/preferences/PHPPreferencesMessages.properties
index fb7e05c..ec58e3d 100644
--- a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/preferences/PHPPreferencesMessages.properties
+++ b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/preferences/PHPPreferencesMessages.properties
@@ -15,9 +15,10 @@ PHPProjectPropertyPage.phpProjectClosed=The project selected is a PHP project, b
 PHPProjectPropertyPage.performOkExceptionDialogTitle=Unable to save
 PHPProjectPropertyPage.performOkExceptionDialogMessage=ERROR: Unable to save project properties.
 
-PHPMiscProjectPreferences.localhost=Localhost
-PHPMiscProjectPreferences.documentroot=DocumentRoot
+PHPMiscProjectPreferences.localhost=Localhost:
+PHPMiscProjectPreferences.documentroot=DocumentRoot:
 PHPMiscProjectPreferences.bookmark=SQL default bookmark:
+PHPMiscProjectPreferences.include_paths=Include Paths:
 
 PHPMiscProjectPreferences.obfuscator=Obfuscator directory:
 
diff --git a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/text/rules/AbstractPartitioner.java b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/text/rules/AbstractPartitioner.java
index d104237..ab96dd5 100644
--- a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/text/rules/AbstractPartitioner.java
+++ b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/text/rules/AbstractPartitioner.java
@@ -8,7 +8,7 @@
  * Contributors:
  *     Igor Malinin - initial contribution
  * 
- * $Id: AbstractPartitioner.java,v 1.2 2004-11-13 12:36:32 axelcl Exp $
+ * $Id: AbstractPartitioner.java,v 1.3 2004-12-29 21:42:31 axelcl Exp $
  */
 
 package net.sourceforge.phpeclipse.ui.text.rules;
@@ -103,7 +103,9 @@ public abstract class AbstractPartitioner implements IDocumentPartitioner, IDocu
    */
   protected void initialize() {
     scanner.setRange(document, 0, document.getLength());
+    // axelcl start
     nodes.clear();
+    // axelcl end
     IToken token = scanner.nextToken();
     while (!token.isEOF()) {
       String contentType = getTokenContentType(token);
-- 
1.7.1