mirror of
https://github.com/gnustep/libs-gdl2.git
synced 2025-02-22 10:51:04 +00:00
assignment. Replace label with window title. (-runAdaptorsPanel:): Remove unused variable. * DBModeler/DefaultColumnProvider.m: Add missing braces, remove unused ivars. (-cellForColumnNamed:): Autorelease cells. * DBModeler/EOAdditions.m: New EOAttribute KVC methods -allowNull and -setAllowNull:. * DBModeler/GNUmakefile: Add new to project. * DBModeler/KVDataSource.m (-createObject:): Return nil after throwing exception. * DBModeler/MainModelEditor.m (-dragImageForRows:event:dragImageOffset:):: Enable drag and drop for relationships. (-initWithDocument:): Add parenthesis around assignment. Don't release the document window on close. (-ecStuff:): temporarily reload everything in the outline view when something changes. (-viewSelectedObject:): Remove NSLog. Rewrite editor activation. Fix leaks. * DBModeler/Modeler.m (-applicationWillFinishLaunching:): Add new menu items. Don't order our menu in. (-new:,-open:): Move document initializition to _newDocumentWithModel:. (-_newDocumentWithModel:,-newFromDatabase:): New methods. (-validateMenuItem:,-generateSQL:): Ditto. * DBModeler/ModelerAttributeEditor.m (-initWithParentEditor:): Remove unused variables. (-displayGroupDidChangeSelection:): return early if there is no longer a selection. * DBModeler/ModelerEntityEditor.m: (-canSupportCurrentSelection): Remove NSLog. (-displayGroupDidChangeSelection:): Ditto. (-dealloc:): New method. (-initWithParentEditor:): Remove unused variables. Add parens around assignment. Release local variables. * DBModeler/ModelerTableEmbedibleEditor: (-addDefaultTableColumnsForTableView:displayGroup:): Release table columns. (-addTableColumnForItem:tableView:): Ditto. * DBModeler/Inspectors/RelationshipInspector.m: (-selectedEntity, -selectedDestinationAttribute): New methods. (-selectedSourceAttribute, -indexOfSourceAttribute:): Ditto. (-indexOfDestinationAttribute:,joinWithSource:destination:): Ditto. (-selectedJoin:,updateConnectButton,): Ditto. (-refresh): Rewrite using new methods. (-numberOfRowsInTableView:): Add fallback return value. (-tableView:objectValueForTableColumn:row:): Ditto. (-tableView:selectionDidChange:): If a source or destination attribute is now selected, select its counterpart. (-tableView:shouldSelectRow:): New method to disallow entity selection if there is a destination entity. (-tableView:willDisplayCell:forTableColumn:row:): New method, set the cell text color to disabled text color, if we would disallow selection. (-connectionChanged:): Implement disconnection. * DBModeler/SQLGenerator.h/m: New files initial implementation. * DBModeler/Resources/SQLGenerator.gorm: Ditto. * DBModeler/ConsistencyChecker.h/m: Ditto. * DBModeler/ConsistencyResults.h/m: Ditto. * DBModeler/ConsistencyResults.gorm: Ditto. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@21438 72102866-910b-0410-8b05-ffd578937521
212 lines
6.1 KiB
Objective-C
212 lines
6.1 KiB
Objective-C
/**
|
|
ModelerEntityEditor.m
|
|
|
|
Author: Matt Rice <ratmice@yahoo.com>
|
|
Date: Apr 2005
|
|
|
|
This file is part of DBModeler.
|
|
|
|
<license>
|
|
DBModeler is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
DBModeler 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 General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with DBModeler; if not, write to the Free Software
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
</license>
|
|
**/
|
|
|
|
|
|
#include "DefaultColumnProvider.h"
|
|
#include "ModelerAttributeEditor.h"
|
|
#include "ModelerEntityEditor.h"
|
|
#include "KVDataSource.h"
|
|
|
|
#include <EOInterface/EODisplayGroup.h>
|
|
#include <EOAccess/EOEntity.h>
|
|
#include <EOControl/EOObserver.h>
|
|
#include <EOModeler/EOModelerApp.h>
|
|
#include <EOModeler/EOModelerDocument.h>
|
|
|
|
#include <AppKit/NSImage.h>
|
|
#include <AppKit/NSSplitView.h>
|
|
#include <AppKit/NSScrollView.h>
|
|
#include <AppKit/NSTableColumn.h>
|
|
#include <AppKit/NSTableView.h>
|
|
#include <AppKit/NSMenu.h>
|
|
#include <AppKit/NSMenuItem.h>
|
|
#include <AppKit/NSPopUpButton.h>
|
|
#include <AppKit/NSPopUpButtonCell.h>
|
|
|
|
@interface EOModelerDocument (asdf)
|
|
-(void)_setDisplayGroup:(id)displayGroup;
|
|
@end
|
|
|
|
@interface ModelerEntityEditor (Private)
|
|
- (void) _loadColumnsForClass:(Class) aClass;
|
|
@end
|
|
|
|
@implementation ModelerEntityEditor
|
|
|
|
- (BOOL) canSupportCurrentSelection
|
|
{
|
|
id selection = [self selectionWithinViewedObject];
|
|
BOOL flag;
|
|
|
|
if ([selection count] == 0)
|
|
{
|
|
flag = NO;
|
|
return flag;
|
|
}
|
|
selection = [selection objectAtIndex:0];
|
|
flag = [selection isKindOfClass:[EOModel class]];
|
|
return flag;
|
|
}
|
|
|
|
- (NSArray *) friendEditorClasses
|
|
{
|
|
return [NSArray arrayWithObjects: [ModelerAttributeEditor class], nil];
|
|
}
|
|
|
|
- (void) dealloc
|
|
{
|
|
[EOObserverCenter removeObserver:self forObject:[[self document] model]];
|
|
RELEASE(_splitView);
|
|
[dg setDataSource:nil];
|
|
RELEASE(dg);
|
|
[super dealloc];
|
|
}
|
|
|
|
- (id) initWithParentEditor: (EOModelerCompoundEditor *)parentEditor
|
|
{
|
|
if ((self = [super initWithParentEditor:parentEditor]))
|
|
{
|
|
EOClassDescription *classDescription = nil;
|
|
KVDataSource *wds;
|
|
NSScrollView *scrollView;
|
|
NSPopUpButton *cornerView;
|
|
NSMenuItem *mi = [[NSMenuItem alloc] initWithTitle:@"+" action:(SEL)nil keyEquivalent:@""];
|
|
|
|
_splitView = [[NSSplitView alloc] initWithFrame:NSMakeRect(0,0,10,10)];
|
|
scrollView = [[NSScrollView alloc] initWithFrame:NSMakeRect(0,0,10,10)];
|
|
[scrollView setHasHorizontalScroller:YES];
|
|
[scrollView setHasVerticalScroller:YES];
|
|
[scrollView setBorderType: NSBezelBorder];
|
|
|
|
_topTable = [[NSTableView alloc] initWithFrame:NSMakeRect(0,0,10,10)];
|
|
_bottomTable = [[NSTableView alloc] initWithFrame:NSMakeRect(0,0,10,10)];
|
|
[_topTable setAutoresizesAllColumnsToFit:YES];
|
|
[scrollView setDocumentView:_topTable];
|
|
RELEASE(_topTable);
|
|
[_splitView addSubview:scrollView];
|
|
RELEASE(scrollView);
|
|
|
|
scrollView = [[NSScrollView alloc] initWithFrame:NSMakeRect(0,0,10,10)];
|
|
[scrollView setHasHorizontalScroller:YES];
|
|
[scrollView setHasVerticalScroller:YES];
|
|
[scrollView setBorderType: NSBezelBorder];
|
|
[_bottomTable setAutoresizesAllColumnsToFit:YES];
|
|
[scrollView setDocumentView:_bottomTable];
|
|
RELEASE(_bottomTable);
|
|
[_splitView addSubview:scrollView];
|
|
RELEASE(scrollView);
|
|
|
|
|
|
[DefaultColumnProvider class]; // calls +initialize
|
|
|
|
cornerView = [[NSPopUpButton alloc] initWithFrame:[[_topTable cornerView] bounds] pullsDown:YES];
|
|
[cornerView setPreferredEdge:NSMinYEdge];
|
|
[cornerView setTitle:@"+"];
|
|
[[cornerView cell] setArrowPosition:NSPopUpNoArrow];
|
|
//[mi setImage:[NSImage imageNamed:@"plus"]];
|
|
// [mi setOnStateImage:[NSImage imageNamed:@"plus"]];
|
|
// [mi setOffStateImage:[NSImage imageNamed:@"plus"]];
|
|
//[mi setState:NSOnState];
|
|
[[cornerView cell] setUsesItemFromMenu:NO];
|
|
[[cornerView cell] setShowsFirstResponder:NO];
|
|
[[cornerView cell] setShowsStateBy:NSContentsCellMask];
|
|
[[cornerView cell] setMenuItem:mi];
|
|
RELEASE(mi);
|
|
[[cornerView cell] setImagePosition:NSNoImage];
|
|
|
|
[_topTable setCornerView:cornerView];
|
|
RELEASE(cornerView);
|
|
[_topTable setAllowsMultipleSelection:YES];
|
|
|
|
classDescription = nil;
|
|
wds = [[KVDataSource alloc]
|
|
initWithClassDescription:classDescription
|
|
editingContext:[[self document] editingContext]];
|
|
|
|
[wds setDataObject: [[self document] model]];
|
|
[wds setKey:@"entities"];
|
|
dg = [[EODisplayGroup alloc] init];
|
|
[EOObserverCenter addObserver:self forObject:[[self document] model]];
|
|
[dg setDataSource: wds];
|
|
RELEASE(wds);
|
|
[dg setFetchesOnLoad:YES];
|
|
[dg setDelegate: self];
|
|
|
|
[self setupCornerView:cornerView
|
|
tableView:_topTable
|
|
displayGroup:dg
|
|
forClass:[EOEntity class]];
|
|
|
|
[self addDefaultTableColumnsForTableView:_topTable
|
|
displayGroup:dg];
|
|
|
|
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (NSArray *)defaultColumnNamesForClass:(Class)aClass
|
|
{
|
|
NSArray *colNames = [super defaultColumnNamesForClass:aClass];
|
|
if (colNames == nil || [colNames count] == 0)
|
|
{
|
|
if (aClass == [EOEntity class])
|
|
return DefaultEntityColumns;
|
|
else return nil;
|
|
}
|
|
|
|
return colNames;
|
|
}
|
|
|
|
- (void) activate
|
|
{
|
|
[dg fetch];
|
|
}
|
|
|
|
- (NSView *)mainView
|
|
{
|
|
return _splitView;
|
|
}
|
|
|
|
- (void) objectWillChange:(id)anObject
|
|
{
|
|
[[NSRunLoop currentRunLoop] performSelector:@selector(needToFetch:) target:self argument:nil order:999 modes:[NSArray arrayWithObject:NSDefaultRunLoopMode]];
|
|
}
|
|
|
|
- (void) needToFetch:(id)sth
|
|
{
|
|
[dg fetch];
|
|
[_topTable reloadData];
|
|
}
|
|
@end
|
|
|
|
@implementation ModelerEntityEditor (DisplayGroupDelegate)
|
|
- (void) displayGroupDidChangeSelection:(EODisplayGroup *)displayGroup
|
|
{
|
|
[self setSelectionWithinViewedObject: [displayGroup selectedObjects]];
|
|
}
|
|
|
|
@end
|
|
|