File Browser: at startup the up-arrow was slightly truncated 27/8927/3
Calixte DENIZET [Tue, 4 Sep 2012 09:17:30 +0000 (11:17 +0200)]
Change-Id: Ib9b442295cf71d19824b9423e7262d98e51cb25d

scilab/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/ScilabFileBrowserComponent.java
scilab/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/ScilabTreeTableCellRenderer.java

index 4fcd17a..409670a 100644 (file)
@@ -50,7 +50,6 @@ public class ScilabFileBrowserComponent extends JPanel {
         add(new ScilabFileSelectorFilter(stt), BorderLayout.PAGE_END);
 
         JScrollPane jsp = new JScrollPane(stt);
-        jsp.getViewport().setScrollMode(JViewport.BACKINGSTORE_SCROLL_MODE);
         jsp.getViewport().setBackground(bg);
         add(jsp, BorderLayout.CENTER);
     }
index 4199327..2078e4d 100644 (file)
@@ -53,43 +53,43 @@ public class ScilabTreeTableCellRenderer extends JTree implements TableCellRende
         this.table = table;
         DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer() {
 
-            public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
-                FileNode fn = (FileNode) value;
-                super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
-                if (leaf) {
-                    if (fn instanceof ScilabFileBrowserModel.ParentNode) {
-                        this.setLeafIcon(FileUtils.getUpDirIcon());
+                public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
+                    FileNode fn = (FileNode) value;
+                    if (leaf) {
+                        if (fn instanceof ScilabFileBrowserModel.ParentNode) {
+                            this.setLeafIcon(FileUtils.getUpDirIcon());
+                        } else {
+                            this.setLeafIcon(fn.getIcon());
+                        }
+                    } else if (fn.isUserHome()) {
+                        this.setClosedIcon(FileUtils.getClosedUserHomeIcon());
+                        this.setOpenIcon(FileUtils.getOpenUserHomeIcon());
+                    } else if (fn.isSCI()) {
+                        this.setClosedIcon(FileUtils.getSCIIcon());
+                        this.setOpenIcon(FileUtils.getOpenSCIIcon());
                     } else {
-                        this.setLeafIcon(fn.getIcon());
+                        this.setClosedIcon(FileUtils.getClosedDirIcon());
+                        this.setOpenIcon(FileUtils.getOpenDirIcon());
                     }
-                } else if (fn.isUserHome()) {
-                    this.setClosedIcon(FileUtils.getClosedUserHomeIcon());
-                    this.setOpenIcon(FileUtils.getOpenUserHomeIcon());
-                } else if (fn.isSCI()) {
-                    this.setClosedIcon(FileUtils.getSCIIcon());
-                    this.setOpenIcon(FileUtils.getOpenSCIIcon());
-                } else {
-                    this.setClosedIcon(FileUtils.getClosedDirIcon());
-                    this.setOpenIcon(FileUtils.getOpenDirIcon());
-                }
+                    super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
 
-                return this;
-            }
-        };
+                    return this;
+                }
+            };
 
         /* Force the JTable and JTree to share their row selection models.
            And let the table to handle the selection rather than the tree; */
         setSelectionModel(new DefaultTreeSelectionModel() {
-            {
-                ScilabTreeTableCellRenderer.this.table.setSelectionModel(listSelectionModel);
-            }
+                    {
+                        ScilabTreeTableCellRenderer.this.table.setSelectionModel(listSelectionModel);
+                    }
 
-            public void setSelectionPaths(TreePath[] pPaths) { }
+                public void setSelectionPaths(TreePath[] pPaths) { }
 
-            public void addSelectionPaths(TreePath[] paths) { }
+                public void addSelectionPaths(TreePath[] paths) { }
 
-            public void removeSelectionPaths(TreePath[] paths) { }
-        });
+                public void removeSelectionPaths(TreePath[] paths) { }
+            });
 
         setCellRenderer(renderer);
         setRootVisible(true);
@@ -99,49 +99,49 @@ public class ScilabTreeTableCellRenderer extends JTree implements TableCellRende
         setToggleClickCount(0);
 
         addMouseListener(new MouseAdapter() {
-            public void mousePressed(MouseEvent e) {
-                int selRow = getRowForLocation(e.getX(), e.getY());
-                TreePath selPath = getPathForLocation(e.getX(), e.getY());
-                if (selRow != -1) {
-                    switch (e.getClickCount()) {
+                public void mousePressed(MouseEvent e) {
+                    int selRow = getRowForLocation(e.getX(), e.getY());
+                    TreePath selPath = getPathForLocation(e.getX(), e.getY());
+                    if (selRow != -1) {
+                        switch (e.getClickCount()) {
                         case 1 :
                             /*int sel = SwingScilabTreeTable.this.getSelectedRow();
-                                  System.out.println(sel+":::"+selRow+":::"+isEditable());
-                                  if (sel == selRow) {
-                                  System.out.println(getCellEditor().getTreeCellEditorComponent(ScilabTreeTableCellRenderer.this, getCellEditor().getCellEditorValue(), true, false, true, selRow));
-                                  }
-                                  e.consume();*/
+                              System.out.println(sel+":::"+selRow+":::"+isEditable());
+                              if (sel == selRow) {
+                              System.out.println(getCellEditor().getTreeCellEditorComponent(ScilabTreeTableCellRenderer.this, getCellEditor().getCellEditorValue(), true, false, true, selRow));
+                              }
+                              e.consume();*/
                             break;
                         case 2:
                             ((CommonCallBack) ScilabTreeTableCellRenderer.this.table.getActionMap().get("validate")).callBack();
                             e.consume();
+                        }
                     }
                 }
-            }
 
-            public void mouseReleased(MouseEvent e) { }
-        });
+                public void mouseReleased(MouseEvent e) { }
+            });
 
         addTreeWillExpandListener(new TreeWillExpandListener() {
-            public void treeWillCollapse(TreeExpansionEvent event) { }
+                public void treeWillCollapse(TreeExpansionEvent event) { }
 
-            public void treeWillExpand(TreeExpansionEvent event) {
-                Container win = SwingUtilities.getAncestorOfClass(SwingScilabWindow.class, ScilabTreeTableCellRenderer.this.table);
-                if (win != null) {
-                    win.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+                public void treeWillExpand(TreeExpansionEvent event) {
+                    Container win = SwingUtilities.getAncestorOfClass(SwingScilabWindow.class, ScilabTreeTableCellRenderer.this.table);
+                    if (win != null) {
+                        win.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+                    }
                 }
-            }
-        });
+            });
         addTreeExpansionListener(new TreeExpansionListener() {
-            public void treeCollapsed(TreeExpansionEvent event) { }
+                public void treeCollapsed(TreeExpansionEvent event) { }
 
-            public void treeExpanded(TreeExpansionEvent event) {
-                Container win = SwingUtilities.getAncestorOfClass(SwingScilabWindow.class, ScilabTreeTableCellRenderer.this.table);
-                if (win != null) {
-                    win.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+                public void treeExpanded(TreeExpansionEvent event) {
+                    Container win = SwingUtilities.getAncestorOfClass(SwingScilabWindow.class, ScilabTreeTableCellRenderer.this.table);
+                    if (win != null) {
+                        win.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+                    }
                 }
-            }
-        });
+            });
     }
 
     /**