From d5fac992bb6a91e52a90e8318060f5f26ddab982 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Sun, 15 Sep 2019 10:55:46 -0400 Subject: [PATCH] Fix navigation and hide cursor. --- cFileSystemPane.java | 87 +++++++++++++++++++++++++++---------------- 1 files changed, 54 insertions(+), 33 deletions(-) diff --git a/cFileSystemPane.java b/cFileSystemPane.java index 8bd7ccd..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; } @@ -235,7 +256,7 @@ System.out.println("drop2 = " + dtde + "; drop : " + target); //assert dropTarget == dtde.getSource(); - if (target instanceof CameraPane) + if (target instanceof iCameraPane) { Object object = null; try -- Gitblit v1.6.2