misc changes
authorkhartlage <khartlage>
Fri, 27 Dec 2002 21:18:43 +0000 (21:18 +0000)
committerkhartlage <khartlage>
Fri, 27 Dec 2002 21:18:43 +0000 (21:18 +0000)
12 files changed:
net.sourceforge.phpeclipse.debug.phphelp/plugin.xml
net.sourceforge.phpeclipse/.classpath
net.sourceforge.phpeclipse/.project
net.sourceforge.phpeclipse/icons/obj16/apache_restart.gif [new file with mode: 0644]
net.sourceforge.phpeclipse/icons/obj16/apache_stop.gif [new file with mode: 0644]
net.sourceforge.phpeclipse/icons/obj16/sql.gif [new file with mode: 0644]
net.sourceforge.phpeclipse/plugin.properties
net.sourceforge.phpeclipse/plugin.xml
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/BuiltInEngine.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/BuiltInProposal.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPActionContributor.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java

index 8d80216..6af417e 100644 (file)
          </action>
       </viewerContribution>
    </extension>
+   <extension
+         point="org.eclipse.help.toc">
+      <toc
+            file="phphelp.xml"
+            primary="true">
+      </toc>
+   </extension>
 </plugin>
index bee2fe3..af9f5e2 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
     <classpathentry kind="src" path="src/"/>
-    <classpathentry kind="lib" path="phpeclipse.jar" sourcepath="/net.sourceforge.phpeclipse/phpeclipsesrc.zip"/>
+    <classpathentry kind="lib" path="phpeclipse.jar"/>
     <classpathentry kind="var"
         path="ECLIPSE_HOME/plugins/org.eclipse.core.resources_2.0.0/resources.jar" sourcepath="_ORG_ECLIPSE_PLATFORM_SOURCE/org.eclipse.core.resources_2.0.0/resourcessrc.zip"/>
     <classpathentry kind="var"
@@ -21,6 +21,5 @@
     <classpathentry kind="var"
         path="ECLIPSE_HOME/plugins/org.eclipse.core.boot_2.0.0/boot.jar" sourcepath="_ORG_ECLIPSE_PLATFORM_SOURCE/org.eclipse.core.boot_2.0.0/bootsrc.zip"/>
     <classpathentry kind="var" path="JRE_LIB" rootpath="JRE_SRCROOT" sourcepath="JRE_SRC"/>
-    <classpathentry kind="lib" path="C:/eclipse/plugins/org.junit_3.7.0/junit.jar"/>
     <classpathentry kind="output" path="bin"/>
 </classpath>
index 8acc1f7..9020b50 100644 (file)
@@ -3,7 +3,7 @@
        <name>net.sourceforge.phpeclipse</name>
        <comment></comment>
        <projects>
-               <project>org.rubypeople.rdt.core</project>
+               <project>net.sourceforge.phpeclipse</project>
        </projects>
        <buildSpec>
                <buildCommand>
diff --git a/net.sourceforge.phpeclipse/icons/obj16/apache_restart.gif b/net.sourceforge.phpeclipse/icons/obj16/apache_restart.gif
new file mode 100644 (file)
index 0000000..5b3c0cb
Binary files /dev/null and b/net.sourceforge.phpeclipse/icons/obj16/apache_restart.gif differ
diff --git a/net.sourceforge.phpeclipse/icons/obj16/apache_stop.gif b/net.sourceforge.phpeclipse/icons/obj16/apache_stop.gif
new file mode 100644 (file)
index 0000000..462d170
Binary files /dev/null and b/net.sourceforge.phpeclipse/icons/obj16/apache_stop.gif differ
diff --git a/net.sourceforge.phpeclipse/icons/obj16/sql.gif b/net.sourceforge.phpeclipse/icons/obj16/sql.gif
new file mode 100644 (file)
index 0000000..dc85791
Binary files /dev/null and b/net.sourceforge.phpeclipse/icons/obj16/sql.gif differ
index 8ef16ae..19fe179 100644 (file)
@@ -22,12 +22,14 @@ phpConsoleView=PHP Console
 phpFileExtension=php
 php3FileExtension=php3
 php4FileExtension=php4
+incFileExtension=inc
+phtmlFileExtension=phtml
 
 #
 # Action sets
 #
 
-php.menu.label=&PHP
-phpActionSet.label=PHP Actions
+php.menu.label=&Source
+phpActionSet.label=Source Actions
 phpUncommentAction.label=&Uncomment@Ctrl+\\
 phpCommentAction.label=&Comment@Ctrl+/
\ No newline at end of file
index b84555d..68bde16 100644 (file)
       </fileTypes>
       <fileTypes
             type="text"
+            extension="phtml">
+      </fileTypes>
+      <fileTypes
+            type="text"
             extension="html">
       </fileTypes>
       <fileTypes
@@ -83,7 +87,7 @@
          </description>
       </wizard>
    </extension>
- <!--   <extension
+<!--   <extension
          point="org.eclipse.ui.newWizards">
       <category
             name="%newWizardCategory.name"
       </view>
    </extension>
    <extension
-         point="org.eclipse.ui.actionDefinitions">
-      <actionDefinition
-            id="net.sourceforge.phpeclipse.phpeditor.comment">
-      </actionDefinition>
-      <actionDefinition
-            id="net.sourceforge.phpeclipse.phpeditor.uncomment">
-      </actionDefinition>
-   </extension>
-   <extension
-         point="org.eclipse.ui.acceleratorSets">
-      <acceleratorSet
-            scopeId="org.eclipse.ui.textEditorScope"
-            configurationId="org.eclipse.ui.defaultAcceleratorConfiguration">
-         <accelerator
-               key="Ctrl+/"
-               id="net.sourceforge.phpeclipse.phpeditor.comment">
-         </accelerator>
-         <accelerator
-               key="Ctrl+\"
-               id="net.sourceforge.phpeclipse.phpeditor.uncomment">
-         </accelerator>
-      </acceleratorSet>
-   </extension>
-   <extension
          point="org.eclipse.ui.actionSets">
       <actionSet
             label="PHP/Apache"
          </menu>
          <action
                label="Restart Apache"
-               icon="icons/obj16/apache.gif"
+               icon="icons/obj16/apache_restart.gif"
                tooltip="Restart Apache"
                class="net.sourceforge.phpeclipse.actions.PHPRestartApacheAction"
                menubarPath="net.sourceforge.phpeclipse.PHPMenu/phpeclipse"
          </action>
          <action
                label="Stop Apache"
-               icon="icons/obj16/apache.gif"
+               icon="icons/obj16/apache_stop.gif"
                tooltip="Stop Apache"
                class="net.sourceforge.phpeclipse.actions.PHPStopApacheAction"
                menubarPath="net.sourceforge.phpeclipse.PHPMenu/phpeclipse"
          </action>
          <action
                label="Start MySQL"
-               icon="icons/obj16/apache.gif"
+               icon="icons/obj16/sql.gif"
                tooltip="Start MySQL"
                class="net.sourceforge.phpeclipse.actions.PHPStartMySQLAction"
                menubarPath="net.sourceforge.phpeclipse.PHPMenu/phpeclipse"
                id="net.sourceforge.phpeclipse.actions.PHPStartMySQLAction">
          </action>
       </actionSet>
-      <actionSet
+ <!--     <actionSet
             label="%phpActionSet.label"
             visible="false"
             id="net.sourceforge.phpeclipse.phpeditor.actions.phpActionSet">
             </separator>
          </menu>
          <action
-               definitionId="net.sourceforge.phpeclipse.phpeditor.uncomment"
-               accelerator="Ctrl+Shift+\\"
                label="%phpUncommentAction.label"
                retarget="true"
                menubarPath="net.sourceforge.phpeclipse.phpeditor.menu/editGroup"
-               id="net.sourceforge.phpeclipse.phpeditor.actions.Uncomment">
+               id="net.sourceforge.phpeclipse.phpeditor.uncomment">
          </action>
          <action
-               definitionId="net.sourceforge.phpeclipse.phpeditor.comment"
-               accelerator="Ctrl+Shift+/"
                label="%phpCommentAction.label"
                retarget="true"
                menubarPath="net.sourceforge.phpeclipse.phpeditor.menu/editGroup"
-               id="net.sourceforge.phpeclipse.phpeditor.actions.Comment">
+               id="net.sourceforge.phpeclipse.phpeditor.comment">
          </action>
-      </actionSet>
+      </actionSet>  -->
    </extension>
+ <!--  <extension
+         point="org.eclipse.ui.actionDefinitions">
+      <actionDefinition
+            id="net.sourceforge.phpeclipse.phpeditor.comment">
+      </actionDefinition>
+      <actionDefinition
+            id="net.sourceforge.phpeclipse.phpeditor.uncomment">
+      </actionDefinition>
+   </extension> 
+   <extension
+         point="org.eclipse.ui.acceleratorSets">
+      <acceleratorSet
+            scopeId="org.eclipse.ui.textEditorScope"
+            configurationId="org.eclipse.ui.defaultAcceleratorConfiguration">
+         <accelerator
+               key="Ctrl+/"
+               id="net.sourceforge.phpeclipse.phpeditor.comment">
+         </accelerator>
+         <accelerator
+               key="Ctrl+\\"
+               id="net.sourceforge.phpeclipse.phpeditor.uncomment">
+         </accelerator>
+      </acceleratorSet>
+   </extension> -->
    <extension
          point="org.eclipse.ui.editors">
       <editor
       <editor
             name="%phpEditorName"
             icon="icons/obj16/phpedit.gif"
+            extensions="phtml"
+            contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
+            class="net.sourceforge.phpeclipse.phpeditor.PHPEditor"
+            id="net.sourceforge.phpeclipse.PHPEditor">
+      </editor>
+      <editor
+            name="%phpEditorName"
+            icon="icons/obj16/phpedit.gif"
             extensions="htm"
             contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
             class="net.sourceforge.phpeclipse.phpeditor.PHPEditor"
       </objectContribution>
       <objectContribution
             objectClass="org.eclipse.core.resources.IFile"
+            nameFilter="*.inc"
+            id="net.sourceforge.phpeclipse.actions.externalParserAction">
+         <action
+               label="Run External PHP Parser"
+               class="net.sourceforge.phpeclipse.actions.PHPExternalParserAction"
+               menubarPath="additions"
+               id="net.sourceforge.phpeclipse.actions.externalParserAction">
+         </action>
+      </objectContribution>
+      <objectContribution
+            objectClass="org.eclipse.core.resources.IFile"
+            nameFilter="*.phtml"
+            id="net.sourceforge.phpeclipse.actions.externalParserAction">
+         <action
+               label="Run External PHP Parser"
+               class="net.sourceforge.phpeclipse.actions.PHPExternalParserAction"
+               menubarPath="additions"
+               id="net.sourceforge.phpeclipse.actions.externalParserAction">
+         </action>
+      </objectContribution>
+      <objectContribution
+            objectClass="org.eclipse.core.resources.IFile"
             nameFilter="*.php"
             id="net.sourceforge.phpeclipse.actions.popupShowAction">
          <action
                id="net.sourceforge.phpeclipse.actions.showAction">
          </action>
       </objectContribution>
+      <objectContribution
+            objectClass="org.eclipse.core.resources.IFile"
+            nameFilter="*.inc"
+            id="net.sourceforge.phpeclipse.actions.popupShowAction">
+         <action
+               label="Open PHP Browser"
+               class="net.sourceforge.phpeclipse.actions.PHPEclipseShowAction"
+               menubarPath="additions"
+               id="net.sourceforge.phpeclipse.actions.showAction">
+         </action>
+      </objectContribution>
+      <objectContribution
+            objectClass="org.eclipse.core.resources.IFile"
+            nameFilter="*.phtml"
+            id="net.sourceforge.phpeclipse.actions.popupShowAction">
+         <action
+               label="Open PHP Browser"
+               class="net.sourceforge.phpeclipse.actions.PHPEclipseShowAction"
+               menubarPath="additions"
+               id="net.sourceforge.phpeclipse.actions.showAction">
+         </action>
+      </objectContribution>
    </extension>
    <extension
          point="org.eclipse.ui.preferencePages">
       </provider>
    </extension>
    <extension
+         point="org.eclipse.ui.documentProviders">
+      <provider
+            extensions="%incFileExtension"
+            class="net.sourceforge.phpeclipse.phpeditor.PHPDocumentProvider"
+            id="net.sourceforge.phpeclipse.phpeditor.PHPDocumentProvider">
+      </provider>
+   </extension>
+   <extension
+         point="org.eclipse.ui.documentProviders">
+      <provider
+            extensions="%phtmlFileExtension"
+            class="net.sourceforge.phpeclipse.phpeditor.PHPDocumentProvider"
+            id="net.sourceforge.phpeclipse.phpeditor.PHPDocumentProvider">
+      </provider>
+   </extension>
+   <extension
          point="org.eclipse.ui.views">
       <view
             name="%phpConsoleView"
             id="net.sourceforge.phpeclipse.views.phpconsoleview">
       </view>
    </extension>
-   <extension
-         point="org.eclipse.help.toc">
-      <toc
-            file="phphelp.xml"
-            primary="true">
-      </toc>
-   </extension>
-
 </plugin>
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/BuiltInEngine.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/BuiltInEngine.java
new file mode 100644 (file)
index 0000000..68d6a36
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+package net.sourceforge.phpdt.internal.ui.text.template;
+
+import java.util.ArrayList;
+
+import net.sourceforge.phpdt.internal.corext.template.ContextType;
+import net.sourceforge.phpdt.internal.corext.template.java.CompilationUnitContext;
+import net.sourceforge.phpdt.internal.corext.template.java.CompilationUnitContextType;
+import net.sourceforge.phpdt.internal.ui.PHPUiImages;
+import net.sourceforge.phpdt.internal.ui.text.java.IJavaCompletionProposal;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.Region;
+//import org.eclipse.jdt.internal.ui.text.link.LinkedPositionManager;
+
+public class BuiltInEngine {
+
+       /** The context type. */
+       private ContextType fContextType;
+       /** The result proposals. */
+       private ArrayList fProposals= new ArrayList();
+
+       /**
+        * Creates the template engine for a particular context type.
+        * See <code>TemplateContext</code> for supported context types.
+        */
+       public BuiltInEngine(ContextType contextType) {
+       //      Assert.isNotNull(contextType);
+               fContextType= contextType;
+       }
+
+       /**
+        * Empties the collector.
+        * 
+        * @param viewer the text viewer  
+        * @param unit   the compilation unit (may be <code>null</code>)
+        */
+       public void reset() {
+               fProposals.clear();
+       }
+
+       /**
+        * Returns the array of matching templates.
+        */
+       public IJavaCompletionProposal[] getResults() {
+               return (IJavaCompletionProposal[]) fProposals.toArray(new IJavaCompletionProposal[fProposals.size()]);
+       }
+
+       /**
+        * Inspects the context of the compilation unit around <code>completionPosition</code>
+        * and feeds the collector with proposals.
+        * @param viewer the text viewer
+        * @param completionPosition the context position in the document of the text viewer
+        * @param compilationUnit the compilation unit (may be <code>null</code>)
+        */
+       public void complete(ITextViewer viewer, int completionPosition, Object[] identifiers)
+  //,ICompilationUnit compilationUnit)
+       //hrows JavaModelException
+       {
+           IDocument document= viewer.getDocument();
+           
+               // prohibit recursion
+//             if (LinkedPositionManager.hasActiveManager(document))
+//                     return;
+
+               if (!(fContextType instanceof CompilationUnitContextType))
+                       return;
+               
+               ((CompilationUnitContextType) fContextType).setContextParameters(document, completionPosition);//mpilationUnit);
+               CompilationUnitContext context= (CompilationUnitContext) fContextType.createContext();
+               int start= context.getStart();
+               int end= context.getEnd();
+               IRegion region= new Region(start, end - start);
+
+//             Template[] templates= Templates.getInstance().getTemplates();
+    String identifier = null;
+               for (int i= 0; i != identifiers.length; i++) {
+      identifier = (String) identifiers[i];
+                       if (context.canEvaluate(identifier)) {
+                               fProposals.add(new BuiltInProposal(identifier, context, region, viewer, PHPUiImages.get(PHPUiImages.IMG_BUILTIN))); 
+      }
+    }
+       }
+
+}
+
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/BuiltInProposal.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/BuiltInProposal.java
new file mode 100644 (file)
index 0000000..1ff6be7
--- /dev/null
@@ -0,0 +1,245 @@
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+package net.sourceforge.phpdt.internal.ui.text.template;
+
+import net.sourceforge.phpdt.internal.corext.template.Template;
+import net.sourceforge.phpdt.internal.corext.template.TemplateBuffer;
+import net.sourceforge.phpdt.internal.corext.template.TemplateContext;
+import net.sourceforge.phpdt.internal.corext.template.TemplateMessages;
+import net.sourceforge.phpdt.internal.corext.template.TemplatePosition;
+import net.sourceforge.phpdt.internal.corext.template.java.CompilationUnitContext;
+import net.sourceforge.phpdt.internal.corext.template.java.JavaTemplateMessages;
+import net.sourceforge.phpdt.internal.ui.text.java.IJavaCompletionProposal;
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+import org.eclipse.core.runtime.CoreException;
+import net.sourceforge.phpdt.internal.ui.text.link.LinkedPositionManager;
+import net.sourceforge.phpdt.internal.ui.text.link.LinkedPositionUI;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Shell;
+//import org.eclipse.jdt.internal.ui.text.link.LinkedPositionManager;
+//import org.eclipse.jdt.internal.ui.text.link.LinkedPositionUI;
+//import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
+
+/**
+ * A PHP identifier proposal.
+ */
+public class BuiltInProposal implements IJavaCompletionProposal {
+
+  private final String fTemplate;
+  private final TemplateContext fContext;
+  private final ITextViewer fViewer;
+  private final Image fImage_builtin;
+
+  private final IRegion fRegion;
+
+  //private TemplateBuffer fTemplateBuffer;
+  private String fOldText;
+  private IRegion fSelectedRegion; // initialized by apply()
+
+  /**
+   * Creates a template proposal with a template and its context.
+   * @param template  the template
+   * @param context   the context in which the template was requested.
+   * @param image     the icon of the proposal.
+   */
+  public BuiltInProposal(String template, TemplateContext context, IRegion region, ITextViewer viewer, Image image_builtin) {
+    //         Assert.isNotNull(template);
+    //         Assert.isNotNull(context);
+    //         Assert.isNotNull(region);
+    //         Assert.isNotNull(viewer);
+
+    fTemplate = template;
+    fContext = context;
+    fViewer = viewer;
+       fImage_builtin= image_builtin;
+    fRegion = region;
+  }
+
+  /*
+   * @see ICompletionProposal#apply(IDocument)
+   */
+  public void apply(IDocument document) {
+    try {
+      //                   if (fTemplateBuffer == null)
+      //                               fTemplateBuffer= fContext.evaluate(fTemplate);
+
+      int start = fRegion.getOffset();
+      int end = fRegion.getOffset() + fRegion.getLength();
+
+      // insert template string
+    //  String templateString = fTemplate; // fTemplateBuffer.getString();     
+      document.replace(start, end - start, fTemplate);
+
+      // translate positions
+      LinkedPositionManager manager = new LinkedPositionManager(document);
+      //                       TemplatePosition[] variables= fTemplateBuffer.getVariables();
+      //                       for (int i= 0; i != variables.length; i++) {
+      //                               TemplatePosition variable= variables[i];
+      //
+      //                               if (variable.isResolved())
+      //                                       continue;
+      //                               
+      //                               int[] offsets= variable.getOffsets();
+      //                               int length= variable.getLength();
+      //                               
+      //                               for (int j= 0; j != offsets.length; j++)
+      //                                       manager.addPosition(offsets[j] + start, length);
+      //                       }
+
+      LinkedPositionUI editor = new LinkedPositionUI(fViewer, manager);
+      editor.setFinalCaretOffset(fTemplate.length()+start);
+   //   editor.setFinalCaretOffset(getCaretOffset(fTemplateBuffer) + start);
+      editor.enter();
+
+      fSelectedRegion = editor.getSelectedRegion();
+
+    } catch (BadLocationException e) {
+      PHPeclipsePlugin.log(e);
+      openErrorDialog(e);
+
+    }
+    //      catch (CoreException e) {
+    //                 handleException(e);
+    //     }       
+  }
+
+//  private static int getCaretOffset(TemplateBuffer buffer) {
+//    TemplatePosition[] variables = buffer.getVariables();
+//    for (int i = 0; i != variables.length; i++) {
+//      TemplatePosition variable = variables[i];
+//
+//      if (variable.getName().equals(JavaTemplateMessages.getString("GlobalVariables.variable.name.cursor"))) //$NON-NLS-1$
+//        return variable.getOffsets()[0];
+//    }
+//
+//    return buffer.getString().length();
+//  }
+
+  /*
+   * @see ICompletionProposal#getSelection(IDocument)
+   */
+  public Point getSelection(IDocument document) {
+    return new Point(fSelectedRegion.getOffset(), fSelectedRegion.getLength());
+    //   return null;
+  }
+
+  /*
+   * @see ICompletionProposal#getAdditionalProposalInfo()
+   */
+  public String getAdditionalProposalInfo() {
+    //     try {
+    //                 if (fTemplateBuffer == null)
+    //                         fTemplateBuffer= fContext.evaluate(fTemplate);
+
+    return textToHTML(fTemplate); // fTemplateBuffer.getString());
+
+    //     } catch (CoreException e) {
+    //                 handleException(e);                 
+    //                 return null;
+    //     }
+  }
+
+  /*
+   * @see ICompletionProposal#getDisplayString()
+   */
+  public String getDisplayString() {
+    return fTemplate + TemplateMessages.getString("TemplateProposal.delimiter") + fTemplate; // $NON-NLS-1$ //$NON-NLS-1$
+    //         return fTemplate.getName() + TemplateMessages.getString("TemplateProposal.delimiter") + fTemplate.getDescription(); // $NON-NLS-1$ //$NON-NLS-1$
+  }
+
+  /*
+   * @see ICompletionProposal#getImage()
+   */
+  public Image getImage() {
+               return fImage_builtin;
+  }
+
+  /*
+   * @see ICompletionProposal#getContextInformation()
+   */
+  public IContextInformation getContextInformation() {
+    return null;
+  }
+
+  private static String textToHTML(String string) {
+    StringBuffer buffer = new StringBuffer(string.length());
+    buffer.append("<pre>"); //$NON-NLS-1$
+
+    for (int i = 0; i != string.length(); i++) {
+      char ch = string.charAt(i);
+
+      switch (ch) {
+        case '&' :
+          buffer.append("&amp;"); //$NON-NLS-1$
+          break;
+
+        case '<' :
+          buffer.append("&lt;"); //$NON-NLS-1$
+          break;
+
+        case '>' :
+          buffer.append("&gt;"); //$NON-NLS-1$
+          break;
+
+        case '\t' :
+          buffer.append("    "); //$NON-NLS-1$
+          break;
+
+        case '\n' :
+          buffer.append("<br>"); //$NON-NLS-1$
+          break;
+
+        default :
+          buffer.append(ch);
+          break;
+      }
+    }
+
+    buffer.append("</pre>"); //$NON-NLS-1$
+    return buffer.toString();
+  }
+
+  private void openErrorDialog(BadLocationException e) {
+    Shell shell = fViewer.getTextWidget().getShell();
+    MessageDialog.openError(shell, TemplateMessages.getString("TemplateEvaluator.error.title"), e.getMessage()); //$NON-NLS-1$
+  }
+
+  private void handleException(CoreException e) {
+    Shell shell = fViewer.getTextWidget().getShell();
+    PHPeclipsePlugin.log(e);
+    //         ExceptionHandler.handle(e, shell, TemplateMessages.getString("TemplateEvaluator.error.title"), null); //$NON-NLS-1$
+  }
+
+  /*
+   * @see IJavaCompletionProposal#getRelevance()
+   */
+  public int getRelevance() {
+
+    if (fContext instanceof CompilationUnitContext) {
+      CompilationUnitContext context = (CompilationUnitContext) fContext;
+      switch (context.getCharacterBeforeStart()) {
+        // high relevance after whitespace
+        case ' ' :
+        case '\r' :
+        case '\n' :
+        case '\t' :
+          return 90;
+
+        default :
+          return 0;
+      }
+    } else {
+      return 90;
+    }
+  }
+
+}
\ No newline at end of file
index 6f35ce5..84fdf1c 100644 (file)
@@ -26,16 +26,13 @@ import org.eclipse.ui.texteditor.RetargetTextEditorAction;
 import org.eclipse.ui.texteditor.TextEditorAction;
 
 /**
- * Contributes interesting Java actions to the desktop's Edit menu and the toolbar.
+ * Contributes interesting PHP actions to the desktop's Edit menu and the toolbar.
  */
-public class PHPActionContributor extends TextEditorActionContributor {
+public class PHPActionContributor extends BasicTextEditorActionContributor implements PHPEditorActionDefinitionIds {
 
-  public static final String COMMENT = "net.sourceforge.phpeclipse.phpeditor.comment";
-  public static final String UNCOMMENT = "net.sourceforge.phpeclipse.phpeditor.uncomment";
-  
   protected RetargetTextEditorAction fContentAssistProposal;
-  protected RetargetTextEditorAction fContentAssistTip;
-  protected TextEditorAction fTogglePresentation;
+  // protected RetargetTextEditorAction fContentAssistTip;
+  // protected TextEditorAction fTogglePresentation;
   protected PHPParserAction parserAction;
 
   /**
@@ -44,8 +41,8 @@ public class PHPActionContributor extends TextEditorActionContributor {
   public PHPActionContributor() {
     super();
     fContentAssistProposal = new RetargetTextEditorAction(PHPEditorMessages.getResourceBundle(), "ContentAssistProposal."); //$NON-NLS-1$
-    fContentAssistTip = new RetargetTextEditorAction(PHPEditorMessages.getResourceBundle(), "ContentAssistTip."); //$NON-NLS-1$
-    fTogglePresentation = new PresentationAction();
+    //  fContentAssistTip = new RetargetTextEditorAction(PHPEditorMessages.getResourceBundle(), "ContentAssistTip."); //$NON-NLS-1$
+    //  fTogglePresentation = new PresentationAction();
     parserAction = PHPParserAction.getInstance();
   }
 
@@ -60,34 +57,34 @@ public class PHPActionContributor extends TextEditorActionContributor {
     if (editMenu != null) {
       editMenu.add(new Separator());
       editMenu.add(fContentAssistProposal);
-      editMenu.add(fContentAssistTip);
+      //   editMenu.add(fContentAssistTip);
     }
 
-    IToolBarManager toolBarManager = bars.getToolBarManager();
-    if (toolBarManager != null) {
-      toolBarManager.add(new Separator());
-      toolBarManager.add(fTogglePresentation);
-    }
+    //    IToolBarManager toolBarManager = bars.getToolBarManager();
+    //    if (toolBarManager != null) {
+    //      toolBarManager.add(new Separator());
+    //      toolBarManager.add(fTogglePresentation);
+    //    }
   }
 
   private void doSetActiveEditor(IEditorPart part) {
     super.setActiveEditor(part);
 
-    ITextEditor editor = null;
+    ITextEditor textEditor = null;
     if (part instanceof ITextEditor)
-      editor = (ITextEditor) part;
+      textEditor = (ITextEditor) part;
+
+    fContentAssistProposal.setAction(getAction(textEditor, "ContentAssistProposal")); //$NON-NLS-1$
+    //  fContentAssistTip.setAction(getAction(editor, "ContentAssistTip")); //$NON-NLS-1$
 
-    fContentAssistProposal.setAction(getAction(editor, "ContentAssistProposal")); //$NON-NLS-1$
-    fContentAssistTip.setAction(getAction(editor, "ContentAssistTip")); //$NON-NLS-1$
+    IActionBars bars = getActionBars();
+    bars.setGlobalActionHandler(COMMENT, getAction(textEditor, "Comment"));
+    bars.setGlobalActionHandler(UNCOMMENT, getAction(textEditor, "Uncomment"));
 
-    IActionBars bars= getActionBars();    
-    bars.setGlobalActionHandler(COMMENT, getAction(editor, "Comment"));
-    bars.setGlobalActionHandler(UNCOMMENT, getAction(editor, "Uncomment"));
-    
-    fTogglePresentation.setEditor(editor);
-    fTogglePresentation.update();
+    //    fTogglePresentation.setEditor(editor);
+    //    fTogglePresentation.update();
 
-    parserAction.setEditor(editor);
+    parserAction.setEditor(textEditor);
     parserAction.update();
   }
 
index adcf53d..04f7d9e 100644 (file)
@@ -67,9 +67,10 @@ public class PHPEditor extends TextEditor {
   }
 
   public PHPContentOutlinePage getfOutlinePage() {
-    return fOutlinePage; 
+    return fOutlinePage;
   }
-  /** The <code>JavaEditor</code> implementation of this 
+
+  /** The <code>PHPEditor</code> implementation of this 
    * <code>AbstractTextEditor</code> method extend the 
    * actions to add those specific to the receiver
    */
@@ -100,6 +101,8 @@ public class PHPEditor extends TextEditor {
 
     actionGroup = new PHPActionGroup(this, ITextEditorActionConstants.GROUP_EDIT);
 
+    markAsStateDependentAction("Comment", true); //$NON-NLS-1$
+    markAsStateDependentAction("Uncomment", true); //$NON-NLS-1$
   }
 
   /** The <code>JavaEditor</code> implementation of this