From aedc34d55462a75e329bbf342251ff6504cd117e Mon Sep 17 00:00:00 2001 From: Benjamin Culkin Date: Sun, 19 May 2024 17:56:33 -0400 Subject: Initial import from SVN --- .../java/net/wotonomy/ui/DebuggingDelegate.java | 333 +++++++++++++++++++++ 1 file changed, 333 insertions(+) create mode 100644 projects/net.wotonomy.ui/src/main/java/net/wotonomy/ui/DebuggingDelegate.java (limited to 'projects/net.wotonomy.ui/src/main/java/net/wotonomy/ui/DebuggingDelegate.java') diff --git a/projects/net.wotonomy.ui/src/main/java/net/wotonomy/ui/DebuggingDelegate.java b/projects/net.wotonomy.ui/src/main/java/net/wotonomy/ui/DebuggingDelegate.java new file mode 100644 index 0000000..8e9fae2 --- /dev/null +++ b/projects/net.wotonomy.ui/src/main/java/net/wotonomy/ui/DebuggingDelegate.java @@ -0,0 +1,333 @@ +/* +Wotonomy: OpenStep design patterns for pure Java applications. +Copyright (C) 2001 Intersect Software Corporation + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, see http://www.gnu.org +*/ + +package net.wotonomy.ui; + +import java.util.List; + +import net.wotonomy.control.EODataSource; +import net.wotonomy.foundation.NSArray; +import net.wotonomy.foundation.NSNotification; + + /** + * A display group delegate that prints messages for each + * of the delegate methods. + * + * @author michael@mpowers.net + * @author $Author: cgruber $ + * @version $Revision: 904 $ + */ + public class DebuggingDelegate implements EODisplayGroup.Delegate + { + /** + * Called when the specified data source fails + * to create an object for the specified display group. + */ + public void displayGroupCreateObjectFailed ( + EODisplayGroup aDisplayGroup, + EODataSource aDataSource ) + { + report( "displayGroupCreateObjectFailed", + aDisplayGroup, + new Object[] { aDataSource } ); + } + + /** + * Called after the specified display group's + * data source is changed. + */ + public void displayGroupDidChangeDataSource ( + EODisplayGroup aDisplayGroup ) + { + report( "displayGroupDidChangeDataSource", + aDisplayGroup, + new Object[] { } ); + } + + /** + * Called after the specified display group's + * selection has changed. + */ + public void displayGroupDidChangeSelectedObjects ( + EODisplayGroup aDisplayGroup ) + { + report( "displayGroupDidChangeSelectedObjects", + aDisplayGroup, + new Object[] { } ); + } + + /** + * Called after the specified display group's + * selection has changed. + */ + public void displayGroupDidChangeSelection ( + EODisplayGroup aDisplayGroup ) + { + report( "displayGroupDidChangeSelection", + aDisplayGroup, + new Object[] { } ); + } + + /** + * Called after the specified object display group's + * selection has changed. + */ + public void displayGroupDidDeleteObject ( + EODisplayGroup aDisplayGroup, + Object anObject ) + { + report( "displayGroupDidDeleteObject", + aDisplayGroup, + new Object[] { anObject } ); + } + + /** + * Called after the specified display group + * has fetched the specified object list. + */ + public void displayGroupDidFetchObjects ( + EODisplayGroup aDisplayGroup, + List anObjectList ) + { + report( "displayGroupDidFetchObjects", + aDisplayGroup, + new Object[] { anObjectList } ); + } + + /** + * Called after the specified display group + * has inserted the specified object into + * its internal object list. + */ + public void displayGroupDidInsertObject ( + EODisplayGroup aDisplayGroup, + Object anObject ) + { + report( "displayGroupDidInsertObject", + aDisplayGroup, + new Object[] { anObject } ); + } + + /** + * Called after the specified display group + * has set the specified value for the specified + * object and key. + */ + public void displayGroupDidSetValueForObject ( + EODisplayGroup aDisplayGroup, + Object aValue, + Object anObject, + String aKey ) + { + report( "displayGroupDidSetValueForObject", + aDisplayGroup, + new Object[] { aValue, anObject, aKey } ); + } + + /** + * Called by the specified display group to + * determine what objects should be displayed + * for the objects in the specified list. + * @return An NSArray containing the objects + * to be displayed for the objects in the + * specified list. + */ + public NSArray displayGroupDisplayArrayForObjects ( + EODisplayGroup aDisplayGroup, + List aList ) + { + return get( "displayGroupDisplayArrayForObjects", + aDisplayGroup, + aList ); + } + + /** + * Called by the specified display group before + * it attempts to change the selection. + * This implementation returns true. + * @return True to allow the selection to change, + * false otherwise. + */ + public boolean displayGroupShouldChangeSelection ( + EODisplayGroup aDisplayGroup, + List aSelectionList ) + { + return ask( "displayGroupShouldChangeSelection", + aDisplayGroup, + new Object[] { aSelectionList } ); + } + + /** + * Called by the specified display group before + * it attempts to delete the specified object. + * This implementation returns true. + * @return True to allow the object to be deleted + * false to prevent the deletion. + */ + public boolean displayGroupShouldDeleteObject ( + EODisplayGroup aDisplayGroup, + Object anObject ) + { + return ask( "displayGroupShouldDeleteObject", + aDisplayGroup, + new Object[] { anObject } ); + } + + /** + * Called by the specified display group before + * it attempts display the specified alert to + * the user. + * This implementation returns true. + * @return True to allow the message to be + * displayed, false if you want to handle the + * alert yourself and suppress the display group's + * notification. + */ + public boolean displayGroupShouldDisplayAlert ( + EODisplayGroup aDisplayGroup, + String aTitle, + String aMessage ) + { + return ask( "displayGroupShouldDisplayAlert", + aDisplayGroup, + new Object[] { aTitle, aMessage } ); + } + + /** + * Called by the specified display group before + * it attempts fetch objects. + * This implementation returns true. + * @return True to allow the fetch to take place, + * false to prevent the fetch. + */ + public boolean displayGroupShouldFetch ( + EODisplayGroup aDisplayGroup ) + { + return ask( "displayGroupShouldFetch", + aDisplayGroup, + new Object[] { } ); + } + + /** + * Called by the specified display group before + * it attempts to insert the specified object. + * This implementation returns true. + * @return True to allow the object to be inserted + * false to prevent the insertion. + */ + public boolean displayGroupShouldInsertObject ( + EODisplayGroup aDisplayGroup, + Object anObject, + int anIndex ) + { + return ask( "displayGroupShouldInsertObject", + aDisplayGroup, + new Object[] { anObject, new Integer( anIndex ) } ); + } + + /** + * No idea what this might indicate, + * nor what the notification indicates. + * This implementation returns true. + */ + public boolean displayGroupShouldRedisplay ( + EODisplayGroup aDisplayGroup, + NSNotification aNotification ) + { + return ask( "displayGroupShouldRedisplay", + aDisplayGroup, + new Object[] { aNotification } ); + } + + /** + * No idea what this might indicate, + * nor what the notification indicates. + */ + public boolean displayGroupShouldRefetch ( + EODisplayGroup aDisplayGroup, + NSNotification aNotification ) + { + return ask( "displayGroupShouldRefetch", + aDisplayGroup, + new Object[] { aNotification } ); + } + + /** + * This method is called by all delegate methods that + * return void. + * This implementation calls System.out.println. + * Override to customize or replace the output. + */ + protected void report( String aTitle, + EODisplayGroup aDisplayGroup, + Object[] aParameterArray ) + { + String result = aTitle + " : " + aDisplayGroup; + for ( int i = 0; i < aParameterArray.length; i++ ) + { + result += " : " + aParameterArray[i]; + } + System.out.println( result ); + } + + /** + * This method is called by displayGroupDisplayArrayForObjects. + * This implementation calls report + * and returns a copy of the specified list. + */ + protected NSArray get( String aTitle, + EODisplayGroup aDisplayGroup, + List anObjectList ) + { + report( aTitle, aDisplayGroup, new Object[] { anObjectList } ); + return new NSArray( anObjectList ); + } + + /** + * This method is called by the methods that + * return a boolean. + * This implementation calls report and return true. + */ + protected boolean ask( String aTitle, + EODisplayGroup aDisplayGroup, + Object[] aParameterArray ) + { + report( aTitle, aDisplayGroup, aParameterArray ); + return true; + } + + + } + +/* + * $Log$ + * Revision 1.2 2006/02/18 23:14:35 cgruber + * Update imports and maven dependencies. + * + * Revision 1.1 2006/02/16 13:22:22 cgruber + * Check in all sources in eclipse-friendly maven-enabled packages. + * + * Revision 1.2 2003/08/06 23:07:52 chochos + * general code cleanup (mostly, removing unused imports) + * + * Revision 1.1 2001/01/24 14:37:24 mpowers + * Contributing a delegate useful for debugging. + * + * + */ + -- cgit v1.2.3