1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package de.mindcrimeilab.xsanalyzer;
19
20 import java.awt.BorderLayout;
21
22 import javax.swing.JComponent;
23 import javax.swing.JList;
24 import javax.swing.JPanel;
25 import javax.swing.ScrollPaneConstants;
26
27 import org.springframework.context.ApplicationEvent;
28 import org.springframework.context.ApplicationListener;
29 import org.springframework.richclient.application.support.AbstractView;
30
31 import de.mindcrimeilab.xsanalyzer.actions.XsAnalyzerApplicationEvent;
32 import de.mindcrimeilab.xsanalyzer.model.NamespacesListModel;
33 import de.mindcrimeilab.xsanalyzer.model.XsAnalyzerApplicationModel;
34 import de.mindcrimeilab.xsanalyzer.ui.renderer.NamespaceItemRenderer;
35
36
37
38
39
40
41
42 public class NamespaceToolWindow extends AbstractView implements ApplicationListener {
43
44 private JList jlNamespaces;
45
46 private XsAnalyzerApplicationModel model;
47
48
49
50
51 public XsAnalyzerApplicationModel getModel() {
52 return model;
53 }
54
55
56
57
58
59 public void setModel(XsAnalyzerApplicationModel model) {
60 this.model = model;
61 if (null != this.model && null != jlNamespaces) {
62 jlNamespaces.setModel(new NamespacesListModel(model.getSchemaModel()));
63 }
64 }
65
66
67
68
69
70
71 @Override
72 protected JComponent createControl() {
73 createList();
74 JPanel jpNamespaces = getComponentFactory().createPanel(new BorderLayout());
75 jpNamespaces.add(getComponentFactory().createScrollPane(jlNamespaces, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED), BorderLayout.CENTER);
76 return jpNamespaces;
77 }
78
79 @Override
80 public void onApplicationEvent(ApplicationEvent event) {
81 logger.debug(event);
82 if (event instanceof XsAnalyzerApplicationEvent) {
83 switch (((XsAnalyzerApplicationEvent) event).getEventType()) {
84 case OPEN:
85 jlNamespaces.setModel(new NamespacesListModel(model.getSchemaModel()));
86 break;
87 }
88 }
89
90 }
91
92 private void createList() {
93 jlNamespaces = getComponentFactory().createList();
94 jlNamespaces.setCellRenderer(new NamespaceItemRenderer());
95 }
96 }