mirror of
https://github.com/gnustep/libs-gdl2.git
synced 2025-02-19 17:50:47 +00:00
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
188 lines
4.6 KiB
Objective-C
188 lines
4.6 KiB
Objective-C
/**
|
|
EOModelerApp.m <title>EOModelerApp 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/EODefines.h"
|
|
#include "EOModeler/EOModelerApp.h"
|
|
#include "EOModeler/EOModelerDocument.h"
|
|
|
|
#include <EOAccess/EOModel.h>
|
|
#include <EOAccess/EOModelGroup.h>
|
|
|
|
EOModelerApp *EOMApp;
|
|
NSString *EOMSelectionChangedNotification = @"EOModelerSelectionChanged";
|
|
NSString *EOMPropertyPboardType = @"EOModelProperty";
|
|
|
|
static EOModelerDocument *_activeDocument;
|
|
|
|
@interface EOModel (Private)
|
|
- (void) setCreateMutableObjects:(BOOL)flag;
|
|
@end
|
|
|
|
@implementation EOModelerApp : NSApplication
|
|
|
|
- (id) init
|
|
{
|
|
if ((self = [super init]))
|
|
{
|
|
EOMApp = (EOModelerApp*)NSApp;
|
|
_documents = [[NSMutableArray alloc] init];
|
|
_columnsByClass = [[NSMutableDictionary alloc] init];
|
|
}
|
|
|
|
return self;
|
|
}
|
|
|
|
- (NSArray *)allPasteboardTypes
|
|
{
|
|
return [NSArray arrayWithObject:EOMPropertyPboardType];
|
|
}
|
|
|
|
- (EOModelerEditor *)currentEditor;
|
|
{
|
|
return _currentEditor;
|
|
}
|
|
|
|
- (void) setCurrentEditor:(EOModelerEditor *)newEditor
|
|
{
|
|
_currentEditor = newEditor;
|
|
}
|
|
|
|
- (void)addDocument:(EOModelerDocument *)document
|
|
{
|
|
[_documents addObject: document];
|
|
}
|
|
|
|
- (void)removeDocument:(EOModelerDocument *)document
|
|
{
|
|
if (_activeDocument == document)
|
|
_activeDocument = nil;
|
|
[_documents removeObject: document];
|
|
}
|
|
|
|
- (NSArray *)documents
|
|
{
|
|
return [NSArray arrayWithArray: _documents];
|
|
}
|
|
|
|
- (EOModelerDocument *)activeDocument
|
|
{
|
|
//TODO
|
|
return _activeDocument;
|
|
}
|
|
|
|
- (EOModelerDocument *)loadDocumentAtPath:(NSString *)path
|
|
{
|
|
EOModel *loadedModel = [[EOModel alloc] initWithContentsOfFile:path];
|
|
[loadedModel setCreateMutableObjects:YES];
|
|
[[EOModelGroup defaultGroup] addModel:loadedModel];
|
|
EOModelerDocument *loadedDocument = [[EOModelerDocument alloc] initWithModel: loadedModel];
|
|
[self addDocument: loadedDocument];
|
|
RELEASE(loadedDocument);
|
|
return loadedDocument;
|
|
}
|
|
|
|
- (EOModelerDocument *)documentWithPath:(NSString *)path
|
|
{
|
|
unsigned i = 0;
|
|
for (i=0; i < [_documents count]; i++)
|
|
{
|
|
if ([[[_documents objectAtIndex:i] documentPath] isEqual: path])
|
|
return [_documents objectAtIndex:i];
|
|
}
|
|
return nil;
|
|
}
|
|
|
|
- (void)registerColumnName:(NSString *)name
|
|
forClass:(Class)class
|
|
provider:(id <EOMColumnProvider>)provider
|
|
{
|
|
NSMutableDictionary *classDict = [_columnsByClass objectForKey: class];
|
|
if (!classDict)
|
|
{
|
|
classDict = [[NSMutableDictionary alloc] init];
|
|
[_columnsByClass setObject:classDict forKey:class];
|
|
RELEASE(classDict);
|
|
}
|
|
[classDict setObject:provider forKey:name];
|
|
}
|
|
|
|
- (void)registerColumnNames:(NSArray *)names
|
|
forClass:(Class)class
|
|
provider:(id <EOMColumnProvider>)provider
|
|
{
|
|
unsigned i,count = [names count];
|
|
NSMutableDictionary *classDict = [_columnsByClass objectForKey: class];
|
|
|
|
if (!classDict)
|
|
{
|
|
classDict = [[NSMutableDictionary alloc] init];
|
|
[_columnsByClass setObject:classDict forKey:class];
|
|
RELEASE(classDict);
|
|
}
|
|
|
|
for (i = 0; i < count; i++)
|
|
{
|
|
[classDict setObject:provider forKey:[names objectAtIndex:i]];
|
|
}
|
|
}
|
|
|
|
- (NSArray *)columnNamesForClass:(Class)class
|
|
{
|
|
return [[_columnsByClass objectForKey:class] allKeys];
|
|
}
|
|
|
|
- (id <EOMColumnProvider>)providerForName:(NSString *)name class:(Class)class
|
|
{
|
|
return [[_columnsByClass objectForKey:class] objectForKey:name];
|
|
}
|
|
|
|
+ (EOModel *)modelWithPath:(NSString *)path
|
|
{
|
|
id _eom = [[EOModel alloc] initWithContentsOfFile:path];
|
|
[_eom setCreateMutableObjects:YES];
|
|
[[EOModelGroup defaultGroup] addModel: _eom];
|
|
return _eom;
|
|
}
|
|
|
|
+ (EOModel *)modelContainingFetchSpecification:(EOFetchSpecification *)fs
|
|
{
|
|
/* TODO */
|
|
return nil;
|
|
}
|
|
|
|
+ (NSString *)nameForFetchSpecification:(EOFetchSpecification *)fs
|
|
{
|
|
/* TODO */
|
|
return nil;
|
|
}
|
|
|
|
-(void)_setActiveDocument:(EOModelerDocument*)ad
|
|
{
|
|
_activeDocument = ad;
|
|
}
|
|
|
|
@end
|