1 26 package org.objectweb.util.explorer.swing.lib; 27 28 import java.awt.BorderLayout ; 29 import java.awt.Color ; 30 31 import javax.swing.BorderFactory ; 32 import javax.swing.JPanel ; 33 34 import org.objectweb.util.explorer.api.Panel; 35 import org.objectweb.util.explorer.api.Table; 36 import org.objectweb.util.explorer.api.Tree; 37 import org.objectweb.util.explorer.api.TreeView; 38 import org.objectweb.util.explorer.interpreter.api.DescriptionInterpreter; 39 import org.objectweb.util.explorer.resolver.api.PropertyResolver; 40 import org.objectweb.util.explorer.swing.lib.DynamicTable; 41 42 50 public class BasicTablePanel 51 implements Panel 52 { 53 54 60 protected JPanel panel_; 61 62 65 protected Table table_; 66 67 70 protected PropertyResolver propertyResolver_; 71 72 75 protected DescriptionInterpreter descriptionInterpreter_; 76 77 80 protected Tree tree_; 81 82 83 85 87 88 94 110 111 public BasicTablePanel(){ 112 panel_ = new JPanel (); 113 panel_.setBackground(Color.white); 114 panel_.setBorder(BorderFactory.createLineBorder(Color.black)); 115 panel_.setLayout(new BorderLayout ()); 117 } 118 119 125 131 public void setPropertyResolver(PropertyResolver propertyResolver){ 132 propertyResolver_ = propertyResolver; 134 } 135 136 public void setDescriptionInterpreter(DescriptionInterpreter descriptionInterpreter){ 137 descriptionInterpreter_ = descriptionInterpreter; 139 } 140 141 public void setTree(Tree tree){ 142 tree_ = tree; 144 } 145 146 public void setTable(Table table){ 147 table_ = table; 148 } 149 150 156 159 public void selected(TreeView treeView) { 160 if(table_!=null){ 161 DynamicTable dynamicTable = null; 162 dynamicTable = new DynamicTable(); 166 dynamicTable.setPropertyResolver(propertyResolver_); 167 dynamicTable.setDescriptionInterpreter(descriptionInterpreter_); 168 dynamicTable.setTree(tree_); 169 String [] headers = table_.getHeaders(treeView); 171 Object [][] values = table_.getRows(treeView); 172 if(values!=null && values.length>0){ 173 dynamicTable.setData(headers,values); 174 panel_.add(dynamicTable.getTableHeader(),BorderLayout.NORTH); 176 panel_.add(dynamicTable,BorderLayout.CENTER); 177 } 178 } 179 } 180 181 184 public Object getPanel() { 185 return panel_; 186 } 187 188 191 public void unselected(TreeView treeview) { 192 } 194 195 } 196 197 198 | Popular Tags |