From e8908d5b90d44e43b9da885bc0202fb665a912d0 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Mon, 30 Sep 2019 20:00:22 -0400 Subject: [PATCH] klein --- cFileSystemPane.java | 47 +++++++++++++++++++++++++++++------------------ 1 files changed, 29 insertions(+), 18 deletions(-) diff --git a/cFileSystemPane.java b/cFileSystemPane.java index 56bc5ea..6abec53 100644 --- a/cFileSystemPane.java +++ b/cFileSystemPane.java @@ -14,10 +14,11 @@ //DragSourceListener, DropTargetListener { - cTree jTree = new cTree(null); + cTree jTree = new cTree(); iCallBack owner; JButton refreshButton; + JButton rootButton; JButton loadButton; JButton printButton; JButton replaceButton; @@ -32,14 +33,14 @@ { owner = o; - setName("File system"); + setName("Files"); //System.out.println("layout : " + getLayout()); //setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); //setLayout(new GridBagLayout()); //ToolTipManager.sharedInstance().registerComponent(jTree); jTree.setCellRenderer(new cFileSystemModel.Renderer()); - ResetModel(); + ResetModel(true); JScrollPane tree = new JScrollPane(jTree); //jTree.addTreeSelectionListener(this); @@ -60,22 +61,24 @@ GridBagConstraints aConstraints = new GridBagConstraints(0,0,1,1, 1.0,1.0, GridBagConstraints.EAST,GridBagConstraints.HORIZONTAL,new Insets(1,1,1,1), 0,0); - cGridBag fileCommsnds = new cGridBag(); + cGridBag fileCommands = new cGridBag(); - fileCommsnds.add(loadButton = new JButton("Load")); //, aConstraints); + fileCommands.add(loadButton = new JButton("Load")); //, aConstraints); loadButton.setToolTipText("Load selected file(s)"); - fileCommsnds.add(refreshButton = new JButton("Refresh")); //, aConstraints); - refreshButton.setToolTipText("Refresh entire tree"); - - refreshButton.addActionListener(this); - loadButton.addActionListener(this); + 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) { - fileCommsnds.add(printButton = new JButton("Print")); //, aConstraints); + fileCommands.add(printButton = new JButton("Print")); //, aConstraints); printButton.setToolTipText("Print file path in terminal"); printButton.addActionListener(this); - fileCommsnds.add(mergeAttributesCB = new cCheckBox("Merge", cJME.mergeAttributes)); //, aConstraints); + fileCommands.add(mergeAttributesCB = new cCheckBox("Merge", cJME.mergeAttributes)); //, aConstraints); mergeAttributesCB.setToolTipText("Merge common attributes (recommended)"); mergeAttributesCB.addItemListener(this); // replaceButton.addActionListener(this); @@ -95,8 +98,8 @@ // add(genUVCB = new cCheckBox("UV", cJME.genUV), aConstraints); // genUVCB.addItemListener(this); - add(fileCommsnds); - fileCommsnds.preferredHeight = 1; + add(fileCommands); + fileCommands.preferredHeight = 1; Return(); @@ -114,7 +117,7 @@ // /*DropTarget dropTarget =*/ new DropTarget(oe.cameraView, this); } - void ResetModel() + void ResetModel(boolean user) { cFilter filter = new cFilter(); @@ -134,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 )); } @@ -167,7 +172,13 @@ { if(event.getSource() == refreshButton) { - ResetModel(); + ResetModel(true); + return; + } + + if(event.getSource() == rootButton) + { + ResetModel(false); return; } -- Gitblit v1.6.2