From 94ffb94a6c551c8571378a8b83c502887d8df8b0 Mon Sep 17 00:00:00 2001 From: Matt Rice Date: Fri, 13 May 2005 00:00:56 +0000 Subject: [PATCH] * GNUmakefile: Compile EOInterface, EOModeler, DBModeler, GDL2Palette if gui is installed. * EOModeler/EOModelExtensions.h: Update copyright header. * EOModeler/EOModelExtensions.m: Ditto. * EOModeler/GNUmakefile: Make EOModeler a native-library, add new files. * EOModeler/Makefile.preamble: Change link flag to use FND_LIBS. * EOModeler/EODefines.h: New file, initial implementation. * EOModeler/EOMInspector.h/m: Ditto. * EOModeler/EOMInspectorController.h/m: Ditto. * EOModeler/EOModelerApp.h/m: Ditto. * EOModeler/EOModelerDocument.h/m: Ditto. * EOModeler/EOModelerEditor.h/m: Ditto. * DBModeler: New directory. * DBModeler/COPYING: New file... * DBModeler/AdaptorsPanel.h/m: New files. * DBModeler/DefaultColumnProvider.h/m: Ditto. * DBModeler/EOAdditions.h/m: Ditto. * DBModeler/KVDataSource.h/m: Ditto. * DBModeler/MainModelEdtior.h/m: Ditto. * DBModeler/Modeler.m: Ditto. * DBModeler/ModelerAttributeEditor.h/m: Ditto. * DBModeler/ModelerTableEmbedibleEditor.h/m: Ditto. * DBModeler/main.m: Ditto. * DBModeler/GNUmakefile: Ditto. * DBModeler/Resources: New directory. * DBModeler/Resources/ModelDrag.tiff: New file. * DBModeler/Resources/ClassProperty_On.tiff: Ditto. * DBModeler/Resources/Key_On.tiff: Ditto. * DBModeler/Inspectors: New directory. * DBModeler/Inspectors/RelationshipInspector.h/m: New files. * DBModeler/Inspectors/AttributeInspector.h/m: Ditto. * DBModeler/Inspectors/RelationshipInspector.gorm: New gorm directory. * DBModeler/Inspectors/AttributeInspector.gorm: Ditto. * GDL2Palette: New directory. * GDL2Palette/GNUmakefile: New file. * GDL2Palette/ConnectionInspector.h/m: Ditto. * GDL2Palette/Foundation+Categories.h/m: Ditto. * GDL2Palette/IB+Categories.m: Ditto. * GDL2Palette/Palette.h/m: Ditto. * GDL2Palette/ResourceManager.h/m: Ditto. * GDL2Palette/GDL2ConnectionInspector.gorm: Ditto. * GDL2Palette/GDL2Palette.tiff: Ditto * GDL2Palette/palette.table git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@21223 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 46 ++++ EOModeler/EODefines.h | 46 ++++ EOModeler/EOMInspector.h | 53 ++++ EOModeler/EOMInspector.m | 211 +++++++++++++++ EOModeler/EOMInspectorController.h | 46 ++++ EOModeler/EOMInspectorController.m | 131 ++++++++++ EOModeler/EOModelExtensions.h | 13 +- EOModeler/EOModelExtensions.m | 14 +- EOModeler/EOModelerApp.h | 70 +++++ EOModeler/EOModelerApp.m | 182 +++++++++++++ EOModeler/EOModelerDocument.h | 54 ++++ EOModeler/EOModelerDocument.m | 399 +++++++++++++++++++++++++++++ EOModeler/EOModelerEditor.h | 77 ++++++ EOModeler/EOModelerEditor.m | 391 ++++++++++++++++++++++++++++ EOModeler/GNUmakefile | 31 ++- EOModeler/Makefile.preamble | 2 +- GNUmakefile | 7 +- 17 files changed, 1750 insertions(+), 23 deletions(-) create mode 100644 EOModeler/EODefines.h create mode 100644 EOModeler/EOMInspector.h create mode 100644 EOModeler/EOMInspector.m create mode 100644 EOModeler/EOMInspectorController.h create mode 100644 EOModeler/EOMInspectorController.m create mode 100644 EOModeler/EOModelerApp.h create mode 100644 EOModeler/EOModelerApp.m create mode 100644 EOModeler/EOModelerDocument.h create mode 100644 EOModeler/EOModelerDocument.m create mode 100644 EOModeler/EOModelerEditor.h create mode 100644 EOModeler/EOModelerEditor.m diff --git a/ChangeLog b/ChangeLog index 3eff422..78d00f5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,49 @@ +2005-05-11 Matt Rice + + * GNUmakefile: Compile EOInterface, EOModeler, DBModeler, GDL2Palette + if gui is installed. + * EOModeler/EOModelExtensions.h: Update copyright header. + * EOModeler/EOModelExtensions.m: Ditto. + * EOModeler/GNUmakefile: Make EOModeler a native-library, add new files. + * EOModeler/Makefile.preamble: Change link flag to use FND_LIBS. + * EOModeler/EODefines.h: New file, initial implementation. + * EOModeler/EOMInspector.h/m: Ditto. + * EOModeler/EOMInspectorController.h/m: Ditto. + * EOModeler/EOModelerApp.h/m: Ditto. + * EOModeler/EOModelerDocument.h/m: Ditto. + * EOModeler/EOModelerEditor.h/m: Ditto. + * DBModeler: New directory. + * DBModeler/COPYING: New file... + * DBModeler/AdaptorsPanel.h/m: New files. + * DBModeler/DefaultColumnProvider.h/m: Ditto. + * DBModeler/EOAdditions.h/m: Ditto. + * DBModeler/KVDataSource.h/m: Ditto. + * DBModeler/MainModelEdtior.h/m: Ditto. + * DBModeler/Modeler.m: Ditto. + * DBModeler/ModelerAttributeEditor.h/m: Ditto. + * DBModeler/ModelerTableEmbedibleEditor.h/m: Ditto. + * DBModeler/main.m: Ditto. + * DBModeler/GNUmakefile: Ditto. + * DBModeler/Resources: New directory. + * DBModeler/Resources/ModelDrag.tiff: New file. + * DBModeler/Resources/ClassProperty_On.tiff: Ditto. + * DBModeler/Resources/Key_On.tiff: Ditto. + * DBModeler/Inspectors: New directory. + * DBModeler/Inspectors/RelationshipInspector.h/m: New files. + * DBModeler/Inspectors/AttributeInspector.h/m: Ditto. + * DBModeler/Inspectors/RelationshipInspector.gorm: New gorm directory. + * DBModeler/Inspectors/AttributeInspector.gorm: Ditto. + * GDL2Palette: New directory. + * GDL2Palette/GNUmakefile: New file. + * GDL2Palette/ConnectionInspector.h/m: Ditto. + * GDL2Palette/Foundation+Categories.h/m: Ditto. + * GDL2Palette/IB+Categories.m: Ditto. + * GDL2Palette/Palette.h/m: Ditto. + * GDL2Palette/ResourceManager.h/m: Ditto. + * GDL2Palette/GDL2ConnectionInspector.gorm: Ditto. + * GDL2Palette/GDL2Palette.tiff: Ditto + * GDL2Palette/palette.table + 2005-05-12 Matt Rice * ChangeLog: Fix previous ChangeLog entry. diff --git a/EOModeler/EODefines.h b/EOModeler/EODefines.h new file mode 100644 index 0000000..623f5ba --- /dev/null +++ b/EOModeler/EODefines.h @@ -0,0 +1,46 @@ +/* -*-objc-*- + EODefines.h + + Copyright (C) 2005 Free Software Foundation, Inc. + + Author: Matt Rice + Date: Apr 2005 + + This file is part of the GNUstep Database Library. + + 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 +*/ + +#ifndef __EOModeler_EODefines_h__ +#define __EOModeler_EODefines_h__ + +#ifdef GNUSTEP_WITH_DLL + +#if BUILD_libEOModeler_DLL +# define GDL2MODELER_EXPORT __declspec(dllexport) +# define GDL2MODELER_DECLARE __declspec(dllexport) +#else +# define GDL2MODELER_EXPORT extern __declspec(dllimport) +# define GDL2MODELER_DECLARE __declspec(dllimport) +#endif + +#else /* GNUSTEP_WITH[OUT]_DLL */ + +# define GDL2MODELER_EXPORT extern +# define GDL2MODELER_DECLARE + +#endif + +#endif /* __EOMODELER_EODefines_h__ */ diff --git a/EOModeler/EOMInspector.h b/EOModeler/EOMInspector.h new file mode 100644 index 0000000..51397b2 --- /dev/null +++ b/EOModeler/EOMInspector.h @@ -0,0 +1,53 @@ +#ifndef __EOMInspector_H__ +#define __EOMInspector_H__ + +/* -*-objc-*- + EOMInspector.h + + Copyright (C) 2005 Free Software Foundation, Inc. + + Author: Matt Rice + Date: Apr 2005 + + This file is part of the GNUstep Database Library. + + 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 +*/ + +#include + +@class NSArray; +@class NSWindow; +@class NSView; +@class NSImage; + +@interface EOMInspector : NSObject +{ + NSImage *image; + NSView *view; + NSWindow *window; +} ++ (NSArray *)allRegisteredInspectors; ++ (NSArray *)allInspectorsThatCanInspectObject:(id)anObject; ++ (EOMInspector *) sharedInspector; + +- (NSView *)view; +- (BOOL) canInspectObject:(id)anObject; +- (void) prepareForDisplay; +- (void) refresh; +- (id) selectedObject; +@end + +#endif // __EOMInspector_H__ diff --git a/EOModeler/EOMInspector.m b/EOModeler/EOMInspector.m new file mode 100644 index 0000000..ed52ad3 --- /dev/null +++ b/EOModeler/EOMInspector.m @@ -0,0 +1,211 @@ +/** + EOMInspector.m EOMInspector Class + + Copyright (C) 2005 Free Software Foundation, Inc. + + Author: Matt Rice + Date: April 2005 + + This file is part of the GNUstep Database Library. + + + 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 + +**/ + +#include +#include "EOModeler/EOMInspector.h" +#include "EOModeler/EOMInspectorController.h" +#include "EOModeler/EOModelerApp.h" +#include "EOModeler/EOModelerEditor.h" +#include +static NSMapTable *_inspectorsByClass; + + +@implementation EOMInspector + +- (id) init +{ + self = [super init]; + + return self; +} + +/* this method currently assumes that allRegisteredInspectors has been called *after* all bundles have been loaded. */ + ++ (NSArray *) allRegisteredInspectors +{ + if (!_inspectorsByClass) + { + NSArray *inspectorClasses = GSObjCAllSubclassesOfClass([self class]); + int i,c; + _inspectorsByClass = NSCreateMapTableWithZone(NSObjectMapKeyCallBacks, + NSObjectMapValueCallBacks, + [inspectorClasses count], + [self zone]); + + for (i = 0, c = [inspectorClasses count]; i < c; i++) + { + [[inspectorClasses objectAtIndex:i] sharedInspector]; + } + } + + return [NSAllMapTableValues(_inspectorsByClass) sortedArrayUsingSelector:@selector(_compareDisplayOrder:)]; +} + ++ (NSArray *) allInspectorsThatCanInspectObject:(id)selectedObject +{ + int i,c; + NSMutableArray *inspectors = [[NSMutableArray alloc] init]; + NSArray *_allInspectors = [self allRegisteredInspectors]; + + for (i = 0, c = [_allInspectors count]; i < c; i++) + { + id gadget = [_allInspectors objectAtIndex:i]; + + if ([gadget canInspectObject:selectedObject]) + { + [inspectors addObject:gadget]; + } + } + return inspectors; +} + ++ (EOMInspector *)sharedInspector +{ + EOMInspector *_sharedInspector = NSMapGet(_inspectorsByClass, [self class]); + + if (!_sharedInspector) + { + id foo = [[self alloc] init]; + NSMapInsert(_inspectorsByClass,[self class], foo); + _sharedInspector = foo; + } + + return _sharedInspector; +} + ++ (BOOL) usesControlActionForValidation +{ + return YES; +} + ++ (NSArray *) selectionBeingValidated +{ + return nil; // FIXME +} + +- (NSString *) displayName +{ + return [window title]; +} + +- (NSImage *) image +{ + if (!image) + image = [NSImage imageNamed:NSStringFromClass([self class])]; + return image; +} + +- (NSImage *) hilightedImage +{ + return [self image]; +} + +- (float) displayOrder +{ + return 10.0; +} + +- (NSComparisonResult) _compareDisplayOrder:(EOMInspector *)inspector +{ + float itsResult, myResult; + + myResult = [self displayOrder]; + itsResult = [inspector displayOrder]; + + return (myResult < itsResult) + ? NSOrderedAscending + : (myResult == itsResult) + ? NSOrderedSame + : NSOrderedDescending; + +} + +- (BOOL) canInspectObject:(id)selectedObject +{ + return NO; +} + +- (void) load +{ + NSLog(@"loading inspector %@",NSStringFromClass([self class])); + if (![NSBundle loadNibNamed:NSStringFromClass([self class]) + owner: self]) + NSLog(@"failed to load: %@.gorm", NSStringFromClass([self class])); +} + +- (void) unload +{ + +} + +- (void) prepareForDisplay +{ + if (!view) + { + [self load]; + } +} + +/* returns the 'view' ivar if it exists otherwise the 'window' ivars content view */ +- (NSView *) view +{ + /* yes we leak this but these live throughout the applictions lifespan, + * we'll only leak one because inspectors are singletons. + * and theres no good way to release it in all cases. */ + if (!view && window) + view = RETAIN([window contentView]); + + return view; +} + +- (void) refresh +{ + return; +} + +- (NSArray *) selectedObjects +{ + return [[EOMApp currentEditor] selectionWithinViewedObject]; +} + +- (id) selectedObject +{ + NSArray *selection = [[EOMApp currentEditor] selectionWithinViewedObject]; + + if ([selection count]) + return [selection objectAtIndex:0]; + + return nil; +} + +- (BOOL) isAdvanced +{ + return NO; +} + + +@end diff --git a/EOModeler/EOMInspectorController.h b/EOModeler/EOMInspectorController.h new file mode 100644 index 0000000..bced420 --- /dev/null +++ b/EOModeler/EOMInspectorController.h @@ -0,0 +1,46 @@ +#ifndef __EOMInspectorController_H__ +#define __EOMInspectorController_H__ + +/* -*-objc-*- + EOMInspectorController.h + + Copyright (C) 2005 Free Software Foundation, Inc. + + Author: Matt Rice + Date: Apr 2005 + + This file is part of the GNUstep Database Library. + + 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 +*/ + +#include + +@class NSWindow; +@class NSScrollView; +@class EOMInspector; + +@interface EOMInspectorController : NSObject +{ + NSWindow *window; + NSScrollView *scrollView; + EOMInspector *lastInspector; +} + ++ (EOMInspectorController *)sharedInstance; ++ (void) showInspector; +@end + +#endif // __EOMInspectorController_H__ diff --git a/EOModeler/EOMInspectorController.m b/EOModeler/EOMInspectorController.m new file mode 100644 index 0000000..32c6226 --- /dev/null +++ b/EOModeler/EOMInspectorController.m @@ -0,0 +1,131 @@ +/** + EOMInspectorController.m EOMInspectorController Class + + Copyright (C) 2005 Free Software Foundation, Inc. + + Author: Matt Rice + Date: April 2005 + + This file is part of the GNUstep Database Library. + + + 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 + +**/ + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +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]; + 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]; + [[window contentView] replaceSubview:[lastInspector view] with:[inspector view]]; + [inspector refresh]; + lastInspector = inspector; + } + else + { + NSLog(@"no inspector"); + } + } + else + { + NSLog(@"no selection"); + } +} + +- (void) selectInspector:(id)sender +{ + +} + +@end diff --git a/EOModeler/EOModelExtensions.h b/EOModeler/EOModelExtensions.h index 0b82274..59b7b63 100644 --- a/EOModeler/EOModelExtensions.h +++ b/EOModeler/EOModelExtensions.h @@ -9,19 +9,18 @@ This file is part of the GNUstep Database Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public + modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + 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 - Library General Public License for more details. + Lesser General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this library; see the file COPYING.LIB. - If not, write to the Free Software Foundation, - 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + 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 */ #ifndef __EOModelExtensions_h__ diff --git a/EOModeler/EOModelExtensions.m b/EOModeler/EOModelExtensions.m index d2d6481..be29bef 100644 --- a/EOModeler/EOModelExtensions.m +++ b/EOModeler/EOModelExtensions.m @@ -9,19 +9,19 @@ This file is part of the GNUstep Database Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public + modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + 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 - Library General Public License for more details. + Lesser General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this library; see the file COPYING.LIB. - If not, write to the Free Software Foundation, - 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + 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 + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "config.h" diff --git a/EOModeler/EOModelerApp.h b/EOModeler/EOModelerApp.h new file mode 100644 index 0000000..c7fbbe3 --- /dev/null +++ b/EOModeler/EOModelerApp.h @@ -0,0 +1,70 @@ +#ifndef __EOModelerApp_H__ +#define __EOModelerApp_H__ + +/* -*-objc-*- + EOModelerApp.h + + Copyright (C) 2005 Free Software Foundation, Inc. + + Author: Matt Rice + Date: Apr 2005 + + This file is part of the GNUstep Database Library. + + 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 +*/ + +#include +#include + +@class EOModelerApp; +@class EOModelerEditor; +@class EOModelerDocument; +@class NSMutableArray; +@class NSMutableDictionary; +@class EODisplayGroup; +@class NSTableColumn; +GDL2MODELER_EXPORT NSString *EOMSelectionChangedNotification; +GDL2MODELER_EXPORT EOModelerApp *EOMApp; +GDL2MODELER_EXPORT NSString *EOMPropertyPboardType; +@protocol EOMColumnProvider +- (void) initColumn:(NSTableColumn *)tableColumn + class:(Class)objectClass + name:(NSString *)columnName + displayGroup:(EODisplayGroup *)dg + document:(EOModelerDocument *)document; +@end + +@interface EOModelerApp : NSApplication +{ + NSMutableArray *_documents; + NSMutableDictionary *_columnsByClass; + EOModelerEditor *_currentEditor; +} +- (EOModelerDocument *)activeDocument; +- (EOModelerEditor *)currentEditor; +- (void)setCurrentEditor:(EOModelerEditor *)editor; +- (NSArray *)documents; +- (void) addDocument:(EOModelerDocument *)document; +- (NSArray *)columnNamesForClass:(Class)aClass; +- (id ) providerForName:(NSString *)name class:(Class)objectClass; +- (void) registerColumnName:(NSString *)columnNames forClass:(Class)objectClass +provider:(id )provider; +- (void) registerColumnNames:(NSArray *)columnNames forClass:(Class)objectClass +provider:(id )provider; + +@end + +#endif // __EOModelerApp_H__ diff --git a/EOModeler/EOModelerApp.m b/EOModeler/EOModelerApp.m new file mode 100644 index 0000000..3c381df --- /dev/null +++ b/EOModeler/EOModelerApp.m @@ -0,0 +1,182 @@ +/** + EOModelerApp.m EOModelerApp Class + + Copyright (C) 2005 Free Software Foundation, Inc. + + Author: Matt Rice + Date: April 2005 + + This file is part of the GNUstep Database Library. + + + 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 + +**/ + +#include "EOModeler/EODefines.h" +#include "EOModeler/EOModelerApp.h" +#include "EOModeler/EOModelerDocument.h" + +#include +#include + +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 +{ + +} + +- (EOModelerEditor *)currentEditor; +{ + return _currentEditor; +} + +- (void) setCurrentEditor:(EOModelerEditor *)newEditor +{ + _currentEditor = newEditor; +} + +- (void)addDocument:(EOModelerDocument *)document +{ + [_documents addObject: document]; +} + +- (void)removeDocument:(EOModelerDocument *)document +{ + [_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 +{ + int 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 )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 )provider +{ + int 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 )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 +{ + +} + ++ (NSString *)nameForFetchSpecification:(EOFetchSpecification *)fs +{ + +} +-(void)_setActiveDocument:(EOModelerDocument*)ad +{ + _activeDocument = ad; +} +@end diff --git a/EOModeler/EOModelerDocument.h b/EOModeler/EOModelerDocument.h new file mode 100644 index 0000000..eac596d --- /dev/null +++ b/EOModeler/EOModelerDocument.h @@ -0,0 +1,54 @@ +#ifndef __EOModelerDocument_H__ +#define __EOModelerDocument_H__ + +/* -*-objc-*- + EOModelerDocument.h + + Copyright (C) 2005 Free Software Foundation, Inc. + + Author: Matt Rice + Date: Apr 2005 + + This file is part of the GNUstep Database Library. + + 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 +*/ + +#include + +@class EOModel; +@class NSMutableArray; +@class NSDictionary; +@class EOEditingContext; +@class EOModelerEditor; + +@interface EOModelerDocument : NSObject +{ + EOModel *_model; + NSMutableArray *_editors; + NSDictionary *_userInfo; + EOEditingContext *_editingContext; +} + ++ (void) setDefaultEditorClass: (Class)defaultEditorClass; +- (id) initWithModel:(EOModel *)model; +- (void) saveAs:(id)sender; +- (NSString *)documentPath; +- (EOModel *)model; +- (EOModelerEditor *) addDefaultEditor; +- (void) activate; +@end + +#endif // __EOModelerDocument_H__ diff --git a/EOModeler/EOModelerDocument.m b/EOModeler/EOModelerDocument.m new file mode 100644 index 0000000..835ba08 --- /dev/null +++ b/EOModeler/EOModelerDocument.m @@ -0,0 +1,399 @@ +/** + EOModelerDocument.m EOModelerDocument Class + + Copyright (C) 2005 Free Software Foundation, Inc. + + Author: Matt Rice + Date: April 2005 + + This file is part of the GNUstep Database Library. + + + 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 + +**/ + +#include + +#include + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include "EOModeler/EODefines.h" +#include "EOModeler/EOModelerDocument.h" +#include "EOModeler/EOModelerEditor.h" +#include "EOModeler/EOModelerApp.h" + +static Class _defaultEditorClass; +static EOModelerEditor *_currentEditorForDocument; + +@interface EOModelerApp (PrivateStuff) +- (void) _setActiveDocument:(EOModelerDocument *)newDocument; +@end + +@interface NSArray (EOMAdditions) +- (id) firstSelectionOfClass:(Class)aClass; +@end +@implementation NSArray (EOMAdditions) +- (id) firstSelectionOfClass:(Class)aClass +{ + int i, c; + id obj; + for (i = 0, c = [self count]; i < c; i++) + { + obj = [self objectAtIndex:i]; + if ([obj isKindOfClass:aClass]) + { + break; + } + + if ([obj isKindOfClass:[NSArray class]]) + { + int j, d; + for (j = 0, d = [obj count]; j < d; j++) + { + id obj2 = [obj objectAtIndex:j]; + + if ([obj2 isKindOfClass:aClass]) + { + obj = obj2; + break; + } + } + } + } + if (![obj isKindOfClass:aClass]) + { + NSLog(@"blah:"); + for (i = 0; c < [self count]; i++) + NSLog(@"## %@", [self objectAtIndex:i]); + /* [[NSException exceptionWithName:NSInternalInconsistencyException + reason:[NSString stringWithFormat:@"Couldn't find a selected %@", aClass] + userInfo:[NSDictionary dictionaryWithObject:self forKey:@"array"]] raise];*/ + return nil; + } + + return obj; +} +@end + +@implementation EOModelerDocument + +- (id)initWithModel:(EOModel*)model +{ + if (self = [super init]) + { + _model = RETAIN(model); + _userInfo = nil; + _editors = [[NSMutableArray alloc] init]; + _editingContext = [[EOEditingContext alloc] init]; + [_editingContext insertObject:model]; + } + return self; +} + +- (EOAdaptor *)adaptor +{ + NS_DURING + return [EOAdaptor adaptorWithModel:_model]; + NS_HANDLER + return nil; + NS_ENDHANDLER +} + +- (EOModel *)model; +{ + return _model; +} + +- (EOEditingContext *)editingContext +{ + return _editingContext; +} + +- (BOOL) isDirty +{ + +} + +- (BOOL) prepareToSave +{ + +} + +- (NSString *)documentPath +{ + return [[[EOMApp activeDocument] model] path]; +} + +- (BOOL)saveToPath:(NSString *)path +{ + if (![[path pathExtension] isEqual:@"eomodeld"]) + path = [path stringByAppendingPathExtension:@"eomodeld"]; + NS_DURING + [_model writeToFile: path]; + return YES; + NS_HANDLER + NSRunAlertPanel(@"Error",@"Save failed: %@",@"Ok",NULL,NULL,[localException reason]); + return NO; + NS_ENDHANDLER +} + +- (BOOL)checkCloseDocument +{ + +} + +- (void)activate +{ + [EOMApp _setActiveDocument: self]; + [[_editors objectAtIndex:0] activate]; + + //[[EOMApp currentEditor] activate]; + // int i,count=[_editors count]; + /* should we really activate the _defaultEditorClass or have some _currentEditor private variable? */ + /* for (i = 0; i < count; i++) + { + EOModelerEditor *anEditor = [_editors objectAtIndex:i]; + if ([anEditor isKindOfClass: _defaultEditorClass]) + { + [anEditor activate]; + } + } + */ +} + +/* Editors stuff */ + +- (NSArray *)editors +{ + return [NSArray arrayWithArray:_editors]; +} + +- (void)addEditor:(EOModelerEditor *)editor +{ + /* check if we already have an editor object? */ + [_editors addObject:editor]; +} + +- (void) closeEditor:(EOModelerEditor *)editor +{ + +} + +- (BOOL)checkCloseEditor:(EOModelerEditor *)editor +{ + +} + +- (EOModelerEditor *) addDefaultEditor +{ + EOModelerEditor *defaultEditor = [[_defaultEditorClass alloc] initWithDocument:self]; + [self addEditor: defaultEditor]; + _currentEditorForDocument = defaultEditor; + RELEASE(defaultEditor); + return defaultEditor; +} + +- (void)addEntity:(id)sender +{ + EOAttribute *attrb; + int entityCount = [[_model entities] count]; + EOEntity *newEntity = [[EOEntity alloc] init]; + + if (![_editors containsObject:[EOMApp currentEditor]]) + { + [[NSException exceptionWithName:NSInternalInconsistencyException reason:@"currentEditor not in edited document exception" userInfo:nil] raise]; + return; + } + + + [newEntity setName: entityCount ? [NSString stringWithFormat: @"Entity%i",entityCount + 1] : @"Entity"]; + [newEntity setClassName:@"EOGenericRecord"]; + attrb = [EOAttribute new]; + [attrb setName:@"Attribute"]; + [newEntity addAttribute:attrb]; + [_editingContext insertObject:newEntity]; + [_model addEntity:AUTORELEASE(newEntity)]; + [(EOModelerCompoundEditor *)[EOMApp currentEditor] viewSelectedObject]; +} + +- (void)addAttribute:(id)sender +{ + EOAttribute *attrb; + EOModelerEditor *currEd = [EOMApp currentEditor]; + int attributeCount; + EOEntity *entityObject; + + /* the currentEditor must be in this document */ + if (![_editors containsObject:currEd]) + { + [[NSException exceptionWithName:NSInternalInconsistencyException reason:@"currentEditor not in edited document exception" userInfo:nil] raise]; + return; + } + + entityObject = [[currEd selectionPath] firstSelectionOfClass:[EOEntity class]]; + attributeCount = [[entityObject attributes] count]; + + attrb = [[EOAttribute alloc] init]; + [attrb setName: attributeCount ? [NSString stringWithFormat: @"Attribute%i", attributeCount + 1] : @"Attribute"]; + [entityObject addAttribute:attrb]; + [_editingContext insertObject:attrb]; + //[[(EOModelerCompoundEditor *)[EOMApp currentEditor] activeEditor] setSelectionWithinViewedObject:[NSArray arrayWithObject: entityObject]]; + [[NSRunLoop currentRunLoop] runUntilDate: [NSDate dateWithTimeIntervalSinceNow:0.001]]; + [(EOModelerCompoundEditor *)[EOMApp currentEditor] viewSelectedObject]; +} + +- (void)addRelationship:(id)sender +{ + EORelationship *newRel; + EOEntity *srcEntity; + EOModelerEditor *currentEditor = [EOMApp currentEditor]; + int count; + + if (![_editors containsObject:currentEditor]) + { + [[NSException exceptionWithName:NSInternalInconsistencyException reason:@"currentEditor not in edited document exception" userInfo:nil] raise]; + return; + } + + srcEntity = [[currentEditor selectionPath] firstSelectionOfClass:[EOEntity class]]; + count = [[srcEntity relationships] count]; + newRel = [[EORelationship alloc] init]; + [newRel setName: count ? [NSString stringWithFormat:@"Relationship%i", count + 1] : @"Relationship"]; + [srcEntity addRelationship:newRel]; + [_editingContext insertObject:newRel]; + //[[(EOModelerCompoundEditor *)[EOMApp currentEditor] activeEditor] setSelectionWithinViewedObject:[NSArray arrayWithObject: srcEntity]]; + [(EOModelerCompoundEditor *)[EOMApp currentEditor] viewSelectedObject]; +} + +- (void)addFetchSpecification:(id)sender +{ + +} + +- (void)addStoredProcedure:(id)sender +{ + +} + +- (void)addArgument:(id)sender +{ + +} + +- (BOOL)canFlattenSelectedAttribute; +{ + // no idea +} + +- (void)flattenAttribute:(id)sender +{ + // likewise +} + +- (void)save:(id)sender +{ + NSString *path; + path = [_model path]; + if (!path) + [self saveAs:self]; + else + [self saveToPath:path]; +} + +- (void)saveAs:(id)sender +{ + NSString *path = [_model path]; + if (!path) + { + id savePanel = [NSSavePanel savePanel]; + int result = [savePanel runModal]; + + if (result == NSOKButton) + { + path = [savePanel filename]; + } + } + [self saveToPath: path]; +} + +- (void)revertToSaved:(id)sender +{ + +} + +-(void)close:(id)sender +{ + +} + +- (void)undo:(id)sender +{ + +} + +- (void)redo:(id)sender +{ + +} + +/* consitency checking stuff */ +- (void) appendConcistencyCheckErrorText: (NSAttributedString *)errorText +{ + +} +- (void) appendConcistencyCheckSuccessText: (NSAttributedString *)successText +{ + +} + ++ (void)setDefaultEditorClass:(Class)editorClass +{ + _defaultEditorClass = editorClass; +} + ++ (Class)defaultEditorClass +{ + return _defaultEditorClass; +} + +- (void)setUserInfo:(NSDictionary*)dictionary +{ + ASSIGN(_userInfo,dictionary); //just a guess +} + +- (NSDictionary *)userInfo +{ + return _userInfo; +} + +- (void) windowDidBecomeKey:(NSNotification *)notif +{ + [self activate]; +} + +@end + diff --git a/EOModeler/EOModelerEditor.h b/EOModeler/EOModelerEditor.h new file mode 100644 index 0000000..0f22194 --- /dev/null +++ b/EOModeler/EOModelerEditor.h @@ -0,0 +1,77 @@ +#ifndef __EOModelerEditor_H__ +#define __EOModelerEditor_H__ + +/* -*-objc-*- + EOModelerEditor.h + + Copyright (C) 2005 Free Software Foundation, Inc. + + Author: Matt Rice + Date: Apr 2005 + + This file is part of the GNUstep Database Library. + + 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 +*/ + +#include + +@class EOModelerDocument; +@class EOModelerEmbedibleEditor; +@class NSView; +@class NSMutableArray; + +@interface EOModelerEditor : NSObject +{ + EOModelerDocument *_document; + NSMutableArray *_editors; + EOModelerEmbedibleEditor *_activeEditor; + NSArray *_viewedObjectPath; + NSArray *_selectionWithinViewedObject; + BOOL _storedProceduresSelected; +} +- (id) initWithDocument:(EOModelerDocument *)document; +- (EOModelerDocument *)document; +- (void) setSelectionWithinViewedObject:(NSArray *)selectionWithin; +- (id) selectionWithinViewedObject; +- (void) setSelectionPath:(NSArray *)selectionPath; +- (NSArray *)selectionPath; +- (void) setViewedObjectPath:(NSArray *)viewedObjectPath; +- (NSArray *)viewedObjectPath; +@end + +@interface EOModelerCompoundEditor : EOModelerEditor +- (void) viewSelectedObject; +- (void) registerEmbedibleEditor:(EOModelerEmbedibleEditor *)embedibleEditor; +- (void) activateEmbeddedEditor:(EOModelerEmbedibleEditor *)embedibleEditor; +- (void) activateEditorWithClass:(Class)editorClass; +- (void) activate; +- (EOModelerEmbedibleEditor *) activeEditor; +- (EOModelerEmbedibleEditor *) embedibleEditorOfClass:(Class)eeClass; +@end + + +@interface EOModelerEmbedibleEditor : EOModelerEditor +{ + EOModelerCompoundEditor *_parentEditor; +} +- (id)initWithParentEditor:(EOModelerCompoundEditor *)parentEditor; +- (NSView *)mainView; +- (BOOL) canSupportCurrentSelection; +- (NSArray *)friendEditorClasses; +@end + +#endif // __EOModelerEditor_H__ + diff --git a/EOModeler/EOModelerEditor.m b/EOModeler/EOModelerEditor.m new file mode 100644 index 0000000..0004a93 --- /dev/null +++ b/EOModeler/EOModelerEditor.m @@ -0,0 +1,391 @@ +/** + EOModelerEditor.m EOModelerEditor Classes + + Copyright (C) 2005 Free Software Foundation, Inc. + + Author: Matt Rice + Date: April 2005 + + This file is part of the GNUstep Database Library. + + + 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 + +**/ + +//#include + +#include +#include + +#include "EOModeler/EOModelerEditor.h" +#include "EOModeler/EOModelerDocument.h" +#include "EOModeler/EOModelerApp.h" + +#include +#include + +#include + +@implementation EOModelerEditor + +- (EOModelerEditor *)initWithDocument:(EOModelerDocument *)document +{ + if (self = [super init]) + { + ASSIGN(_document,document); + } + return self; +} + +- (EOModelerDocument *)document +{ + return _document; +} + +- (void)setSelectionPath:(NSArray *)newSelection +{ + [self subclassResponsibility: _cmd]; +} + +- (NSArray *)selectionPath +{ + [self subclassResponsibility: _cmd]; +} + +- (void)activate +{ + [self subclassResponsibility: _cmd]; +} + +- (NSArray *)selectionWithinViewedObject +{ + return [NSArray array]; +} + +- (void)setSelectionWithinViewedObject:(NSArray *)newSelection +{ + [self subclassResponsibility: _cmd]; +} + +- (void)setViewedObjectPath:(NSArray *)newPath +{ + [self subclassResponsibility: _cmd]; +} + +- (NSArray *)viewedObjectPath +{ + [self subclassResponsibility: _cmd]; +} + +@end + +@implementation EOModelerCompoundEditor + +- (id) initWithDocument:(id)doc +{ + self = [super initWithDocument:doc]; + _editors = [[NSMutableArray alloc] init]; + _activeEditor = nil; + _viewedObjectPath = [[NSArray alloc] initWithObjects:[doc model], nil]; + _selectionWithinViewedObject = [NSArray new]; + return self; +} + +- (EOModelerEmbedibleEditor *)activeEditor +{ + return _activeEditor; +} + +- (void)activateEditorWithClass:(Class)embedibleEditorClass +{ + int i, count = [_editors count]; + for (i = 0; i < count; i++) + { + EOModelerEmbedibleEditor *anEditor = [_editors objectAtIndex:i]; + if ([anEditor isKindOfClass: embedibleEditorClass]) + { + [anEditor activate]; + _activeEditor = anEditor; + } + } +} + +- (void)activateEmbeddedEditor:(EOModelerEmbedibleEditor *)editor +{ + unsigned int index = [_editors indexOfObjectIdenticalTo: editor]; + if (index == NSNotFound) + { + [_editors addObject: editor]; + } + [editor activate]; + _activeEditor = editor; +} + +- (EOModelerEmbedibleEditor *)embedibleEditorOfClass:(Class)editorClass +{ + int i, count = [_editors count]; + for (i = 0; i < count; i++) + { + EOModelerEmbedibleEditor *anEditor = [_editors objectAtIndex:i]; + if ([anEditor isKindOfClass: editorClass]) + { + return anEditor; + } + } + { + EOModelerEmbedibleEditor *newEditor = [[editorClass alloc] initWithParentEditor:self]; + [self registerEmbedibleEditor: newEditor]; + RELEASE(newEditor); + return newEditor; + } +} + + +- (void)registerEmbedibleEditor:(EOModelerEmbedibleEditor *)editor +{ + [_editors addObject:editor]; +} + + +/* getting the selection */ +- (NSArray *)selectionPath +{ + return [_viewedObjectPath arrayByAddingObject:_selectionWithinViewedObject]; +} + +- (NSArray *) viewedObjectPath +{ + return _viewedObjectPath; +} +- (NSArray *)selectionWithinViewedObject +{ + return _selectionWithinViewedObject; +} + + +/* setting the selection */ + +- (void)setSelectionPath:(NSArray *)newSelection +{ + unsigned int indexOfLast = [newSelection indexOfObject:[newSelection lastObject]]; + NSRange allButLastElement; +/* int i,j; + + + printf("%@\n",NSStringFromSelector(_cmd)); + for (i = 0; i < [newSelection count]; i++) + { + id foo = [newSelection objectAtIndex:i]; + if ([foo isKindOfClass:[NSArray class]]) + { + printf("\t"); + for (j = 0; j < [foo count]; j++) + printf("%@", [[foo objectAtIndex:j] class]); + printf("\n"); + } + else + printf("%@\n", [[newSelection objectAtIndex:i] class]); + + } +*/ + if (indexOfLast != NSNotFound || indexOfLast != 1) + { + + allButLastElement.location = 0; + allButLastElement.length = indexOfLast; + + ASSIGN(_viewedObjectPath, [newSelection subarrayWithRange:allButLastElement]); + ASSIGN(_selectionWithinViewedObject, [newSelection lastObject]); + } + else + { + [[NSException exceptionWithName:@"foo" reason:@"bar" userInfo:nil] raise]; + ASSIGN(_viewedObjectPath, [NSArray array]); + ASSIGN(_selectionWithinViewedObject, [NSArray array]); + } + + [[NSNotificationCenter defaultCenter] postNotificationName:EOMSelectionChangedNotification + object:nil]; +} + +- (void) setSelectionWithinViewedObject:(NSArray *) newSelection +{ + /* + int i,j; + printf("%@\n",NSStringFromSelector(_cmd)); + for (i = 0; i < [newSelection count]; i++) + { + id foo = [newSelection objectAtIndex:i]; + if ([foo isKindOfClass:[NSArray class]]) + { + printf("\t"); + for (j = 0; j < [foo count]; j++) + printf("%@", [[foo objectAtIndex:j] class]); + printf("\n"); + } + else + printf("%@\n", [[newSelection objectAtIndex:i] class]); + } */ + ASSIGN(_selectionWithinViewedObject, newSelection); + [[NSNotificationCenter defaultCenter] postNotificationName:EOMSelectionChangedNotification + object:nil]; +} + +- (void) setViewedObjectPath:(NSArray *)newPath +{ + /* + int i,j; + printf("%@\n",NSStringFromSelector(_cmd)); + for (i = 0; i < [newPath count]; i++) + { + id foo = [newPath objectAtIndex:i]; + if ([foo isKindOfClass:[NSArray class]]) + { + printf("\t"); + for (j = 0; j < [foo count]; j++) + printf("%@", [[foo objectAtIndex:j] class]); + printf("\n"); + } + else + printf("%@\n", [[newPath objectAtIndex:i] class]); + } + */ + ASSIGN(_viewedObjectPath, newPath); + [[NSNotificationCenter defaultCenter] postNotificationName:EOMSelectionChangedNotification + object:nil]; +} + +- (void)setStoredProceduresSelected:(BOOL)selected +{ + _storedProceduresSelected = selected; +} + +- (BOOL)storedProceduresSelected +{ + if ([[_viewedObjectPath lastObject] isKindOfClass: NSClassFromString(@"EOModel")]) + { + return _storedProceduresSelected; + } + return NO; +} + +/* viewing the selection */ + +- (void)viewSelectedObject +{ +/* + if (![_selectionWithinViewedObject count]) + return; + { + id object = [_selectionWithinViewedObject objectAtIndex:0]; + [self setSelectionPath: [[_viewedObjectPath arrayByAddingObject: object] + arrayByAddingObject:[NSArray array]]]; + } +*/ +} + +- (void) activate +{ + [EOMApp setCurrentEditor:self]; +} + +@end + +@implementation EOModelerEmbedibleEditor + +- (EOModelerEmbedibleEditor *) initWithParentEditor:(EOModelerCompoundEditor *)parentEditor +{ + if (self = [super initWithDocument: [parentEditor document]]) + { + _parentEditor = parentEditor; + } + return self; +} + +- (EOModelerCompoundEditor *)parentEditor +{ + return _parentEditor; +} + +- (void)selectionDidChange:(NSNotification *)notification +{ + if (self == [_parentEditor activeEditor]) + { + [self activate]; + } +} +/** subclasses should return YES if they can edit the current selection (should return NO if there is no selection */ +- (BOOL)canSupportCurrentSelection +{ + return NO; +} + +/* subclasses should implement */ +- (NSArray *)friendEditorClasses +{ + return nil; +} + +/* subclasses should implement */ +- (NSView *)mainView +{ + return nil; +} + +- (NSString *)pathViewPreferenceHint +{ + [self subclassResponsibility: _cmd]; +} + +- (void)print +{ + [self subclassResponsibility: _cmd]; +} + +/* getting the selection */ +- (NSArray *)selectionPath +{ + return [[self parentEditor] selectionPath]; +} + +- (NSArray *) viewedObjectPath +{ + return [[self parentEditor] viewedObjectPath]; +} +- (NSArray *)selectionWithinViewedObject +{ + return [[self parentEditor] selectionWithinViewedObject]; +} + + +/* setting the selection */ + +- (void)setSelectionPath:(NSArray *)newSelection +{ + [[self parentEditor] setSelectionPath: newSelection]; +} +- (void) setSelectionWithinViewedObject:(NSArray *) newSelection +{ + [[self parentEditor] setSelectionWithinViewedObject: newSelection]; +} + +- (void) setViewedObjectPath:(NSArray *)newPath +{ + [[self parentEditor] setViewedObjectPath: newPath]; +} + +@end + diff --git a/EOModeler/GNUmakefile b/EOModeler/GNUmakefile index 63ad1d5..4ddf508 100644 --- a/EOModeler/GNUmakefile +++ b/EOModeler/GNUmakefile @@ -30,24 +30,41 @@ include $(GNUSTEP_MAKEFILES)/common.make include ../Version # The library to be compiled -LIBRARY_NAME=libgnustep-db2modeler +NATIVE_LIBRARY_NAME=gnustep-db2modeler # The C source files to be compiled -libgnustep-db2modeler_C_FILES = +gnustep-db2modeler_C_FILES = # The Objective-C source files to be compiled -libgnustep-db2modeler_OBJC_FILES = EOModelExtensions.m +gnustep-db2modeler_OBJC_FILES = \ +EOModelExtensions.m \ +EOMInspector.m \ +EOModelExtensions.m \ +EOModelerDocument.m \ +EOMInspectorController.m \ +EOModelerApp.m \ +EOModelerEditor.m -libgnustep-db2modeler_HEADER_FILES_DIR = . -libgnustep-db2modeler_HEADER_FILES_INSTALL_DIR = /EOModeler -libgnustep-db2modeler_HEADER_FILES = EOModelExtensions.h +gnustep-db2modeler_HEADER_FILES_DIR = . +gnustep-db2modeler_HEADER_FILES_INSTALL_DIR = /EOModeler + +gnustep-db2modeler_HEADER_FILES = \ +EOModelExtensions.h \ +EOMInspector.h \ +EOModelExtensions.h \ +EOModelerDocument.h \ +EOMInspectorController.h \ +EOModelerApp.h \ +EOModelerEditor.h \ +EODefines.h + -include Makefile.preamble -include GNUmakefile.local -include $(GNUSTEP_MAKEFILES)/library.make +include $(GNUSTEP_MAKEFILES)/native-library.make -include Makefile.postamble diff --git a/EOModeler/Makefile.preamble b/EOModeler/Makefile.preamble index 945d68b..a2b64cd 100644 --- a/EOModeler/Makefile.preamble +++ b/EOModeler/Makefile.preamble @@ -66,7 +66,7 @@ ADDITIONAL_INSTALL_DIRS = # all the libraries the target library depends upon. ifneq ($(FOUNDATION_LIBRARY_NAME),) -LIBRARIES_DEPEND_UPON = -l$(FOUNDATION_LIBRARY_NAME) +LIBRARIES_DEPEND_UPON = $(FND_LIBS) endif ifneq ($(FOUNDATION_LIB),gnu) LIBRARIES_DEPEND_UPON += -lgnustep-baseadd diff --git a/GNUmakefile b/GNUmakefile index 9d7216a..b985b59 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -29,7 +29,12 @@ include ./Version # # The list of subproject directories # -SUBPROJECTS = EOControl EOAccess EOAdaptors EOModeler Tools +SUBPROJECTS = EOControl EOAccess EOAdaptors Tools + +ifeq ($(GUI_MAKE_LOADED),yes) +SUBPROJECTS += EOInterface EOModeler DBModeler GDL2Palette +endif + DOCUMENT_NAME = GDL2 GDL2_AGSDOC_FILES = GDL2.gsdoc