< prev index next >

src/com/sun/javatest/exec/TP_PropertySubpanel.java

Print this page
rev 145 : 7902237: Fixing raw use of parameterized class
Reviewed-by: jjg


  73         add(caption, BorderLayout.NORTH);
  74 
  75         table = new Table(uif);
  76 
  77         JScrollPane sp = uif.createScrollPane(table);
  78         sp.getViewport().setViewPosition(new Point(0, 0));
  79         sp.getViewport().setBackground(Color.white);
  80         add(sp, BorderLayout.CENTER);
  81     }
  82 
  83     void setHead(String nameTitle, String valueTitle) {
  84         table.setHead(nameTitle, valueTitle);
  85     }
  86 
  87     protected void updateSubpanel(TestResult currTest) {
  88         //System.err.println("TP_PS: updateSubpanel");
  89         super.updateSubpanel(currTest);
  90         table.reset();
  91     }
  92 
  93     protected void updateEntries(Map map) {
  94         for (Iterator i = map.entrySet().iterator(); i.hasNext(); ) {
  95             Map.Entry e = (Map.Entry) (i.next());
  96             String key = (String) (e.getKey());
  97             String val = (String) (e.getValue());
  98             if (val != null && !val.trim().isEmpty()) {
  99                 table.updateEntry(key, val);
 100             }
 101         }
 102     }
 103 
 104     protected void updateEntry(String key, String val) {
 105         if (val != null && !val.trim().isEmpty()) {
 106             table.updateEntry(key, val);
 107         }
 108     }
 109 
 110     private Table table;
 111 
 112     private class Table extends JPanel
 113         implements ComponentListener, Scrollable
 114     {
 115         Table(UIFactory uif) {
 116             addComponentListener(this);
 117             setLayout(null);


 224 
 225         public void componentShown(ComponentEvent e) {
 226             //System.err.println("TP_PS.Table: componentShown");
 227         }
 228 
 229         // Layout
 230 
 231         public void doLayout() {
 232             //System.err.println("TP_PS.Table: doLayout");
 233             synchronized (getTreeLock()) {
 234                 Insets ni = bodyBorder.getBorderInsets(this);
 235                 int nameWidth = ni.left + maxNameStringWidth + 10 + ni.right; // allow padding
 236                 int valueWidth = Math.max(getWidth() - nameWidth, 200);
 237 
 238                 int h = nameLabel.getPreferredSize().height;
 239                 nameLabel.setBounds(0, 0, nameWidth, h);
 240                 valueLabel.setBounds(nameWidth, 0, valueWidth, h);
 241 
 242                 int y = (inScrollPane ? 0 : h);
 243 
 244                 for (Iterator iter = entries.values().iterator(); iter.hasNext(); ) {
 245                     Entry e = (Entry) (iter.next());
 246                     // need to take insets into account for value, since we are dealing
 247                     // with the elemental view inside the valueField
 248                     Insets vi = e.valueText.getInsets();
 249                     View v = e.valueText.getUI().getRootView(e.valueText);
 250                     v.setSize(valueWidth, Integer.MAX_VALUE);
 251                     h = vi.top + ((int) (v.getPreferredSpan(View.Y_AXIS))) + vi.bottom;
 252                     e.nameField.setBounds(0, y, nameWidth, h);
 253                     e.valueText.setBounds(nameWidth, y, valueWidth, h);
 254                     y += h;
 255                 }
 256             }
 257         }
 258 
 259         public Dimension getMinimumSize() {
 260             //System.err.println("TP_PS.Table: minimumLayoutSize");
 261             int h = (inScrollPane ? 0 : nameLabel.getPreferredSize().height);
 262             for (Iterator iter = entries.values().iterator(); iter.hasNext(); ) {
 263                 Entry e = (Entry) (iter.next());
 264                 h += e.valueText.getMinimumSize().height;
 265             }
 266             return new Dimension(maxNameStringWidth + 400, h);
 267         }
 268 
 269         public Dimension getPreferredSize() {
 270             //System.err.println("TP_PS.Table: preferredLayoutSize");
 271             int h = (inScrollPane ? 0 : nameLabel.getPreferredSize().height);
 272             for (Iterator iter = entries.values().iterator(); iter.hasNext(); ) {
 273                 Entry e = (Entry) (iter.next());
 274                 h += e.valueText.getPreferredSize().height;
 275             }
 276             return new Dimension(maxNameStringWidth + 400, h);
 277         }
 278 
 279         // Scrollable
 280 
 281         public Dimension getPreferredScrollableViewportSize() {
 282             return getPreferredSize();
 283         }
 284 
 285         public boolean getScrollableTracksViewportHeight() {
 286             return false;
 287         }
 288 
 289         public boolean getScrollableTracksViewportWidth() {
 290             return true;
 291         }
 292 
 293         public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) {




  73         add(caption, BorderLayout.NORTH);
  74 
  75         table = new Table(uif);
  76 
  77         JScrollPane sp = uif.createScrollPane(table);
  78         sp.getViewport().setViewPosition(new Point(0, 0));
  79         sp.getViewport().setBackground(Color.white);
  80         add(sp, BorderLayout.CENTER);
  81     }
  82 
  83     void setHead(String nameTitle, String valueTitle) {
  84         table.setHead(nameTitle, valueTitle);
  85     }
  86 
  87     protected void updateSubpanel(TestResult currTest) {
  88         //System.err.println("TP_PS: updateSubpanel");
  89         super.updateSubpanel(currTest);
  90         table.reset();
  91     }
  92 
  93     protected void updateEntries(Map<String, String> map) {
  94         for (Map.Entry<String, String> e : map.entrySet()) {
  95             String key = (e.getKey());
  96             String val = (e.getValue());

  97             if (val != null && !val.trim().isEmpty()) {
  98                 table.updateEntry(key, val);
  99             }
 100         }
 101     }
 102 
 103     protected void updateEntry(String key, String val) {
 104         if (val != null && !val.trim().isEmpty()) {
 105             table.updateEntry(key, val);
 106         }
 107     }
 108 
 109     private Table table;
 110 
 111     private class Table extends JPanel
 112         implements ComponentListener, Scrollable
 113     {
 114         Table(UIFactory uif) {
 115             addComponentListener(this);
 116             setLayout(null);


 223 
 224         public void componentShown(ComponentEvent e) {
 225             //System.err.println("TP_PS.Table: componentShown");
 226         }
 227 
 228         // Layout
 229 
 230         public void doLayout() {
 231             //System.err.println("TP_PS.Table: doLayout");
 232             synchronized (getTreeLock()) {
 233                 Insets ni = bodyBorder.getBorderInsets(this);
 234                 int nameWidth = ni.left + maxNameStringWidth + 10 + ni.right; // allow padding
 235                 int valueWidth = Math.max(getWidth() - nameWidth, 200);
 236 
 237                 int h = nameLabel.getPreferredSize().height;
 238                 nameLabel.setBounds(0, 0, nameWidth, h);
 239                 valueLabel.setBounds(nameWidth, 0, valueWidth, h);
 240 
 241                 int y = (inScrollPane ? 0 : h);
 242 
 243                 for (Iterator<Entry> iter = entries.values().iterator(); iter.hasNext(); ) {
 244                     Entry e = (iter.next());
 245                     // need to take insets into account for value, since we are dealing
 246                     // with the elemental view inside the valueField
 247                     Insets vi = e.valueText.getInsets();
 248                     View v = e.valueText.getUI().getRootView(e.valueText);
 249                     v.setSize(valueWidth, Integer.MAX_VALUE);
 250                     h = vi.top + ((int) (v.getPreferredSpan(View.Y_AXIS))) + vi.bottom;
 251                     e.nameField.setBounds(0, y, nameWidth, h);
 252                     e.valueText.setBounds(nameWidth, y, valueWidth, h);
 253                     y += h;
 254                 }
 255             }
 256         }
 257 
 258         public Dimension getMinimumSize() {
 259             //System.err.println("TP_PS.Table: minimumLayoutSize");
 260             int h = (inScrollPane ? 0 : nameLabel.getPreferredSize().height);
 261             for (Iterator<Entry> iter = entries.values().iterator(); iter.hasNext(); ) {
 262                 Entry e = (iter.next());
 263                 h += e.valueText.getMinimumSize().height;
 264             }
 265             return new Dimension(maxNameStringWidth + 400, h);
 266         }
 267 
 268         public Dimension getPreferredSize() {
 269             //System.err.println("TP_PS.Table: preferredLayoutSize");
 270             int h = (inScrollPane ? 0 : nameLabel.getPreferredSize().height);
 271             for (Iterator<Entry> iter = entries.values().iterator(); iter.hasNext(); ) {
 272                 Entry e = (iter.next());
 273                 h += e.valueText.getPreferredSize().height;
 274             }
 275             return new Dimension(maxNameStringWidth + 400, h);
 276         }
 277 
 278         // Scrollable
 279 
 280         public Dimension getPreferredScrollableViewportSize() {
 281             return getPreferredSize();
 282         }
 283 
 284         public boolean getScrollableTracksViewportHeight() {
 285             return false;
 286         }
 287 
 288         public boolean getScrollableTracksViewportWidth() {
 289             return true;
 290         }
 291 
 292         public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) {


< prev index next >