X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnet%2Fpterodactylus%2Fjsite%2Fgui%2FFileManager.java;h=e827008a084acebe04e9398d8b4f9d9691ce39cc;hb=c7defb27215d24fb5609ce1a41ef1414b3333929;hp=bc903e6d0f7dab9d674d1f262d8aa67d7452d6a2;hpb=022e29eabeac96f1b6c10ce6120ef92a5f7aa9dc;p=jSite2.git 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())); }