Normand Briere
2019-09-24 767be784dc7fe293bf5c5ee6507df242526be3ed
cFileSystemPane.java
....@@ -8,14 +8,17 @@
88
99 import java.io.File;
1010
11
-public class cFileSystemPane extends JPanel implements ActionListener, ItemListener, DragGestureListener,
11
+import grafeme.ui.*;
12
+
13
+public class cFileSystemPane extends cGridBag implements ActionListener, ItemListener, DragGestureListener,
1214 //DragSourceListener,
1315 DropTargetListener
1416 {
15
- cTree jTree = new cTree(null);
17
+ cTree jTree = new cTree();
1618 iCallBack owner;
1719
1820 JButton refreshButton;
21
+ JButton rootButton;
1922 JButton loadButton;
2023 JButton printButton;
2124 JButton replaceButton;
....@@ -24,20 +27,20 @@
2427 JCheckBox stripCB;
2528 JCheckBox genUVCB;
2629
27
- JCheckBox mergeAttributesCB;
30
+ cCheckBox mergeAttributesCB;
2831
2932 cFileSystemPane(iCallBack o)
3033 {
3134 owner = o;
3235
33
- setName("File system");
36
+ setName("Files");
3437 //System.out.println("layout : " + getLayout());
3538 //setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
36
- setLayout(new GridBagLayout());
39
+ //setLayout(new GridBagLayout());
3740 //ToolTipManager.sharedInstance().registerComponent(jTree);
3841 jTree.setCellRenderer(new cFileSystemModel.Renderer());
3942
40
- ResetModel();
43
+ ResetModel(true);
4144
4245 JScrollPane tree = new JScrollPane(jTree);
4346 //jTree.addTreeSelectionListener(this);
....@@ -58,20 +61,29 @@
5861 GridBagConstraints aConstraints = new GridBagConstraints(0,0,1,1, 1.0,1.0,
5962 GridBagConstraints.EAST,GridBagConstraints.HORIZONTAL,new Insets(1,1,1,1), 0,0);
6063
61
- aConstraints.weighty = 0;
62
- aConstraints.gridwidth = 1;
63
- add(refreshButton = new JButton("Refresh"), aConstraints);
64
- aConstraints.gridx += 1;
65
- add(loadButton = new JButton("Load"), aConstraints);
66
- aConstraints.gridx += 1;
67
- add(printButton = new JButton("Print"), aConstraints);
68
- // aConstraints.gridx += 1;
69
- // add(replaceButton = new JButton("Replace"), aConstraints);
64
+ cGridBag fileCommands = new cGridBag();
7065
71
- refreshButton.addActionListener(this);
72
- loadButton.addActionListener(this);
73
- printButton.addActionListener(this);
66
+ fileCommands.add(loadButton = new JButton("Load")); //, aConstraints);
67
+ loadButton.setToolTipText("Load selected file(s)");
68
+ loadButton.addActionListener(this);
69
+ fileCommands.add(refreshButton = new JButton("User")); //, aConstraints);
70
+ refreshButton.setToolTipText("Refresh user tree");
71
+ refreshButton.addActionListener(this);
72
+ fileCommands.add(rootButton = new JButton("Root")); //, aConstraints);
73
+ rootButton.setToolTipText("Refresh root tree");
74
+ rootButton.addActionListener(this);
75
+
76
+ if (Globals.ADVANCED)
77
+ {
78
+ fileCommands.add(printButton = new JButton("Print")); //, aConstraints);
79
+ printButton.setToolTipText("Print file path in terminal");
80
+ printButton.addActionListener(this);
81
+ fileCommands.add(mergeAttributesCB = new cCheckBox("Merge", cJME.mergeAttributes)); //, aConstraints);
82
+ mergeAttributesCB.setToolTipText("Merge common attributes (recommended)");
83
+ mergeAttributesCB.addItemListener(this);
7484 // replaceButton.addActionListener(this);
85
+ // add(replaceButton = new JButton("Replace"), aConstraints);
86
+ }
7587
7688 // aConstraints.gridx += 1;
7789 // add(trimCB = new cCheckBox("Trim", cJME.trim), aConstraints);
....@@ -86,17 +98,18 @@
8698 // add(genUVCB = new cCheckBox("UV", cJME.genUV), aConstraints);
8799 // genUVCB.addItemListener(this);
88100
89
- aConstraints.gridx += 1;
90
- add(mergeAttributesCB = new cCheckBox("Merge", cJME.mergeAttributes), aConstraints);
91
- mergeAttributesCB.addItemListener(this);
101
+ add(fileCommands);
102
+ fileCommands.preferredHeight = 1;
92103
93
- aConstraints.gridx = 0;
94
- aConstraints.gridy += 1;
95
- aConstraints.weighty = 1;
96
- aConstraints.gridwidth = 10;
97
- aConstraints.fill = GridBagConstraints.BOTH;
98
-
99
- add(tree, aConstraints);
104
+ Return();
105
+
106
+ cGridBag treeBag = new cGridBag();
107
+
108
+ treeBag.add(tree);
109
+
110
+ treeBag.preferredHeight = 30;
111
+
112
+ add(treeBag); //, aConstraints);
100113
101114 GroupEditor oe = (GroupEditor) owner;
102115
....@@ -104,7 +117,7 @@
104117 // /*DropTarget dropTarget =*/ new DropTarget(oe.cameraView, this);
105118 }
106119
107
- void ResetModel()
120
+ void ResetModel(boolean user)
108121 {
109122 cFilter filter = new cFilter();
110123
....@@ -124,9 +137,11 @@
124137 filter.add("tga");
125138 filter.add("bmp"); // not supported
126139
140
+ File root = java.io.File.listRoots()[0];
141
+ File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
142
+
127143 jTree.setModel(new cFileSystemModel(
128
- //java.io.File.listRoots()[1])
129
- javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(),
144
+ user?defaultDirectory:root,
130145 filter
131146 ));
132147 }
....@@ -157,7 +172,13 @@
157172 {
158173 if(event.getSource() == refreshButton)
159174 {
160
- ResetModel();
175
+ ResetModel(true);
176
+ return;
177
+ }
178
+
179
+ if(event.getSource() == rootButton)
180
+ {
181
+ ResetModel(false);
161182 return;
162183 }
163184