* The button's icon will be the current folder's one.
*/
private void updateButton() {
AbstractFile currentFolder = folderPanel.getCurrentFolder();
String currentPath = currentFolder.getAbsolutePath();
FileURL currentURL = currentFolder.getURL();
String newLabel = null;
// String newToolTip = null;
// First tries to find a bookmark matching the specified folder
java.util.List<Bookmark> bookmarks = BookmarkManager.getBookmarks();
int nbBookmarks = bookmarks.size();
Bookmark b;
for(int i=0; i<nbBookmarks; i++) {
b = bookmarks.get(i);
if(currentPath.equals(b.getLocation())) {
// Note: if several bookmarks match current folder, the first one will be used
newLabel = b.getName();
break;
}
}
// If no bookmark matched current folder
if(newLabel == null) {
String protocol = currentURL.getScheme();
// Remote file, use the protocol's name
if(!protocol.equals(FileProtocols.FILE)) {
newLabel = protocol.toUpperCase();
}
// Local file, use volume's name
else {
// Patch for Windows UNC network paths (weakly characterized by having a host different from 'localhost'):
// display 'SMB' which is the underlying protocol
if(OsFamily.WINDOWS.isCurrent() && !FileURL.LOCALHOST.equals(currentURL.getHost())) {
newLabel = "SMB";
}
else {
// getCanonicalPath() must be avoided under Windows for the following reasons:
// a) it is not necessary, Windows doesn't have symlinks