View Javadoc
1 /*** 2 * $Header: /cvsroot/ebxmlrr/jaxr/src/com/sun/xml/registry/client/browser/ExternalLinksList.java,v 1.9 2003/08/10 09:33:18 doballve Exp $ 3 */ 4 package com.sun.xml.registry.client.browser; 5 6 import java.util.*; 7 import javax.xml.registry.*; 8 import javax.xml.registry.infomodel.*; 9 10 import java.awt.*; 11 import java.awt.event.*; 12 import javax.swing.*; 13 import javax.swing.event.*; 14 15 /*** 16 * Specialized JList for showing ExternalLinks. 17 * Supports drag&drop of ExternalLink objects. 18 * 19 * @author <a href="mailto:Farrukh.Najmi@Sun.COM">Farrukh S. Najmi</a> 20 */ 21 public class ExternalLinksList extends RegistryObjectsList { 22 23 24 /*** 25 * Default constructor 26 */ 27 public ExternalLinksList() { 28 this(new ExternalLinksListModel()); 29 } 30 31 /*** 32 * Constructor 33 */ 34 public ExternalLinksList(ExternalLinksListModel model) { 35 super(LifeCycleManager.EXTERNAL_LINK, model); 36 37 setCellRenderer(new ExternalLinkRenderer()); 38 } 39 40 class ExternalLinkRenderer extends JLabel implements ListCellRenderer { 41 public ExternalLinkRenderer() { 42 setOpaque(true); 43 //setHorizontalAlignment(CENTER); 44 //setVerticalAlignment(CENTER); 45 } 46 47 public Component getListCellRendererComponent( 48 JList list, 49 Object value, 50 int index, 51 boolean isSelected, 52 boolean cellHasFocus) { 53 54 if (isSelected) { 55 setBackground(list.getSelectionBackground()); 56 setForeground(list.getSelectionForeground()); 57 } 58 else { 59 setBackground(list.getBackground()); 60 setForeground(list.getForeground()); 61 } 62 63 try { 64 ExternalLinksListModel model = (ExternalLinksListModel)list.getModel(); 65 ExternalLink link = (ExternalLink)(model.elementAt(index)); 66 67 String externalURI = link.getExternalURI(); 68 69 String str = externalURI; 70 String desc = RegistryBrowser.getDescription(link); 71 if ((desc != null) && (desc.length() > 0)) { 72 str += " ( " + desc + " )"; 73 } 74 75 setText(str); 76 } 77 catch (JAXRException e) { 78 RegistryBrowser.displayError(e); 79 } 80 81 return this; 82 } 83 } 84 85 }

This page was automatically generated by Maven