<classpathentry kind="var"
path="ECLIPSE_HOME/plugins/org.eclipse.ui_2.0.0/workbench.jar" sourcepath="_ORG_ECLIPSE_PLATFORM_SOURCE/org.eclipse.ui_2.0.0/workbenchsrc.zip"/>
<classpathentry kind="var"
- path="ECLIPSE_HOME/plugins/org.eclipse.ui.win32_2.0.0/workbenchwin32.jar" sourcepath="_ORG_ECLIPSE_PLATFORM_WIN32_SOURCE/org.eclipse.ui.win32_2.0.0/workbenchwin32src.zip"/>
- <classpathentry kind="var"
- path="ECLIPSE_HOME/plugins/org.eclipse.swt.win32_2.0.0/ws/win32/swt.jar" sourcepath="_ORG_ECLIPSE_PLATFORM_WIN32_SOURCE/org.eclipse.swt.win32_2.0.0/ws/win32/swtsrc.zip"/>
- <classpathentry kind="var"
path="ECLIPSE_HOME/plugins/org.eclipse.core.runtime_2.0.0/runtime.jar" sourcepath="_ORG_ECLIPSE_PLATFORM_SOURCE/org.eclipse.core.runtime_2.0.0/runtimesrc.zip"/>
<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="var" path="ECLIPSE_HOME/plugins/org.eclipse.jdt.ui_2.0.0/jdt.jar"/>
+ <classpathentry kind="var" path="ECLIPSE_HOME/plugins/org.eclipse.help_2.0.0/help.jar"/>
+ <classpathentry kind="var" path="ECLIPSE_HOME/plugins/org.eclipse.swt.win32_2.0.0/ws/win32/swt.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
--- /dev/null
+<toc label="PHP Online Help" topic="doc/index.html">
+ <topic label="I. Getting Started" href="doc/getting-started.html"/>
+ <topic label="II. Language Reference" href="doc/langref.html"/>
+ <topic label="III. Features" href="doc/features.html"/>
+ <topic label="IV. Function Reference" href="doc/funcref.html"/>
+ <topic label="V. Extending PHP 4.0" href="doc/zend.html"/>
+ <topic label="VI. FAQ: Frequently Asked Questions" href="doc/faq.html"/>
+ <topic label="VII. Appendixes" href="doc/appendixes.html"/>
+</toc>
\ No newline at end of file
#
# Extension point names
#
-phpEditorName=Example Java Editor
+phpEditorName=PHP Editor
phpFileExtension=php
<?xml version="1.0" encoding="UTF-8"?>
<plugin
- id="PHPEclipse"
+ id="net.sourceforge.phpeclipse"
name="%pluginName"
version="1.0.1"
provider-name="%providerName"
<runtime>
<library name="PHPEclipse.jar"/>
</runtime>
- <requires>
+ <requires>s
<import plugin="org.eclipse.core.resources"/>
<import plugin="org.eclipse.ui"/>
- <import plugin="org.eclipse.jdt"/>
- <import plugin="org.eclipse.jdt.ui"/>
+ <import plugin="org.eclipse.help"/>
+ <import plugin="org.eclipse.swt"/>
</requires>
+
<extension
point="org.eclipse.ui.actionSets">
<actionSet
- id="net.sourceforge.phpeclipse.PHPActionSet"
label="PHP/Apache"
+ description="Starting MySQL and Apache."
visible="true"
- description="Starting MySQL and Apache.">
+ id="net.sourceforge.phpeclipse.PHPActionSet">
<menu
- id="net.sourceforge.phpeclipse.PHPMenu"
- label="PHP/Apache">
- <separator name="phpeclipse"/>
+ label="PHP/Apache"
+ id="net.sourceforge.phpeclipse.PHPMenu">
+ <separator
+ name="phpeclipse">
+ </separator>
</menu>
<action
- id="net.sourceforge.phpeclipse.actions.PHPRestartApacheAction"
- menubarPath="net.sourceforge.phpeclipse.PHPMenu/phpeclipse"
- toolbarPath="Normal"
- label="Restart Apache"
- tooltip="Restart Apache"
- icon="icons/obj16/apache.gif"
- start="true"
- class="net.sourceforge.phpeclipse.actions.PHPRestartApacheAction">
+ label="Restart Apache"
+ icon="icons/obj16/apache.gif"
+ tooltip="Restart Apache"
+ class="net.sourceforge.phpeclipse.actions.PHPRestartApacheAction"
+ menubarPath="net.sourceforge.phpeclipse.PHPMenu/phpeclipse"
+ toolbarPath="Normal"
+ start="true"
+ id="net.sourceforge.phpeclipse.actions.PHPRestartApacheAction">
</action>
<action
- id="net.sourceforge.phpeclipse.actions.PHPStopApacheAction"
- menubarPath="net.sourceforge.phpeclipse.PHPMenu/phpeclipse"
- toolbarPath="Normal"
- label="Stop Apache"
- tooltip="Stop Apache"
- icon="icons/obj16/apache.gif"
- start="true"
- class="net.sourceforge.phpeclipse.actions.PHPStopApacheAction">
+ label="Stop Apache"
+ icon="icons/obj16/apache.gif"
+ tooltip="Stop Apache"
+ class="net.sourceforge.phpeclipse.actions.PHPStopApacheAction"
+ menubarPath="net.sourceforge.phpeclipse.PHPMenu/phpeclipse"
+ toolbarPath="Normal"
+ start="true"
+ id="net.sourceforge.phpeclipse.actions.PHPStopApacheAction">
</action>
<action
- id="net.sourceforge.phpeclipse.actions.PHPStartApacheAction"
- menubarPath="net.sourceforge.phpeclipse.PHPMenu/phpeclipse"
- toolbarPath="Normal"
- label="Start Apache"
- tooltip="Start Apache"
- icon="icons/obj16/apache.gif"
- start="true"
- class="net.sourceforge.phpeclipse.actions.PHPStartApacheAction">
- </action>
+ label="Start Apache"
+ icon="icons/obj16/apache.gif"
+ tooltip="Start Apache"
+ class="net.sourceforge.phpeclipse.actions.PHPStartApacheAction"
+ menubarPath="net.sourceforge.phpeclipse.PHPMenu/phpeclipse"
+ toolbarPath="Normal"
+ start="true"
+ id="net.sourceforge.phpeclipse.actions.PHPStartApacheAction">
+ </action>
<action
- id="net.sourceforge.phpeclipse.actions.PHPStartMySQLAction"
- menubarPath="net.sourceforge.phpeclipse.PHPMenu/phpeclipse"
- toolbarPath="Normal"
- label="Start MySQL"
- tooltip="Start MySQL"
- icon="icons/obj16/apache.gif"
- start="true"
- class="net.sourceforge.phpeclipse.actions.PHPStartMySQLAction">
+ label="Start MySQL"
+ icon="icons/obj16/apache.gif"
+ tooltip="Start MySQL"
+ class="net.sourceforge.phpeclipse.actions.PHPStartMySQLAction"
+ menubarPath="net.sourceforge.phpeclipse.PHPMenu/phpeclipse"
+ toolbarPath="Normal"
+ start="true"
+ id="net.sourceforge.phpeclipse.actions.PHPStartMySQLAction">
</action>
</actionSet>
</extension>
id="net.sourceforge.phpeclipse.actions.showAction">
</action>
</objectContribution>
- <viewerContribution
- targetID="#TextEditorContext"
+ <!-- <viewerContribution
+ targetID="#PHPEditorContext"
id="net.sourceforge.phpeclipse.actions.popup.editor">
<action
label="PHP Help"
menubarPath="additions"
id="net.sourceforge.phpeclipse.actions.editor.contexthelp">
</action>
- >
- </viewerContribution>
+ </viewerContribution> -->
</extension>
<extension
point="org.eclipse.ui.preferencePages">
id="net.sourceforge.phpeclipse.phpeditor.PHPDocumentProvider">
</provider>
</extension>
-
+ <extension point="org.eclipse.help.toc">
+ <toc file="phphelp.xml" primary="true"/>
+ </extension>
</plugin>
**********************************************************************/
package net.sourceforge.phpeclipse;
-import java.io.IOException;
-import java.text.MessageFormat;
-
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.DirectoryFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.StringFieldEditor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
}
protected void createFieldEditors() {
- Shell shell = getShell();
final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
StringFieldEditor localhost = new StringFieldEditor(PHPeclipsePlugin.LOCALHOST_PREF, "&Localhost:", 60, getFieldEditorParent());
new DirectoryFieldEditor(PHPeclipsePlugin.DOCUMENTROOT_PREF, "&DocumentRoot:", getFieldEditorParent());
BooleanFieldEditor useExternalBrowser =
- new BooleanFieldEditor(PHPeclipsePlugin.USE_EXTERNAL_BROWSER_PREF, "&Use External Browser", 60, getFieldEditorParent());
+ new BooleanFieldEditor(PHPeclipsePlugin.USE_EXTERNAL_BROWSER_PREF, "&Use External Browser", getFieldEditorParent());
StringFieldEditor externalBrowser =
new StringFieldEditor(PHPeclipsePlugin.EXTERNAL_BROWSER_PREF, "&External Browser command:", 60, getFieldEditorParent());
StringFieldEditor startMySQL =
new StringFieldEditor(PHPeclipsePlugin.MYSQL_PREF, "&MySQL command:", 60, getFieldEditorParent());
-// Button button = new Button(shell, SWT.PUSH);
-// button.setText("Start MySQL");
-// button.addSelectionListener(new SelectionAdapter() {
-// public void widgetSelected(SelectionEvent e) {
-// try {
-// Runtime runtime = Runtime.getRuntime();
-// runtime.exec(store.getString(PHPeclipsePlugin.MYSQL_PREF));
-// } catch (IOException e1) {
-// }
-// }
-// });
+
StringFieldEditor startApache =
new StringFieldEditor(PHPeclipsePlugin.APACHE_START_PREF, "Start &Apache command:", 60, getFieldEditorParent());
-// Button startButton = new Button(shell, SWT.PUSH);
-// startButton.setText("Start Apache");
-// startButton.addSelectionListener(new SelectionAdapter() {
-// public void widgetSelected(SelectionEvent e) {
-// String[] arguments = { store.getString(PHPeclipsePlugin.DOCUMENTROOT_PREF)};
-// MessageFormat form = new MessageFormat(store.getString(PHPeclipsePlugin.APACHE_START_PREF));
-//
-// try {
-// Runtime runtime = Runtime.getRuntime();
-// runtime.exec(form.format(arguments));
-// } catch (IOException e2) {
-// }
-// }
-// });
-
- StringFieldEditor stopApache =
+
+
+ StringFieldEditor stopApache =
new StringFieldEditor(PHPeclipsePlugin.APACHE_STOP_PREF, "&Stop Apache command:", 60, getFieldEditorParent());
- Button stopButton = new Button(shell, SWT.PUSH);
- stopButton.setText("Stop Apache");
- stopButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- try {
- Runtime runtime = Runtime.getRuntime();
- runtime.exec(store.getString(PHPeclipsePlugin.MYSQL_PREF));
- } catch (IOException e1) {
- }
- }
- });
+
StringFieldEditor restartApache =
new StringFieldEditor(PHPeclipsePlugin.APACHE_RESTART_PREF, "&Restart Apache command:", 60, getFieldEditorParent());
- Button restartButton = new Button(shell, SWT.PUSH);
- restartButton.setText("Restart Apache");
- restartButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- try {
- Runtime runtime = Runtime.getRuntime();
- runtime.exec(store.getString(PHPeclipsePlugin.MYSQL_PREF));
- } catch (IOException e1) {
- }
- }
- });
+
addField(localhost);
addField(documentRoot);
addField(externalBrowser);
addField(startMySQL);
addField(startApache);
-// add(startButton);
+
addField(stopApache);
addField(restartApache);
}
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.jdt.internal.ui.actions.OpenBrowserUtil;
+
+import org.eclipse.ui.help.WorkbenchHelp;
+import org.eclipse.help.IHelp;
+//import org.eclipse.jdt.internal.ui.actions.OpenBrowserUtil;
// import org.eclipse.help.ui.browser.LaunchURL;
public class PHPEclipseShowAction implements IObjectActionDelegate {
- private IWorkbenchPart workbenchPart;
- /**
- * Constructor for Action1.
- */
- public PHPEclipseShowAction() {
- super();
- }
-
- /**
- * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
- */
- public void setActivePart(IAction action, IWorkbenchPart targetPart) {
- workbenchPart = targetPart;
- }
-
- // public static void open(final URL url, final Shell shell, final String dialogTitle) {
- // IHelp help= WorkbenchHelp.getHelpSupport();
- // if (help != null) {
- // WorkbenchHelp.getHelpSupport().displayHelpResource(url.toExternalForm());
- // } else {
- // showMessage(shell, dialogTitle, ActionMessages.getString("OpenBrowserUtil.help_not_available"), false); //$NON-NLS-1$
- // }
- // }
-
- public void run(IAction action) {
- ISelectionProvider selectionProvider = null;
- selectionProvider = workbenchPart.getSite().getSelectionProvider();
-
- StructuredSelection selection = null;
- selection = (StructuredSelection) selectionProvider.getSelection();
-
- IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
-
- Shell shell = null;
- Iterator iterator = null;
- iterator = selection.iterator();
- while (iterator.hasNext()) {
- // obj => selected object in the view
- Object obj = iterator.next();
-
- // is it a resource
- if (obj instanceof IResource) {
- IResource resource = (IResource) obj;
-
- // check if it's a file resource
- switch (resource.getType()) {
-
- case IResource.FILE :
- // single file:
- IFile file = (IFile) resource;
- IPath path = file.getFullPath();
- // if (j2h==null) {
- // shell = new Shell();
- // j2h = new Java2HTML(shell);
- // }
-
- String fileName = file.getLocation().toString();
+ private IWorkbenchPart workbenchPart;
+ /**
+ * Constructor for Action1.
+ */
+ public PHPEclipseShowAction() {
+ super();
+ }
+
+ /**
+ * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
+ */
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ workbenchPart = targetPart;
+ }
+
+ // public static void open(final URL url, final Shell shell, final String dialogTitle) {
+ // IHelp help= WorkbenchHelp.getHelpSupport();
+ // if (help != null) {
+ // WorkbenchHelp.getHelpSupport().displayHelpResource(url.toExternalForm());
+ // } else {
+ // showMessage(shell, dialogTitle, ActionMessages.getString("OpenBrowserUtil.help_not_available"), false); //$NON-NLS-1$
+ // }
+ // }
+
+ public void run(IAction action) {
+ ISelectionProvider selectionProvider = null;
+ selectionProvider = workbenchPart.getSite().getSelectionProvider();
+
+ StructuredSelection selection = null;
+ selection = (StructuredSelection) selectionProvider.getSelection();
+
+ IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
+
+ Shell shell = null;
+ Iterator iterator = null;
+ iterator = selection.iterator();
+ while (iterator.hasNext()) {
+ // obj => selected object in the view
+ Object obj = iterator.next();
+
+ // is it a resource
+ if (obj instanceof IResource) {
+ IResource resource = (IResource) obj;
+
+ // check if it's a file resource
+ switch (resource.getType()) {
+
+ case IResource.FILE :
+ // single file:
+ IFile file = (IFile) resource;
+ IPath path = file.getFullPath();
+ // if (j2h==null) {
+ // shell = new Shell();
+ // j2h = new Java2HTML(shell);
+ // }
+
+ String fileName = file.getLocation().toString();
String lowerCaseFileName = fileName.toLowerCase();
- // fileName = "http://localhost"+fileName.replaceAll("c:", "");
- String documentRoot = store.getString(PHPeclipsePlugin.DOCUMENTROOT_PREF);
+ // fileName = "http://localhost"+fileName.replaceAll("c:", "");
+ String documentRoot = store.getString(PHPeclipsePlugin.DOCUMENTROOT_PREF);
documentRoot = documentRoot.replace('\\', '/');
documentRoot = documentRoot.toLowerCase();
MessageDialog.openInformation(shell, "lowerCaseFileName", "lowerCaseFileName: " + lowerCaseFileName);
-
- if ( lowerCaseFileName.startsWith(documentRoot) ) {
+
+ if (lowerCaseFileName.startsWith(documentRoot)) {
fileName = fileName.substring(documentRoot.length());
} else {
MessageDialog.openInformation(shell, "Wrong DocumentRoot", "Adjust DocumentRoot: " + documentRoot);
return;
}
-
- fileName = store.getString(PHPeclipsePlugin.LOCALHOST_PREF) + fileName.replaceAll(documentRoot, "");
-
- try {
- if (store.getBoolean(PHPeclipsePlugin.USE_EXTERNAL_BROWSER_PREF)) {
- String[] arguments = { fileName };
- MessageFormat form = new MessageFormat(store.getString(PHPeclipsePlugin.EXTERNAL_BROWSER_PREF));
-
- Runtime runtime = Runtime.getRuntime();
- runtime.exec(form.format(arguments));
- // runtime.exec(store.getString(PHPeclipsePlugin.EXTERNAL_BROWSER_PREF) + " " + fileName);
- // runtime.exec("command.com /c start iexplore " + fileName);
- } else {
- OpenBrowserUtil.open(new URL(fileName), shell, fileName);
- }
- } catch (MalformedURLException e) {
- MessageDialog.openInformation(shell, "MalformedURLException: ", e.toString());
- } catch (IOException e) {
- MessageDialog.openInformation(shell, "IOException", "Cannot show: " + fileName);
-
- }
-
- // MessageDialog.openInformation(shell, "PHPEclipse", "FileName - " + fileName);
- //
- // Runtime runtime = Runtime.getRuntime();
- // try {
- // runtime.exec("command.com /c start iexplore "+fileName);
-
- // MessageDialog.openInformation(shell, "J2h Plug-in", "FileName - " + fileName);
- // j2h.convert( fileName );
- }
- }
- }
- } /**
- * @see IActionDelegate#selectionChanged(IAction, ISelection)
- */
- public void selectionChanged(IAction action, ISelection selection) {
- }
+ fileName = store.getString(PHPeclipsePlugin.LOCALHOST_PREF) + fileName.replaceAll(documentRoot, "");
+
+ try {
+ if (store.getBoolean(PHPeclipsePlugin.USE_EXTERNAL_BROWSER_PREF)) {
+ String[] arguments = { fileName };
+ MessageFormat form = new MessageFormat(store.getString(PHPeclipsePlugin.EXTERNAL_BROWSER_PREF));
+
+ Runtime runtime = Runtime.getRuntime();
+ runtime.exec(form.format(arguments));
+ // runtime.exec(store.getString(PHPeclipsePlugin.EXTERNAL_BROWSER_PREF) + " " + fileName);
+ // runtime.exec("command.com /c start iexplore " + fileName);
+ } else {
+ open(new URL(fileName), shell, fileName);
+ }
+ } catch (MalformedURLException e) {
+ MessageDialog.openInformation(shell, "MalformedURLException: ", e.toString());
+ } catch (IOException e) {
+ MessageDialog.openInformation(shell, "IOException", "Cannot show: " + fileName);
+
+ }
+
+ // MessageDialog.openInformation(shell, "PHPEclipse", "FileName - " + fileName);
+ //
+ // Runtime runtime = Runtime.getRuntime();
+ // try {
+ // runtime.exec("command.com /c start iexplore "+fileName);
+
+ // MessageDialog.openInformation(shell, "J2h Plug-in", "FileName - " + fileName);
+ // j2h.convert( fileName );
+ }
+ }
+ }
+ } /**
+ * @see IActionDelegate#selectionChanged(IAction, ISelection)
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ }
+
+ public static void open(final URL url, final Shell shell, final String dialogTitle) {
+ IHelp help = WorkbenchHelp.getHelpSupport();
+ if (help != null) {
+ WorkbenchHelp.getHelpSupport().displayHelpResource(url.toExternalForm());
+ } else {
+ // showMessage(shell, dialogTitle, ActionMessages.getString("OpenBrowserUtil.help_not_available"), false); //$NON-NLS-1$
+ }
+ }
}
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.ui.IEditorActionDelegate;
-import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.actions.ActionDelegate;
+import org.eclipse.ui.editors.text.TextEditor;
import org.eclipse.ui.internal.EditorPluginAction;
+import org.eclipse.ui.part.FileEditorInput;
-public class PHPEclipseShowContextHelp
- extends ActionDelegate
- implements IEditorActionDelegate {
-
-private IEditorPart editor;
+public class PHPEclipseShowContextHelp extends ActionDelegate implements IEditorActionDelegate {
+
+ private TextEditor editor;
/**
* @see ActionDelegate#run(IAction)
*/
public void run(IAction action) {
EditorPluginAction editorPluginAction = (EditorPluginAction) action;
- IEditorInput input = editor.getEditorInput();
+ FileEditorInput input = (FileEditorInput) editor.getEditorInput();
// Add your code here to perform the action
- MessageDialog.openInformation(
- editor.getSite().getShell(),
- "Context Help: ",
- input.toString());
+ MessageDialog.openInformation(editor.getSite().getShell(), "Context Help: ", input.toString());
}
/**
* @see IEditorActionDelegate#setActiveEditor(IAction, IEditorPart)
*/
public void setActiveEditor(IAction action, IEditorPart targetEditor) {
- this.editor = targetEditor;
+ this.editor = (TextEditor) targetEditor;
}
}
IBM Corporation - Initial implementation
Klaus Hartlage - www.eclipseproject.de
**********************************************************************/
-import java.util.ResourceBundle;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.MenuManager;
*/
public class PHPEditor extends TextEditor {
- /** The outline page */
- private PHPContentOutlinePage fOutlinePage;
-
- /**
- * Default constructor.
- */
- public PHPEditor() {
- super();
- }
-
- /** The <code>JavaEditor</code> implementation of this
- * <code>AbstractTextEditor</code> method extend the
- * actions to add those specific to the receiver
- */
- protected void createActions() {
- super.createActions();
- setAction("ContentAssistProposal", new TextOperationAction(PHPEditorMessages.getResourceBundle(), "ContentAssistProposal.", this, ISourceViewer.CONTENTASSIST_PROPOSALS));
- setAction("ContentAssistTip", new TextOperationAction(PHPEditorMessages.getResourceBundle(), "ContentAssistTip.", this, ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION));
- }
-
- /** The <code>JavaEditor</code> implementation of this
- * <code>AbstractTextEditor</code> method performs any extra
- * disposal actions required by the java editor.
- */
- public void dispose() {
- PHPEditorEnvironment.disconnect(this);
- if (fOutlinePage != null)
- fOutlinePage.setInput(null);
- super.dispose();
- }
-
- /** The <code>JavaEditor</code> implementation of this
- * <code>AbstractTextEditor</code> method performs any extra
- * revert behavior required by the java editor.
- */
- public void doRevertToSaved() {
- super.doRevertToSaved();
- if (fOutlinePage != null)
- fOutlinePage.update();
- }
-
- /** The <code>JavaEditor</code> implementation of this
- * <code>AbstractTextEditor</code> method performs any extra
- * save behavior required by the java editor.
- */
- public void doSave(IProgressMonitor monitor) {
- super.doSave(monitor);
- if (fOutlinePage != null)
- fOutlinePage.update();
- }
-
- /** The <code>JavaEditor</code> implementation of this
- * <code>AbstractTextEditor</code> method performs any extra
- * save as behavior required by the java editor.
- */
- public void doSaveAs() {
- super.doSaveAs();
- if (fOutlinePage != null)
- fOutlinePage.update();
- }
-
- /** The <code>JavaEditor</code> implementation of this
- * <code>AbstractTextEditor</code> method performs sets the
- * input of the outline page after AbstractTextEditor has set input.
- */
- public void doSetInput(IEditorInput input) throws CoreException {
- super.doSetInput(input);
- if (fOutlinePage != null)
- fOutlinePage.setInput(input);
- }
-
- /** The <code>JavaEditor</code> implementation of this
- * <code>AbstractTextEditor</code> method adds any
- * JavaEditor specific entries.
- */
- public void editorContextMenuAboutToShow(MenuManager menu) {
- super.editorContextMenuAboutToShow(menu);
- addAction(menu, "ContentAssistProposal"); //$NON-NLS-1$
- addAction(menu, "ContentAssistTip"); //$NON-NLS-1$
- }
-
- /** The <code>JavaEditor</code> implementation of this
- * <code>AbstractTextEditor</code> method performs gets
- * the java content outline page if request is for a an
- * outline page.
- */
- public Object getAdapter(Class required) {
- if (IContentOutlinePage.class.equals(required)) {
- if (fOutlinePage == null) {
- fOutlinePage= new PHPContentOutlinePage(getDocumentProvider(), this);
- if (getEditorInput() != null)
- fOutlinePage.setInput(getEditorInput());
- }
- return fOutlinePage;
- }
- return super.getAdapter(required);
- }
-
- /* (non-Javadoc)
- * Method declared on AbstractTextEditor
- */
- protected void initializeEditor() {
-
- PHPEditorEnvironment.connect(this);
-
- setSourceViewerConfiguration(new PHPSourceViewerConfiguration());
- setRangeIndicator(new DefaultRangeIndicator());
- setEditorContextMenuId("#PHPEditorContext"); //$NON-NLS-1$
- setRulerContextMenuId("#PHPRulerContext"); //$NON-NLS-1$
- }
+ /** The outline page */
+ private PHPContentOutlinePage fOutlinePage;
+
+ /**
+ * Default constructor.
+ */
+ public PHPEditor() {
+ super();
+ }
+
+ /** The <code>JavaEditor</code> implementation of this
+ * <code>AbstractTextEditor</code> method extend the
+ * actions to add those specific to the receiver
+ */
+ protected void createActions() {
+ super.createActions();
+ setAction(
+ "ContentAssistProposal",
+ new TextOperationAction(
+ PHPEditorMessages.getResourceBundle(),
+ "ContentAssistProposal.",
+ this,
+ ISourceViewer.CONTENTASSIST_PROPOSALS));
+ setAction(
+ "ContentAssistTip",
+ new TextOperationAction(
+ PHPEditorMessages.getResourceBundle(),
+ "ContentAssistTip.",
+ this,
+ ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION));
+ }
+
+ /** The <code>JavaEditor</code> implementation of this
+ * <code>AbstractTextEditor</code> method performs any extra
+ * disposal actions required by the java editor.
+ */
+ public void dispose() {
+ PHPEditorEnvironment.disconnect(this);
+ if (fOutlinePage != null)
+ fOutlinePage.setInput(null);
+ super.dispose();
+ }
+
+ /** The <code>JavaEditor</code> implementation of this
+ * <code>AbstractTextEditor</code> method performs any extra
+ * revert behavior required by the java editor.
+ */
+ public void doRevertToSaved() {
+ super.doRevertToSaved();
+ if (fOutlinePage != null)
+ fOutlinePage.update();
+ }
+
+ /** The <code>JavaEditor</code> implementation of this
+ * <code>AbstractTextEditor</code> method performs any extra
+ * save behavior required by the java editor.
+ */
+ public void doSave(IProgressMonitor monitor) {
+ super.doSave(monitor);
+ if (fOutlinePage != null)
+ fOutlinePage.update();
+ }
+
+ /** The <code>JavaEditor</code> implementation of this
+ * <code>AbstractTextEditor</code> method performs any extra
+ * save as behavior required by the java editor.
+ */
+ public void doSaveAs() {
+ super.doSaveAs();
+ if (fOutlinePage != null)
+ fOutlinePage.update();
+ }
+
+ /** The <code>JavaEditor</code> implementation of this
+ * <code>AbstractTextEditor</code> method performs sets the
+ * input of the outline page after AbstractTextEditor has set input.
+ */
+ public void doSetInput(IEditorInput input) throws CoreException {
+ super.doSetInput(input);
+ if (fOutlinePage != null)
+ fOutlinePage.setInput(input);
+ }
+
+ /** The <code>JavaEditor</code> implementation of this
+ * <code>AbstractTextEditor</code> method adds any
+ * JavaEditor specific entries.
+ */
+ public void editorContextMenuAboutToShow(MenuManager menu) {
+ super.editorContextMenuAboutToShow(menu);
+ addAction(menu, "ContentAssistProposal"); //$NON-NLS-1$
+ addAction(menu, "ContentAssistTip"); //$NON-NLS-1$
+ }
+
+ /** The <code>JavaEditor</code> implementation of this
+ * <code>AbstractTextEditor</code> method performs gets
+ * the java content outline page if request is for a an
+ * outline page.
+ */
+ public Object getAdapter(Class required) {
+ if (IContentOutlinePage.class.equals(required)) {
+ if (fOutlinePage == null) {
+ fOutlinePage = new PHPContentOutlinePage(getDocumentProvider(), this);
+ if (getEditorInput() != null)
+ fOutlinePage.setInput(getEditorInput());
+ }
+ return fOutlinePage;
+ }
+ return super.getAdapter(required);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on AbstractTextEditor
+ */
+ protected void initializeEditor() {
+
+ PHPEditorEnvironment.connect(this);
+
+ setSourceViewerConfiguration(new PHPSourceViewerConfiguration());
+ setRangeIndicator(new DefaultRangeIndicator());
+ setEditorContextMenuId("#PHPEditorContext"); //$NON-NLS-1$
+ setRulerContextMenuId("#PHPRulerContext"); //$NON-NLS-1$
+ }
}
protected static char[] fgBrackets = { '{', '}', '(', ')', '[', ']', '"', '"' };
/*
- * Create a JavaDoubleClickSelector.
+ * Create a PHPDoubleClickSelector.
*/
public PHPDoubleClickSelector() {
super();
**********************************************************************/
package net.sourceforge.phpeclipse.phpeditor.php;
+import java.io.CharArrayWriter;
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.jface.text.rules.EndOfLineRule;
+
import org.eclipse.jface.text.rules.ICharacterScanner;
import org.eclipse.jface.text.rules.IPredicateRule;
-import org.eclipse.jface.text.rules.IRule;
import org.eclipse.jface.text.rules.IToken;
import org.eclipse.jface.text.rules.IWordDetector;
import org.eclipse.jface.text.rules.MultiLineRule;
import org.eclipse.jface.text.rules.RuleBasedPartitionScanner;
-import org.eclipse.jface.text.rules.RuleBasedScanner;
-import org.eclipse.jface.text.rules.SingleLineRule;
import org.eclipse.jface.text.rules.Token;
import org.eclipse.jface.text.rules.WordRule;
*/
public class PHPPartitionScanner extends RuleBasedPartitionScanner {
- private final static String SKIP = "__skip"; //$NON-NLS-1$
- public final static String JAVA_MULTILINE_COMMENT = "__html_multiline_comment"; //$NON-NLS-1$
- // public final static String JAVA_DOC= "__java_javadoc"; //$NON-NLS-1$
- public final static String PHP = "__php";
-
- public class PHPMultiLineRule extends MultiLineRule {
-
- public PHPMultiLineRule(String startSequence, String endSequence, IToken token) {
- super(startSequence, endSequence, token);
- }
-
- public PHPMultiLineRule(String startSequence, String endSequence, IToken token, char escapeCharacter) {
- super(startSequence, endSequence, token, escapeCharacter);
- }
-
- protected boolean endSequenceDetected(ICharacterScanner scanner) {
- int c;
- int c2;
-
- boolean lineCommentMode = false;
- boolean multiLineCommentMode = false;
- boolean stringMode = false;
-
- char[][] delimiters = scanner.getLegalLineDelimiters();
- while ((c = scanner.read()) != ICharacterScanner.EOF) {
- if (c == '\n') {
- lineCommentMode = false;
- // read until end of line
- } else if (c == '#') {
- // read until end of line
- lineCommentMode = true;
- continue;
- } else if (c == '/') {
- c2 = scanner.read();
- if (c2 == '/') {
- lineCommentMode = true;
+ private final static String SKIP = "__skip"; //$NON-NLS-1$
+ public final static String JAVA_MULTILINE_COMMENT = "__html_multiline_comment"; //$NON-NLS-1$
+ // public final static String JAVA_DOC= "__java_javadoc"; //$NON-NLS-1$
+ public final static String PHP = "__php";
+ private StringBuffer test;
+ public class PHPMultiLineRule extends MultiLineRule {
+
+ public PHPMultiLineRule(String startSequence, String endSequence, IToken token) {
+ super(startSequence, endSequence, token);
+ }
+
+ public PHPMultiLineRule(String startSequence, String endSequence, IToken token, char escapeCharacter) {
+ super(startSequence, endSequence, token, escapeCharacter);
+ }
+
+ protected boolean endSequenceDetected(ICharacterScanner scanner) {
+ int c;
+ int c2;
+
+ boolean lineCommentMode = false;
+ boolean multiLineCommentMode = false;
+ boolean stringMode = false;
+
+ char[][] delimiters = scanner.getLegalLineDelimiters();
+ while ((c = scanner.read()) != ICharacterScanner.EOF) {
+ if (lineCommentMode && (c == '\n')) {
+ lineCommentMode = false;
+ // read until end of line
+ } else if ((!stringMode) && (c == '#')) {
+ // read until end of line
+ lineCommentMode = true;
+ continue;
+ } else if ((!stringMode) && (!multiLineCommentMode) && (c == '/')) {
+ c2 = scanner.read();
+ if (c2 == '/') {
+ lineCommentMode = true;
+ continue;
+ } else if (c2 == '*') {
+ multiLineCommentMode = true;
+ continue;
+ } else {
+ scanner.unread();
+ }
+ } else if (c == '*' && multiLineCommentMode) {
+ c2 = scanner.read();
+ if (c2 == '/') {
+ multiLineCommentMode = false;
+ continue;
+ } else {
+ scanner.unread();
+ }
+ } else if (c == '\\' && stringMode) {
+ c2 = scanner.read();
+ if (c2 == '"') {
continue;
- } else if(c2 == '*') {
- multiLineCommentMode = true;
- continue;
- } else {
- scanner.unread();
- }
- } else if (c == '*' && multiLineCommentMode) {
- c2 = scanner.read();
- if (c2 == '/') {
- multiLineCommentMode = false;
- continue;
- } else {
- scanner.unread();
- }
- } else if (c == '\\' && stringMode) {
- c2 = scanner.read();
- if (c2 == '"') {
- continue;
- } else {
- scanner.unread();
- }
- } else if (c == '"') {
- if (stringMode) {
- stringMode = false;
- } else {
- stringMode = true;
- }
- continue;
- }
- if (lineCommentMode || multiLineCommentMode || stringMode) {
- continue;
- }
-
- if (c == fEscapeCharacter) {
- // Skip the escaped character.
- scanner.read();
- } else if (fEndSequence.length > 0 && c == fEndSequence[0]) {
- // Check if the specified end sequence has been found.
- if (sequenceDetected(scanner, fEndSequence, true))
- return true;
- } else if (fBreaksOnEOL) {
- // Check for end of line since it can be used to terminate the pattern.
- for (int i = 0; i < delimiters.length; i++) {
- if (c == delimiters[i][0] && sequenceDetected(scanner, delimiters[i], false))
- return true;
- }
- }
- }
- scanner.unread();
- return true;
- }
- }
- /**
- * Detector for empty comments.
- */
- static class EmptyCommentDetector implements IWordDetector {
-
- /* (non-Javadoc)
- * Method declared on IWordDetector
- */
- public boolean isWordStart(char c) {
- return (c == '/');
- }
-
- /* (non-Javadoc)
- * Method declared on IWordDetector
- */
- public boolean isWordPart(char c) {
- return (c == '*' || c == '/');
- }
- };
-
- /**
- *
- */
- static class WordPredicateRule extends WordRule implements IPredicateRule {
-
- private IToken fSuccessToken;
-
- public WordPredicateRule(IToken successToken) {
- super(new EmptyCommentDetector());
- fSuccessToken = successToken;
- addWord("/**/", fSuccessToken);
- }
-
- /*
- * @see org.eclipse.jface.text.rules.IPredicateRule#evaluate(ICharacterScanner, boolean)
- */
- public IToken evaluate(ICharacterScanner scanner, boolean resume) {
- return super.evaluate(scanner);
- }
-
- /*
- * @see org.eclipse.jface.text.rules.IPredicateRule#getSuccessToken()
- */
- public IToken getSuccessToken() {
- return fSuccessToken;
- }
- };
-
- /**
- * Creates the partitioner and sets up the appropriate rules.
- */
- public PHPPartitionScanner() {
- super();
-
- // IToken javaDoc= new Token(JAVA_DOC);
- IToken comment = new Token(JAVA_MULTILINE_COMMENT);
- IToken php = new Token(PHP);
-
- List rules = new ArrayList();
-
- // Add rule for single line comments.
- // rules.add(new EndOfLineRule("//", Token.UNDEFINED));
-
- // Add rule for strings and character constants.
- // rules.add(new SingleLineRule("\"", "\"", Token.UNDEFINED, '\\'));
- // rules.add(new SingleLineRule("'", "'", Token.UNDEFINED, '\\'));
-
- // Add special case word rule.
- rules.add(new WordPredicateRule(comment));
-
- // Add rules for multi-line comments and javadoc.
- //rules.add(new MultiLineRule("/**", "*/", javaDoc));
- rules.add(new MultiLineRule("<!--", "-->", comment));
- rules.add(new PHPMultiLineRule("<? ", "?>", php));
- rules.add(new PHPMultiLineRule("<?php", "?>", php));
- rules.add(new PHPMultiLineRule("<?PHP", "?>", php));
- //Add rule for processing instructions
-
- IPredicateRule[] result = new IPredicateRule[rules.size()];
- rules.toArray(result);
- setPredicateRules(result);
- }
+ } else {
+ scanner.unread();
+ }
+ } else if ((!lineCommentMode) && (!multiLineCommentMode) && (c == '"')) {
+ if (stringMode) {
+ stringMode = false;
+ } else {
+ stringMode = true;
+ }
+ continue;
+ }
+ if (lineCommentMode || multiLineCommentMode || stringMode) {
+ continue;
+ }
+
+ if (c == fEscapeCharacter) {
+ // Skip the escaped character.
+ scanner.read();
+ } else if (fEndSequence.length > 0 && c == fEndSequence[0]) {
+ // Check if the specified end sequence has been found.
+ if (sequenceDetected(scanner, fEndSequence, true))
+ return true;
+ } else if (fBreaksOnEOL) {
+ // Check for end of line since it can be used to terminate the pattern.
+ for (int i = 0; i < delimiters.length; i++) {
+ if (c == delimiters[i][0] && sequenceDetected(scanner, delimiters[i], false))
+ return true;
+ }
+ }
+ }
+ scanner.unread();
+ return true;
+ }
+ }
+ /**
+ * Detector for empty comments.
+ */
+ static class EmptyCommentDetector implements IWordDetector {
+
+ /* (non-Javadoc)
+ * Method declared on IWordDetector
+ */
+ public boolean isWordStart(char c) {
+ return (c == '/');
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IWordDetector
+ */
+ public boolean isWordPart(char c) {
+ return (c == '*' || c == '/');
+ }
+ };
+
+ /**
+ *
+ */
+ static class WordPredicateRule extends WordRule implements IPredicateRule {
+
+ private IToken fSuccessToken;
+
+ public WordPredicateRule(IToken successToken) {
+ super(new EmptyCommentDetector());
+ fSuccessToken = successToken;
+ addWord("/**/", fSuccessToken);
+ }
+
+ /*
+ * @see org.eclipse.jface.text.rules.IPredicateRule#evaluate(ICharacterScanner, boolean)
+ */
+ public IToken evaluate(ICharacterScanner scanner, boolean resume) {
+ return super.evaluate(scanner);
+ }
+
+ /*
+ * @see org.eclipse.jface.text.rules.IPredicateRule#getSuccessToken()
+ */
+ public IToken getSuccessToken() {
+ return fSuccessToken;
+ }
+ };
+
+ /**
+ * Creates the partitioner and sets up the appropriate rules.
+ */
+ public PHPPartitionScanner() {
+ super();
+
+ // IToken javaDoc= new Token(JAVA_DOC);
+ IToken comment = new Token(JAVA_MULTILINE_COMMENT);
+ IToken php = new Token(PHP);
+
+ List rules = new ArrayList();
+
+ // Add rule for single line comments.
+ // rules.add(new EndOfLineRule("//", Token.UNDEFINED));
+
+ // Add rule for strings and character constants.
+ // rules.add(new SingleLineRule("\"", "\"", Token.UNDEFINED, '\\'));
+ // rules.add(new SingleLineRule("'", "'", Token.UNDEFINED, '\\'));
+
+ // Add special case word rule.
+ rules.add(new WordPredicateRule(comment));
+
+ // Add rules for multi-line comments and javadoc.
+ //rules.add(new MultiLineRule("/**", "*/", javaDoc));
+ rules.add(new MultiLineRule("<!--", "-->", comment));
+ rules.add(new PHPMultiLineRule("<?\r", "?>", php));
+ rules.add(new PHPMultiLineRule("<?\n", "?>", php));
+ rules.add(new PHPMultiLineRule("<?\t", "?>", php));
+ rules.add(new PHPMultiLineRule("<? ", "?>", php));
+ rules.add(new PHPMultiLineRule("<?php", "?>", php));
+ rules.add(new PHPMultiLineRule("<?PHP", "?>", php));
+ //Add rule for processing instructions
+
+ IPredicateRule[] result = new IPredicateRule[rules.size()];
+ rules.toArray(result);
+ setPredicateRules(result);
+ }
}