From e96132853038f55cdb6e27f116852cff0e813f00 Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Sun, 22 Sep 2019 09:27:26 -0400
Subject: [PATCH] Replace on make off.

---
 cFileSystemPane.java |   85 ++++++++++++++++++++++++++----------------
 1 files changed, 53 insertions(+), 32 deletions(-)

diff --git a/cFileSystemPane.java b/cFileSystemPane.java
index ccd740b..6abec53 100644
--- a/cFileSystemPane.java
+++ b/cFileSystemPane.java
@@ -8,14 +8,17 @@
 
 import java.io.File;
 
-public class cFileSystemPane extends JPanel implements ActionListener, ItemListener, DragGestureListener,
+import grafeme.ui.*;
+
+public class cFileSystemPane extends cGridBag implements ActionListener, ItemListener, DragGestureListener,
         //DragSourceListener,
         DropTargetListener
 {
-    cTree jTree = new cTree(null);
+    cTree jTree = new cTree();
     iCallBack owner;
     
     JButton refreshButton;
+    JButton rootButton;
     JButton loadButton;
     JButton printButton;
     JButton replaceButton;
@@ -24,20 +27,20 @@
     JCheckBox stripCB;
     JCheckBox genUVCB;
 
-    JCheckBox mergeAttributesCB;
+    cCheckBox mergeAttributesCB;
     
     cFileSystemPane(iCallBack o)
     {
         owner = o;
         
-        setName("File system");
+        setName("Files");
         //System.out.println("layout : " + getLayout());
         //setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
-        setLayout(new GridBagLayout());
+        //setLayout(new GridBagLayout());
         //ToolTipManager.sharedInstance().registerComponent(jTree);
         jTree.setCellRenderer(new cFileSystemModel.Renderer());
         
-        ResetModel();
+        ResetModel(true);
 
         JScrollPane tree = new JScrollPane(jTree);
         //jTree.addTreeSelectionListener(this);
@@ -58,20 +61,29 @@
 	GridBagConstraints aConstraints = new GridBagConstraints(0,0,1,1, 1.0,1.0,
         	GridBagConstraints.EAST,GridBagConstraints.HORIZONTAL,new Insets(1,1,1,1), 0,0);
 
-	aConstraints.weighty = 0;
-	aConstraints.gridwidth = 1;
-        add(refreshButton = new JButton("Refresh"), aConstraints);
-        aConstraints.gridx += 1;
-        add(loadButton = new JButton("Load"), aConstraints);
-        aConstraints.gridx += 1;
-        add(printButton = new JButton("Print"), aConstraints);
-   //     aConstraints.gridx += 1;
-   //     add(replaceButton = new JButton("Replace"), aConstraints);
+        cGridBag fileCommands = new cGridBag();
         
-        refreshButton.addActionListener(this);
-        loadButton.addActionListener(this);
-        printButton.addActionListener(this);
+        fileCommands.add(loadButton = new JButton("Load")); //, aConstraints);
+                loadButton.setToolTipText("Load selected file(s)");
+                loadButton.addActionListener(this);
+        fileCommands.add(refreshButton = new JButton("User")); //, aConstraints);
+                refreshButton.setToolTipText("Refresh user tree");
+                refreshButton.addActionListener(this);
+        fileCommands.add(rootButton = new JButton("Root")); //, aConstraints);
+                rootButton.setToolTipText("Refresh root tree");
+                rootButton.addActionListener(this);
+        
+        if (Globals.ADVANCED)
+        {
+                fileCommands.add(printButton = new JButton("Print")); //, aConstraints);
+                printButton.setToolTipText("Print file path in terminal");
+                printButton.addActionListener(this);
+                fileCommands.add(mergeAttributesCB = new cCheckBox("Merge", cJME.mergeAttributes)); //, aConstraints);
+                mergeAttributesCB.setToolTipText("Merge common attributes (recommended)");
+                mergeAttributesCB.addItemListener(this);
 //        replaceButton.addActionListener(this);
+   //     add(replaceButton = new JButton("Replace"), aConstraints);
+        }
 
 //        aConstraints.gridx += 1;
 //            add(trimCB = new cCheckBox("Trim", cJME.trim), aConstraints);
@@ -86,17 +98,18 @@
 //            add(genUVCB = new cCheckBox("UV", cJME.genUV), aConstraints);
 //			genUVCB.addItemListener(this);
                         
-        aConstraints.gridx += 1;
-            add(mergeAttributesCB = new cCheckBox("Merge", cJME.mergeAttributes), aConstraints);
-			mergeAttributesCB.addItemListener(this);
+        add(fileCommands);
+        fileCommands.preferredHeight = 1;
         
-        aConstraints.gridx = 0;
-        aConstraints.gridy += 1;
-	aConstraints.weighty = 1;
-	aConstraints.gridwidth = 10;
-	aConstraints.fill = GridBagConstraints.BOTH;
-
-        add(tree, aConstraints);
+        Return();
+        
+        cGridBag treeBag = new cGridBag();
+        
+        treeBag.add(tree);
+        
+        treeBag.preferredHeight = 30;
+        
+        add(treeBag); //, aConstraints);
         
             GroupEditor oe = (GroupEditor) owner;
 
@@ -104,7 +117,7 @@
 //            /*DropTarget dropTarget =*/ new DropTarget(oe.cameraView, this);
     }
 
-    void ResetModel()
+    void ResetModel(boolean user)
     {
         cFilter filter = new cFilter();
         
@@ -124,9 +137,11 @@
         filter.add("tga");
         filter.add("bmp"); // not supported
         
+        File root = java.io.File.listRoots()[0];
+        File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
+        
         jTree.setModel(new cFileSystemModel(
-                //java.io.File.listRoots()[1])
-                javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(),
+                user?defaultDirectory:root,
                 filter
         ));
     }
@@ -157,7 +172,13 @@
     {
         if(event.getSource() == refreshButton)
         {
-            ResetModel();
+            ResetModel(true);
+            return;
+        }
+        
+        if(event.getSource() == rootButton)
+        {
+            ResetModel(false);
             return;
         }
         

--
Gitblit v1.6.2