1 package net.sourceforge.phpdt.externaltools.variable;
3 import net.sourceforge.phpeclipse.externaltools.ExternalToolsPlugin;
4 import net.sourceforge.phpeclipse.ui.WebUI;
6 import org.eclipse.core.runtime.IPath;
7 import org.eclipse.jface.preference.IPreferenceStore;
10 * Expands a variable into a localhost/documentRoot URL string
12 * This class is not intended to be extended by clients.
15 public class UrlExpander extends ResourceExpander { //implements IVariableTextExpander {
20 public UrlExpander() {
25 * Returns a string representation to a localhost/documentRoot URL
26 * for the given variable tag and value or <code>null</code>.
28 * @see IVariableTextExpander#getText(String, String, ExpandVariableContext)
30 public String getText(String varTag, String varValue, ExpandVariableContext context) {
31 IPath path = getPath(varTag, varValue, context);
33 IPreferenceStore store = ExternalToolsPlugin.getDefault().getPreferenceStore();
34 String localhostURL = path.toString();
35 String lowerCaseFileName = localhostURL.toLowerCase();
36 String documentRoot = store.getString(WebUI.PHP_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(WebUI.PHP_LOCALHOST_PREF)+ localhostURL;
46 return "<no file selected>";