Coverage Report - net.wotonomy.ui.swing.DisplayGroupInspector
 
Classes in this File Line Coverage Branch Coverage Complexity
DisplayGroupInspector
0% 
0% 
1.667
 
 1  0
 /*
 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  0
     public DisplayGroupInspector( EODisplayGroup aDisplayGroup )
 54  0
     {
 55  0
         displayGroup = aDisplayGroup;
 56  
 
 57  0
         list = new JList();
 58  0
         list.addMouseListener( new MouseAdapter()
 59  
         {
 60  0
             public void mouseClicked( MouseEvent e )
 61  
             {
 62  0
                 if ( e.getClickCount() == 2 )
 63  
                 {
 64  0
                     Object selection = displayGroup.selectedObject();
 65  0
                     if ( selection != null )
 66  
                     {
 67  0
                         new ObjectInspector( selection );
 68  
                     }
 69  
                 }
 70  0
             }
 71  
         } );
 72  
         
 73  0
         EOAssociation assoc = new ListAssociation( list );
 74  0
         assoc.bindAspect( EOAssociation.TitlesAspect, displayGroup, "" );
 75  0
         assoc.establishConnection();
 76  
 
 77  0
         initLayout();
 78  
 
 79  0
     }
 80  
     
 81  
     protected void initLayout()
 82  
     {
 83  0
         JPanel panel = new JPanel();
 84  0
         panel.setLayout( new BorderLayout() );
 85  0
             panel.setBorder( new EmptyBorder( 10, 10, 10, 10 ) );
 86  
 
 87  0
         JScrollPane scrollPane = new JScrollPane( list );
 88  0
         scrollPane.setPreferredSize( new Dimension( 200, 200 ) );
 89  0
                 panel.add( scrollPane, BorderLayout.CENTER );
 90  
 
 91  0
         JFrame window = new JFrame();
 92  0
         window.setTitle( "Display Group Inspector" );
 93  0
         window.getContentPane().add( panel );
 94  
 
 95  0
         window.pack();
 96  0
         WindowUtilities.cascade( window );
 97  0
         window.show();
 98  0
     }
 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