From c7defb27215d24fb5609ce1a41ef1414b3333929 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 30 May 2008 17:35:21 +0200 Subject: [PATCH] fix file information display --- src/net/pterodactylus/jsite/gui/FileManager.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/net/pterodactylus/jsite/gui/FileManager.java b/src/net/pterodactylus/jsite/gui/FileManager.java index bc903e6..e827008 100644 --- a/src/net/pterodactylus/jsite/gui/FileManager.java +++ b/src/net/pterodactylus/jsite/gui/FileManager.java @@ -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())); } -- 2.7.4