< prev index next >

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

Print this page




  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);
 118             setBackground(Color.white);
 119             entries = new TreeMap();
 120 
 121             // space to go around text
 122             Border bsp = BorderFactory.createEmptyBorder(2, 4, 2, 4); // top, left, bottom, right
 123 
 124             // Border for head components, including head corner above possible scrollbar
 125             // (lines above and below)
 126             Border bh = BorderFactory.createMatteBorder(1, 0, 1, 0, Color.lightGray);
 127             headBorder = BorderFactory.createCompoundBorder(bh, bsp);
 128 
 129             // Border for body components (line below)
 130             Border br = BorderFactory.createMatteBorder(0, 0, 1, 0, Color.lightGray);
 131             bodyBorder = BorderFactory.createCompoundBorder(br, bsp);
 132 
 133             nameLabel = uif.createHeading("test.table.name");
 134             nameLabel.setBorder(headBorder);
 135 
 136             valueLabel = uif.createHeading("test.table.value");
 137             valueLabel.setBorder(headBorder);
 138         }
 139 
 140         void setHead(String nameTitle, String valueTitle) {
 141             nameLabel.setText(nameTitle);
 142             valueLabel.setText(valueTitle);
 143         }
 144 
 145         void updateEntry(String key, String value) {
 146             //System.err.println("TP_PS.Table: updateEntry " + key + "=" + value);
 147             Entry e = (Entry) (entries.get(key));
 148             if (e == null) {
 149                 e = new Entry(key, value);
 150                 entries.put(key, e);
 151                 maxNameStringWidth = Math.max(maxNameStringWidth, getFontMetrics(getFont()).stringWidth(key));
 152             }
 153             else
 154                 e.valueText.setText(value);
 155 
 156             revalidate();
 157         }
 158 
 159         void reset() {
 160             //System.err.println("TP_PS.Table: reset");
 161             entries.clear();
 162             removeAll();
 163             maxNameStringWidth = 100;
 164             if (!inScrollPane) {
 165                 add(nameLabel);
 166                 add(valueLabel);
 167             }


 338         }
 339 
 340         private void unconfigureEnclosingScrollPane() {
 341             Container p = getParent();
 342             if (p instanceof JViewport) {
 343                 Container gp = p.getParent();
 344                 if (gp instanceof JScrollPane) {
 345                     JScrollPane scrollPane = (JScrollPane)gp;
 346                     // Make certain we are the viewPort's view and not, for
 347                     // example, the rowHeaderView of the scrollPane -
 348                     // an implementor of fixed columns might do this.
 349                     JViewport viewport = scrollPane.getViewport();
 350                     if (viewport == null || viewport.getView() != this)
 351                         return;
 352                     inScrollPane = false;
 353                     scrollPane.setColumnHeaderView(null);
 354                 }
 355             }
 356         }
 357 
 358         private SortedMap entries;
 359         private int maxNameStringWidth = 100;
 360         private JTextField nameLabel;
 361         private JTextField valueLabel;
 362         private Border headBorder;
 363         private Border bodyBorder;
 364         private boolean inScrollPane;
 365         private boolean pendingValidate;
 366 
 367         private class Entry
 368         {
 369             Entry(String name, String value) {
 370                 this.name = name;
 371                 this.value = value;
 372 
 373                 nameField = uif.createOutputField("test.table.entry.name", name);
 374                 nameField.setBorder(bodyBorder);
 375                 nameField.setEditable(false);
 376                 nameField.setOpaque(false);
 377                 add(nameField);
 378 




  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);
 118             setBackground(Color.white);
 119             entries = new TreeMap<>();
 120 
 121             // space to go around text
 122             Border bsp = BorderFactory.createEmptyBorder(2, 4, 2, 4); // top, left, bottom, right
 123 
 124             // Border for head components, including head corner above possible scrollbar
 125             // (lines above and below)
 126             Border bh = BorderFactory.createMatteBorder(1, 0, 1, 0, Color.lightGray);
 127             headBorder = BorderFactory.createCompoundBorder(bh, bsp);
 128 
 129             // Border for body components (line below)
 130             Border br = BorderFactory.createMatteBorder(0, 0, 1, 0, Color.lightGray);
 131             bodyBorder = BorderFactory.createCompoundBorder(br, bsp);
 132 
 133             nameLabel = uif.createHeading("test.table.name");
 134             nameLabel.setBorder(headBorder);
 135 
 136             valueLabel = uif.createHeading("test.table.value");
 137             valueLabel.setBorder(headBorder);
 138         }
 139 
 140         void setHead(String nameTitle, String valueTitle) {
 141             nameLabel.setText(nameTitle);
 142             valueLabel.setText(valueTitle);
 143         }
 144 
 145         void updateEntry(String key, String value) {
 146             //System.err.println("TP_PS.Table: updateEntry " + key + "=" + value);
 147             Entry e =  entries.get(key);
 148             if (e == null) {
 149                 e = new Entry(key, value);
 150                 entries.put(key, e);
 151                 maxNameStringWidth = Math.max(maxNameStringWidth, getFontMetrics(getFont()).stringWidth(key));
 152             }
 153             else
 154                 e.valueText.setText(value);
 155 
 156             revalidate();
 157         }
 158 
 159         void reset() {
 160             //System.err.println("TP_PS.Table: reset");
 161             entries.clear();
 162             removeAll();
 163             maxNameStringWidth = 100;
 164             if (!inScrollPane) {
 165                 add(nameLabel);
 166                 add(valueLabel);
 167             }


 338         }
 339 
 340         private void unconfigureEnclosingScrollPane() {
 341             Container p = getParent();
 342             if (p instanceof JViewport) {
 343                 Container gp = p.getParent();
 344                 if (gp instanceof JScrollPane) {
 345                     JScrollPane scrollPane = (JScrollPane)gp;
 346                     // Make certain we are the viewPort's view and not, for
 347                     // example, the rowHeaderView of the scrollPane -
 348                     // an implementor of fixed columns might do this.
 349                     JViewport viewport = scrollPane.getViewport();
 350                     if (viewport == null || viewport.getView() != this)
 351                         return;
 352                     inScrollPane = false;
 353                     scrollPane.setColumnHeaderView(null);
 354                 }
 355             }
 356         }
 357 
 358         private SortedMap<String, Entry> entries;
 359         private int maxNameStringWidth = 100;
 360         private JTextField nameLabel;
 361         private JTextField valueLabel;
 362         private Border headBorder;
 363         private Border bodyBorder;
 364         private boolean inScrollPane;
 365         private boolean pendingValidate;
 366 
 367         private class Entry
 368         {
 369             Entry(String name, String value) {
 370                 this.name = name;
 371                 this.value = value;
 372 
 373                 nameField = uif.createOutputField("test.table.entry.name", name);
 374                 nameField.setBorder(bodyBorder);
 375                 nameField.setEditable(false);
 376                 nameField.setOpaque(false);
 377                 add(nameField);
 378 


< prev index next >