fix file information display
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 30 May 2008 15:35:21 +0000 (17:35 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 30 May 2008 15:35:21 +0000 (17:35 +0200)
src/net/pterodactylus/jsite/gui/FileManager.java

index bc903e6..e827008 100644 (file)
@@ -35,6 +35,7 @@ import java.awt.event.MouseEvent;
 import java.awt.event.MouseListener;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
+import java.io.File;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -433,6 +434,9 @@ public class FileManager extends JDialog implements I18nable, ActionListener, Tr
         */
        public void valueChanged(TreeSelectionEvent treeSelectionEvent) {
                TreePath[] selectedPaths = fileTree.getSelectionPaths();
+               filePathTextField.setText("");
+               fileNameTextField.setText("");
+               fileSizeTextField.setText("");
                if ((selectedPaths != null) && (selectedPaths.length == 1)) {
                        Object lastPathComponent = selectedPaths[0].getLastPathComponent();
                        if (!(lastPathComponent instanceof ProjectFileWrapper)) {
@@ -442,6 +446,13 @@ public class FileManager extends JDialog implements I18nable, ActionListener, Tr
                        ProjectFileWrapper projectFileWrapper = (ProjectFileWrapper) lastPathComponent;
                        ProjectFile projectFile = projectFileWrapper.getProjectFile();
                        if (projectFile.isFile()) {
+                               String completePath = projectFile.getCompletePath();
+                               int lastSeparator = completePath.lastIndexOf(File.separatorChar);
+                               if (lastSeparator == -1) {
+                                       filePathTextField.setText("");
+                               } else {
+                                       filePathTextField.setText(completePath.substring(0, lastSeparator));
+                               }
                                fileNameTextField.setText(projectFile.getName());
                                fileSizeTextField.setText(String.valueOf(projectFile.getSize()));
                        }