From 930ddf7d085b681d1280423c3e7656f786e567a7 Mon Sep 17 00:00:00 2001 From: khartlage Date: Sun, 25 May 2003 17:57:49 +0000 Subject: [PATCH] first version of external tools --- net.sourceforge.phpeclipse/plugin.xml | 5 ++++ .../variable/LastPHPFileExpander.java | 24 ++++++++++++++++++++ .../sourceforge/phpeclipse/PHPeclipsePlugin.java | 12 +++++----- .../phpeclipse/phpeditor/PHPActionContributor.java | 17 ++++++++++--- 4 files changed, 48 insertions(+), 10 deletions(-) create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/variable/LastPHPFileExpander.java diff --git a/net.sourceforge.phpeclipse/plugin.xml b/net.sourceforge.phpeclipse/plugin.xml index 58d7d90..f31066f 100644 --- a/net.sourceforge.phpeclipse/plugin.xml +++ b/net.sourceforge.phpeclipse/plugin.xml @@ -917,6 +917,11 @@ Temporarily replaced until errors can be ironed out... expanderClass="net.sourceforge.phpdt.externaltools.variable.WorkspaceExpander"> + + diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/variable/LastPHPFileExpander.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/variable/LastPHPFileExpander.java new file mode 100644 index 0000000..0801ca4 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/variable/LastPHPFileExpander.java @@ -0,0 +1,24 @@ +package net.sourceforge.phpdt.externaltools.variable; + +import net.sourceforge.phpeclipse.PHPeclipsePlugin; + +import org.eclipse.core.resources.IFile; + +/** + * Expands a variable into the last opened PHP file + *

+ * This class is not intended to be extended by clients. + *

+ */ +public class LastPHPFileExpander implements IVariableTextExpander { + + public String getText(String varTag, String varValue, ExpandVariableContext context) { + IFile file = PHPeclipsePlugin.getDefault().getLastEditorFile(); + String fileLocation =""; + if (file != null) { + fileLocation = file.getLocation().toString(); + } + return fileLocation; + } + +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java index e54b1a7..d0b9d99 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java @@ -26,6 +26,7 @@ import net.sourceforge.phpeclipse.resourcesview.PHPElementAdapterFactory; import net.sourceforge.phpeclipse.resourcesview.ResourceAdapterFactory; import org.eclipse.core.boot.BootLoader; +import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.ResourcesPlugin; @@ -44,7 +45,6 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.eclipse.ui.texteditor.ITextEditor; /** * The main plugin class to be used in the desktop. @@ -87,7 +87,7 @@ public class PHPeclipsePlugin private ImageDescriptorRegistry fImageDescriptorRegistry; private PHPDocumentProvider fCompilationUnitDocumentProvider; - private ITextEditor fTextEditor = null; + private IFile fLastEditorFile = null; private JavaTextTools fJavaTextTools; @@ -477,11 +477,11 @@ public class PHPeclipsePlugin ColorManager.getDefault().dispose(); } - public void setTextEditor(ITextEditor textEditor) { - this.fTextEditor = textEditor; + public void setLastEditorFile(IFile textEditor) { + this.fLastEditorFile = textEditor; } - public ITextEditor getTextEditor() { - return fTextEditor; + public IFile getLastEditorFile() { + return fLastEditorFile; } } \ No newline at end of file diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPActionContributor.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPActionContributor.java index 5fa5d64..501813f 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPActionContributor.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPActionContributor.java @@ -21,6 +21,7 @@ import net.sourceforge.phpdt.ui.actions.GotoMatchingBracketAction; import net.sourceforge.phpdt.ui.actions.PHPdtActionConstants; import net.sourceforge.phpeclipse.PHPeclipsePlugin; +import org.eclipse.core.resources.IFile; import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IToolBarManager; @@ -28,7 +29,9 @@ import org.eclipse.jface.action.Separator; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.swt.SWT; import org.eclipse.ui.IActionBars; +import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IFileEditorInput; import org.eclipse.ui.IWorkbenchActionConstants; import org.eclipse.ui.actions.ActionGroup; import org.eclipse.ui.actions.RetargetAction; @@ -78,7 +81,7 @@ public class PHPActionContributor extends BasicTextEditorActionContributor { // fTogglePresentation = new PresentationAction(); fParserAction = PHPParserAction.getInstance(); - + if (SWT.getPlatform().equals("win32")) { fShowExternalPreviewAction = ShowExternalPreviewAction.getInstance(); } @@ -179,11 +182,17 @@ public class PHPActionContributor extends BasicTextEditorActionContributor { // fTogglePresentation.setEditor(editor); // fTogglePresentation.update(); - PHPeclipsePlugin.getDefault().setTextEditor(textEditor); + IFile file = null; + IEditorInput editorInput = textEditor.getEditorInput(); + + if (editorInput instanceof IFileEditorInput) { + file = ((IFileEditorInput) editorInput).getFile(); + } + + PHPeclipsePlugin.getDefault().setLastEditorFile(file); fParserAction.setEditor(textEditor); fParserAction.update(); - if (SWT.getPlatform().equals("win32") && - textEditor instanceof AbstractTextEditor) { + if (SWT.getPlatform().equals("win32") && textEditor instanceof AbstractTextEditor) { fShowExternalPreviewAction.setEditor(textEditor); fShowExternalPreviewAction.update(); IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); -- 1.7.1