libs-gdl2/EOModeler/EOMInspectorController.m
Matt Rice 93221c9bc9 * EOModeler/EOMInspectorController.m (-init): Don't release the window
on close.
        (_selectionChanged:): Fix view swapping.  Set view as needing display.

        * EOModeler/EOModelExtensions.m:
        (+mutableAttributedStringWithBoldSubstitutionsWithFormat:): Implement.

        * EOModeler/EOModelerApp.h: Add -removeDocument:, -documentAtPath:,
        and -loadDocumentAtPath: methods.

        * EOModeler/EOModelerApp.m (-init:): Add parentheses around
        assignment.
        (-allPasteboardTypes): Initial implementation.
        (-removeDocument:): If removing the active document, set the active
        document to nil.
        (-documentWithPath:): Change array iterators to unsigned.
        (-registerColumNames:forClass:provider:): Ditto.
        (-modelContainingFetchSpecification:): Temporarily return nil.
        (-nameForFetchSpecification:): Ditto.

        * EOModeler/EOModelerDocument.h: Declare consistency check
        notification constants. Add -adaptor, -appendConsistencyCheckErrorText:,
        -appendConsistencyCheckSuccessText:, -addEntity:, -addRelationship,
        -addAttribute and -delete.

        * EOModeler/EOModelerDocument.m: Add consistency check notification
        constants.  Add private category interface.
        (-firstSelectionOfClass:): Change array iterators to unsigned.
        Remove debugging logs.
        (-validateMenuItem:): Initial implementation.
        (-initWithModel:): Add parentheses around assignment.  Add the model
        to the default model group.
        (-dealloc, -delete:): Initial implementation.
        (-isDirty, -prepareToSave,-checkCloseDocument): Return no temporarily
        until implemented.
        (-saveToPath:): Break long messages into separate lines.
        (-addDefaultEditor:, -addEntity:, -addAttribute:): Ditto.
        (-addRelationship:, ):
        (-activate): Remove commented out code.
        (-closeEditor:, -checkCloseEditor:): Add comments.
        (-canFlattenSelectedAttribute): Add temporary return value.
        (-windowWillClose:): Remove self from the open documents.
        (-checkConsistency:): Implement.
        (-appendConsistencyCheckErrorText:): Ditto.
        (-appendConsistencyCheckSuccessText:): Ditto.

        * EOModeler/EOModelerEditor.m (-initWithDocument:): Add parentheses
        around assignment.  Don't retain our document.
        (-selectionPath:, -viewedObjectPath): Return nil.
        (-[EOModelerCompoundEditor dealloc]): Implement.
        (-[EOModelerCompoundEditor initWithParentObject:): Add parentheses
        around assignment.
        (-[EOModelerEmbedibleEditor pathViewPreferenceHint:): Return nil.

        * EOModeler/GNUmakefile: Remove extra whitespace.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@21440 72102866-910b-0410-8b05-ffd578937521
2005-07-09 17:44:40 +00:00

140 lines
3.9 KiB
Objective-C

/**
EOMInspectorController.m <title>EOMInspectorController Class</title>
Copyright (C) 2005 Free Software Foundation, Inc.
Author: Matt Rice <ratmice@yahoo.com>
Date: April 2005
This file is part of the GNUstep Database Library.
<license>
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, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
</license>
**/
#include <EOModeler/EOModelerApp.h>
#include <EOModeler/EOMInspector.h>
#include <EOModeler/EOMInspectorController.h>
#include <EOModeler/EOModelerEditor.h>
#include <AppKit/NSWindow.h>
#include <AppKit/NSScrollView.h>
#include <AppKit/NSBox.h>
#include <AppKit/NSButtonCell.h>
#include <Foundation/NSNotification.h>
#include <Foundation/NSException.h>
#include <Foundation/NSArray.h>
static EOMInspectorController *_sharedInspectorController;
static NSBox *_placeHolderView;
@interface EOMInspectorController(Private)
- (void) _selectionChanged:(NSNotification *)notif;
@end
@implementation EOMInspectorController
- (id) init
{
if (_sharedInspectorController)
[[NSException exceptionWithName: NSInternalInconsistencyException
reason: @"EOMInspectorController is a singleton"
userInfo:nil] raise];
self = [super init];
window = [[NSWindow alloc] initWithContentRect:NSMakeRect(220, 536, 272, 388)
styleMask:NSTitledWindowMask | NSClosableWindowMask
backing:NSBackingStoreBuffered
defer:YES];
[window setReleasedWhenClosed:NO];
scrollView = [[NSScrollView alloc] initWithFrame: NSMakeRect(0, 0, 250, 68)];
_placeHolderView = [[NSBox alloc] initWithFrame:NSMakeRect(0,68,250,333)];
[_placeHolderView setBorderType:NSNoBorder];
_sharedInspectorController = self;
[[NSNotificationCenter defaultCenter]
addObserver:_sharedInspectorController
selector:@selector(_selectionChanged:)
name:EOMSelectionChangedNotification
object:nil];
[[window contentView] addSubview: scrollView];
return self;
}
- (void) _showInspector
{
[window makeKeyAndOrderFront:self];
[self _selectionChanged:nil];
}
+ (void) showInspector
{
[[self sharedInstance] _showInspector];
}
+ (EOMInspectorController *)sharedInstance
{
if (!_sharedInspectorController)
return [[self alloc] init];
return _sharedInspectorController;
}
- (void) _selectionChanged:(NSNotification *)notif
{
/* load the highest ordered inspector for the new selection
* if the current inspector can support the object, select it instead. */
NSArray *selection = [[EOMApp currentEditor] selectionWithinViewedObject];
id inspector;
if ([selection count])
{
NSArray *inspectors = [EOMInspector allInspectorsThatCanInspectObject: [selection objectAtIndex:0]];
if ([inspectors count])
{
inspector = [inspectors objectAtIndex:0];
[inspector prepareForDisplay];
if ([lastInspector view])
[[window contentView] removeSubview:[lastInspector view]];
if ([inspector view])
[[window contentView] addSubview:[inspector view]];
[[inspector view] setNeedsDisplay:YES];
[inspector refresh];
lastInspector = inspector;
}
else
{
[[lastInspector view] removeFromSuperview];
lastInspector = nil;
NSLog(@"no inspector");
}
}
else
{
NSLog(@"no selection");
}
}
- (void) selectInspector:(id)sender
{
}
@end