Coverage Report - net.wotonomy.ui.DebuggingDelegate
 
Classes in this File Line Coverage Branch Coverage Complexity
DebuggingDelegate
0% 
0% 
1.053
 
 1  
 /*
 2  
 Wotonomy: OpenStep design patterns for pure Java applications.
 3  
 Copyright (C) 2001 Intersect Software Corporation
 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;
 20  
 
 21  
 import java.util.List;
 22  
 
 23  
 import net.wotonomy.control.EODataSource;
 24  
 import net.wotonomy.foundation.NSArray;
 25  
 import net.wotonomy.foundation.NSNotification;
 26  
 
 27  
     /**
 28  
     * A display group delegate that prints messages for each
 29  
     * of the delegate methods.
 30  
     *
 31  
     * @author michael@mpowers.net
 32  
     * @author $Author: cgruber $
 33  
     * @version $Revision: 904 $
 34  
     */
 35  0
     public class DebuggingDelegate implements EODisplayGroup.Delegate
 36  
     {
 37  
         /**
 38  
         * Called when the specified data source fails
 39  
         * to create an object for the specified display group.
 40  
         */
 41  
                 public void displayGroupCreateObjectFailed ( 
 42  
                         EODisplayGroup aDisplayGroup,
 43  
                         EODataSource aDataSource )
 44  
         {
 45  0
             report( "displayGroupCreateObjectFailed", 
 46  0
                 aDisplayGroup,
 47  0
                 new Object[] { aDataSource } );
 48  0
         }
 49  
 
 50  
         /**
 51  
                 * Called after the specified display group's
 52  
                 * data source is changed.
 53  
                 */
 54  
                 public void displayGroupDidChangeDataSource ( 
 55  
                         EODisplayGroup aDisplayGroup )
 56  
         {
 57  0
             report( "displayGroupDidChangeDataSource", 
 58  0
                 aDisplayGroup, 
 59  0
                 new Object[] { } );
 60  0
         }
 61  
 
 62  
                 /**
 63  
                 * Called after the specified display group's
 64  
                 * selection has changed.
 65  
                 */
 66  
                 public void displayGroupDidChangeSelectedObjects ( 
 67  
                         EODisplayGroup aDisplayGroup )
 68  
         {
 69  0
             report( "displayGroupDidChangeSelectedObjects", 
 70  0
                 aDisplayGroup, 
 71  0
                 new Object[] { } );
 72  0
         }
 73  
 
 74  
                 /**
 75  
                 * Called after the specified display group's
 76  
                 * selection has changed.
 77  
                 */
 78  
                 public void displayGroupDidChangeSelection ( 
 79  
                         EODisplayGroup aDisplayGroup )
 80  
         {
 81  0
             report( "displayGroupDidChangeSelection", 
 82  0
                 aDisplayGroup, 
 83  0
                 new Object[] { } );
 84  0
         }
 85  
 
 86  
                 /**
 87  
                 * Called after the specified object display group's
 88  
                 * selection has changed.
 89  
                 */
 90  
                 public void displayGroupDidDeleteObject ( 
 91  
                         EODisplayGroup aDisplayGroup,
 92  
                         Object anObject )
 93  
         {
 94  0
             report( "displayGroupDidDeleteObject", 
 95  0
                 aDisplayGroup, 
 96  0
                 new Object[] { anObject } );
 97  0
         }
 98  
 
 99  
                 /**
 100  
                 * Called after the specified display group
 101  
                 * has fetched the specified object list.
 102  
                 */
 103  
                 public void displayGroupDidFetchObjects ( 
 104  
                         EODisplayGroup aDisplayGroup,
 105  
                         List anObjectList )
 106  
         {
 107  0
             report( "displayGroupDidFetchObjects", 
 108  0
                 aDisplayGroup, 
 109  0
                 new Object[] { anObjectList } );
 110  0
         }
 111  
 
 112  
                 /**
 113  
                 * Called after the specified display group
 114  
                 * has inserted the specified object into
 115  
                 * its internal object list.
 116  
                 */
 117  
                 public void displayGroupDidInsertObject ( 
 118  
                         EODisplayGroup aDisplayGroup,
 119  
                         Object anObject )
 120  
         {
 121  0
             report( "displayGroupDidInsertObject", 
 122  0
                 aDisplayGroup, 
 123  0
                 new Object[] { anObject } );
 124  0
         }
 125  
 
 126  
                 /**
 127  
                 * Called after the specified display group
 128  
                 * has set the specified value for the specified
 129  
                 * object and key.
 130  
                 */
 131  
                 public void displayGroupDidSetValueForObject ( 
 132  
                         EODisplayGroup aDisplayGroup,
 133  
                         Object aValue,
 134  
                         Object anObject,
 135  
                         String aKey )
 136  
         {
 137  0
             report( "displayGroupDidSetValueForObject", 
 138  0
                 aDisplayGroup, 
 139  0
                 new Object[] { aValue, anObject, aKey } );
 140  0
         }
 141  
 
 142  
                 /**
 143  
                 * Called by the specified display group to
 144  
                 * determine what objects should be displayed
 145  
                 * for the objects in the specified list.
 146  
                 * @return An NSArray containing the objects
 147  
                 * to be displayed for the objects in the 
 148  
                 * specified list.
 149  
                 */
 150  
                 public NSArray displayGroupDisplayArrayForObjects ( 
 151  
                         EODisplayGroup aDisplayGroup,
 152  
                         List aList )
 153  
         {
 154  0
             return get( "displayGroupDisplayArrayForObjects", 
 155  0
                 aDisplayGroup, 
 156  0
                 aList );
 157  
         }
 158  
 
 159  
                 /**
 160  
                 * Called by the specified display group before
 161  
                 * it attempts to change the selection.
 162  
         * This implementation returns true.
 163  
                 * @return True to allow the selection to change,
 164  
                 * false otherwise.
 165  
                 */
 166  
                 public boolean displayGroupShouldChangeSelection ( 
 167  
                         EODisplayGroup aDisplayGroup,
 168  
                         List aSelectionList )
 169  
         {
 170  0
             return ask( "displayGroupShouldChangeSelection", 
 171  0
                 aDisplayGroup, 
 172  0
                 new Object[] { aSelectionList } );
 173  
         }
 174  
 
 175  
                 /**
 176  
                 * Called by the specified display group before
 177  
                 * it attempts to delete the specified object.
 178  
         * This implementation returns true.
 179  
                 * @return True to allow the object to be deleted
 180  
                 * false to prevent the deletion.
 181  
                 */
 182  
                 public boolean displayGroupShouldDeleteObject ( 
 183  
                         EODisplayGroup aDisplayGroup,
 184  
                         Object anObject )
 185  
         {
 186  0
             return ask( "displayGroupShouldDeleteObject", 
 187  0
                 aDisplayGroup, 
 188  0
                 new Object[] { anObject } );
 189  
         }
 190  
 
 191  
                 /**
 192  
                 * Called by the specified display group before
 193  
                 * it attempts display the specified alert to
 194  
                 * the user.
 195  
         * This implementation returns true.
 196  
                 * @return True to allow the message to be 
 197  
                 * displayed, false if you want to handle the
 198  
                 * alert yourself and suppress the display group's
 199  
                 * notification.
 200  
                 */
 201  
                 public boolean displayGroupShouldDisplayAlert ( 
 202  
                         EODisplayGroup aDisplayGroup,
 203  
                         String aTitle,
 204  
                         String aMessage )
 205  
         {
 206  0
             return ask( "displayGroupShouldDisplayAlert", 
 207  0
                 aDisplayGroup, 
 208  0
                 new Object[] { aTitle, aMessage } );
 209  
         }
 210  
 
 211  
                 /**
 212  
                 * Called by the specified display group before
 213  
                 * it attempts fetch objects.
 214  
         * This implementation returns true.
 215  
                 * @return True to allow the fetch to take place,
 216  
                 * false to prevent the fetch.
 217  
                 */
 218  
                 public boolean displayGroupShouldFetch ( 
 219  
                         EODisplayGroup aDisplayGroup )
 220  
         {
 221  0
             return ask( "displayGroupShouldFetch", 
 222  0
                 aDisplayGroup, 
 223  0
                 new Object[] {  } );
 224  
         }
 225  
 
 226  
                 /**
 227  
                 * Called by the specified display group before
 228  
                 * it attempts to insert the specified object.
 229  
         * This implementation returns true.
 230  
                 * @return True to allow the object to be inserted
 231  
                 * false to prevent the insertion.
 232  
                 */
 233  
                 public boolean displayGroupShouldInsertObject ( 
 234  
                         EODisplayGroup aDisplayGroup,
 235  
                         Object anObject,
 236  
                         int anIndex )
 237  
         {
 238  0
             return ask( "displayGroupShouldInsertObject", 
 239  0
                 aDisplayGroup, 
 240  0
                 new Object[] { anObject, new Integer( anIndex ) } );
 241  
         }
 242  
 
 243  
                 /**
 244  
                 * No idea what this might indicate,
 245  
                 * nor what the notification indicates.
 246  
         * This implementation returns true.
 247  
                 */
 248  
                 public boolean displayGroupShouldRedisplay ( 
 249  
                         EODisplayGroup aDisplayGroup,
 250  
                         NSNotification aNotification )
 251  
         {
 252  0
             return ask( "displayGroupShouldRedisplay", 
 253  0
                 aDisplayGroup, 
 254  0
                 new Object[] { aNotification } );
 255  
         }
 256  
 
 257  
                 /**
 258  
                 * No idea what this might indicate,
 259  
                 * nor what the notification indicates.
 260  
                 */
 261  
                 public boolean displayGroupShouldRefetch ( 
 262  
                         EODisplayGroup aDisplayGroup,
 263  
                         NSNotification aNotification )
 264  
         {
 265  0
             return ask( "displayGroupShouldRefetch", 
 266  0
                 aDisplayGroup, 
 267  0
                 new Object[] { aNotification } );
 268  
         }
 269  
         
 270  
                 /**
 271  
         * This method is called by all delegate methods that
 272  
         * return void.
 273  
                 * This implementation calls System.out.println.
 274  
         * Override to customize or replace the output.
 275  
                 */
 276  
         protected void report( String aTitle, 
 277  
             EODisplayGroup aDisplayGroup,
 278  
             Object[] aParameterArray )
 279  
         {
 280  0
             String result = aTitle + " : " + aDisplayGroup;
 281  0
             for ( int i = 0; i < aParameterArray.length; i++ )
 282  
             {   
 283  0
                 result += " : " + aParameterArray[i];
 284  
             }
 285  0
             System.out.println( result );
 286  0
         }
 287  
         
 288  
                 /**
 289  
         * This method is called by displayGroupDisplayArrayForObjects.
 290  
                 * This implementation calls report
 291  
         * and returns a copy of the specified list.
 292  
                 */
 293  
         protected NSArray get( String aTitle, 
 294  
             EODisplayGroup aDisplayGroup,
 295  
             List anObjectList )
 296  
         {
 297  0
             report( aTitle, aDisplayGroup, new Object[] { anObjectList } );
 298  0
             return new NSArray( anObjectList );
 299  
         }
 300  
         
 301  
                 /**
 302  
         * This method is called by the methods that 
 303  
         * return a boolean.
 304  
                 * This implementation calls report and return true.
 305  
                 */
 306  
         protected boolean ask( String aTitle, 
 307  
             EODisplayGroup aDisplayGroup,
 308  
             Object[] aParameterArray )
 309  
         {
 310  0
             report( aTitle, aDisplayGroup, aParameterArray );
 311  0
             return true;
 312  
         }
 313  
         
 314  
         
 315  
     }
 316  
 
 317  
 /*
 318  
  * $Log$
 319  
  * Revision 1.2  2006/02/18 23:14:35  cgruber
 320  
  * Update imports and maven dependencies.
 321  
  *
 322  
  * Revision 1.1  2006/02/16 13:22:22  cgruber
 323  
  * Check in all sources in eclipse-friendly maven-enabled packages.
 324  
  *
 325  
  * Revision 1.2  2003/08/06 23:07:52  chochos
 326  
  * general code cleanup (mostly, removing unused imports)
 327  
  *
 328  
  * Revision 1.1  2001/01/24 14:37:24  mpowers
 329  
  * Contributing a delegate useful for debugging.
 330  
  *
 331  
  *
 332  
  */
 333