fix file information display
[jSite2.git] / src / net / pterodactylus / jsite / gui / FileManager.java
index 6bd83fc..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;
@@ -279,7 +280,7 @@ public class FileManager extends JDialog implements I18nable, ActionListener, Tr
                fileTree.addMouseListener(this);
                fileTree.setCellRenderer(fileCellRenderer);
                fileTreePanel.add(fileScrollPane = new JScrollPane(fileTree), BorderLayout.CENTER);
-               fileScrollPane.setPreferredSize(new Dimension(250, 400));
+               fileScrollPane.setPreferredSize(new Dimension(200, 350));
 
                projectFilesLabel = new I18nLabel("fileManager.label.projectFiles", fileTree);
                JPanel projectFilesLabelPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0));
@@ -294,6 +295,7 @@ public class FileManager extends JDialog implements I18nable, ActionListener, Tr
                JPanel propertiesPanel = new JPanel(new GridBagLayout());
                rightPanel.add(propertiesPanel, BorderLayout.CENTER);
                propertiesPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEtchedBorder(), BorderFactory.createEmptyBorder(12, 12, 12, 12)));
+               propertiesPanel.setPreferredSize(new Dimension(400, 350));
 
                filePropertiesLabel = new I18nLabel("fileManager.label.fileProperties");
                filePropertiesLabel.setFont(filePropertiesLabel.getFont().deriveFont(Font.BOLD));
@@ -432,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)) {
@@ -441,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()));
                        }
@@ -749,8 +761,7 @@ public class FileManager extends JDialog implements I18nable, ActionListener, Tr
                                return true;
                        }
                        ProjectFileWrapper projectFileWrapper = (ProjectFileWrapper) node;
-                       ProjectFile projectFile = projectFileWrapper.getProjectFile();
-                       return projectFile.getFiles().isEmpty();
+                       return projectFileWrapper.getProjectFile().isFile();
                }
 
                /**