< prev index next >

src/com/sun/javatest/mrep/BrowserPane.java

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


 545                     noteField.setText(u.toString());
 546                 }
 547             }
 548             else if (et == HyperlinkEvent.EventType.EXITED) {
 549                 textArea.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
 550                 noteField.setText("");
 551             }
 552         }
 553 
 554         public void itemStateChanged(ItemEvent e) {
 555             if (e.getStateChange() == ItemEvent.SELECTED) {
 556                 URL url = (URL) e.getItem();
 557                 loadPage(url);
 558             }
 559         }
 560     }
 561 
 562     //------------------------------------------------------------------------------------
 563 
 564     private class Renderer extends DefaultListCellRenderer {
 565         public Component getListCellRendererComponent(JList list, Object o, int index, boolean isSelected, boolean cellHasFocus) {
 566             String name = null;
 567             if (o instanceof URL) {
 568                 URL url = (URL) o;
 569 
 570                 // if not file URL
 571                 if (!url.getProtocol().equals("file")) {
 572                     name = url.toString();
 573                 }
 574                 else {
 575                     // if file URL, remove the "file:" prefix
 576                     name = extractPrefix(url.toString(), "file:");
 577                     String baseName = null;
 578                     name = new File(name).getAbsolutePath();
 579                     if (baseDir != null && baseDir.getParentFile() != null) {
 580                         baseName = baseDir.getParentFile().getAbsolutePath();
 581                     }
 582                     // if contains base dir, only show file name
 583                     if (baseName != null &&
 584                         name.startsWith(baseName) &&
 585                         (name.length() > baseName.length())) {


 545                     noteField.setText(u.toString());
 546                 }
 547             }
 548             else if (et == HyperlinkEvent.EventType.EXITED) {
 549                 textArea.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
 550                 noteField.setText("");
 551             }
 552         }
 553 
 554         public void itemStateChanged(ItemEvent e) {
 555             if (e.getStateChange() == ItemEvent.SELECTED) {
 556                 URL url = (URL) e.getItem();
 557                 loadPage(url);
 558             }
 559         }
 560     }
 561 
 562     //------------------------------------------------------------------------------------
 563 
 564     private class Renderer extends DefaultListCellRenderer {
 565         public Component getListCellRendererComponent(JList<?> list, Object o, int index, boolean isSelected, boolean cellHasFocus) {
 566             String name = null;
 567             if (o instanceof URL) {
 568                 URL url = (URL) o;
 569 
 570                 // if not file URL
 571                 if (!url.getProtocol().equals("file")) {
 572                     name = url.toString();
 573                 }
 574                 else {
 575                     // if file URL, remove the "file:" prefix
 576                     name = extractPrefix(url.toString(), "file:");
 577                     String baseName = null;
 578                     name = new File(name).getAbsolutePath();
 579                     if (baseDir != null && baseDir.getParentFile() != null) {
 580                         baseName = baseDir.getParentFile().getAbsolutePath();
 581                     }
 582                     // if contains base dir, only show file name
 583                     if (baseName != null &&
 584                         name.startsWith(baseName) &&
 585                         (name.length() > baseName.length())) {
< prev index next >