import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.tree.*; import java.awt.dnd.*; import java.awt.datatransfer.*; import java.io.File; public class cFileSystemPane extends JPanel implements ActionListener, ItemListener, DragGestureListener, //DragSourceListener, DropTargetListener { cTree jTree = new cTree(null); iCallBack owner; JButton refreshButton; JButton loadButton; JButton printButton; JButton replaceButton; JCheckBox normalsCB; JCheckBox trimCB; JCheckBox stripCB; JCheckBox genUVCB; JCheckBox mergeAttributesCB; cFileSystemPane(iCallBack o) { owner = o; setName("File system"); //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(); JScrollPane tree = new JScrollPane(jTree); //jTree.addTreeSelectionListener(this); //jTree.setRootVisible(false); //jTree.setEditable(true); jTree.setDragEnabled(true); /* JPanel jp = new JPanel(new GridBagLayout()); //System.out.println("layout : " + jp.getPreferredSize()); jp.add(refreshButton = new JButton("Refresh")); jp.add(refreshButton = new JButton("Refresh")); jp.add(refreshButton = new JButton("Refresh")); //jp.add(refreshButton = new JButton("Refresh")); //jp.add(refreshButton = new JButton("Refresh")); //jp.setSize(new Dimension(20,20)); */ 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); refreshButton.addActionListener(this); loadButton.addActionListener(this); printButton.addActionListener(this); // replaceButton.addActionListener(this); // aConstraints.gridx += 1; // add(trimCB = new cCheckBox("Trim", cJME.trim), aConstraints); // trimCB.addItemListener(this); // aConstraints.gridx += 1; // add(normalsCB = new cCheckBox("Normal", cJME.gennormals), aConstraints); // normalsCB.addItemListener(this); // aConstraints.gridx += 1; // add(stripCB = new cCheckBox("Strip", cJME.stripify), aConstraints); // stripCB.addItemListener(this); // aConstraints.gridx += 1; // 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); aConstraints.gridx = 0; aConstraints.gridy += 1; aConstraints.weighty = 1; aConstraints.gridwidth = 10; aConstraints.fill = GridBagConstraints.BOTH; add(tree, aConstraints); GroupEditor oe = (GroupEditor) owner; // DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer(oe.cameraView, DnDConstants.ACTION_COPY_OR_MOVE, this); // ACTION_LINK ?? // /*DropTarget dropTarget =*/ new DropTarget(oe.cameraView, this); } void ResetModel() { cFilter filter = new cFilter(); filter.add("3ds"); filter.add("dae"); filter.add("obj"); filter.add("gfd"); filter.add("bvh"); filter.add("wrl"); filter.add("vrml"); filter.add("x3d"); filter.add("jpg"); filter.add("jpeg"); filter.add("gif"); filter.add("png"); filter.add("tre"); filter.add("tga"); filter.add("bmp"); // not supported jTree.setModel(new cFileSystemModel( //java.io.File.listRoots()[1]) javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(), filter )); } public void itemStateChanged(ItemEvent e) { if(e.getSource() == normalsCB) cJME.gennormals = (e.getStateChange() == ItemEvent.SELECTED); else if(e.getSource() == trimCB) cJME.trim = (e.getStateChange() == ItemEvent.SELECTED); else if(e.getSource() == stripCB) cJME.stripify = (e.getStateChange() == ItemEvent.SELECTED); else if(e.getSource() == genUVCB) cJME.genUV = (e.getStateChange() == ItemEvent.SELECTED); else if(e.getSource() == mergeAttributesCB) cJME.mergeAttributes = (e.getStateChange() == ItemEvent.SELECTED); else assert(false); //preserveCB.setEnabled(cJME.gennormals || cJME.stripify); } public void actionPerformed(ActionEvent event) { if(event.getSource() == refreshButton) { ResetModel(); return; } if(event.getSource() == loadButton) { TreePath[] paths = jTree.getSelectionPaths(); if (paths == null) // || (path.getPathCount() <= 1)) // We can't move the root node or an empty selection return; File[] files = new File[paths.length]; for(int i=0; i