From: <sim...@us...> - 2002-07-29 07:23:49
|
Update of /cvsroot/cdchamber/CDChamber/src/org/cdchamber/gui In directory usw-pr-cvs1:/tmp/cvs-serv32053/src/org/cdchamber/gui Modified Files: CDCMainFrame.java CDCMainFrameController.java ICDCMainFrame.java Log Message: Select on search result will be reflect on the jlist Index: CDCMainFrame.java =================================================================== RCS file: /cvsroot/cdchamber/CDChamber/src/org/cdchamber/gui/CDCMainFrame.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** CDCMainFrame.java 26 Jul 2002 06:56:57 -0000 1.19 --- CDCMainFrame.java 29 Jul 2002 07:23:43 -0000 1.20 *************** *** 19,23 **** public class CDCMainFrame extends JFrame implements ICDCMainFrame { JPanel contentPane; - BorderLayout borderLayout1 = new BorderLayout(); JMenuBar mainMenu = new JMenuBar(); JMenu cdromMenu = new JMenu(); --- 19,22 ---- *************** *** 89,93 **** contentPane = (JPanel) this.getContentPane(); ! contentPane.setLayout(borderLayout1); contentPane.add( BorderLayout.CENTER, realMainPane); --- 88,92 ---- contentPane = (JPanel) this.getContentPane(); ! contentPane.setLayout(new BorderLayout()); contentPane.add( BorderLayout.CENTER, realMainPane); *************** *** 109,112 **** --- 108,112 ---- directoryTree.addTreeSelectionListener( controller); + resultList.addListSelectionListener( controller); } *************** *** 166,169 **** --- 166,173 ---- CDChamber.showWinowAtCenter( searchDialog); return searchDialog.searcher; + } + + public JTree getDirectoryTree() { + return directoryTree; } Index: CDCMainFrameController.java =================================================================== RCS file: /cvsroot/cdchamber/CDChamber/src/org/cdchamber/gui/CDCMainFrameController.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** CDCMainFrameController.java 26 Jul 2002 14:00:47 -0000 1.15 --- CDCMainFrameController.java 29 Jul 2002 07:23:43 -0000 1.16 *************** *** 7,20 **** package org.cdchamber.gui; ! import org.cdchamber.elements.DirectoryType; ! import org.cdchamber.elements.CDRomType; import org.cdchamber.util.DirPath; import org.cdchamber.searcher.Searcher; import org.exolab.castor.xml.MarshalException; import org.exolab.castor.xml.ValidationException; ! import javax.swing.event.TreeSelectionEvent; ! import javax.swing.event.TreeSelectionListener; ! import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.*; import java.io.*; --- 7,19 ---- package org.cdchamber.gui; ! import org.cdchamber.elements.*; import org.cdchamber.util.DirPath; import org.cdchamber.searcher.Searcher; + import org.cdchamber.searcher.SearchResult; import org.exolab.castor.xml.MarshalException; import org.exolab.castor.xml.ValidationException; ! import javax.swing.event.*; ! import javax.swing.tree.*; import javax.swing.*; import java.io.*; *************** *** 22,26 **** import java.util.Vector; ! public class CDCMainFrameController implements TreeSelectionListener { ICDCMainFrame frame; --- 21,25 ---- import java.util.Vector; ! public class CDCMainFrameController implements TreeSelectionListener, ListSelectionListener { ICDCMainFrame frame; *************** *** 69,76 **** if (node == null) return; ! if (!node.isLeaf()) tree.expandPath(e.getNewLeadSelectionPath()); frame.setFilesTableModel( new FilesTableModel(node)); } public Action getCreateNewCDRomAction() { return new CreateNewCDRomAction(); --- 68,96 ---- if (node == null) return; ! tree.expandPath(e.getNewLeadSelectionPath()); ! tree.scrollPathToVisible(e.getNewLeadSelectionPath()); frame.setFilesTableModel( new FilesTableModel(node)); } + public void valueChanged(ListSelectionEvent e) { + JList list = (JList)e.getSource(); + SearchResult result = (SearchResult)list.getSelectedValue(); + DefaultMutableTreeNode node = (DefaultMutableTreeNode)frame.getDirectoryTree().getModel().getRoot(); + DefaultMutableTreeNode []nodes = new DefaultMutableTreeNode[ result.getPathDepth()]; + nodes[0] = node; + for ( int i=0; i<result.getPathDepth()-1; i++) { + for ( int j=0; j<node.getChildCount(); j++) { + DefaultMutableTreeNode childNode = (DefaultMutableTreeNode)node.getChildAt(j); + if ( childNode.getUserObject() == result.getFileAt(i)) { + nodes[i+1] = childNode; + node = childNode; + } + } + } + frame.getDirectoryTree().setSelectionPath(new TreePath(nodes)); + // set table selection + } + + public Action getCreateNewCDRomAction() { return new CreateNewCDRomAction(); *************** *** 196,199 **** } } - } --- 216,218 ---- Index: ICDCMainFrame.java =================================================================== RCS file: /cvsroot/cdchamber/CDChamber/src/org/cdchamber/gui/ICDCMainFrame.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ICDCMainFrame.java 26 Jul 2002 06:56:57 -0000 1.4 --- ICDCMainFrame.java 29 Jul 2002 07:23:43 -0000 1.5 *************** *** 9,12 **** --- 9,13 ---- import javax.swing.table.TableModel; import javax.swing.tree.TreeModel; + import javax.swing.*; import java.util.Vector; *************** *** 56,58 **** --- 57,61 ---- */ public Searcher getSearcher(); + + public JTree getDirectoryTree(); } |