public void locationChanging(LocationEvent e) {
// Change the location field's text to the folder being changed, only if the folder change was not initiated
// by the location field (to preserve the path entered by the user while the folder is being changed)
if(!folderChangeInitiatedByLocationField) {
FileURL folderURL = e.getFolderURL();
String locationText;
if(folderURL.getScheme().equals(FileProtocols.FILE)) {
// Do not display the URL's scheme & host for local files
if (FileURL.LOCALHOST.equals(folderURL.getHost())) {
locationText = folderURL.getPath();
// Under for OSes with 'root drives' (Windows, OS/2), remove the leading '/' character
if(LocalFile.hasRootDrives())
locationText = PathUtils.removeLeadingSeparator(locationText, "/");
}
// For network files with FILE scheme display the URL in UNC format
else {
locationText = "\\\\" + folderURL.getHost() + folderURL.getPath().replace('/', '\\');
if(!locationText.endsWith(UNCFile.SEPARATOR))
locationText += UNCFile.SEPARATOR;
}
}
// Display the full URL for protocols other than 'file'
else {
locationText = folderURL.toString(false);
}
setText(locationText);
}
// Disable component until the folder has been changed, cancelled or failed.