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
16 // IVariableTextExpander {
21 public UrlExpander() {
26 * Returns a string representation to a localhost/documentRoot URL for the
27 * given variable tag and value or <code>null</code>.
29 * @see IVariableTextExpander#getText(String, String, ExpandVariableContext)
31 public String getText(String varTag, String varValue,
32 ExpandVariableContext context) {
33 IPath path = getPath(varTag, varValue, context);
35 IPreferenceStore store = ExternalToolsPlugin.getDefault()
36 .getPreferenceStore();
37 String localhostURL = path.toString();
38 String lowerCaseFileName = localhostURL.toLowerCase();
39 String documentRoot = store.getString(WebUI.PHP_DOCUMENTROOT_PREF);
40 documentRoot = documentRoot.replace('\\', '/');
41 documentRoot = documentRoot.toLowerCase();
43 if (lowerCaseFileName.startsWith(documentRoot)) {
44 localhostURL = localhostURL.substring(documentRoot.length());
45 localhostURL = store.getString(WebUI.PHP_LOCALHOST_PREF)
50 return "<no file selected>";