View Javadoc
1 /* 2 * $Header: /cvsroot/ebxmlrr/jaxr/src/com/sun/xml/registry/client/browser/LocalizedStringsList.java,v 1.2 2003/08/10 14:58:43 farrukh_najmi Exp $ 3 * 4 * ==================================================================== 5 * 6 * This code is subject to the freebxml License, Version 1.1 7 * 8 * Copyright (c) 2003 freebxml.org. All rights reserved. 9 * 10 * ==================================================================== 11 */ 12 package com.sun.xml.registry.client.browser; 13 14 import java.util.*; 15 import javax.xml.registry.*; 16 import javax.xml.registry.infomodel.*; 17 18 import java.awt.*; 19 import java.awt.event.*; 20 import javax.swing.*; 21 import javax.swing.event.*; 22 23 /*** 24 * Specialized JList for showing LocalizedStrings. 25 * Supports drag&drop of Slot objects. 26 * 27 * @author <a href="mailto:Farrukh.Najmi@Sun.COM">Farrukh S. Najmi</a> 28 * <a href="mailto:diego.ballve@republica.fi">Diego Ballve</a> 29 */ 30 public class LocalizedStringsList extends RegistryObjectsList { 31 32 33 /*** 34 * Default constructor 35 */ 36 public LocalizedStringsList() { 37 this(new LocalizedStringsListModel()); 38 } 39 40 /*** 41 * Constructor 42 */ 43 public LocalizedStringsList(LocalizedStringsListModel model) { 44 super(LifeCycleManager.LOCALIZED_STRING, model); 45 46 setCellRenderer(new LocalizedStringRenderer()); 47 } 48 49 class LocalizedStringRenderer extends JLabel implements ListCellRenderer { 50 public LocalizedStringRenderer() { 51 setOpaque(true); 52 //setHorizontalAlignment(CENTER); 53 //setVerticalAlignment(CENTER); 54 } 55 56 public Component getListCellRendererComponent( 57 JList list, 58 Object value, 59 int index, 60 boolean isSelected, 61 boolean cellHasFocus) { 62 63 if (isSelected) { 64 setBackground(list.getSelectionBackground()); 65 setForeground(list.getSelectionForeground()); 66 } 67 else { 68 setBackground(list.getBackground()); 69 setForeground(list.getForeground()); 70 } 71 72 try { 73 LocalizedStringsListModel model = (LocalizedStringsListModel)list.getModel(); 74 LocalizedString lString = (LocalizedString)(model.elementAt(index)); 75 76 setText(LocalizedStringsList.localizedStringToString(lString)); 77 } 78 catch (JAXRException e) { 79 RegistryBrowser.displayError(e); 80 } 81 82 return this; 83 } 84 } 85 86 public static String localizedStringToString(LocalizedString lString) throws JAXRException { 87 String str = "(" + lString.getLocale() + "): " + lString.getValue(); 88 return str; 89 } 90 91 }

This page was automatically generated by Maven