1 // $Id: AnnotationToolWindow.java 165 2009-05-28 21:46:38Z agony $
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;
19
20 import javax.swing.JComponent;
21
22 import org.apache.commons.logging.Log;
23 import org.apache.commons.logging.LogFactory;
24 import org.apache.xerces.xs.XSObject;
25 import org.springframework.context.ApplicationEvent;
26 import org.springframework.context.ApplicationListener;
27 import org.springframework.richclient.application.support.AbstractView;
28
29 import de.mindcrimeilab.xsanalyzer.actions.XsAnalyzerApplicationEvent;
30 import de.mindcrimeilab.xsanalyzer.ui.panels.AnnotationPanel;
31
32 /**
33 * @author Michael Engelhardt<me@mindcrime-ilab.de>
34 * @author $Author: agony $
35 * @version $Revision: 165 $
36 *
37 */
38 public class AnnotationToolWindow extends AbstractView implements ApplicationListener {
39
40 /** logger */
41 private static final Log logger = LogFactory.getLog("xsAnalyzerApplicationLogger");
42
43 private final AnnotationPanel annotationPanel;
44
45 /**
46 * ctor()
47 */
48 public AnnotationToolWindow() {
49 this.annotationPanel = new AnnotationPanel();
50 }
51
52 /*
53 * (non-Javadoc)
54 *
55 * @see org.springframework.richclient.application.support.AbstractView#createControl()
56 */
57 @Override
58 protected JComponent createControl() {
59 return annotationPanel.getPanel();
60 }
61
62 @Override
63 public void onApplicationEvent(ApplicationEvent event) {
64 logger.debug(event);
65 if (event instanceof XsAnalyzerApplicationEvent) {
66 switch (((XsAnalyzerApplicationEvent) event).getEventType()) {
67 case SHOW_SCHEMA_ELEMENT_DETAIL:
68 Object obj = event.getSource();
69 if (obj instanceof XSObject) {
70 update((XSObject) obj);
71 }
72 break;
73 }
74 }
75 }
76
77 /**
78 * update content view
79 *
80 * @param xso
81 * object to extract annotations from
82 */
83 private void update(XSObject xso) {
84 this.annotationPanel.update(xso);
85 }
86 }