mirror of
https://github.com/gnustep/libs-gdl2.git
synced 2025-04-22 21:00:44 +00:00
* DBModeler/Modeler.m: Add ability to change the editor.
* DBModeler/MainModelerEditor.m (-activateEmbeddedEditor:): Don't modify editors view subview resizing behaviour. Dont call supers implementation until we have resized the subview. * DBModeler/GNUmakefile: Add new files. * DBModeler/Resources/Key_Diagram.tiff * DBModeler/Resources/Locking_Diagram.tiff * DBModeler/Resources/ClassProperty_Diagram.tiff * DBModeler/AttributesCell.{h,m} * DBModeler/DiagramView.{h,m} * DBModeler/DiagramEditor.{h,m} * DBModeler/EntityView.{h,m} * DBModeler/NSView+Additions.{h,m}: New files, initial implementation of diagram editor. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@23805 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
fa9b96612d
commit
244fbb7fae
17 changed files with 1141 additions and 20 deletions
18
ChangeLog
18
ChangeLog
|
@ -1,3 +1,21 @@
|
|||
2006-10-09 Matt Rice <ratmice@yahoo.com>
|
||||
|
||||
* DBModeler/Modeler.m: Add ability to change the editor.
|
||||
* DBModeler/MainModelerEditor.m (-activateEmbeddedEditor:): Don't
|
||||
modify editors view subview resizing behaviour.
|
||||
Dont call supers implementation until we have resized the subview.
|
||||
* DBModeler/GNUmakefile: Add new files.
|
||||
* DBModeler/Resources/Key_Diagram.tiff
|
||||
* DBModeler/Resources/Locking_Diagram.tiff
|
||||
* DBModeler/Resources/ClassProperty_Diagram.tiff
|
||||
* DBModeler/AttributesCell.{h,m}
|
||||
* DBModeler/DiagramView.{h,m}
|
||||
* DBModeler/DiagramEditor.{h,m}
|
||||
* DBModeler/EntityView.{h,m}
|
||||
* DBModeler/NSView+Additions.{h,m}: New files, initial implementation
|
||||
of diagram editor.
|
||||
|
||||
|
||||
2006-10-03 Matt Rice <ratmice@yahoo.com>
|
||||
|
||||
* EOAccess/EOEntity.m (-awakeWithPropertyList:): Setup the connection
|
||||
|
|
54
DBModeler/AttributeCell.h
Normal file
54
DBModeler/AttributeCell.h
Normal file
|
@ -0,0 +1,54 @@
|
|||
/**
|
||||
AttributeCell.h
|
||||
|
||||
Author: Matt Rice <ratmice@yahoo.com>
|
||||
Date: Oct 2006
|
||||
|
||||
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>
|
||||
**/
|
||||
|
||||
#ifndef __ATTRIBUTE_CELL_H
|
||||
|
||||
#include <AppKit/NSCell.h>
|
||||
#include <AppKit/NSTextFieldCell.h>
|
||||
|
||||
@class NSImageCell;
|
||||
|
||||
@interface TitleCell : NSTextFieldCell
|
||||
@end
|
||||
|
||||
@interface AttributeCell : NSCell
|
||||
{
|
||||
NSTextFieldCell *name;
|
||||
NSSize sz;
|
||||
BOOL isKey, isLock, isProp;
|
||||
NSImageCell *key;
|
||||
NSImageCell *lock;
|
||||
NSImageCell *prop;
|
||||
|
||||
}
|
||||
|
||||
- (void) setLock:(BOOL)flag;
|
||||
- (void) setKey:(BOOL)flag;
|
||||
- (void) setProp:(BOOL)flag;
|
||||
@end
|
||||
|
||||
|
||||
#define __ATTRIBUTE_CELL_H
|
||||
#endif
|
140
DBModeler/AttributeCell.m
Normal file
140
DBModeler/AttributeCell.m
Normal file
|
@ -0,0 +1,140 @@
|
|||
/**
|
||||
AttributeCell.m
|
||||
|
||||
Author: Matt Rice <ratmice@yahoo.com>
|
||||
Date: Oct 2006
|
||||
|
||||
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 "AttributeCell.h"
|
||||
#include <AppKit/NSTextFieldCell.h>
|
||||
#include <AppKit/NSImageCell.h>
|
||||
#include <AppKit/NSImage.h>
|
||||
#include <AppKit/NSGraphics.h>
|
||||
|
||||
@implementation TitleCell
|
||||
- (void) setShowsFirstResponder:(BOOL)flag
|
||||
{
|
||||
}
|
||||
@end
|
||||
|
||||
/* this should probably be done in seperate matrices */
|
||||
@implementation AttributeCell
|
||||
|
||||
- (id) copyWithZone:(NSZone *)zone
|
||||
{
|
||||
AttributeCell *cell = [super copyWithZone:zone];
|
||||
|
||||
cell->name = [name copyWithZone:zone];
|
||||
cell->prop = [prop copyWithZone:zone];
|
||||
cell->lock = [lock copyWithZone:zone];
|
||||
cell->key = [key copyWithZone:zone];
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(name);
|
||||
RELEASE(key);
|
||||
RELEASE(lock);
|
||||
RELEASE(prop);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (id) init
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
name = [[TitleCell alloc] init];
|
||||
[name setEditable:NO];
|
||||
[name setSelectable:NO];
|
||||
[name setAlignment:NSLeftTextAlignment];
|
||||
key = [[NSImageCell alloc] init];
|
||||
lock = [[NSImageCell alloc] init];
|
||||
prop = [[NSImageCell alloc] init];
|
||||
|
||||
[key setImage:[NSImage imageNamed:@"Key_Diagram"]];
|
||||
[lock setImage:[NSImage imageNamed:@"Locking_Diagram"]];
|
||||
[prop setImage:[NSImage imageNamed:@"ClassProperty_Diagram"]];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) setStringValue:(NSString *)str
|
||||
{
|
||||
[name setStringValue:str];
|
||||
}
|
||||
|
||||
- (id) stringValue:(NSString *)str
|
||||
{
|
||||
return [name stringValue];
|
||||
}
|
||||
|
||||
- (void) setKey:(BOOL)flag
|
||||
{
|
||||
|
||||
if (flag)
|
||||
{
|
||||
isKey = flag;
|
||||
}
|
||||
}
|
||||
|
||||
- (void) setLock:(BOOL)flag
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
isLock = flag;
|
||||
}
|
||||
}
|
||||
|
||||
- (void) setProp:(BOOL)flag
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
isProp = flag;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSSize) cellSize
|
||||
{
|
||||
sz = [name cellSize];
|
||||
sz.width += 60;
|
||||
return sz;
|
||||
}
|
||||
|
||||
- (void) drawWithFrame:(NSRect)frame inView:(NSView *)view
|
||||
{
|
||||
|
||||
[name drawWithFrame:NSMakeRect(frame.origin.x, frame.origin.y, sz.width, sz.height) inView:view];
|
||||
|
||||
if (isKey)
|
||||
[key drawWithFrame:NSMakeRect(frame.size.width - 18, frame.origin.y + 2, 11, 6) inView:view];
|
||||
|
||||
if (isLock)
|
||||
[lock drawWithFrame:NSMakeRect(frame.size.width - 36, frame.origin.y + 2, 10, 11) inView:view];
|
||||
|
||||
if (isProp)
|
||||
[prop drawWithFrame:NSMakeRect(frame.size.width - 54, frame.origin.y + 2, 9, 8) inView:view];
|
||||
|
||||
if (_cell.shows_first_responder)
|
||||
{
|
||||
NSFrameRect(frame);
|
||||
}
|
||||
}
|
||||
@end
|
34
DBModeler/DiagramEditor.h
Normal file
34
DBModeler/DiagramEditor.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
/**
|
||||
DiagramEditor.h
|
||||
|
||||
Author: Matt Rice <ratmice@yahoo.com>
|
||||
Date: Oct 2006
|
||||
|
||||
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 <EOModeler/EOModelerEditor.h>
|
||||
@class NSScrollView;
|
||||
|
||||
@interface DiagramEditor : EOModelerEmbedibleEditor
|
||||
{
|
||||
NSScrollView *_mainView;
|
||||
}
|
||||
@end
|
||||
|
88
DBModeler/DiagramEditor.m
Normal file
88
DBModeler/DiagramEditor.m
Normal file
|
@ -0,0 +1,88 @@
|
|||
/**
|
||||
DiagramEditor.m
|
||||
|
||||
Author: Matt Rice <ratmice@yahoo.com>
|
||||
Date: Oct 2006
|
||||
|
||||
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 "DiagramEditor.h"
|
||||
#include "DiagramView.h"
|
||||
#include <EOModeler/EOModelerDocument.h>
|
||||
#include <EOAccess/EOModel.h>
|
||||
#include <EOAccess/EOEntity.h>
|
||||
#include <AppKit/NSScrollView.h>
|
||||
#include <AppKit/NSClipView.h>
|
||||
|
||||
@implementation DiagramEditor
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(_mainView);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (id) initWithParentEditor:(id)parent
|
||||
{
|
||||
DiagramView *dv;
|
||||
NSClipView *cv;
|
||||
self = [super initWithParentEditor:parent];
|
||||
_mainView = [[NSScrollView alloc] initWithFrame:NSMakeRect(0,0,1,1)];
|
||||
cv = [[NSClipView alloc] initWithFrame:NSMakeRect(0,0,1,1)];
|
||||
[_mainView setHasVerticalScroller:YES];
|
||||
[_mainView setHasHorizontalScroller:YES];
|
||||
[_mainView setContentView:cv];
|
||||
RELEASE(cv);
|
||||
dv = [[DiagramView alloc] initWithFrame:NSMakeRect(0,0,1,1)];
|
||||
[_mainView setDocumentView:dv];
|
||||
RELEASE(dv);
|
||||
[dv setModel:[[self document] model]];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSView *)mainView
|
||||
{
|
||||
return _mainView;
|
||||
}
|
||||
|
||||
- (void) activate
|
||||
{
|
||||
EOModel *model = [[self document] model];
|
||||
NSArray *entities = [model entities];
|
||||
int i, c;
|
||||
NSSize s = [_mainView contentSize];
|
||||
id docView = [_mainView documentView];
|
||||
|
||||
[docView setFrameSize:s];
|
||||
for (i = 0, c = [entities count]; i < c; i++)
|
||||
{
|
||||
EOEntity *ent = [entities objectAtIndex:i];
|
||||
NSString *name = [ent name];
|
||||
|
||||
[docView showEntity:name];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL) canSupportCurrentSelection
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
49
DBModeler/DiagramView.h
Normal file
49
DBModeler/DiagramView.h
Normal file
|
@ -0,0 +1,49 @@
|
|||
/**
|
||||
DiagramView.h
|
||||
|
||||
Author: Matt Rice <ratmice@yahoo.com>
|
||||
Date: Oct 2006
|
||||
|
||||
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>
|
||||
**/
|
||||
|
||||
#ifndef __DIAGRAM_VIEW_H
|
||||
#include <AppKit/NSView.h>
|
||||
@class NSColor;
|
||||
@class NSMutableDictionary;
|
||||
@class EOModel;
|
||||
@class NSArray;
|
||||
@class NSString;
|
||||
|
||||
@interface DiagramView : NSView
|
||||
{
|
||||
EOModel *_model;
|
||||
NSMutableDictionary *_shownEntities;
|
||||
NSMutableArray *_relationships;
|
||||
NSColor *_bgColor;
|
||||
NSMutableArray *_subview_order;
|
||||
}
|
||||
- (void) setModel:(EOModel *)model;
|
||||
- (void) showEntity:(NSString *)name;
|
||||
- (void) setupRelationships;
|
||||
- (void) orderViewFront:(id)sender;
|
||||
@end
|
||||
|
||||
#define __DIAGRAM_VIEW_H
|
||||
#endif
|
406
DBModeler/DiagramView.m
Normal file
406
DBModeler/DiagramView.m
Normal file
|
@ -0,0 +1,406 @@
|
|||
/**
|
||||
DiagramView.m
|
||||
|
||||
Author: Matt Rice <ratmice@yahoo.com>
|
||||
Date: Oct 2006
|
||||
|
||||
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 "DiagramView.h"
|
||||
#include "EntityView.h"
|
||||
#include "AttributeCell.h"
|
||||
#include <Foundation/NSSet.h>
|
||||
#include <AppKit/NSScrollView.h>
|
||||
#include <AppKit/NSEvent.h>
|
||||
#include <AppKit/NSGraphics.h>
|
||||
#include <AppKit/NSBezierPath.h>
|
||||
#include <AppKit/NSPasteboard.h>
|
||||
#include <AppKit/NSDragging.h>
|
||||
#include <EOAccess/EOModel.h>
|
||||
#include <EOAccess/EOAttribute.h>
|
||||
#include <EOAccess/EORelationship.h>
|
||||
#include <EOModeler/EOModelExtensions.h>
|
||||
|
||||
@implementation DiagramView
|
||||
- (id) initWithFrame:(NSRect)frameRect
|
||||
{
|
||||
self = [super initWithFrame:frameRect];
|
||||
_shownEntities = [NSMutableDictionary new];
|
||||
_relationships = [NSMutableArray new];
|
||||
_subview_order = [NSMutableArray new];
|
||||
_bgColor = RETAIN([NSColor colorWithCalibratedRed:0.881437 green:0.941223 blue:1.0 alpha:1.0]);
|
||||
[self registerForDraggedTypes:[NSArray arrayWithObject:NSColorPboardType]];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(_shownEntities);
|
||||
RELEASE(_relationships);
|
||||
RELEASE(_subview_order);
|
||||
RELEASE(_bgColor);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (BOOL) prepareForDragOperation:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
- (NSDragOperation) draggingEntered:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
return [sender draggingSourceOperationMask];
|
||||
}
|
||||
|
||||
- (BOOL) performDragOperation:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
NSPasteboard *pb = [sender draggingPasteboard];
|
||||
NSColor *color = [NSColor colorFromPasteboard:pb];
|
||||
|
||||
ASSIGN(_bgColor, color);
|
||||
[self setNeedsDisplay:YES];
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL) isFlipped
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void) setModel:(EOModel *)model
|
||||
{
|
||||
ASSIGN(_model, model);
|
||||
}
|
||||
|
||||
- (void) showEntity:(NSString *)name
|
||||
{
|
||||
EntityView *ev;
|
||||
|
||||
if (!(ev = [_shownEntities objectForKey:name]))
|
||||
{
|
||||
EOEntity *entity = [_model entityNamed:name];
|
||||
NSArray *attribs = [entity attributes];
|
||||
NSRect vis = [[self enclosingScrollView] documentVisibleRect];
|
||||
NSRect evFrame;
|
||||
NSPoint toPoint;
|
||||
int i, c = [attribs count];
|
||||
|
||||
ev = [[EntityView alloc] initWithFrame:NSMakeRect(0,0,1,1)];
|
||||
[ev setTitle:[entity name]];
|
||||
[ev setNumberOfAttributes:c];
|
||||
|
||||
for (i = 0; i < c; i++)
|
||||
{
|
||||
EOAttribute *attrib = [attribs objectAtIndex:i];
|
||||
AttributeCell *cell = [ev cellAtRow:i];
|
||||
|
||||
[cell setStringValue:[attrib name]];
|
||||
[cell setLock:[[entity attributesUsedForLocking] containsObject:attrib]];
|
||||
[cell setProp:[[entity classProperties] containsObject:attrib]];
|
||||
[cell setKey:[[entity primaryKeyAttributes] containsObject:attrib]];
|
||||
}
|
||||
|
||||
[ev sizeToFit];
|
||||
evFrame = [ev frame];
|
||||
|
||||
/* this "layout mechanism" is pure evil... */
|
||||
toPoint.x = vis.origin.x + ((vis.size.width - evFrame.size.width) * rand()/(RAND_MAX + vis.origin.x));
|
||||
toPoint.y = vis.origin.y + ((vis.size.height - evFrame.size.height) * rand()/(RAND_MAX + vis.origin.y));
|
||||
|
||||
[ev setFrameOrigin:toPoint];
|
||||
[_shownEntities setObject:ev forKey:[entity name]];
|
||||
|
||||
[self addSubview:ev];
|
||||
[_subview_order addObject:ev];
|
||||
[self setupRelationships];
|
||||
}
|
||||
else
|
||||
{
|
||||
EOEntity *entity = [_model entityNamed:name];
|
||||
NSArray *attribs = [entity attributes];
|
||||
int i, c = [attribs count];
|
||||
|
||||
[ev setTitle:[entity name]];
|
||||
[ev setNumberOfAttributes:c];
|
||||
|
||||
for (i = 0; i < c; i++)
|
||||
{
|
||||
EOAttribute *attrib = [attribs objectAtIndex:i];
|
||||
AttributeCell *cell = [ev cellAtRow:i];
|
||||
|
||||
[cell setStringValue:[attrib name]];
|
||||
[cell setLock:[[entity attributesUsedForLocking] containsObject:attrib]];
|
||||
[cell setProp:[[entity classProperties] containsObject:attrib]];
|
||||
[cell setKey:[[entity primaryKeyAttributes] containsObject:attrib]];
|
||||
}
|
||||
[ev sizeToFit];
|
||||
[ev setNeedsDisplay:YES];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
int sortSubviews(id view1, id view2, void *context)
|
||||
{
|
||||
DiagramView *self = context;
|
||||
unsigned idx1, idx2;
|
||||
|
||||
idx1 = [self->_subview_order indexOfObject:view1];
|
||||
idx2 = [self->_subview_order indexOfObject:view2];
|
||||
|
||||
return (idx1 < idx2) ? NSOrderedDescending : NSOrderedAscending;
|
||||
}
|
||||
|
||||
- (void) orderViewFront:(NSView *)v
|
||||
{
|
||||
int idx = [_subview_order indexOfObject:v];
|
||||
RETAIN(v);
|
||||
[_subview_order removeObjectAtIndex:idx];
|
||||
[_subview_order insertObject:v atIndex:0];
|
||||
RELEASE(v);
|
||||
[self sortSubviewsUsingFunction:(int (*)(id, id, void *))sortSubviews context:self];
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
- (void) setupRelationships
|
||||
{
|
||||
int i,c;
|
||||
NSArray *stuff = [_shownEntities allKeys];
|
||||
[_relationships removeAllObjects];
|
||||
for (i = 0, c = [stuff count]; i < c; i++)
|
||||
{
|
||||
int j, d;
|
||||
NSString *entName = [stuff objectAtIndex:i];
|
||||
EOEntity *ent = [_model entityNamed:entName];
|
||||
NSArray *rels = [ent relationships];
|
||||
|
||||
for (j = 0, d = [rels count]; j < d; j++)
|
||||
{
|
||||
EORelationship *rel = [rels objectAtIndex:j];
|
||||
EOEntity *dest = [rel destinationEntity];
|
||||
id srcName = [ent name];
|
||||
id destName = [dest name];
|
||||
EntityView *from = [_shownEntities objectForKey:srcName];
|
||||
EntityView *to = [_shownEntities objectForKey:destName];
|
||||
NSArray *srcAttribs = [rel sourceAttributes];
|
||||
NSArray *destAttribs = [rel destinationAttributes];
|
||||
int k, e;
|
||||
for (k = 0, e = [srcAttribs count]; k < e; k++)
|
||||
{
|
||||
id sAttrib = [srcAttribs objectAtIndex:k];
|
||||
id dAttrib = [destAttribs objectAtIndex:k];
|
||||
int sIdx = [[ent attributes] indexOfObject:sAttrib];
|
||||
int dIdx = [[dest attributes] indexOfObject:dAttrib];
|
||||
NSRect fromRect = [from attributeRectAtRow:sIdx];
|
||||
NSRect toRect = [to attributeRectAtRow:dIdx];
|
||||
NSRect fromViewFrame = [from frame];
|
||||
NSRect toViewFrame = [to frame];
|
||||
NSPoint midPoint;
|
||||
NSPoint tmp;
|
||||
float arrowOffset;
|
||||
NSBezierPath *path = [NSBezierPath bezierPath];
|
||||
BOOL fromRight;
|
||||
BOOL toRight;
|
||||
|
||||
[path setLineWidth:2];
|
||||
|
||||
fromRect.origin.y += fromViewFrame.origin.y;
|
||||
toRect.origin.y += toViewFrame.origin.y;
|
||||
|
||||
/* which side of the EntityView the arrow line will be connecting
|
||||
* to, for the source and destination entities */
|
||||
fromRight = (fromViewFrame.origin.x - 40 < toViewFrame.origin.x + toViewFrame.size.width);
|
||||
toRight = (toViewFrame.origin.x - 40 < fromViewFrame.origin.x + fromViewFrame.size.width);
|
||||
|
||||
if (fromRight)
|
||||
{
|
||||
fromRect.origin.x = fromViewFrame.origin.x + fromViewFrame.size.width + 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
fromRect.origin.x = fromViewFrame.origin.x - 5;
|
||||
}
|
||||
|
||||
if (toRight)
|
||||
{
|
||||
toRect.origin.x = toViewFrame.origin.x + toViewFrame.size.width;
|
||||
toRect.origin.x += 5;
|
||||
/* <- */
|
||||
arrowOffset = -5.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
toRect.origin.x = toViewFrame.origin.x;
|
||||
toRect.origin.x -= 5;
|
||||
/* -> */
|
||||
arrowOffset = 5.0;
|
||||
}
|
||||
|
||||
fromRect.origin.y = NSMidY(fromRect);
|
||||
toRect.origin.y = NSMidY(toRect);
|
||||
|
||||
/* every line segment is drawn forwards and backwards so we dont
|
||||
* end up with lightning bolts when filling the arrow */
|
||||
|
||||
/* a recursive relationship...
|
||||
* Don't think they are particularly useful but... */
|
||||
if (fromRect.origin.y == toRect.origin.y
|
||||
&& fromRect.origin.x == toRect.origin.x)
|
||||
{
|
||||
[path moveToPoint:NSMakePoint(toRect.origin.x + 15, toRect.origin.y)];
|
||||
[path lineToPoint:NSMakePoint(toRect.origin.x + 15, toRect.origin.y + 5)];
|
||||
[path lineToPoint:NSMakePoint(toRect.origin.x + 15, toRect.origin.y)];
|
||||
|
||||
[path moveToPoint:NSMakePoint(toRect.origin.x + 15, toRect.origin.y + 5)];
|
||||
[path lineToPoint:NSMakePoint(toRect.origin.x + 20, toRect.origin.y + 5)];
|
||||
[path lineToPoint:NSMakePoint(toRect.origin.x + 15, toRect.origin.y + 5)];
|
||||
|
||||
[path moveToPoint:NSMakePoint(toRect.origin.x + 20, toRect.origin.y + 5)];
|
||||
[path lineToPoint:NSMakePoint(toRect.origin.x + 20, toRect.origin.y)];
|
||||
[path lineToPoint:NSMakePoint(toRect.origin.x + 20, toRect.origin.y + 5)];
|
||||
}
|
||||
|
||||
if ((fromRight || toRight) && !(fromRight && toRight))
|
||||
{
|
||||
/* a line like... +-----
|
||||
* |
|
||||
* -----+
|
||||
* (from the right side, to the left side or vice versa)
|
||||
*/
|
||||
[path moveToPoint:fromRect.origin];
|
||||
|
||||
midPoint.x = (fromRect.origin.x + toRect.origin.x) / 2;
|
||||
midPoint.y = fromRect.origin.y;
|
||||
[path lineToPoint:midPoint];
|
||||
|
||||
[path lineToPoint:fromRect.origin];
|
||||
[path moveToPoint:midPoint];
|
||||
tmp = midPoint;
|
||||
midPoint.x = (fromRect.origin.x + toRect.origin.x) / 2;
|
||||
midPoint.y = toRect.origin.y;
|
||||
[path lineToPoint:midPoint];
|
||||
[path lineToPoint:tmp];
|
||||
|
||||
[path moveToPoint:midPoint];
|
||||
[path lineToPoint:toRect.origin];
|
||||
[path lineToPoint:midPoint];
|
||||
}
|
||||
else if (fromRight && toRight)
|
||||
{
|
||||
/* need to --+ or -------+ <- joint end or start.
|
||||
* make a line | |
|
||||
* like... -------+ --+ <- joint start or end.
|
||||
* from the right side to the right side.
|
||||
*/
|
||||
|
||||
NSPoint jointStart;
|
||||
NSPoint jointEnd;
|
||||
|
||||
if (toRect.origin.x + toRect.size.width < fromRect.origin.x + fromRect.size.width)
|
||||
{
|
||||
jointStart = NSMakePoint(fromRect.origin.x + 20, fromRect.origin.y);
|
||||
jointEnd = NSMakePoint(fromRect.origin.x + 20, toRect.origin.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
jointStart = NSMakePoint(toRect.origin.x + 20, fromRect.origin.y);
|
||||
jointEnd = NSMakePoint(toRect.origin.x + 20, toRect.origin.y);
|
||||
}
|
||||
[path moveToPoint:fromRect.origin];
|
||||
[path lineToPoint:jointStart];
|
||||
[path lineToPoint:fromRect.origin];
|
||||
|
||||
[path moveToPoint:jointStart];
|
||||
[path lineToPoint:jointEnd];
|
||||
[path lineToPoint:jointStart];
|
||||
|
||||
[path moveToPoint:jointEnd];
|
||||
[path lineToPoint:toRect.origin];
|
||||
[path lineToPoint:jointEnd];
|
||||
}
|
||||
|
||||
/* draw arrows.. */
|
||||
if ([rel isToMany])
|
||||
{
|
||||
[path moveToPoint:toRect.origin];
|
||||
[path lineToPoint:NSMakePoint(toRect.origin.x - arrowOffset, toRect.origin.y + arrowOffset)];
|
||||
[path lineToPoint:NSMakePoint(toRect.origin.x - arrowOffset, toRect.origin.y - arrowOffset)];
|
||||
[path lineToPoint:toRect.origin];
|
||||
toRect.origin.x -= arrowOffset;
|
||||
[path moveToPoint:toRect.origin];
|
||||
[path lineToPoint:NSMakePoint(toRect.origin.x - arrowOffset, toRect.origin.y + arrowOffset)];
|
||||
[path lineToPoint:NSMakePoint(toRect.origin.x - arrowOffset, toRect.origin.y - arrowOffset)];
|
||||
[path lineToPoint:toRect.origin];
|
||||
}
|
||||
else
|
||||
{
|
||||
[path moveToPoint:toRect.origin];
|
||||
[path lineToPoint:NSMakePoint(toRect.origin.x - arrowOffset, toRect.origin.y + arrowOffset)];
|
||||
[path lineToPoint:NSMakePoint(toRect.origin.x - arrowOffset, toRect.origin.y - arrowOffset)];
|
||||
[path lineToPoint:toRect.origin];
|
||||
}
|
||||
|
||||
[path closePath];
|
||||
[_relationships addObject:path];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) mouseDown:(NSEvent *)ev
|
||||
{
|
||||
/* create new relationshp??*/
|
||||
}
|
||||
|
||||
- (BOOL) autoscroll:(NSEvent *)ev
|
||||
{
|
||||
NSPoint pt = [self convertPoint:[ev locationInWindow] fromView:nil];
|
||||
NSRect r = _frame;
|
||||
BOOL flag;
|
||||
|
||||
if (!NSPointInRect(pt, r))
|
||||
{
|
||||
if (pt.x > r.size.width)
|
||||
r.size.width = pt.x;
|
||||
if (pt.y > r.size.height)
|
||||
r.size.height = pt.y;
|
||||
[self setFrameSize:r.size];
|
||||
}
|
||||
flag = [super autoscroll:ev];
|
||||
return flag;
|
||||
}
|
||||
|
||||
- (void) drawRect:(NSRect)aRect
|
||||
{
|
||||
int i, c;
|
||||
[_bgColor set];
|
||||
NSRectFill([self frame]);
|
||||
[self setupRelationships];
|
||||
|
||||
for (i = 0, c = [_relationships count]; i < c; i++)
|
||||
{
|
||||
[[NSColor blackColor] set];
|
||||
NSBezierPath *path = [_relationships objectAtIndex:i];
|
||||
[path stroke];
|
||||
[path fill];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
56
DBModeler/EntityView.h
Normal file
56
DBModeler/EntityView.h
Normal file
|
@ -0,0 +1,56 @@
|
|||
/**
|
||||
EntityView.h
|
||||
|
||||
Author: Matt Rice <ratmice@yahoo.com>
|
||||
Date: Oct 2006
|
||||
|
||||
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>
|
||||
**/
|
||||
|
||||
#ifndef _ENTITY_VIEW_H
|
||||
|
||||
#include <AppKit/NSView.h>
|
||||
#include <EOAccess/EOEntity.h>
|
||||
#include "AttributeCell.h"
|
||||
|
||||
@class NSTextFieldCell;
|
||||
@class NSMatrix;
|
||||
@class NSBox;
|
||||
|
||||
@interface EntityView : NSView
|
||||
{
|
||||
NSTextFieldCell *_title;
|
||||
NSRect _titleRect;
|
||||
|
||||
NSMatrix *_attributesView;
|
||||
|
||||
NSBox *_box;
|
||||
NSRect _attribRect;
|
||||
}
|
||||
|
||||
- (void) sizeToFit;
|
||||
- (void) setNumberOfAttributes:(int)num;
|
||||
- (void) setTitle:(NSString *)name;
|
||||
- (AttributeCell *)cellAtRow:(int)row;
|
||||
- (NSRect) attributeRectAtRow:(int)row;
|
||||
- (void) orderViewFront:(id)sender;
|
||||
@end
|
||||
|
||||
#define _ENTITY_VIEW_H
|
||||
#endif
|
202
DBModeler/EntityView.m
Normal file
202
DBModeler/EntityView.m
Normal file
|
@ -0,0 +1,202 @@
|
|||
/**
|
||||
EntityView.m
|
||||
|
||||
Author: Matt Rice <ratmice@yahoo.com>
|
||||
Date: Oct 2006
|
||||
|
||||
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 "EntityView.h"
|
||||
#include "DiagramView.h"
|
||||
#include "AttributeCell.h"
|
||||
#include "NSView+Additions.h"
|
||||
#include <AppKit/NSApplication.h>
|
||||
#include <AppKit/NSGraphics.h>
|
||||
#include <AppKit/NSTextFieldCell.h>
|
||||
#include <AppKit/NSMatrix.h>
|
||||
#include <AppKit/NSEvent.h>
|
||||
#include <AppKit/NSBox.h>
|
||||
#include <AppKit/NSImageCell.h>
|
||||
#include <AppKit/NSImage.h>
|
||||
#include <AppKit/NSScrollView.h>
|
||||
|
||||
|
||||
|
||||
@interface AttributeMatrix : NSMatrix
|
||||
@end
|
||||
|
||||
@implementation AttributeMatrix : NSMatrix
|
||||
- (void) mouseDown:(NSEvent *)ev
|
||||
{
|
||||
[self orderViewFront:self];
|
||||
[super mouseDown:ev];
|
||||
}
|
||||
@end
|
||||
|
||||
@interface AttributeBox : NSBox
|
||||
|
||||
@end
|
||||
|
||||
@implementation AttributeBox : NSBox
|
||||
- (void) drawRect:(NSRect)aRect
|
||||
{
|
||||
[[NSColor blackColor] set];
|
||||
NSFrameRect(aRect);
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation EntityView
|
||||
- (NSString *) description
|
||||
{
|
||||
return [NSString stringWithFormat:@"<%@ %p %@>", [self class], self, [_title stringValue]];
|
||||
}
|
||||
- (BOOL) isFlipped
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void) setTitle:(NSString *)title
|
||||
{
|
||||
[_title setStringValue:title];
|
||||
}
|
||||
|
||||
- (AttributeCell *)cellAtRow:(int)row
|
||||
{
|
||||
return [_attributesView cellAtRow:row column:0];
|
||||
}
|
||||
|
||||
- (void) setNumberOfAttributes:(int)num
|
||||
{
|
||||
[_attributesView renewRows:num columns:1];
|
||||
|
||||
}
|
||||
|
||||
- (void) sizeToFit
|
||||
{
|
||||
NSSize s;
|
||||
NSRect r;
|
||||
[_attributesView sizeToCells];
|
||||
[_attributesView sizeToFit];
|
||||
[_box sizeToFit];
|
||||
|
||||
_titleRect.size = [_title cellSize];
|
||||
r = [_box bounds];
|
||||
s.height = _titleRect.size.height + r.size.height + 4;
|
||||
s.width = ((_titleRect.size.width > r.size.width) ? _titleRect.size.width : r.size.width) + 4;
|
||||
|
||||
[_box setFrameOrigin:NSMakePoint(2, _titleRect.size.height + 2)];
|
||||
[self setFrameSize:s];
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(_title);
|
||||
[super release];
|
||||
}
|
||||
|
||||
- (id) initWithFrame:(NSRect)frameRect
|
||||
{
|
||||
self = [super initWithFrame:frameRect];
|
||||
|
||||
_title = [[TitleCell alloc] init];
|
||||
[_title setFont: [NSFont boldSystemFontOfSize:0]];
|
||||
[_title setEditable:NO];
|
||||
[_title setSelectable:NO];
|
||||
[_title setAlignment:NSLeftTextAlignment];
|
||||
_titleRect = NSMakeRect(2,2, 0, 0);
|
||||
|
||||
_box = [[AttributeBox alloc] initWithFrame:NSMakeRect(2,2,0,0)];
|
||||
[_box setContentViewMargins:NSMakeSize(0,0)];
|
||||
[_box setBorderType:NSBezelBorder];
|
||||
[_box setTitlePosition:NSNoTitle];
|
||||
|
||||
_attributesView = [[AttributeMatrix alloc] initWithFrame:NSMakeRect(1,1,1,1)];
|
||||
[_attributesView setBackgroundColor:[NSColor whiteColor]];
|
||||
[_attributesView setPrototype:[[AttributeCell alloc] init]];
|
||||
[_attributesView setAutosizesCells:YES];
|
||||
|
||||
[[_box contentView] addSubview:_attributesView];
|
||||
RELEASE(_attributesView);
|
||||
[_box sizeToFit];
|
||||
|
||||
[self addSubview:_box];
|
||||
RELEASE(_box);
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) drawRect:(NSRect)dRect
|
||||
{
|
||||
[[NSColor lightGrayColor] set];
|
||||
NSRectFill([self bounds]);
|
||||
|
||||
[_title drawWithFrame:_titleRect inView:self];
|
||||
[[NSColor controlShadowColor] set];
|
||||
NSFrameRect(_bounds);
|
||||
|
||||
[_attributesView setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
- (void) orderViewFront:(NSView *)v
|
||||
{
|
||||
[(DiagramView *)[self superview] orderViewFront:self];
|
||||
}
|
||||
|
||||
- (void) mouseDown:(NSEvent *)ev
|
||||
{
|
||||
NSPoint pt = [self convertPoint:[ev locationInWindow] fromView:nil];
|
||||
// allow clicking on title to move it..
|
||||
if (NSMouseInRect(pt, NSMakeRect(0, 0, _frame.size.width, _titleRect.size.height), YES))
|
||||
{
|
||||
DiagramView *dv = [self superview];
|
||||
float in, up;
|
||||
pt = [dv convertPoint:pt fromView:self];
|
||||
up = pt.y - _frame.origin.y ;
|
||||
in = pt.x - _frame.origin.x;
|
||||
|
||||
[dv orderViewFront:self];
|
||||
|
||||
while ((ev = [NSApp nextEventMatchingMask:NSLeftMouseDraggedMask|NSLeftMouseUpMask untilDate:nil inMode:NSEventTrackingRunLoopMode dequeue:YES]))
|
||||
{
|
||||
float tox, toy;
|
||||
if ([ev type] == NSLeftMouseUp) break;
|
||||
NSPoint pt2 = [dv convertPoint:[ev locationInWindow] fromView:nil];
|
||||
tox = pt2.x - in;
|
||||
toy = pt2.y - up;
|
||||
/* contrain to a positive x,y. */
|
||||
// at 1.0 we can get some libart artifacts for some reason..
|
||||
pt2.x = tox > 1.0 ? tox : 1.1;
|
||||
pt2.y = toy > 1.0 ? toy : 1.1;
|
||||
[self setFrameOrigin:pt2];
|
||||
[self autoscroll:ev];
|
||||
[dv setNeedsDisplay:YES];
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (NSRect) attributeRectAtRow:(int)row
|
||||
{
|
||||
NSRect cellFrame = [_attributesView cellFrameAtRow:row column:0];
|
||||
cellFrame.origin.y += _titleRect.origin.y + _titleRect.size.height;
|
||||
return cellFrame;
|
||||
}
|
||||
@end
|
||||
|
|
@ -36,15 +36,18 @@ ADDITIONAL_NATIVE_LIB_DIRS+=../EOAccess ../EOControl ../EOInterface ../EOModeler
|
|||
ADDITIONAL_NATIVE_LIBS += EOAccess EOControl EOInterface EOModeler
|
||||
|
||||
$(APP_NAME)_RESOURCE_FILES = \
|
||||
Resources/Key_On.tiff \
|
||||
Resources/ClassProperty_On.tiff \
|
||||
Resources/ModelDrag.tiff \
|
||||
Resources/SQLGenerator.gorm \
|
||||
Resources/Info-gnustep.plist \
|
||||
Resources/Key_Diagram.tiff \
|
||||
Resources/Key_Header.tiff \
|
||||
Resources/Locking_On.tiff \
|
||||
Resources/Key_On.tiff \
|
||||
Resources/Locking_Diagram.tiff \
|
||||
Resources/Locking_Header.tiff \
|
||||
Resources/Locking_On.tiff \
|
||||
Resources/ClassProperty_Diagram.tiff \
|
||||
Resources/ClassProperty_Header.tiff \
|
||||
Resources/ClassProperty_On.tiff \
|
||||
Resources/Preferences.gorm \
|
||||
Resources/ConsistencyResults.gorm \
|
||||
Resources/DBModeler.tiff \
|
||||
|
@ -65,7 +68,12 @@ $(APP_NAME)_OBJC_FILES = \
|
|||
SQLGenerator.m \
|
||||
ConsistencyResults.m \
|
||||
Preferences.m \
|
||||
ConsistencyChecker.m
|
||||
ConsistencyChecker.m \
|
||||
DiagramView.m \
|
||||
AttributeCell.m \
|
||||
NSView+Additions.m \
|
||||
EntityView.m \
|
||||
DiagramEditor.m
|
||||
|
||||
include ../common.make
|
||||
include $(GNUSTEP_MAKEFILES)/application.make
|
||||
|
|
|
@ -153,26 +153,11 @@
|
|||
- (void)activateEmbeddedEditor:(EOModelerEmbedibleEditor *)editor
|
||||
{
|
||||
NSView *mainView = [editor mainView];
|
||||
int i, count;
|
||||
NSArray *subviews;
|
||||
|
||||
subviews = [mainView subviews];
|
||||
count = [subviews count];
|
||||
[super activateEmbeddedEditor:editor];
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
NSView *aView = [subviews objectAtIndex:i];
|
||||
|
||||
[aView setAutoresizesSubviews:YES];
|
||||
[aView setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
|
||||
}
|
||||
[mainView setAutoresizesSubviews:YES];
|
||||
[mainView setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
|
||||
[mainView setFrame: [_editorView frame]];
|
||||
|
||||
[_vSplit replaceSubview:_editorView with:mainView];
|
||||
_editorView = mainView;
|
||||
[_editorView setNeedsDisplay:YES];
|
||||
[super activateEmbeddedEditor:editor];
|
||||
}
|
||||
|
||||
- (void)activateEditorWithClass:(Class)embedibleEditorClass
|
||||
|
|
|
@ -201,6 +201,13 @@
|
|||
action: @selector(generateSQL:)
|
||||
keyEquivalent: @""];
|
||||
|
||||
[subMenu addItemWithTitle: _(@"Table Editor")
|
||||
action: @selector(showEditor:)
|
||||
keyEquivalent:@""];
|
||||
|
||||
[subMenu addItemWithTitle: _(@"Diagram Editor")
|
||||
action: @selector(showEditor:)
|
||||
keyEquivalent:@""];
|
||||
[mainMenu setSubmenu:subMenu forItem:[mainMenu addItemWithTitle:_(@"Tools")]];
|
||||
[subMenu release];
|
||||
|
||||
|
@ -236,6 +243,19 @@
|
|||
/* make this a default? */
|
||||
[EOModelerDocument setDefaultEditorClass: NSClassFromString(@"MainModelEditor")];
|
||||
}
|
||||
- (void) showEditor:(id)sender
|
||||
{
|
||||
EOModelerCompoundEditor *ed = [EOMApp currentEditor];
|
||||
|
||||
if ([[sender title] isEqual:_(@"Diagram Editor")])
|
||||
{
|
||||
[ed activateEmbeddedEditor: [ed embedibleEditorOfClass:NSClassFromString(@"DiagramEditor")]];
|
||||
}
|
||||
else if ([[sender title] isEqual:_(@"Table Editor")])
|
||||
{
|
||||
[ed activateEmbeddedEditor: [ed embedibleEditorOfClass:NSClassFromString(@"ModelerEntityEditor")]];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) _newDocumentWithModel:(EOModel *)newModel
|
||||
{
|
||||
|
|
29
DBModeler/NSView+Additions.h
Normal file
29
DBModeler/NSView+Additions.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
/**
|
||||
NSView+Additions.h
|
||||
|
||||
Author: Matt Rice <ratmice@yahoo.com>
|
||||
Date: Oct 2006
|
||||
|
||||
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 <AppKit/NSView.h>
|
||||
|
||||
@interface NSView (Additions)
|
||||
- (void) orderViewFront:(NSView *)v;
|
||||
@end
|
32
DBModeler/NSView+Additions.m
Normal file
32
DBModeler/NSView+Additions.m
Normal file
|
@ -0,0 +1,32 @@
|
|||
/**
|
||||
NSView+Additions.m
|
||||
|
||||
Author: Matt Rice <ratmice@yahoo.com>
|
||||
Date: Oct 2006
|
||||
|
||||
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 "NSView+Additions.h"
|
||||
|
||||
@implementation NSView (Additions)
|
||||
- (void) orderViewFront:(NSView *)v
|
||||
{
|
||||
[[self superview] orderViewFront:self];
|
||||
}
|
||||
@end
|
BIN
DBModeler/Resources/ClassProperty_Diagram.tiff
Normal file
BIN
DBModeler/Resources/ClassProperty_Diagram.tiff
Normal file
Binary file not shown.
BIN
DBModeler/Resources/Key_Diagram.tiff
Normal file
BIN
DBModeler/Resources/Key_Diagram.tiff
Normal file
Binary file not shown.
BIN
DBModeler/Resources/Locking_Diagram.tiff
Normal file
BIN
DBModeler/Resources/Locking_Diagram.tiff
Normal file
Binary file not shown.
Loading…
Reference in a new issue