1
2
3
4
5
6
7
8
9
10
11
12
13
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.XSParticle;
28
29
30
31
32
33
34
35 public class XSParticleRenderer implements ListCellRenderer {
36
37 private final ListCellRenderer listCellRendererDelegate = new DefaultListCellRenderer();
38
39
40
41
42
43
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 XSParticle) {
51 XSParticle particle = (XSParticle) value;
52 StringBuilder sb = new StringBuilder();
53 sb.append(particle.getName());
54 sb.append(":");
55 sb.append(", <");
56 sb.append(particle.getNamespace());
57 sb.append(">");
58 cell.setText(sb.toString());
59 }
60
61 return cell;
62 }
63
64 }