1 26 27 package org.objectweb.util.explorer.plugin.java.swing; 28 29 import java.awt.Color ; 30 import java.util.Collection ; 31 import java.util.Iterator ; 32 33 import javax.swing.BoxLayout ; 34 import javax.swing.JPanel ; 35 import javax.swing.JScrollPane ; 36 import javax.swing.JTable ; 37 38 import org.objectweb.util.explorer.api.Panel; 39 import org.objectweb.util.explorer.api.TreeView; 40 41 42 51 public class CollectionPanel 52 implements Panel { 53 54 60 61 protected JPanel panel_; 62 63 69 73 public CollectionPanel(){ 74 panel_ = new JPanel (); 75 panel_.setBackground(Color.white); 76 panel_.setLayout(new BoxLayout (panel_, BoxLayout.Y_AXIS)); 77 } 78 79 85 91 94 public void selected(TreeView treeView) { 95 String [] titre = {"Class name","Instance"}; 96 Collection collection = (Collection )treeView.getSelectedObject(); 97 String [][] contenu = new String [collection.size()][2]; 98 Iterator iterator = collection.iterator(); 99 int cpt = 0; 100 while (iterator.hasNext()) { 101 Object element = iterator.next(); 102 contenu[cpt] = new String []{element.getClass().getName(), element.toString()}; 103 cpt++; 104 } 105 panel_.add(new JScrollPane (new JTable (contenu,titre))); 106 } 107 108 111 public Object getPanel() { 112 return panel_; 113 } 114 115 118 public void unselected(TreeView treeView) { 119 } 121 122 } | Popular Tags |