View Javadoc

1   /*
2   Wotonomy: OpenStep design patterns for pure Java applications.
3   Copyright (C) 2001 Michael Powers
4   
5   This library is free software; you can redistribute it and/or
6   modify it under the terms of the GNU Lesser General Public
7   License as published by the Free Software Foundation; either
8   version 2.1 of the License, or (at your option) any later version.
9   
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  Lesser General Public License for more details.
14  
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, see http://www.gnu.org
17  */
18  
19  package net.wotonomy.ui.swing;
20  
21  import java.awt.BorderLayout;
22  import java.awt.Dimension;
23  import java.awt.event.MouseAdapter;
24  import java.awt.event.MouseEvent;
25  
26  import javax.swing.JFrame;
27  import javax.swing.JList;
28  import javax.swing.JPanel;
29  import javax.swing.JScrollPane;
30  import javax.swing.border.EmptyBorder;
31  
32  import net.wotonomy.ui.EOAssociation;
33  import net.wotonomy.ui.EODisplayGroup;
34  import net.wotonomy.ui.swing.util.ObjectInspector;
35  import net.wotonomy.ui.swing.util.WindowUtilities;
36  
37  /***
38  * The DisplayGroupInspector displays a JFrame that
39  * shows allows you to view and manipulate a display group.
40  *
41  * @author michael@mpowers.net
42  * @version $Revision: 904 $
43  */
44  
45  public class DisplayGroupInspector
46  {
47      protected JList list;
48      protected EODisplayGroup displayGroup;
49      
50  /***
51  * Displays and manipulats the specified display group.
52  */
53      public DisplayGroupInspector( EODisplayGroup aDisplayGroup )
54      {
55          displayGroup = aDisplayGroup;
56  
57          list = new JList();
58          list.addMouseListener( new MouseAdapter()
59          {
60              public void mouseClicked( MouseEvent e )
61              {
62                  if ( e.getClickCount() == 2 )
63                  {
64                      Object selection = displayGroup.selectedObject();
65                      if ( selection != null )
66                      {
67                          new ObjectInspector( selection );
68                      }
69                  }
70              }
71          } );
72          
73          EOAssociation assoc = new ListAssociation( list );
74          assoc.bindAspect( EOAssociation.TitlesAspect, displayGroup, "" );
75          assoc.establishConnection();
76  
77          initLayout();
78  
79      }
80      
81      protected void initLayout()
82      {
83          JPanel panel = new JPanel();
84          panel.setLayout( new BorderLayout() );
85      	panel.setBorder( new EmptyBorder( 10, 10, 10, 10 ) );
86  
87          JScrollPane scrollPane = new JScrollPane( list );
88          scrollPane.setPreferredSize( new Dimension( 200, 200 ) );
89  		panel.add( scrollPane, BorderLayout.CENTER );
90  
91          JFrame window = new JFrame();
92          window.setTitle( "Display Group Inspector" );
93          window.getContentPane().add( panel );
94  
95          window.pack();
96          WindowUtilities.cascade( window );
97          window.show();
98      }
99  }
100     
101 /*
102  * $Log$
103  * Revision 1.2  2006/02/18 23:19:05  cgruber
104  * Update imports and maven dependencies.
105  *
106  * Revision 1.1  2006/02/16 13:22:22  cgruber
107  * Check in all sources in eclipse-friendly maven-enabled packages.
108  *
109  * Revision 1.3  2003/08/06 23:07:52  chochos
110  * general code cleanup (mostly, removing unused imports)
111  *
112  * Revision 1.2  2003/06/26 23:28:00  mpowers
113  * Added double click.
114  *
115  * Revision 1.1  2001/05/29 19:57:47  mpowers
116  * Added some neglected files.
117  *
118  *
119  */
120