From: khartlage Date: Sun, 25 May 2003 19:50:29 +0000 (+0000) Subject: first version of external tools X-Git-Url: http://secure.phpeclipse.com first version of external tools --- diff --git a/net.sourceforge.phpeclipse/plugin.xml b/net.sourceforge.phpeclipse/plugin.xml index f31066f..c6dbf95 100644 --- a/net.sourceforge.phpeclipse/plugin.xml +++ b/net.sourceforge.phpeclipse/plugin.xml @@ -918,10 +918,15 @@ Temporarily replaced until errors can be ironed out... + + 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 index 0801ca4..28c1f9b 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/variable/LastPHPFileExpander.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/variable/LastPHPFileExpander.java @@ -1,8 +1,6 @@ package net.sourceforge.phpdt.externaltools.variable; -import net.sourceforge.phpeclipse.PHPeclipsePlugin; - -import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.IPath; /** * Expands a variable into the last opened PHP file @@ -10,15 +8,27 @@ import org.eclipse.core.resources.IFile; * This class is not intended to be extended by clients. *

*/ -public class LastPHPFileExpander implements IVariableTextExpander { +public class LastPHPFileExpander extends ResourceExpander { //implements IVariableTextExpander { + + /** + * Create an instance + */ + public LastPHPFileExpander() { + super(); + } + /** + * Returns a string representation of the path to a file or directory + * for the given variable tag and value or null. + * + * @see IVariableTextExpander#getText(String, String, ExpandVariableContext) + */ public String getText(String varTag, String varValue, ExpandVariableContext context) { - IFile file = PHPeclipsePlugin.getDefault().getLastEditorFile(); - String fileLocation =""; - if (file != null) { - fileLocation = file.getLocation().toString(); + IPath path = getPath(varTag, varValue, context); + if (path != null) { + return path.toString(); } - return fileLocation; + return null; } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/variable/LastPHPUrlExpander.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/variable/LastPHPUrlExpander.java new file mode 100644 index 0000000..0ee13f2 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/variable/LastPHPUrlExpander.java @@ -0,0 +1,53 @@ +package net.sourceforge.phpdt.externaltools.variable; + +import net.sourceforge.phpeclipse.PHPeclipsePlugin; + +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IPath; +import org.eclipse.jface.preference.IPreferenceStore; + +/** + * Expands a variable into the last opened PHP file + *

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

+ */ +public class LastPHPUrlExpander extends ResourceExpander { //implements IVariableTextExpander { + + /** + * Create an instance + */ + public LastPHPUrlExpander() { + super(); + } + + /** + * Returns a string representation of the path to a file or directory + * for the given variable tag and value or null. + * + * @see IVariableTextExpander#getText(String, String, ExpandVariableContext) + */ + public String getText(String varTag, String varValue, ExpandVariableContext context) { + IPath path = getPath(varTag, varValue, context); + if (path != null) { + IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); + String localhostURL = path.toString(); + String lowerCaseFileName = localhostURL.toLowerCase(); + // fileName = "http://localhost"+fileName.replaceAll("c:", ""); + String documentRoot = store.getString(PHPeclipsePlugin.DOCUMENTROOT_PREF); + documentRoot = documentRoot.replace('\\', '/'); + documentRoot = documentRoot.toLowerCase(); + + if (lowerCaseFileName.startsWith(documentRoot)) { + localhostURL = localhostURL.substring(documentRoot.length()); + } else { + return localhostURL; + } + + return store.getString(PHPeclipsePlugin.LOCALHOST_PREF) + localhostURL.replaceAll(documentRoot, ""); + + } + return null; + } + +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/default-templates.xml b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/default-templates.xml index e4e9d43..1c6ccfb 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/default-templates.xml +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/default-templates.xml @@ -395,37 +395,49 @@ ${cursor} - - + + - + + + + + + + + - + + + + + +