From: David ‘Bombe’ Roden Date: Fri, 30 May 2008 15:35:21 +0000 (+0200) Subject: fix file information display X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=c7defb27215d24fb5609ce1a41ef1414b3333929;p=jSite2.git fix file information display --- 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())); }