.. | .. |
---|
8 | 8 | |
---|
9 | 9 | import java.io.File; |
---|
10 | 10 | |
---|
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, |
---|
12 | 14 | //DragSourceListener, |
---|
13 | 15 | DropTargetListener |
---|
14 | 16 | { |
---|
15 | | - cTree jTree = new cTree(null); |
---|
| 17 | + cTree jTree = new cTree(); |
---|
16 | 18 | iCallBack owner; |
---|
17 | 19 | |
---|
18 | 20 | JButton refreshButton; |
---|
| 21 | + JButton rootButton; |
---|
19 | 22 | JButton loadButton; |
---|
20 | 23 | JButton printButton; |
---|
21 | 24 | JButton replaceButton; |
---|
.. | .. |
---|
24 | 27 | JCheckBox stripCB; |
---|
25 | 28 | JCheckBox genUVCB; |
---|
26 | 29 | |
---|
27 | | - JCheckBox mergeAttributesCB; |
---|
| 30 | + cCheckBox mergeAttributesCB; |
---|
28 | 31 | |
---|
29 | 32 | cFileSystemPane(iCallBack o) |
---|
30 | 33 | { |
---|
31 | 34 | owner = o; |
---|
32 | 35 | |
---|
33 | | - setName("File system"); |
---|
| 36 | + setName("Files"); |
---|
34 | 37 | //System.out.println("layout : " + getLayout()); |
---|
35 | 38 | //setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
---|
36 | | - setLayout(new GridBagLayout()); |
---|
| 39 | + //setLayout(new GridBagLayout()); |
---|
37 | 40 | //ToolTipManager.sharedInstance().registerComponent(jTree); |
---|
38 | 41 | jTree.setCellRenderer(new cFileSystemModel.Renderer()); |
---|
39 | 42 | |
---|
40 | | - ResetModel(); |
---|
| 43 | + ResetModel(true); |
---|
41 | 44 | |
---|
42 | 45 | JScrollPane tree = new JScrollPane(jTree); |
---|
43 | 46 | //jTree.addTreeSelectionListener(this); |
---|
.. | .. |
---|
58 | 61 | GridBagConstraints aConstraints = new GridBagConstraints(0,0,1,1, 1.0,1.0, |
---|
59 | 62 | GridBagConstraints.EAST,GridBagConstraints.HORIZONTAL,new Insets(1,1,1,1), 0,0); |
---|
60 | 63 | |
---|
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(); |
---|
70 | 65 | |
---|
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); |
---|
74 | 84 | // replaceButton.addActionListener(this); |
---|
| 85 | + // add(replaceButton = new JButton("Replace"), aConstraints); |
---|
| 86 | + } |
---|
75 | 87 | |
---|
76 | 88 | // aConstraints.gridx += 1; |
---|
77 | 89 | // add(trimCB = new cCheckBox("Trim", cJME.trim), aConstraints); |
---|
.. | .. |
---|
86 | 98 | // add(genUVCB = new cCheckBox("UV", cJME.genUV), aConstraints); |
---|
87 | 99 | // genUVCB.addItemListener(this); |
---|
88 | 100 | |
---|
89 | | - aConstraints.gridx += 1; |
---|
90 | | - add(mergeAttributesCB = new cCheckBox("Merge", cJME.mergeAttributes), aConstraints); |
---|
91 | | - mergeAttributesCB.addItemListener(this); |
---|
| 101 | + add(fileCommands); |
---|
| 102 | + fileCommands.preferredHeight = 1; |
---|
92 | 103 | |
---|
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); |
---|
100 | 113 | |
---|
101 | 114 | GroupEditor oe = (GroupEditor) owner; |
---|
102 | 115 | |
---|
.. | .. |
---|
104 | 117 | // /*DropTarget dropTarget =*/ new DropTarget(oe.cameraView, this); |
---|
105 | 118 | } |
---|
106 | 119 | |
---|
107 | | - void ResetModel() |
---|
| 120 | + void ResetModel(boolean user) |
---|
108 | 121 | { |
---|
109 | 122 | cFilter filter = new cFilter(); |
---|
110 | 123 | |
---|
.. | .. |
---|
124 | 137 | filter.add("tga"); |
---|
125 | 138 | filter.add("bmp"); // not supported |
---|
126 | 139 | |
---|
| 140 | + File root = java.io.File.listRoots()[0]; |
---|
| 141 | + File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); |
---|
| 142 | + |
---|
127 | 143 | jTree.setModel(new cFileSystemModel( |
---|
128 | | - //java.io.File.listRoots()[1]) |
---|
129 | | - javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(), |
---|
| 144 | + user?defaultDirectory:root, |
---|
130 | 145 | filter |
---|
131 | 146 | )); |
---|
132 | 147 | } |
---|
.. | .. |
---|
157 | 172 | { |
---|
158 | 173 | if(event.getSource() == refreshButton) |
---|
159 | 174 | { |
---|
160 | | - ResetModel(); |
---|
| 175 | + ResetModel(true); |
---|
| 176 | + return; |
---|
| 177 | + } |
---|
| 178 | + |
---|
| 179 | + if(event.getSource() == rootButton) |
---|
| 180 | + { |
---|
| 181 | + ResetModel(false); |
---|
161 | 182 | return; |
---|
162 | 183 | } |
---|
163 | 184 | |
---|