1 package net.sourceforge.phpdt.externaltools.variable;
3 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
5 import org.eclipse.core.runtime.IPath;
6 import org.eclipse.jface.preference.IPreferenceStore;
9 * Expands a variable into the last opened PHP file
11 * This class is not intended to be extended by clients.
14 public class UrlExpander extends ResourceExpander { //implements IVariableTextExpander {
19 public UrlExpander() {
24 * Returns a string representation of the path to a file or directory
25 * for the given variable tag and value or <code>null</code>.
27 * @see IVariableTextExpander#getText(String, String, ExpandVariableContext)
29 public String getText(String varTag, String varValue, ExpandVariableContext context) {
30 IPath path = getPath(varTag, varValue, context);
32 IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
33 String localhostURL = path.toString();
34 String lowerCaseFileName = localhostURL.toLowerCase();
35 // fileName = "http://localhost"+fileName.replaceAll("c:", "");
36 String documentRoot = store.getString(PHPeclipsePlugin.DOCUMENTROOT_PREF);
37 documentRoot = documentRoot.replace('\\', '/');
38 documentRoot = documentRoot.toLowerCase();
40 if (lowerCaseFileName.startsWith(documentRoot)) {
41 localhostURL = localhostURL.substring(documentRoot.length());
42 localhostURL = store.getString(PHPeclipsePlugin.LOCALHOST_PREF)+ localhostURL;
43 System.out.println(localhostURL);
44 // localhostURL = store.getString(PHPeclipsePlugin.LOCALHOST_PREF)+ localhostURL;// + localhostURL.replaceAll(documentRoot, "");
48 return "<no file selected>";