View Javadoc
1 /*** 2 * $Header: /cvsroot/ebxmlrr/jaxr/src/com/sun/xml/registry/client/browser/SlotsList.java,v 1.3 2003/08/08 04:49:38 farrukh_najmi 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 Slots. 17 * Supports drag&drop of Slot objects. 18 * 19 * @author <a href="mailto:Farrukh.Najmi@Sun.COM">Farrukh S. Najmi</a> 20 */ 21 public class SlotsList extends RegistryObjectsList { 22 23 24 /*** 25 * Default constructor 26 */ 27 public SlotsList() { 28 this(new SlotsListModel()); 29 } 30 31 /*** 32 * Constructor 33 */ 34 public SlotsList(SlotsListModel model) { 35 super(LifeCycleManager.SLOT, model); 36 37 setCellRenderer(new SlotRenderer()); 38 } 39 40 class SlotRenderer extends JLabel implements ListCellRenderer { 41 public SlotRenderer() { 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 SlotsListModel model = (SlotsListModel)list.getModel(); 65 Slot slot = (Slot)(model.elementAt(index)); 66 67 setText(SlotsList.slotToString(slot)); 68 } 69 catch (JAXRException e) { 70 RegistryBrowser.displayError(e); 71 } 72 73 return this; 74 } 75 } 76 77 public static String slotToString(Slot slot) throws JAXRException { 78 String str = "name=" + slot.getName() + " type=" + slot.getSlotType() + " values="; 79 80 81 Collection values=slot.getValues(); 82 if (values == null) { 83 str += values; 84 } 85 else { 86 Iterator iter = values.iterator(); 87 while (iter.hasNext()) { 88 String value = (String)iter.next(); 89 str += value; 90 91 if (iter.hasNext()) { 92 str += ", "; 93 } 94 } 95 } 96 97 98 return str; 99 } 100 101 }

This page was automatically generated by Maven