View Javadoc
1   // $Id: InspectTypeDialog.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.ui;
19  
20  import javax.swing.Box;
21  import javax.swing.JComponent;
22  import javax.swing.JLabel;
23  import javax.swing.JTabbedPane;
24  import javax.swing.JTextField;
25  
26  import org.apache.xerces.xs.XSObject;
27  import org.springframework.richclient.command.AbstractCommand;
28  import org.springframework.richclient.dialog.CloseAction;
29  import org.springframework.richclient.dialog.TitledApplicationDialog;
30  import org.springframework.richclient.factory.ComponentFactory;
31  import org.springframework.richclient.layout.GridBagLayoutBuilder;
32  
33  import de.mindcrimeilab.xsanalyzer.ui.panels.AnnotationPanel;
34  import de.mindcrimeilab.xsanalyzer.ui.panels.TypeHierarchyPanel;
35  
36  /**
37   * 
38   * @author Michael Engelhardt<me@mindcrime-ilab.de>
39   * @author $Author: agony $
40   * @version $Revision: 165 $
41   * 
42   */
43  public class InspectTypeDialog extends TitledApplicationDialog {
44  
45      private final XSObject type;
46  
47      private final AnnotationPanel annotationPanel;
48  
49      public InspectTypeDialog(XSObject type) {
50          super();
51          setTitle(getMessage("inspectType.title"));
52          setTitlePaneTitle(getMessage("inspectType.label"));
53          setDescription(getMessage("inspectType.description", new Object[] { type.getName()}));
54          setResizable(false);
55          setCloseAction(CloseAction.DISPOSE);
56          this.type = type;
57          this.annotationPanel = new AnnotationPanel();
58          this.annotationPanel.update(type);
59      }
60  
61      /*
62       * (non-Javadoc)
63       * 
64       * @see org.springframework.richclient.dialog.ApplicationDialog#onFinish()
65       */
66      @Override
67      protected boolean onFinish() {
68          return true;
69      }
70  
71      @Override
72      protected JComponent createTitledDialogContentPane() {
73          final ComponentFactory cf = getComponentFactory();
74          JTabbedPane jtb = cf.createTabbedPane();
75  
76          final TypeHierarchyPanel typeHierarchyPanel = new TypeHierarchyPanel();
77          typeHierarchyPanel.setType(type);
78  
79          GridBagLayoutBuilder builder = new GridBagLayoutBuilder();
80  
81          final JTextField jtfLocalName = cf.createTextField();
82          jtfLocalName.setText(type.getName());
83          jtfLocalName.setEditable(false);
84  
85          final JTextField jtfNamespace = cf.createTextField();
86          jtfNamespace.setText(type.getNamespace());
87          jtfNamespace.setEditable(false);
88  
89          builder.append(new JLabel("Local name:")).append(jtfLocalName, 1, 1, true, false).nextLine();
90          builder.append(new JLabel("Namespace:")).append(jtfNamespace, 1, 1, true, false).nextLine();
91          builder.append(Box.createVerticalStrut(10), 2, 1, true, true);
92  
93          jtb.add("General", builder.getPanel());
94          jtb.add("Type hierarchy", typeHierarchyPanel);
95          jtb.add("Annotations", annotationPanel.getPanel());
96  
97          return jtb;
98      }
99  
100     @Override
101     protected Object[] getCommandGroupMembers() {
102         return new AbstractCommand[] { getFinishCommand()};
103     }
104 
105 }