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 a localhost/documentRoot URL string
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 to a localhost/documentRoot URL
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 String documentRoot = store.getString(PHPeclipsePlugin.DOCUMENTROOT_PREF);
36 documentRoot = documentRoot.replace('\\', '/');
37 documentRoot = documentRoot.toLowerCase();
39 if (lowerCaseFileName.startsWith(documentRoot)) {
40 localhostURL = localhostURL.substring(documentRoot.length());
41 localhostURL = store.getString(PHPeclipsePlugin.LOCALHOST_PREF)+ localhostURL;
45 return "<no file selected>";