Normand Briere
2019-09-08 4a303a7b3635adfee8f46ac76af4e1b7b4a7029b
cFileSystemPane.java
....@@ -14,10 +14,11 @@
1414 //DragSourceListener,
1515 DropTargetListener
1616 {
17
- cTree jTree = new cTree(null);
17
+ cTree jTree = new cTree();
1818 iCallBack owner;
1919
2020 JButton refreshButton;
21
+ JButton rootButton;
2122 JButton loadButton;
2223 JButton printButton;
2324 JButton replaceButton;
....@@ -26,20 +27,20 @@
2627 JCheckBox stripCB;
2728 JCheckBox genUVCB;
2829
29
- JCheckBox mergeAttributesCB;
30
+ cCheckBox mergeAttributesCB;
3031
3132 cFileSystemPane(iCallBack o)
3233 {
3334 owner = o;
3435
35
- setName("File system");
36
+ setName("Files");
3637 //System.out.println("layout : " + getLayout());
3738 //setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
3839 //setLayout(new GridBagLayout());
3940 //ToolTipManager.sharedInstance().registerComponent(jTree);
4041 jTree.setCellRenderer(new cFileSystemModel.Renderer());
4142
42
- ResetModel();
43
+ ResetModel(true);
4344
4445 JScrollPane tree = new JScrollPane(jTree);
4546 //jTree.addTreeSelectionListener(this);
....@@ -60,22 +61,24 @@
6061 GridBagConstraints aConstraints = new GridBagConstraints(0,0,1,1, 1.0,1.0,
6162 GridBagConstraints.EAST,GridBagConstraints.HORIZONTAL,new Insets(1,1,1,1), 0,0);
6263
63
- cGridBag fileCommsnds = new cGridBag();
64
+ cGridBag fileCommands = new cGridBag();
6465
65
- fileCommsnds.add(refreshButton = new JButton("Refresh")); //, aConstraints);
66
- refreshButton.setToolTipText("Refresh entire tree");
67
- fileCommsnds.add(loadButton = new JButton("Load")); //, aConstraints);
66
+ fileCommands.add(loadButton = new JButton("Load")); //, aConstraints);
6867 loadButton.setToolTipText("Load selected file(s)");
69
-
70
- refreshButton.addActionListener(this);
71
- loadButton.addActionListener(this);
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);
7275
7376 if (Globals.ADVANCED)
7477 {
75
- fileCommsnds.add(printButton = new JButton("Print")); //, aConstraints);
78
+ fileCommands.add(printButton = new JButton("Print")); //, aConstraints);
7679 printButton.setToolTipText("Print file path in terminal");
7780 printButton.addActionListener(this);
78
- fileCommsnds.add(mergeAttributesCB = new cCheckBox("Merge", cJME.mergeAttributes)); //, aConstraints);
81
+ fileCommands.add(mergeAttributesCB = new cCheckBox("Merge", cJME.mergeAttributes)); //, aConstraints);
7982 mergeAttributesCB.setToolTipText("Merge common attributes (recommended)");
8083 mergeAttributesCB.addItemListener(this);
8184 // replaceButton.addActionListener(this);
....@@ -95,8 +98,8 @@
9598 // add(genUVCB = new cCheckBox("UV", cJME.genUV), aConstraints);
9699 // genUVCB.addItemListener(this);
97100
98
- add(fileCommsnds);
99
- fileCommsnds.preferredHeight = 1;
101
+ add(fileCommands);
102
+ fileCommands.preferredHeight = 1;
100103
101104 Return();
102105
....@@ -114,7 +117,7 @@
114117 // /*DropTarget dropTarget =*/ new DropTarget(oe.cameraView, this);
115118 }
116119
117
- void ResetModel()
120
+ void ResetModel(boolean user)
118121 {
119122 cFilter filter = new cFilter();
120123
....@@ -134,9 +137,11 @@
134137 filter.add("tga");
135138 filter.add("bmp"); // not supported
136139
140
+ File root = java.io.File.listRoots()[0];
141
+ File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
142
+
137143 jTree.setModel(new cFileSystemModel(
138
- //java.io.File.listRoots()[1])
139
- javax.swing.filechooser.FileSystemView.getFileSystemView().getHomeDirectory(),
144
+ user?defaultDirectory:root,
140145 filter
141146 ));
142147 }
....@@ -167,7 +172,13 @@
167172 {
168173 if(event.getSource() == refreshButton)
169174 {
170
- ResetModel();
175
+ ResetModel(true);
176
+ return;
177
+ }
178
+
179
+ if(event.getSource() == rootButton)
180
+ {
181
+ ResetModel(false);
171182 return;
172183 }
173184