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
* This class is not intended to be extended by clients.
* </p>
*/
-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 <code>null</code>.
+ *
+ * @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;
}
}
--- /dev/null
+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
+ * <p>
+ * This class is not intended to be extended by clients.
+ * </p>
+ */
+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 <code>null</code>.
+ *
+ * @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;
+ }
+
+}
<template name="&thorn" description="thorn" context="html" enabled="true">&thorn;</template>
<template name="&yuml" description="yuml" context="html" enabled="true">&yuml;</template>
-
-
+ <template name="#00FFFF" description="Aqua (Color Code)" context="html" enabled="true">#00FFFF</template>
<template name="#000000" description="Black (Color Code)" context="html" enabled="true">#000000</template>
<template name="#0000FF" description="Blue (Color Code)" context="html" enabled="true">#0000FF</template>
<template name="#A52A2A" description="Brown (Color Code)" context="html" enabled="true">#A52A2A</template>
<template name="#00FFFF" description="Cyan (Color Code)" context="html" enabled="true">#00FFFF</template>
+ <template name="#FF00FF" description="Fuchsia (Color Code)" context="html" enabled="true">#FF00FF</template>
<template name="#FFD700" description="Gold (Color Code)" context="html" enabled="true">#FFD700</template>
- <template name="#808080" description="Grey (Color Code)" context="html" enabled="true">#808080</template>
+ <template name="#808080" description="Gray (Color Code)" context="html" enabled="true">#808080</template>
<template name="#008000" description="Green (Color Code)" context="html" enabled="true">#008000</template>
+ <template name="#00FF00" description="Lime (Color Code)" context="html" enabled="true">#00FF00</template>
<template name="#FF00FF" description="Magenta (Color Code)" context="html" enabled="true">#FF00FF</template>
+ <template name="#800000" description="Maroon (Color Code)" context="html" enabled="true">#800000</template>
+ <template name="#000080" description="Navy (Color Code)" context="html" enabled="true">#000080</template>
+ <template name="#808000" description="Olive (Color Code)" context="html" enabled="true">#808000</template>
<template name="#FFA500" description="Orange (Color Code)" context="html" enabled="true">#FFA500</template>
<template name="#FFC0CB" description="Pink (Color Code)" context="html" enabled="true">#FFC0CB</template>
<template name="#800080" description="Purple (Color Code)" context="html" enabled="true">#800080</template>
<template name="#FF0000" description="Red (Color Code)" context="html" enabled="true">#FF0000</template>
<template name="#C0C0C0" description="Silver (Color Code)" context="html" enabled="true">#C0C0C0</template>
+ <template name="#008080" description="Teal (Color Code)" context="html" enabled="true">#008080</template>
<template name="#FFFFFF" description="White (Color Code)" context="html" enabled="true">#FFFFFF</template>
<template name="#FFFF00" description="Yellow (Color Code)" context="html" enabled="true">#FFFF00</template>
+ <template name="Aqua" description="Aqua (Color Code)" context="html" enabled="true">#00FFFF</template>
<template name="Black" description="Black (Color Code)" context="html" enabled="true">#000000</template>
<template name="Blue" description="Blue (Color Code)" context="html" enabled="true">#0000FF</template>
<template name="Brown" description="Brown (Color Code)" context="html" enabled="true">#A52A2A</template>
<template name="Cyan" description="Cyan (Color Code)" context="html" enabled="true">#00FFFF</template>
+ <template name="Fuchsia" description="Fuchsia (Color Code)" context="html" enabled="true">#FF00FF</template>
<template name="Gold" description="Gold (Color Code)" context="html" enabled="true">#FFD700</template>
- <template name="Grey" description="Grey (Color Code)" context="html" enabled="true">#808080</template>
+ <template name="Gray" description="Gray (Color Code)" context="html" enabled="true">#808080</template>
<template name="Green" description="Green (Color Code)" context="html" enabled="true">#008000</template>
+ <template name="Lime" description="Lime (Color Code)" context="html" enabled="true">#00FF00</template>
<template name="Magenta" description="Magenta (Color Code)" context="html" enabled="true">#FF00FF</template>
+ <template name="Maroon" description="Maroon (Color Code)" context="html" enabled="true">#800000</template>
+ <template name="Navy" description="Mavy (Color Code)" context="html" enabled="true">#000080</template>
+ <template name="Olive" description="Olive (Color Code)" context="html" enabled="true">#808000</template>
<template name="Orange" description="Orange (Color Code)" context="html" enabled="true">#FFA500</template>
<template name="Pink" description="Pink (Color Code)" context="html" enabled="true">#FFC0CB</template>
<template name="Purple" description="Purple (Color Code)" context="html" enabled="true">#800080</template>
<template name="Red" description="Red (Color Code)" context="html" enabled="true">#FF0000</template>
<template name="Silver" description="Silver (Color Code)" context="html" enabled="true">#C0C0C0</template>
+ <template name="Teal" description="Teal (Color Code)" context="html" enabled="true">#008080</template>
<template name="White" description="White (Color Code)" context="html" enabled="true">#FFFFFF</template>
<template name="Yelow" description="Yellow (Color Code)" context="html" enabled="true">#FFFF00</template>