1 // $Id:NamespaceItemRenderer.java 62 2008-04-20 12:28:56Z me $
2 /*
3 * xsAnalyzer - XML schema analyzing tool. Copyright (C) 2008 Michael Engelhardt
4 *
5 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
6 * License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later
7 * version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
10 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License along with this program; if not, write to the Free
13 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14 */
15 /**
16 *
17 */
18 package de.mindcrimeilab.xsanalyzer.ui.renderer;
19
20 import java.awt.Component;
21
22 import javax.swing.DefaultListCellRenderer;
23 import javax.swing.JLabel;
24 import javax.swing.JList;
25 import javax.swing.ListCellRenderer;
26
27 import org.apache.xerces.xs.XSNamespaceItem;
28
29 /**
30 * @author Michael Engelhardt<me@mindcrime-ilab.de>
31 * @author $Author:me $
32 * @version $Revision:62 $
33 *
34 */
35 public class NamespaceItemRenderer implements ListCellRenderer {
36
37 private final ListCellRenderer listCellRendererDelegate = new DefaultListCellRenderer();
38
39 /*
40 * (non-Javadoc)
41 *
42 * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean,
43 * boolean)
44 */
45 @Override
46 public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
47
48 JLabel cell = (JLabel) listCellRendererDelegate.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
49
50 if (value instanceof XSNamespaceItem) {
51 XSNamespaceItem nsItem = (XSNamespaceItem) value;
52 cell.setText(nsItem.getSchemaNamespace());
53 }
54
55 return cell;
56 }
57
58 }