expanderClass="net.sourceforge.phpdt.externaltools.variable.WorkspaceExpander">
</variable>
<variable
+ tag="last_php_file_loc"
+ description="Expands to the localhost preference settings."
+ expanderClass="net.sourceforge.phpdt.externaltools.variable.LastPHPFileExpander">
+ </variable>
+ <variable
tag="localhost_loc"
description="Expands to the localhost preference settings."
expanderClass="net.sourceforge.phpdt.externaltools.variable.LocalhostExpander">
--- /dev/null
+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
+ * <p>
+ * This class is not intended to be extended by clients.
+ * </p>
+ */
+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;
+ }
+
+}
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;
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.
private ImageDescriptorRegistry fImageDescriptorRegistry;
private PHPDocumentProvider fCompilationUnitDocumentProvider;
- private ITextEditor fTextEditor = null;
+ private IFile fLastEditorFile = null;
private JavaTextTools fJavaTextTools;
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
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;
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;
// fTogglePresentation = new PresentationAction();
fParserAction = PHPParserAction.getInstance();
-
+
if (SWT.getPlatform().equals("win32")) {
fShowExternalPreviewAction = ShowExternalPreviewAction.getInstance();
}
// 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();