ftp.nice.ch/Attic/openStep/developer/resources/MiscKit.2.0.5.s.gnutar.gz#/MiscKit2/Temp/Adder/MiscControllerKit.subproj/MiscInspectorMediator.m

This is MiscInspectorMediator.m in view mode; [Download] [Up]

/* MiscInspectorMediator.m created by todd on Sun 05-May-1996 */

#import <AppKit/AppKit.h>
#import "MiscController.h"
#import "MiscInspectorManager.h"

#import "MiscInspectorMediator.h"


@implementation MiscInspectorMediator

/*"
   MiscInspectorMediator mediates between a controller (MiscController
   or subclass) that knows nothing about being inspected
   and the MiscInspectorManager which manages the MiscInspectorController.
   So far I have just used this class by dropping our header in IB,
   instantiating an instance, and connecting the controllerToInspect
   outlet to the controller you'll be inspecting. You don't have to
   make a connection to the MiscInsectorManager because we use
   MiscWindowManager's #windowManagerOfClass: method to find the
   inspector if one exists.

   This class also monitors it's window's key, main and closing status
   so that it can notify the MiscInspectorManager that it can start
   or stop inspecting our designated controller to inspect.
   
   Please note that the inspector classes are very new and experimental,
   and may not even be the best to do inspecting. I haven't looked too
   closely at Tomi's MiscInspectorKit yet but I will.
"*/


- (void) dealloc
{
    NSLog (@"MiscInspectorMediator is freeing.");
    
    // We may as well remove all our observations (NSWindow and NSWindowManager).
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    
    [_controllerToInspect release];
    [super dealloc];
}


- (MiscController*) controllerToInspect
/*"
   Returns our controller we should be inspecting.
"*/
{
    return _controllerToInspect;
}


- (void) setControllerToInspect:(MiscController*)controller
/*"
   Sets our controller to be inspected. Usually if you have many
   controllers to be inspected you'd choose the "parent" controller and
   from it you'd ask for the other controllers (via it's controllerManager).
"*/
{

    if (controller != [self controllerToInspect]) {

        // Removes the old window notifications that were tied to our
        // old controllerToInspect's window. This has to be done before
        // the old controller to inspect is changed.
        [self _unregisterControllerWindowNotifications];
        [self _unregisterWindowManagerNotifications];

        [_controllerToInspect release];
        _controllerToInspect = [controller retain];

        // Creates the new notifications. 
        [self _registerControllerWindowNotifications];
        [self _registerWindowManagerNotifications];
    }
}


- (MiscInspectorManager*) inspectorManager
/*"
   Returns the application's inspector manager if one exists or
   nil if none could be found (via MiscWindowManager's
   #windowManagerOfClass:). Currently there is no support for multiple
   inspector managers.
"*/
{
    return (MiscInspectorManager*)[MiscInspectorManager windowManagerOfClass:
			[MiscInspectorManager class]];
}


//-------------------------------------------------------------------
// 	Window manager notification
//-------------------------------------------------------------------

- (void) windowManagerWillRelease:(NSNotification*)notification
{
    // Can we do a release of ourselves?
    [self autorelease];
}

@end

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.