mirror of
https://github.com/gnustep/libs-gdl2.git
synced 2025-02-19 17:50:47 +00:00
DBModeler/ConsistencyChecker.m (+modelConsistencyCheck:): Honor
validation preferences. DBModeler/Modeler.m (-new:): Reimplement. (-setAdaptor:): Bail out it adaptor cannot be located. (-application:openFile:): Fine tune path checking and correct return values. (-openPrefs:): Implement. * DBModeler/Inspectors/RelationshipInspector.m (-displayName): Implement. (-selectedEntity): Validate selected row before commencing. (-selectedDestinationAttribute): Reimplement. (-updateConnectButton): Update enabled state of connect button. (-refresh): Correct handling of src/destAttrib_tableView. (-tableViewSelectionDidChange:): Allways call updateConnectButton. * DBModeler/SQLGenerator.m (-openSQLGenerator:): Reimplement. (-executeSQL:): Handle invalid adpator or connection information. (-saveAs:): Handle abort correctly. (-generate): Handle missing expression class. * DBModeler/ModelerTableEmbedibleEditor.h * DBModeler/ModelerEntityEditor.m (initWithParentEditor:): Correct autoresize behavior. (-activate): Update selection. (-needToFetch:): Do not reloadData in _topTable. (-displayGroupDidChangeSelection:): Update selection on parent. * DBModeler/ModelerTableEmbedibleEditor.m (-addDefaultTableColumnsForTableView:displayGroup:): Call tile instead of sizeToFit. * DBModeler/EOAdditions.m: Fix leaks. (setIsClassProperty): Reimplement. (-[setIsPrimaryKey:]): Ditto. (-[setIsClassProperty:]): Correct call to function. (-[isUsedForLocking]): Implement. (-[setIsUsedForLocking:]): Ditto. * DBModeler/MainModelEditor.h * DBModeler/MainModelEditor.m: Update view handling. * DBModeler/DefaultColumnProvider.m: Update handling of properties. * DBModeler/ModelerAttributeEditor.m: Update general GUI interaction. * DBModeler/Preferences.h: New file. * DBModeler/Preferences.m: Ditto. * DBModeler/Inspectors/RelationshipInspector.tiff: New file. * DBModeler/Inspectors/GNUmakefile: Add new file. * DBModeler/Resources/Preferences.gorm: New files. * DBModeler/Resources/Key_Header.tiff: Ditto. * DBModeler/Resources/ClassProperty_Header.tiff: Ditto. * DBModeler/Resources/Locking_On.tiff: Ditto. * DBModeler/Resources/Key_On.tiff: Ditto. * DBModeler/GNUmakefile: Add new files. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@23397 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
5109a54a70
commit
efecac5875
27 changed files with 776 additions and 185 deletions
48
ChangeLog
48
ChangeLog
|
@ -52,6 +52,54 @@
|
|||
(-[EOModelerEmbedibleEditor dealloc]): Implement.
|
||||
(-[EOModelerEmbedibleEditor initWithParentEditor:]): Observe
|
||||
EOMSelectionChangedNotification.
|
||||
|
||||
DBModeler/ConsistencyChecker.m (+modelConsistencyCheck:): Honor
|
||||
validation preferences.
|
||||
DBModeler/Modeler.m (-new:): Reimplement.
|
||||
(-setAdaptor:): Bail out it adaptor cannot be located.
|
||||
(-application:openFile:): Fine tune path checking and correct return
|
||||
values.
|
||||
(-openPrefs:): Implement.
|
||||
* DBModeler/Inspectors/RelationshipInspector.m
|
||||
(-displayName): Implement.
|
||||
(-selectedEntity): Validate selected row before commencing.
|
||||
(-selectedDestinationAttribute): Reimplement.
|
||||
(-updateConnectButton): Update enabled state of connect button.
|
||||
(-refresh): Correct handling of src/destAttrib_tableView.
|
||||
(-tableViewSelectionDidChange:): Allways call updateConnectButton.
|
||||
* DBModeler/SQLGenerator.m (-openSQLGenerator:): Reimplement.
|
||||
(-executeSQL:): Handle invalid adpator or connection information.
|
||||
(-saveAs:): Handle abort correctly.
|
||||
(-generate): Handle missing expression class.
|
||||
* DBModeler/ModelerTableEmbedibleEditor.h
|
||||
* DBModeler/ModelerEntityEditor.m (initWithParentEditor:): Correct
|
||||
autoresize behavior.
|
||||
(-activate): Update selection.
|
||||
(-needToFetch:): Do not reloadData in _topTable.
|
||||
(-displayGroupDidChangeSelection:): Update selection on parent.
|
||||
* DBModeler/ModelerTableEmbedibleEditor.m
|
||||
(-addDefaultTableColumnsForTableView:displayGroup:): Call tile instead
|
||||
of sizeToFit.
|
||||
* DBModeler/EOAdditions.m: Fix leaks.
|
||||
(setIsClassProperty): Reimplement.
|
||||
(-[setIsPrimaryKey:]): Ditto.
|
||||
(-[setIsClassProperty:]): Correct call to function.
|
||||
(-[isUsedForLocking]): Implement.
|
||||
(-[setIsUsedForLocking:]): Ditto.
|
||||
* DBModeler/MainModelEditor.h
|
||||
* DBModeler/MainModelEditor.m: Update view handling.
|
||||
* DBModeler/DefaultColumnProvider.m: Update handling of properties.
|
||||
* DBModeler/ModelerAttributeEditor.m: Update general GUI interaction.
|
||||
* DBModeler/Preferences.h: New file.
|
||||
* DBModeler/Preferences.m: Ditto.
|
||||
* DBModeler/Inspectors/RelationshipInspector.tiff: New file.
|
||||
* DBModeler/Inspectors/GNUmakefile: Add new file.
|
||||
* DBModeler/Resources/Preferences.gorm: New files.
|
||||
* DBModeler/Resources/Key_Header.tiff: Ditto.
|
||||
* DBModeler/Resources/ClassProperty_Header.tiff: Ditto.
|
||||
* DBModeler/Resources/Locking_On.tiff: Ditto.
|
||||
* DBModeler/Resources/Key_On.tiff: Ditto.
|
||||
* DBModeler/GNUmakefile: Add new files.
|
||||
|
||||
2006-05-09 Matt Rice <ratmice@yahoo.com>
|
||||
David Ayers <ayers@fsfe.org>
|
||||
|
|
|
@ -23,9 +23,8 @@
|
|||
</license>
|
||||
**/
|
||||
|
||||
#include <Foundation/NSNotification.h>
|
||||
|
||||
#include "ConsistencyChecker.h"
|
||||
#include "Preferences.h"
|
||||
|
||||
#include <EOModeler/EOModelerApp.h>
|
||||
#include <EOModeler/EOModelerDocument.h>
|
||||
|
@ -36,6 +35,8 @@
|
|||
#include <EOAccess/EOModel.h>
|
||||
#include <EOAccess/EORelationship.h>
|
||||
|
||||
#include <Foundation/NSNotification.h>
|
||||
|
||||
#define MY_PRETTY NSMutableAttributedString \
|
||||
mutableAttributedStringWithBoldSubstitutionsWithFormat
|
||||
|
||||
|
@ -366,6 +367,7 @@ static BOOL isInvalid(NSString *str)
|
|||
NSArray *arr;
|
||||
unsigned i, c, j, d;
|
||||
BOOL flag = YES;
|
||||
|
||||
for (i = 0,c = [ents count]; i < c; i++)
|
||||
{
|
||||
EOEntity *entity = [ents objectAtIndex:i];
|
||||
|
@ -405,12 +407,28 @@ static BOOL isInvalid(NSString *str)
|
|||
{
|
||||
EOModel *model = [[notif userInfo] objectForKey:EOMConsistencyModelObjectKey];
|
||||
doc = [notif object];
|
||||
/* TODO user defaults */
|
||||
[self attributeDetailsCheckForModel:model];
|
||||
[self primaryKeyCheckForModel:model];
|
||||
[self externalNameCheckForModel:model];
|
||||
[self relationshipCheckForModel:model];
|
||||
[self inheritanceCheckForModel:model];
|
||||
|
||||
if ([[DBModelerPrefs sharedPreferences] attributeDetailsCheck])
|
||||
[self attributeDetailsCheckForModel:model];
|
||||
|
||||
if ([[DBModelerPrefs sharedPreferences] primaryKeyCheck])
|
||||
[self primaryKeyCheckForModel:model];
|
||||
|
||||
if ([[DBModelerPrefs sharedPreferences] externalNameCheck])
|
||||
[self externalNameCheckForModel:model];
|
||||
|
||||
if ([[DBModelerPrefs sharedPreferences] relationshipCheck])
|
||||
[self relationshipCheckForModel:model];
|
||||
|
||||
if ([[DBModelerPrefs sharedPreferences] inheritanceCheck])
|
||||
[self inheritanceCheckForModel:model];
|
||||
|
||||
if ([[DBModelerPrefs sharedPreferences] storedProcedureCheck])
|
||||
[self storedProcedureCheckForModel:model];
|
||||
|
||||
if ([[DBModelerPrefs sharedPreferences] entityStoredProcedureCheck])
|
||||
[self entityStoredProcedureCheckForModel:model];
|
||||
|
||||
doc = nil;
|
||||
}
|
||||
@end
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <EOAccess/EOEntity.h>
|
||||
|
||||
#include <AppKit/NSTableColumn.h>
|
||||
#include <AppKit/NSTableHeaderCell.h>
|
||||
#include <AppKit/NSCell.h>
|
||||
#include <AppKit/NSTextFieldCell.h>
|
||||
#include <AppKit/NSButtonCell.h>
|
||||
|
@ -42,43 +43,49 @@
|
|||
#include <Foundation/NSDictionary.h>
|
||||
|
||||
#define DICTSIZE(dict) (sizeof(dict) / sizeof(dict[0]))
|
||||
#define uhuh (id)1
|
||||
|
||||
static DefaultColumnProvider *_sharedDefaultColumnProvider;
|
||||
static NSMutableDictionary *_aspectsAndKeys;
|
||||
|
||||
/* todo make this a struct instead of an array */
|
||||
/* object key default */
|
||||
static id attribute_columns[][3] = {
|
||||
{@"allowNull", @"Allows null", uhuh},
|
||||
{@"isClassProperty", @"Class property", uhuh},
|
||||
{@"columnName", @"Column name", uhuh},
|
||||
{@"definition", @"Definition", nil},
|
||||
{@"externalType", @"External Type", uhuh},
|
||||
{@"isUsedForLocking", @"Locking", uhuh},
|
||||
{@"name", @"Name", uhuh},
|
||||
{@"precision", @"Precision", nil},
|
||||
{@"isPrimaryKey", @"Primary key", uhuh},
|
||||
{@"readFormat", @"Read format", nil},
|
||||
{@"scale", @"Scale", nil},
|
||||
{@"valueClassName", @"Value class name", uhuh},
|
||||
{@"valueType", @"Value type", nil},
|
||||
{@"width", @"Width", uhuh},
|
||||
{@"writeFormat", @"Write format", nil}
|
||||
struct column_info {
|
||||
NSString *key;
|
||||
NSString *name;
|
||||
BOOL isDefault;
|
||||
};
|
||||
|
||||
static struct column_info attribute_columns[] = {
|
||||
{@"allowNull", @"Allows null", YES},
|
||||
{@"isClassProperty", @"Class property", YES},
|
||||
{@"columnName", @"Column name", YES},
|
||||
{@"definition", @"Definition", NO},
|
||||
{@"externalType", @"External Type", YES},
|
||||
{@"isUsedForLocking", @"Locking", YES},
|
||||
{@"name", @"Name", YES},
|
||||
{@"precision", @"Precision", NO},
|
||||
{@"isPrimaryKey", @"Primary key", YES},
|
||||
{@"readFormat", @"Read format", NO},
|
||||
{@"scale", @"Scale", NO},
|
||||
{@"valueClassName", @"Value class name", YES},
|
||||
{@"valueType", @"Value type", NO},
|
||||
{@"width", @"Width", YES},
|
||||
{@"writeFormat", @"Write format", NO}
|
||||
};
|
||||
|
||||
static id relationship_columns[][3]= {
|
||||
{@"isClassProperty", @"Class property", uhuh},
|
||||
{@"definition", @"Definition", nil},
|
||||
{@"name", @"Name", uhuh},
|
||||
{@"destinationEntity.name", @"Destination Entity", uhuh}
|
||||
static struct column_info relationship_columns[]= {
|
||||
{@"isClassProperty", @"Class property", YES},
|
||||
{@"definition", @"Definition", NO},
|
||||
{@"name", @"Name", YES},
|
||||
{@"destinationEntity.name", @"Destination Entity", YES}
|
||||
|
||||
};
|
||||
|
||||
static id entity_columns[][3] = {
|
||||
{@"name", @"Name", uhuh},
|
||||
{@"className", @"Class name", uhuh},
|
||||
{@"externalName", @"External name", uhuh},
|
||||
{@"externalQuery", @"External query", nil},
|
||||
{@"parentEntity.name", @"Parent", nil}
|
||||
static struct column_info entity_columns[] = {
|
||||
{@"name", @"Name", YES},
|
||||
{@"className", @"Class name", YES},
|
||||
{@"externalName", @"External name", YES},
|
||||
{@"externalQuery", @"External query", NO},
|
||||
{@"parentEntity.name", @"Parent", NO}
|
||||
|
||||
};
|
||||
|
||||
|
@ -97,7 +104,7 @@ static id entity_columns[][3] = {
|
|||
}
|
||||
* or something not sure if id columns[][2] would work as a method so i'll use
|
||||
* a function.. it _should_ but iirc buggy somewhere (forwarding?) */
|
||||
void registerColumnsForClass(id columns[][3], int count, Class aClass,NSMutableArray *defaultColumnsArray)
|
||||
void registerColumnsForClass(struct column_info columns[], int count, Class aClass,NSMutableArray *defaultColumnsArray)
|
||||
{
|
||||
id *objects;
|
||||
id *keys;
|
||||
|
@ -111,9 +118,9 @@ void registerColumnsForClass(id columns[][3], int count, Class aClass,NSMutableA
|
|||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
objects[i] = columns[i][0];
|
||||
keys[i] = columns[i][1];
|
||||
if (columns[i][2] == uhuh)
|
||||
objects[i] = columns[i].key;
|
||||
keys[i] = columns[i].name;
|
||||
if (columns[i].isDefault == YES)
|
||||
{
|
||||
[defaultColumnsArray addObject:keys[i]];
|
||||
}
|
||||
|
@ -154,6 +161,31 @@ void registerColumnsForClass(id columns[][3], int count, Class aClass,NSMutableA
|
|||
DefaultRelationshipColumns);
|
||||
}
|
||||
|
||||
- (void) setupTitleForColumn:(NSTableColumn *)tc named:(NSString *)name
|
||||
{
|
||||
NSTableHeaderCell *headerCell = [tc headerCell];
|
||||
if ([name isEqual:@"Primary key"])
|
||||
{
|
||||
NSImage *img = [NSImage imageNamed:@"Key_Header"];
|
||||
[headerCell setImage:img];
|
||||
}
|
||||
else if ([name isEqual:@"Class property"])
|
||||
[headerCell setImage:[NSImage imageNamed:@"ClassProperty_Header"]];
|
||||
else if ([name isEqual:@"Locking"])
|
||||
[headerCell setImage:[NSImage imageNamed:@"Locking_Header"]];
|
||||
else if ([name isEqual:@"Name"])
|
||||
{
|
||||
[tc setWidth:100.0];
|
||||
[headerCell setStringValue:name];
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
[headerCell setStringValue:name];
|
||||
}
|
||||
[tc sizeToFit];
|
||||
}
|
||||
|
||||
- (NSCell *)cellForColumnNamed:(NSString *)name
|
||||
{
|
||||
|
||||
|
@ -192,7 +224,7 @@ void registerColumnsForClass(id columns[][3], int count, Class aClass,NSMutableA
|
|||
[cell setImagePosition:NSImageOnly];
|
||||
[cell setBordered:NO];
|
||||
[cell setBezeled:NO];
|
||||
[cell setAlternateImage:[NSImage imageNamed:@"ClassProperty_On"]];
|
||||
[cell setAlternateImage:[NSImage imageNamed:@"Locking_On"]];
|
||||
[cell setControlSize: NSSmallControlSize];
|
||||
[cell setEditable:YES];
|
||||
return AUTORELEASE(cell);
|
||||
|
@ -233,10 +265,10 @@ void registerColumnsForClass(id columns[][3], int count, Class aClass,NSMutableA
|
|||
aspectKey = [[_aspectsAndKeys objectForKey:class] objectForKey:columnName];
|
||||
aspect = @"value";
|
||||
association = [[EOColumnAssociation alloc] initWithObject:tc];
|
||||
[[tc headerCell] setStringValue:columnName];
|
||||
cell = [self cellForColumnNamed:columnName];
|
||||
[tc setEditable:[cell isEditable]];
|
||||
[tc setDataCell:cell];
|
||||
[self setupTitleForColumn:tc named:columnName];
|
||||
[association bindAspect:aspect displayGroup:displayGroup key:aspectKey];
|
||||
[association establishConnection];
|
||||
[association release];
|
||||
|
|
|
@ -33,18 +33,26 @@
|
|||
/* this is all stuff for key value coding.. */
|
||||
static inline NSNumber * isClassProperty(id self)
|
||||
{
|
||||
return [NSNumber numberWithBool: [[[self entity] classProperties] containsObject:self]];
|
||||
return [NSNumber numberWithBool:
|
||||
[[[self entity] classProperties] containsObject:self]];
|
||||
}
|
||||
|
||||
static inline void setIsClassProperty(id self, NSNumber *flag)
|
||||
{
|
||||
BOOL isProp = [flag boolValue];
|
||||
NSArray *props = RETAIN([[self entity] classProperties]);
|
||||
NSArray *props = [[self entity] classProperties];
|
||||
|
||||
if (isProp)
|
||||
{
|
||||
if (![props containsObject:self])
|
||||
[[self entity] setClassProperties: [props arrayByAddingObject:self]];
|
||||
if (!props)
|
||||
{
|
||||
if (![[self entity] setClassProperties: [NSArray arrayWithObject:self]])
|
||||
NSLog(@"invalid class property");
|
||||
}
|
||||
else if (![props containsObject:self])
|
||||
{
|
||||
[[self entity] setClassProperties: [props arrayByAddingObject:self]];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -55,25 +63,33 @@ static inline void setIsClassProperty(id self, NSNumber *flag)
|
|||
[[self entity] setClassProperties: newProps];
|
||||
}
|
||||
}
|
||||
RELEASE(props);
|
||||
}
|
||||
|
||||
@implementation EOAttribute (ModelerAdditions)
|
||||
|
||||
- (NSNumber *) isPrimaryKey
|
||||
{
|
||||
return [NSNumber numberWithBool: [[[self entity] primaryKeyAttributes] containsObject:self]];
|
||||
BOOL flag = [[[self entity] primaryKeyAttributes] containsObject:self];
|
||||
return [NSNumber numberWithBool: flag];
|
||||
}
|
||||
|
||||
- (void) setIsPrimaryKey:(NSNumber *)flag
|
||||
{
|
||||
BOOL isKey = [flag boolValue];
|
||||
NSArray *pka = RETAIN([[self entity] primaryKeyAttributes]);
|
||||
NSArray *pka = [[self entity] primaryKeyAttributes];
|
||||
|
||||
if (isKey)
|
||||
{
|
||||
if (![pka containsObject:self])
|
||||
[[self entity] setPrimaryKeyAttributes: [pka arrayByAddingObject:self]];
|
||||
if (!pka)
|
||||
{
|
||||
[[self entity]
|
||||
setPrimaryKeyAttributes: [NSArray arrayWithObject:self]];
|
||||
}
|
||||
else if (![pka containsObject:self])
|
||||
{
|
||||
[[self entity]
|
||||
setPrimaryKeyAttributes: [pka arrayByAddingObject:self]];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -85,33 +101,63 @@ static inline void setIsClassProperty(id self, NSNumber *flag)
|
|||
|
||||
}
|
||||
}
|
||||
RELEASE(pka);
|
||||
}
|
||||
|
||||
- (NSNumber *) isClassProperty
|
||||
{
|
||||
return isClassProperty(self);
|
||||
id flag = isClassProperty(self);
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
- (void) setIsClassProperty:(NSNumber *)flag
|
||||
{
|
||||
return setIsClassProperty(self, flag);
|
||||
setIsClassProperty(self, flag);
|
||||
}
|
||||
|
||||
- (NSNumber *) isUsedForLocking
|
||||
{
|
||||
return [NSNumber numberWithBool:NO];
|
||||
/* FIXME */
|
||||
BOOL flag;
|
||||
|
||||
flag = [[[self entity] attributesUsedForLocking] containsObject:self];
|
||||
|
||||
return [NSNumber numberWithBool:flag];
|
||||
}
|
||||
|
||||
- (void) setIsUsedForLocking:(NSNumber *)flag
|
||||
{
|
||||
/* FIXME */
|
||||
BOOL yn = [flag boolValue];
|
||||
NSArray *la = RETAIN([[self entity] attributesUsedForLocking]);
|
||||
|
||||
if (yn)
|
||||
{
|
||||
|
||||
if (la == nil)
|
||||
{
|
||||
[[self entity]
|
||||
setAttributesUsedForLocking:[NSArray arrayWithObject:self]];
|
||||
}
|
||||
else if (![la containsObject:self])
|
||||
{
|
||||
[[self entity]
|
||||
setAttributesUsedForLocking:[la arrayByAddingObject:self]];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ([la containsObject:self])
|
||||
{
|
||||
NSMutableArray *newLA = [NSMutableArray arrayWithArray:la];
|
||||
[newLA removeObject:self];
|
||||
[[self entity] setAttributesUsedForLocking:newLA];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (NSNumber *)allowNull
|
||||
{
|
||||
return [NSNumber numberWithBool:[self allowsNull]];
|
||||
BOOL flag = [self allowsNull];
|
||||
return [NSNumber numberWithBool:flag];
|
||||
}
|
||||
|
||||
- (void) setAllowNull:(NSNumber *)flag
|
||||
|
@ -125,12 +171,13 @@ static inline void setIsClassProperty(id self, NSNumber *flag)
|
|||
@implementation EORelationship (ModelerAdditions)
|
||||
- (NSNumber *) isClassProperty
|
||||
{
|
||||
return isClassProperty(self);
|
||||
id flag = isClassProperty(self);
|
||||
return flag;
|
||||
}
|
||||
|
||||
- (void) setIsClassProperty:(NSNumber *)flag
|
||||
{
|
||||
return setIsClassProperty(self, flag);
|
||||
setIsClassProperty(self, flag);
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -20,13 +20,19 @@ endif
|
|||
|
||||
ADDITIONAL_NATIVE_LIBS += EOInterface gnustep-db2modeler
|
||||
|
||||
$(APP_NAME)_RESOURCE_FILES = \
|
||||
Resources/Key_On.tiff \
|
||||
Resources/ClassProperty_On.tiff \
|
||||
Resources/ModelDrag.tiff \
|
||||
Resources/SQLGenerator.gorm \
|
||||
Resources/Info-gnustep.plist \
|
||||
Resources/ConsistencyResults.gorm
|
||||
$(APP_NAME)_RESOURCE_FILES = \
|
||||
Resources/Key_On.tiff \
|
||||
Resources/ClassProperty_On.tiff \
|
||||
Resources/ModelDrag.tiff \
|
||||
Resources/SQLGenerator.gorm \
|
||||
Resources/Info-gnustep.plist \
|
||||
Resources/Key_Header.tiff \
|
||||
Resources/Locking_On.tiff \
|
||||
Resources/Locking_Header.tiff \
|
||||
Resources/ClassProperty_Header.tiff \
|
||||
Resources/Preferences.gorm \
|
||||
Resources/ConsistencyResults.gorm \
|
||||
Resources/DBModeler.tiff
|
||||
|
||||
$(APP_NAME)_OBJC_FILES = \
|
||||
main.m \
|
||||
|
@ -41,6 +47,7 @@ $(APP_NAME)_OBJC_FILES = \
|
|||
ModelerTableEmbedibleEditor.m \
|
||||
SQLGenerator.m \
|
||||
ConsistencyResults.m \
|
||||
Preferences.m \
|
||||
ConsistencyChecker.m
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/application.make
|
||||
|
|
|
@ -4,7 +4,10 @@ ADDITIONAL_INCLUDE_DIRS+=-I../../
|
|||
|
||||
Inspectors_HAS_RESOURCE_BUNDLE=yes
|
||||
|
||||
Inspectors_RESOURCE_FILES=RelationshipInspector.gorm
|
||||
Inspectors_RESOURCE_FILES= \
|
||||
RelationshipInspector.gorm \
|
||||
RelationshipInspector.tiff
|
||||
|
||||
Inspectors_OBJC_FILES=RelationshipInspector.m
|
||||
|
||||
Inspectors_RESOURCE_FILES+=AttributeInspector.gorm
|
||||
|
|
|
@ -11,11 +11,18 @@
|
|||
#include <Foundation/NSArray.h>
|
||||
|
||||
@implementation RelationshipInspector
|
||||
|
||||
- (NSString *) displayName
|
||||
{
|
||||
return @"Relationship inspector";
|
||||
}
|
||||
|
||||
- (EOEntity *)selectedEntity
|
||||
{
|
||||
int row = [destEntity_tableView selectedRow];
|
||||
NSArray *entities = [[[EOMApp activeDocument] model] entities];
|
||||
|
||||
if (row == -1)
|
||||
if (row == -1 || row == NSNotFound || row > [entities count])
|
||||
return nil;
|
||||
|
||||
return [[[[EOMApp activeDocument] model] entities] objectAtIndex:row];
|
||||
|
@ -24,8 +31,9 @@
|
|||
- (EOAttribute *)selectedDestinationAttribute
|
||||
{
|
||||
int row = [destAttrib_tableView selectedRow];
|
||||
|
||||
if (row == -1)
|
||||
NSArray *attribs = [[self selectedEntity] attributes];
|
||||
|
||||
if (row == -1 || row == NSNotFound || row > [attribs count])
|
||||
return nil;
|
||||
|
||||
return [[[self selectedEntity] attributes]
|
||||
|
@ -35,11 +43,12 @@
|
|||
- (EOAttribute *)selectedSourceAttribute
|
||||
{
|
||||
int row = [srcAttrib_tableView selectedRow];
|
||||
|
||||
if (row == -1)
|
||||
NSArray *attribs = [[[self selectedObject] entity] attributes];
|
||||
|
||||
if (row == -1 || row == NSNotFound || row > [attribs count])
|
||||
return nil;
|
||||
|
||||
return [[[[self selectedObject] entity] attributes] objectAtIndex:[srcAttrib_tableView selectedRow]];
|
||||
|
||||
return [attribs objectAtIndex:[srcAttrib_tableView selectedRow]];
|
||||
}
|
||||
|
||||
- (int) indexOfSourceAttribute:(EOAttribute *)srcAttrib
|
||||
|
@ -120,8 +129,9 @@
|
|||
|
||||
- (EOJoin *) selectedJoin
|
||||
{
|
||||
return [self joinWithSource:[self selectedSourceAttribute]
|
||||
destination:[self selectedDestinationAttribute]];
|
||||
EOJoin *join = [self joinWithSource:[self selectedSourceAttribute]
|
||||
destination:[self selectedDestinationAttribute]];
|
||||
return join;
|
||||
}
|
||||
|
||||
- (void) awakeFromNib
|
||||
|
@ -143,6 +153,7 @@
|
|||
|
||||
- (void) updateConnectButton
|
||||
{
|
||||
[connect_button setEnabled:([self selectedDestinationAttribute] != nil)];
|
||||
[connect_button setState: ([self selectedJoin] != nil) ? NSOnState : NSOffState];
|
||||
}
|
||||
|
||||
|
@ -152,12 +163,13 @@
|
|||
EOEntity *destEntity;
|
||||
EOAttribute *srcAttrib, *destAttrib;
|
||||
NSArray *joins;
|
||||
unsigned int row;
|
||||
unsigned int row = 0;
|
||||
[name_textField setStringValue:[(EORelationship *)[self selectedObject] name]];
|
||||
|
||||
/* it is important that the destEntity has a selected row before the destAttrib tableview
|
||||
* reloads data */
|
||||
[srcAttrib_tableView reloadData];
|
||||
[destAttrib_tableView reloadData];
|
||||
[destEntity_tableView reloadData];
|
||||
|
||||
destEntity = [[self selectedObject] destinationEntity];
|
||||
if (destEntity)
|
||||
{
|
||||
|
@ -167,7 +179,7 @@
|
|||
}
|
||||
else if ([destEntity_tableView numberOfRows])
|
||||
row = 0;
|
||||
|
||||
|
||||
[destEntity_tableView selectRow:row byExtendingSelection:NO];
|
||||
|
||||
joins = [[self selectedObject] joins];
|
||||
|
@ -178,14 +190,23 @@
|
|||
srcAttrib = [join sourceAttribute];
|
||||
destAttrib = [join destinationAttribute];
|
||||
row = [self indexOfSourceAttribute:srcAttrib];
|
||||
[srcAttrib_tableView selectRow:row byExtendingSelection:NO];
|
||||
if (row != NSNotFound)
|
||||
[srcAttrib_tableView selectRow:row byExtendingSelection:NO];
|
||||
row = [self indexOfDestinationAttribute:srcAttrib];
|
||||
[destAttrib_tableView selectRow:row byExtendingSelection:NO];
|
||||
if (row != NSNotFound)
|
||||
[destAttrib_tableView selectRow:row byExtendingSelection:NO];
|
||||
}
|
||||
else
|
||||
{
|
||||
[srcAttrib_tableView selectRow:0 byExtendingSelection:NO];
|
||||
[destAttrib_tableView selectRow:0 byExtendingSelection:NO];
|
||||
if ([self numberOfRowsInTableView:srcAttrib_tableView])
|
||||
{
|
||||
[srcAttrib_tableView selectRow:0 byExtendingSelection:NO];
|
||||
}
|
||||
|
||||
if ([self numberOfRowsInTableView:destAttrib_tableView])
|
||||
{
|
||||
[destAttrib_tableView selectRow:0 byExtendingSelection:NO];
|
||||
}
|
||||
}
|
||||
|
||||
[self updateConnectButton];
|
||||
|
@ -198,7 +219,9 @@
|
|||
{
|
||||
EOModel *activeModel = [[EOMApp activeDocument] model];
|
||||
if (tv == destEntity_tableView)
|
||||
return [[activeModel entities] count];
|
||||
{
|
||||
return [[activeModel entities] count];
|
||||
}
|
||||
else if (tv == srcAttrib_tableView)
|
||||
return [[(EOEntity *)[[self selectedObject] entity] attributes] count];
|
||||
else if (tv == destAttrib_tableView)
|
||||
|
@ -253,7 +276,6 @@ row:(int)rowIndex
|
|||
if (row != NSNotFound)
|
||||
[srcAttrib_tableView selectRow:row byExtendingSelection:NO];
|
||||
|
||||
[self updateConnectButton];
|
||||
}
|
||||
else if (tv == srcAttrib_tableView)
|
||||
{
|
||||
|
@ -262,9 +284,9 @@ row:(int)rowIndex
|
|||
|
||||
if (row != NSNotFound)
|
||||
[destAttrib_tableView selectRow:row byExtendingSelection:NO];
|
||||
|
||||
[self updateConnectButton];
|
||||
}
|
||||
|
||||
[self updateConnectButton];
|
||||
}
|
||||
|
||||
- (BOOL) tableView:(NSTableView *)tv shouldSelectRow:(int)rowIndex
|
||||
|
|
BIN
DBModeler/Inspectors/RelationshipInspector.tiff
Normal file
BIN
DBModeler/Inspectors/RelationshipInspector.tiff
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.3 KiB |
|
@ -26,15 +26,16 @@
|
|||
|
||||
#include <EOModeler/EOModelerEditor.h>
|
||||
|
||||
#include <AppKit/NSBox.h>
|
||||
#include <AppKit/NSOutlineView.h>
|
||||
#include <AppKit/NSWindow.h>
|
||||
#include <AppKit/NSSplitView.h>
|
||||
|
||||
@interface MainModelEditor : EOModelerCompoundEditor
|
||||
{
|
||||
NSBox *_box;
|
||||
NSView *_editorView;
|
||||
NSWindow *_window;
|
||||
NSOutlineView *_iconPath;
|
||||
NSSplitView *_vSplit;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include <AppKit/NSScrollView.h>
|
||||
#include <AppKit/NSSplitView.h>
|
||||
#include <AppKit/NSTableColumn.h>
|
||||
#include <AppKit/NSView.h>
|
||||
|
||||
#include <Foundation/NSNotification.h>
|
||||
#define DEBUG_STUFF 0
|
||||
|
@ -77,12 +78,11 @@
|
|||
if ((self = [super initWithDocument:document]))
|
||||
{
|
||||
NSTableColumn *_col;
|
||||
NSSplitView *vSplit = [[NSSplitView alloc] initWithFrame:NSMakeRect(0,0,400,400)];
|
||||
NSScrollView *sv = [[NSScrollView alloc] initWithFrame:NSMakeRect(0,0,100,400)];
|
||||
// NSImageCell *_cell;
|
||||
|
||||
[vSplit setVertical:YES];
|
||||
|
||||
_vSplit = [[NSSplitView alloc] initWithFrame:NSMakeRect(0,0,600,400)];
|
||||
|
||||
[_vSplit setVertical:YES];
|
||||
|
||||
_iconPath = [[ModelerOutlineView alloc] initWithFrame:NSMakeRect(0,0,100,400)];
|
||||
[_iconPath setIndentationPerLevel:8.0];
|
||||
|
@ -90,15 +90,13 @@
|
|||
|
||||
[_iconPath setDelegate:self];
|
||||
[_iconPath setDataSource:self];
|
||||
//_cell = [[NSImageCell alloc] init];
|
||||
_col = [(NSTableColumn *)[NSTableColumn alloc] initWithIdentifier:@"name"];
|
||||
[_iconPath addTableColumn:_col];
|
||||
[_iconPath setOutlineTableColumn:AUTORELEASE(_col)];
|
||||
//[[_iconPath tableColumnWithIdentifier:@"name"] setDataCell:_cell];
|
||||
[_iconPath setAutoresizesAllColumnsToFit:YES];
|
||||
[_iconPath sizeToFit];
|
||||
|
||||
_window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,400,400)
|
||||
_window = [[NSWindow alloc] initWithContentRect:NSMakeRect(20,80,600,400)
|
||||
styleMask: NSTitledWindowMask | NSMiniaturizableWindowMask | NSClosableWindowMask | NSResizableWindowMask
|
||||
backing:NSBackingStoreBuffered
|
||||
defer:YES];
|
||||
|
@ -110,24 +108,20 @@
|
|||
[_iconPath setAutoresizingMask: NSViewWidthSizable|NSViewHeightSizable];
|
||||
[sv setDocumentView:_iconPath];
|
||||
RELEASE(_iconPath);
|
||||
[vSplit addSubview:sv];
|
||||
[_vSplit addSubview:sv];
|
||||
RELEASE(sv);
|
||||
|
||||
_editorView = [[NSBox alloc] initWithFrame:NSMakeRect(0,0,500,400)];
|
||||
|
||||
_box = [[NSBox alloc] initWithFrame:NSMakeRect(0,0,300,400)];
|
||||
[_box setTitle:@""];
|
||||
[_box setBorderType:NSNoBorder];
|
||||
[_box setAutoresizesSubviews:YES];
|
||||
[_box setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
|
||||
[vSplit addSubview: _box];
|
||||
RELEASE(_box);
|
||||
[_vSplit addSubview: _editorView];
|
||||
RELEASE(_editorView);
|
||||
|
||||
[vSplit setAutoresizesSubviews:YES];
|
||||
[vSplit setAutoresizingMask: NSViewWidthSizable
|
||||
[_vSplit setAutoresizesSubviews:YES];
|
||||
[_vSplit setAutoresizingMask: NSViewWidthSizable
|
||||
| NSViewHeightSizable];
|
||||
[vSplit adjustSubviews];
|
||||
[[_window contentView] addSubview:vSplit];
|
||||
RELEASE(vSplit);
|
||||
[_vSplit adjustSubviews];
|
||||
[[_window contentView] addSubview:_vSplit];
|
||||
RELEASE(_vSplit);
|
||||
|
||||
/* so addEntity: addAttribute: ... menu items work */
|
||||
[_window setDelegate: document];
|
||||
|
@ -140,12 +134,14 @@
|
|||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
||||
RELEASE(_window);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) ecStuff:(NSNotification *)notif
|
||||
{
|
||||
if ([[notif object] isKindOfClass:[EOEditingContext class]])
|
||||
|
@ -172,10 +168,11 @@
|
|||
}
|
||||
[mainView setAutoresizesSubviews:YES];
|
||||
[mainView setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
|
||||
[mainView setFrame: [_box frame]];
|
||||
[mainView setFrame: [_editorView frame]];
|
||||
|
||||
[_box setContentView: mainView];
|
||||
[_box setNeedsDisplay:YES];
|
||||
[_vSplit replaceSubview:_editorView with:mainView];
|
||||
_editorView = mainView;
|
||||
[_editorView setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
- (void)activateEditorWithClass:(Class)embedibleEditorClass
|
||||
|
@ -354,6 +351,7 @@
|
|||
EOModel *bar = [_document model];
|
||||
id item = nil;
|
||||
int selectedRow = [_iconPath selectedRow];
|
||||
|
||||
if (selectedRow == -1)
|
||||
return;
|
||||
while (bar != item)
|
||||
|
|
|
@ -33,7 +33,9 @@
|
|||
|
||||
|
||||
}
|
||||
|
||||
/* runs the adaptor panel and the adaptors login panel, and sets the active
|
||||
* documents connection dictionary. */
|
||||
- (void) setAdaptor:(id)sender;
|
||||
@end
|
||||
|
||||
#endif // __Modeler_H_
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "Modeler.h"
|
||||
#include "ModelerEntityEditor.h"
|
||||
#include "SQLGenerator.h"
|
||||
#include "Preferences.h"
|
||||
|
||||
#include <EOModeler/EOModelerApp.h>
|
||||
#include <EOModeler/EOModelerEditor.h>
|
||||
|
@ -239,11 +240,40 @@
|
|||
{
|
||||
EOModel *newModel = [[EOModel alloc] init];
|
||||
NSString *modelName;
|
||||
unsigned int nDocs;
|
||||
NSArray *docs = [EOMApp documents];
|
||||
unsigned docNumber, c, i;
|
||||
|
||||
nDocs = [[EOMApp documents] count];
|
||||
|
||||
modelName=[NSString stringWithFormat:@"Model_%u",++nDocs];
|
||||
docNumber = [[EOMApp documents] count];
|
||||
|
||||
c = [docs count];
|
||||
docNumber = c;
|
||||
|
||||
/* look for the largest NNNN in models named "Model_NNNN"
|
||||
* or the total number of models whichever is greater.
|
||||
*/
|
||||
for (i = 0; i < c; i++)
|
||||
{
|
||||
NSString *name = [(EOModel*)[[docs objectAtIndex:i] model] name];
|
||||
|
||||
if ([name hasPrefix:@"Model_"])
|
||||
{
|
||||
NSRange range;
|
||||
unsigned tmp;
|
||||
|
||||
name = [name substringFromIndex:6];
|
||||
range = [name rangeOfCharacterFromSet:[[NSCharacterSet decimalDigitCharacterSet] invertedSet]];
|
||||
if (!(range.location == NSNotFound) && !(range.length == 0))
|
||||
continue;
|
||||
range = [name rangeOfCharacterFromSet:[NSCharacterSet decimalDigitCharacterSet]];
|
||||
if (!(range.location == NSNotFound) && !(range.length == 0))
|
||||
{
|
||||
tmp = [name intValue];
|
||||
docNumber = (docNumber < ++tmp) ? tmp : docNumber;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
modelName = [NSString stringWithFormat:@"Model_%u",docNumber];
|
||||
[newModel setName:modelName];
|
||||
[self _newDocumentWithModel:newModel];
|
||||
RELEASE(newModel);
|
||||
|
@ -301,6 +331,10 @@
|
|||
|
||||
adaptorName = [adaptorsPanel runAdaptorsPanel];
|
||||
RELEASE(adaptorsPanel);
|
||||
|
||||
if (!adaptorName)
|
||||
return;
|
||||
|
||||
[[[EOMApp activeDocument] model] setAdaptorName: adaptorName];
|
||||
adaptor = [EOAdaptor adaptorWithName: adaptorName];
|
||||
[[[EOMApp activeDocument] model] setConnectionDictionary:[adaptor runLoginPanel]];
|
||||
|
@ -312,26 +346,37 @@
|
|||
[EOMInspectorController showInspector];
|
||||
}
|
||||
|
||||
- (void) application:(NSApplication *)theApp openFile:(NSString *)filename
|
||||
- (BOOL) application:(NSApplication *)theApp openFile:(NSString *)filename
|
||||
{
|
||||
NSFileManager *fm = [NSFileManager defaultManager];
|
||||
NSString *pathExt = [[filename pathExtension] lowercaseString];
|
||||
|
||||
if ([fm isReadableFileAtPath:filename] == YES
|
||||
&& ([pathExt isEqual:@"eomodeld"]
|
||||
|| [pathExt isEqual:@"eomodel"]))
|
||||
BOOL flag;
|
||||
#if 0
|
||||
NSLog(@"%@ %@ %i %i %i %i %i", NSStringFromSelector(_cmd), filename,
|
||||
[fm isReadableFileAtPath:filename] == YES,
|
||||
[pathExt isEqual:@"eomodel"],
|
||||
[pathExt isEqual:@"eomodeld"],
|
||||
[fm fileExistsAtPath:filename isDirectory:&flag],
|
||||
flag);
|
||||
#endif
|
||||
if (([fm isReadableFileAtPath:filename] == YES
|
||||
&& [pathExt isEqual:@"eomodel"])
|
||||
|| ([pathExt isEqual:@"eomodeld"]
|
||||
&& [fm fileExistsAtPath:filename isDirectory:&flag] && flag))
|
||||
{
|
||||
EOModel *model;
|
||||
|
||||
NS_DURING
|
||||
model = [[EOModel alloc] initWithContentsOfFile:filename];
|
||||
NS_HANDLER
|
||||
return;
|
||||
return NO;
|
||||
NS_ENDHANDLER
|
||||
|
||||
[self _newDocumentWithModel:model];
|
||||
RELEASE(model);
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void) open:(id)sender
|
||||
|
@ -373,5 +418,10 @@
|
|||
[[SQLGenerator sharedGenerator] openSQLGenerator:self];
|
||||
}
|
||||
|
||||
- (void) openPrefs:(id)sender
|
||||
{
|
||||
[[DBModelerPrefs sharedPreferences] showPreferences:self];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
</license>
|
||||
**/
|
||||
|
||||
|
||||
#include "DefaultColumnProvider.h"
|
||||
#include "ModelerAttributeEditor.h"
|
||||
#include "ModelerEntityEditor.h"
|
||||
|
@ -45,8 +44,7 @@
|
|||
#include <EOInterface/EODisplayGroup.h>
|
||||
|
||||
#include <Foundation/NSRunLoop.h>
|
||||
|
||||
|
||||
|
||||
@interface NSArray (EOMAdditions)
|
||||
- (id) firstSelectionOfClass:(Class) aClass;
|
||||
@end
|
||||
|
@ -60,12 +58,16 @@
|
|||
NSMenuItem *mi = [[NSMenuItem alloc] initWithTitle:@"+" action:(SEL)nil keyEquivalent:@""];
|
||||
|
||||
self = [super initWithParentEditor:parentEditor];
|
||||
|
||||
[DefaultColumnProvider class];
|
||||
_mainView = [[NSSplitView alloc] initWithFrame:NSMakeRect(0,0,100,100)];
|
||||
/* setup the attributes table view */
|
||||
scrollView = [[NSScrollView alloc] initWithFrame:NSMakeRect(0,0,100,100)];
|
||||
_attributes_tableView = [[NSTableView alloc] initWithFrame:NSMakeRect(0,0,100,100)];
|
||||
[_attributes_tableView setAutoresizesAllColumnsToFit:YES];
|
||||
[_attributes_tableView setAutoresizesAllColumnsToFit:NO];
|
||||
[_attributes_tableView setAllowsMultipleSelection:YES];
|
||||
[_attributes_tableView setAllowsEmptySelection:YES];
|
||||
|
||||
[scrollView setBorderType: NSBezelBorder];
|
||||
[scrollView setHasHorizontalScroller:YES];
|
||||
[scrollView setHasVerticalScroller:YES];
|
||||
|
@ -79,7 +81,8 @@
|
|||
[[cornerView cell] setArrowPosition:NSPopUpNoArrow];
|
||||
[cornerView setTitle:@"+"];
|
||||
[cornerView setPreferredEdge:NSMinYEdge];
|
||||
|
||||
[cornerView setBezelStyle:NSShadowlessSquareBezelStyle];
|
||||
|
||||
[[cornerView cell] setUsesItemFromMenu:NO];
|
||||
[[cornerView cell] setShowsFirstResponder:NO];
|
||||
[[cornerView cell] setMenuItem:mi];
|
||||
|
@ -95,6 +98,7 @@
|
|||
[_attributes_dg setDataSource:wds1];
|
||||
RELEASE(wds1);
|
||||
[_attributes_dg setFetchesOnLoad:YES];
|
||||
[_attributes_dg setSelectsFirstObjectAfterFetch:NO];
|
||||
[_attributes_dg setDelegate:self];
|
||||
|
||||
[self setupCornerView:cornerView
|
||||
|
@ -110,7 +114,9 @@
|
|||
[scrollView setHasHorizontalScroller:YES];
|
||||
[scrollView setHasVerticalScroller:YES];
|
||||
_relationships_tableView = [[NSTableView alloc] initWithFrame:NSMakeRect(0,0,100,100)];
|
||||
[_relationships_tableView setAutoresizesAllColumnsToFit:YES];
|
||||
[_relationships_tableView setAutoresizesAllColumnsToFit:NO];
|
||||
[_relationships_tableView setAllowsMultipleSelection:YES];
|
||||
[_relationships_tableView setAllowsEmptySelection:YES];
|
||||
[scrollView setDocumentView:_relationships_tableView];
|
||||
RELEASE(_relationships_tableView);
|
||||
[_mainView addSubview:scrollView];
|
||||
|
@ -121,6 +127,7 @@
|
|||
[cornerView setPreferredEdge:NSMinYEdge];
|
||||
[[cornerView cell] setArrowPosition:NSPopUpNoArrow];
|
||||
[cornerView setTitle:@"+"];
|
||||
[cornerView setBezelStyle:NSShadowlessSquareBezelStyle];
|
||||
[[cornerView cell] setUsesItemFromMenu:NO];
|
||||
[[cornerView cell] setShowsFirstResponder:NO];
|
||||
[[cornerView cell] setMenuItem:mi];
|
||||
|
@ -135,6 +142,7 @@
|
|||
[_relationships_dg setDataSource:wds2];
|
||||
RELEASE(wds2);
|
||||
[_relationships_dg setFetchesOnLoad:YES];
|
||||
[_relationships_dg setSelectsFirstObjectAfterFetch:NO];
|
||||
[_relationships_dg setDelegate:self];
|
||||
|
||||
[self setupCornerView:cornerView
|
||||
|
@ -144,7 +152,7 @@
|
|||
|
||||
[self addDefaultTableColumnsForTableView:_relationships_tableView
|
||||
displayGroup:_relationships_dg];
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -178,19 +186,39 @@
|
|||
return flag;
|
||||
}
|
||||
|
||||
- (void) needToFetch:(id)arg
|
||||
{
|
||||
[_attributes_dg fetch];
|
||||
[_relationships_dg fetch];
|
||||
}
|
||||
|
||||
- (void) activate
|
||||
{
|
||||
if (_entityToObserve)
|
||||
[EOObserverCenter removeObserver:self forObject:_entityToObserve];
|
||||
|
||||
_entityToObserve = [[self selectionPath] firstSelectionOfClass:[EOEntity class]];
|
||||
[EOObserverCenter addObserver:self forObject:_entityToObserve];
|
||||
NSArray *selPath = [self selectionPath];
|
||||
NSArray *selWithin = [self selectionWithinViewedObject];
|
||||
id newEntityToObserve = [selPath firstSelectionOfClass:[EOEntity class]];
|
||||
if (_entityToObserve != newEntityToObserve)
|
||||
{
|
||||
if (_entityToObserve)
|
||||
[EOObserverCenter removeObserver:self forObject:_entityToObserve];
|
||||
|
||||
_entityToObserve = newEntityToObserve;
|
||||
[EOObserverCenter addObserver:self forObject:_entityToObserve];
|
||||
[(KVDataSource *)[_attributes_dg dataSource] setDataObject: _entityToObserve];
|
||||
[(KVDataSource *)[_relationships_dg dataSource] setDataObject: _entityToObserve];
|
||||
}
|
||||
|
||||
[(KVDataSource *)[_attributes_dg dataSource] setDataObject: _entityToObserve];
|
||||
[(KVDataSource *)[_relationships_dg dataSource] setDataObject: _entityToObserve];
|
||||
[_attributes_dg fetch];
|
||||
[_relationships_dg fetch];
|
||||
[self needToFetch:self];
|
||||
|
||||
if (![[_attributes_dg selectedObjects] isEqual:selWithin]
|
||||
&& ![_attributes_dg selectObjectsIdenticalTo:selWithin
|
||||
selectFirstOnNoMatch:NO])
|
||||
[_attributes_dg clearSelection];
|
||||
|
||||
if (![[_relationships_dg selectedObjects] isEqual:selWithin]
|
||||
&& ![_relationships_dg selectObjectsIdenticalTo:selWithin
|
||||
selectFirstOnNoMatch:NO])
|
||||
[_relationships_dg clearSelection];
|
||||
}
|
||||
|
||||
- (NSArray *) friendEditorClasses
|
||||
|
@ -200,17 +228,12 @@
|
|||
|
||||
- (void) objectWillChange:(id)sender
|
||||
{
|
||||
[[NSRunLoop currentRunLoop] performSelector:@selector(needToFetch:)
|
||||
target:self
|
||||
argument:nil
|
||||
order:999
|
||||
modes:[NSArray arrayWithObject:NSDefaultRunLoopMode]];
|
||||
}
|
||||
|
||||
- (void) needToFetch:(id)arg
|
||||
{
|
||||
[_attributes_dg fetch];
|
||||
[_relationships_dg fetch];
|
||||
[[NSRunLoop currentRunLoop]
|
||||
performSelector:@selector(needToFetch:)
|
||||
target:self
|
||||
argument:nil
|
||||
order:999 /* this number is probably arbitrary */
|
||||
modes:[NSArray arrayWithObject:NSDefaultRunLoopMode]];
|
||||
}
|
||||
|
||||
- (NSArray *)defaultColumnNamesForClass:(Class)aClass
|
||||
|
@ -231,24 +254,13 @@
|
|||
|
||||
- (void) displayGroupDidChangeSelection:(EODisplayGroup *)displayGroup
|
||||
{
|
||||
NSArray *selObj = [displayGroup selectedObjects];
|
||||
NSArray *selWithin = [self selectionWithinViewedObject];
|
||||
|
||||
NSArray *currentSelection = [_parentEditor selectionWithinViewedObject];
|
||||
id theSelection;
|
||||
int c = [currentSelection count];
|
||||
|
||||
if (!c)
|
||||
return;
|
||||
else
|
||||
theSelection = [currentSelection objectAtIndex:0];
|
||||
|
||||
if ([theSelection isKindOfClass:[EOEntity class]])
|
||||
{
|
||||
NSArray *vop;
|
||||
vop = [_parentEditor viewedObjectPath];
|
||||
[self setViewedObjectPath: [vop arrayByAddingObject:theSelection]];
|
||||
}
|
||||
|
||||
[self setSelectionWithinViewedObject: [displayGroup selectedObjects]];
|
||||
if ([selObj count]
|
||||
&& (![selObj isEqual:selWithin])
|
||||
&& ![selWithin containsObject:_entityToObserve])
|
||||
[self setSelectionWithinViewedObject: selObj];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -102,7 +102,7 @@
|
|||
|
||||
_topTable = [[NSTableView alloc] initWithFrame:NSMakeRect(0,0,10,10)];
|
||||
_bottomTable = [[NSTableView alloc] initWithFrame:NSMakeRect(0,0,10,10)];
|
||||
[_topTable setAutoresizesAllColumnsToFit:YES];
|
||||
[_topTable setAutoresizesAllColumnsToFit:NO];
|
||||
[scrollView setDocumentView:_topTable];
|
||||
RELEASE(_topTable);
|
||||
[_splitView addSubview:scrollView];
|
||||
|
@ -112,7 +112,7 @@
|
|||
[scrollView setHasHorizontalScroller:YES];
|
||||
[scrollView setHasVerticalScroller:YES];
|
||||
[scrollView setBorderType: NSBezelBorder];
|
||||
[_bottomTable setAutoresizesAllColumnsToFit:YES];
|
||||
[_bottomTable setAutoresizesAllColumnsToFit:NO];
|
||||
[scrollView setDocumentView:_bottomTable];
|
||||
RELEASE(_bottomTable);
|
||||
[_splitView addSubview:scrollView];
|
||||
|
@ -124,6 +124,8 @@
|
|||
cornerView = [[NSPopUpButton alloc] initWithFrame:[[_topTable cornerView] bounds] pullsDown:YES];
|
||||
[cornerView setPreferredEdge:NSMinYEdge];
|
||||
[cornerView setTitle:@"+"];
|
||||
[cornerView setBezelStyle:NSShadowlessSquareBezelStyle];
|
||||
[[cornerView cell] setBezelStyle:NSShadowlessSquareBezelStyle];
|
||||
[[cornerView cell] setArrowPosition:NSPopUpNoArrow];
|
||||
//[mi setImage:[NSImage imageNamed:@"plus"]];
|
||||
// [mi setOnStateImage:[NSImage imageNamed:@"plus"]];
|
||||
|
@ -153,7 +155,7 @@
|
|||
RELEASE(wds);
|
||||
[dg setFetchesOnLoad:YES];
|
||||
[dg setDelegate: self];
|
||||
|
||||
|
||||
[self setupCornerView:cornerView
|
||||
tableView:_topTable
|
||||
displayGroup:dg
|
||||
|
@ -183,6 +185,9 @@
|
|||
- (void) activate
|
||||
{
|
||||
[dg fetch];
|
||||
|
||||
[dg selectObjectsIdenticalTo:[self selectionWithinViewedObject]
|
||||
selectFirstOnNoMatch:NO];
|
||||
}
|
||||
|
||||
- (NSView *)mainView
|
||||
|
@ -192,20 +197,25 @@
|
|||
|
||||
- (void) objectWillChange:(id)anObject
|
||||
{
|
||||
[[NSRunLoop currentRunLoop] performSelector:@selector(needToFetch:) target:self argument:nil order:999 modes:[NSArray arrayWithObject:NSDefaultRunLoopMode]];
|
||||
[[NSRunLoop currentRunLoop]
|
||||
performSelector:@selector(needToFetch:)
|
||||
target:self
|
||||
argument:nil
|
||||
order:999 /* this number is probably arbitrary */
|
||||
modes:[NSArray arrayWithObject:NSDefaultRunLoopMode]];
|
||||
}
|
||||
|
||||
- (void) needToFetch:(id)sth
|
||||
{
|
||||
[dg fetch];
|
||||
[_topTable reloadData];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation ModelerEntityEditor (DisplayGroupDelegate)
|
||||
- (void) displayGroupDidChangeSelection:(EODisplayGroup *)displayGroup
|
||||
{
|
||||
[self setSelectionWithinViewedObject: [displayGroup selectedObjects]];
|
||||
[[self parentEditor] setSelectionWithinViewedObject: [displayGroup selectedObjects]];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
* mostly takes care of corner views right now..
|
||||
*/
|
||||
@interface ModelerTableEmbedibleEditor : EOModelerEmbedibleEditor
|
||||
|
||||
- (void) setupCornerView:(NSPopUpButton *)cornerView
|
||||
tableView:(NSTableView *)tableView
|
||||
displayGroup:(EODisplayGroup *)dg
|
||||
|
|
|
@ -85,18 +85,18 @@
|
|||
|
||||
provider = [EOMApp providerForName: columnName class:aClass];
|
||||
|
||||
/* THIS *MUST* be before initColumn:class:name:displayGroup:document calls */
|
||||
/*
|
||||
* THIS *MUST* be before initColumn:class:name:displayGroup:document calls */
|
||||
[tv addTableColumn:tc];
|
||||
RELEASE(tc);
|
||||
|
||||
[provider initColumn:tc class:aClass name:columnName
|
||||
displayGroup:dg document:[self document]];
|
||||
|
||||
item = (NSMenuItem *)[cv itemWithTitle:columnName];
|
||||
[item setRepresentedObject:tc];
|
||||
[item setState:NSOnState];
|
||||
}
|
||||
[tv sizeToFit];
|
||||
[tv tile];
|
||||
}
|
||||
|
||||
- (void) addTableColumnForItem:(NSMenuItem <NSMenuItem>*)item
|
||||
|
@ -120,8 +120,8 @@
|
|||
name:columnName
|
||||
displayGroup:[[tv delegate] displayGroupForAspect:@"source"] // <-+-^
|
||||
document:[self document]];
|
||||
|
||||
[tv sizeToFit];
|
||||
[tc sizeToFit];
|
||||
[tv tile];
|
||||
}
|
||||
|
||||
- (void) removeTableColumnForItem:(NSMenuItem <NSMenuItem>*)item
|
||||
|
|
63
DBModeler/Preferences.h
Normal file
63
DBModeler/Preferences.h
Normal file
|
@ -0,0 +1,63 @@
|
|||
/**
|
||||
Preferences.h
|
||||
|
||||
Author: Matt Rice <ratmice@yahoo.com>
|
||||
Date: Mar 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 <Foundation/NSObject.h>
|
||||
#include <AppKit/NSNibDeclarations.h>
|
||||
|
||||
@class NSWindow;
|
||||
@class NSButton;
|
||||
@class NSTableView;
|
||||
@class NSMatrix;
|
||||
@class NSMutableArray;
|
||||
|
||||
@interface DBModelerPrefs : NSObject
|
||||
{
|
||||
IBOutlet NSWindow *prefsWindow;
|
||||
IBOutlet NSButton *consistencyCheckOnSave;
|
||||
IBOutlet NSTableView *bundlesToLoad;
|
||||
/* consistency checks */
|
||||
IBOutlet NSMatrix *check_matrix;
|
||||
NSMutableArray *_bundles;
|
||||
}
|
||||
|
||||
+ (DBModelerPrefs *) sharedPreferences;
|
||||
|
||||
- (void) showPreferences:(id)sender;
|
||||
|
||||
- (BOOL) consistencyCheckOnSave;
|
||||
- (BOOL) attributeDetailsCheck;
|
||||
- (BOOL) storedProcedureCheck;
|
||||
- (BOOL) relationshipCheck;
|
||||
- (BOOL) primaryKeyCheck;
|
||||
- (BOOL) inheritanceCheck;
|
||||
- (BOOL) externalNameCheck;
|
||||
- (BOOL) entityStoredProcedureCheck;
|
||||
- (NSArray *)bundlesToLoad;
|
||||
|
||||
- (IBAction) switchButtonChanged:(id)sender;
|
||||
- (IBAction) checkOnSaveChanged:(id)sender;
|
||||
- (IBAction) addBundle:(id)sender;
|
||||
- (IBAction) removeBundle:(id)sender;
|
||||
@end
|
206
DBModeler/Preferences.m
Normal file
206
DBModeler/Preferences.m
Normal file
|
@ -0,0 +1,206 @@
|
|||
/**
|
||||
Preferences.m
|
||||
|
||||
Author: Matt Rice <ratmice@yahoo.com>
|
||||
Date: Mar 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 "Preferences.h"
|
||||
|
||||
#include <Foundation/NSInvocation.h>
|
||||
#include <Foundation/NSUserDefaults.h>
|
||||
|
||||
#include <AppKit/NSNibLoading.h>
|
||||
#include <AppKit/NSWindow.h>
|
||||
#include <AppKit/NSButton.h>
|
||||
#include <AppKit/NSTableView.h>
|
||||
#include <AppKit/NSMatrix.h>
|
||||
|
||||
#define DisableAttributeDetailsCheck @"DisableAttributeDetailsCheck"
|
||||
#define DisableEntityStoredProcedureCheck @"DisableEntityStoredProcedureCheck"
|
||||
#define DisableExternalNameCheck @"DisableExternalNameCheck"
|
||||
#define DisableInheritanceCheck @"DisableInheritanceCheck"
|
||||
#define DisablePrimaryKeyCheck @"DisablePrimaryKeyCheck"
|
||||
#define DisableRelationshipCheck @"DisableRelationshipCheck"
|
||||
#define DisableStoredProcedureCheck @"DisableStoredProcedureCheck"
|
||||
static NSString *BundlesToLoad = @"BundlesToLoad";
|
||||
static NSString *DisableConsistencyCheckOnSave=@"DisableConsistencyCheckOnSave";
|
||||
|
||||
|
||||
static NSUserDefaults *ud;
|
||||
static DBModelerPrefs *_sharedPrefs;
|
||||
|
||||
/* do it this way so i can add the switch title later instead of being
|
||||
* hard coded into the .gorm */
|
||||
static NSString *_switches[][2] =
|
||||
{
|
||||
{DisableAttributeDetailsCheck, @"Attribute details"},
|
||||
{DisableExternalNameCheck, @"External name"},
|
||||
{DisablePrimaryKeyCheck, @"Primary key"},
|
||||
{DisableRelationshipCheck, @"Relationship"},
|
||||
{DisableEntityStoredProcedureCheck, @"Entity stored procedure"},
|
||||
{DisableStoredProcedureCheck, @"Stored procedure"},
|
||||
{DisableInheritanceCheck, @"Inheritance"}
|
||||
};
|
||||
|
||||
#define FROBKEY(key) [ud boolForKey:key] ? NO : YES
|
||||
#define COUNT(key) sizeof(key) / sizeof(key[0])
|
||||
|
||||
@implementation DBModelerPrefs : NSObject
|
||||
+ (DBModelerPrefs *) sharedPreferences
|
||||
{
|
||||
return _sharedPrefs ? _sharedPrefs : _sharedPrefs = [self new];
|
||||
}
|
||||
|
||||
- (id) init
|
||||
{
|
||||
self = [super init];
|
||||
/* setup ud before -awakeFromNib is called... */
|
||||
ud = [NSUserDefaults standardUserDefaults];
|
||||
_bundles = [[NSMutableArray alloc] init];
|
||||
[_bundles addObjectsFromArray:[self bundlesToLoad]];
|
||||
[NSBundle loadNibNamed:@"Preferences" owner:self];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) awakeFromNib
|
||||
{
|
||||
int i, c = COUNT(_switches);
|
||||
|
||||
[check_matrix renewRows:c columns:1];
|
||||
|
||||
for (i = 0; i < c; i++)
|
||||
{
|
||||
NSButtonCell *cell = [check_matrix cellAtRow:i column:0];
|
||||
BOOL flag;
|
||||
|
||||
flag = [ud boolForKey:_switches[i][0]];
|
||||
[cell setState: (flag == NO) ? NSOnState : NSOffState];
|
||||
[cell setTitle: _switches[i][1]];
|
||||
}
|
||||
[check_matrix sizeToCells];
|
||||
[consistencyCheckOnSave
|
||||
setState:[ud boolForKey:DisableConsistencyCheckOnSave]
|
||||
? NSOffState
|
||||
: NSOnState];
|
||||
[bundlesToLoad reloadData];
|
||||
}
|
||||
|
||||
- (void) showPreferences:(id)sender
|
||||
{
|
||||
[prefsWindow makeKeyAndOrderFront:self];
|
||||
}
|
||||
|
||||
- (void) switchButtonChanged:(id)sender
|
||||
{
|
||||
[ud setBool:([[sender selectedCell] state] == NSOffState)
|
||||
forKey:_switches[[sender selectedRow]][0]];
|
||||
}
|
||||
|
||||
- (void) checkOnSaveChanged:(id)sender
|
||||
{
|
||||
[ud setBool:([sender state] == NSOffState)
|
||||
forKey:DisableConsistencyCheckOnSave];
|
||||
}
|
||||
|
||||
- (NSArray *)bundlesToLoad
|
||||
{
|
||||
return [ud arrayForKey:BundlesToLoad];
|
||||
}
|
||||
|
||||
- (BOOL) consistencyCheckOnSave
|
||||
{
|
||||
return FROBKEY(DisableConsistencyCheckOnSave);
|
||||
}
|
||||
|
||||
- (BOOL) attributeDetailsCheck
|
||||
{
|
||||
return FROBKEY(DisableAttributeDetailsCheck);
|
||||
}
|
||||
|
||||
- (BOOL) entityStoredProcedureCheck
|
||||
{
|
||||
return FROBKEY(DisableEntityStoredProcedureCheck);
|
||||
}
|
||||
|
||||
- (BOOL) externalNameCheck
|
||||
{
|
||||
return FROBKEY(DisableExternalNameCheck);
|
||||
}
|
||||
|
||||
- (BOOL) inheritanceCheck
|
||||
{
|
||||
return FROBKEY(DisableInheritanceCheck);
|
||||
}
|
||||
|
||||
- (BOOL) primaryKeyCheck
|
||||
{
|
||||
return FROBKEY(DisablePrimaryKeyCheck);
|
||||
}
|
||||
|
||||
- (BOOL) relationshipCheck
|
||||
{
|
||||
return FROBKEY(DisableRelationshipCheck);
|
||||
}
|
||||
|
||||
- (BOOL) storedProcedureCheck
|
||||
{
|
||||
return FROBKEY(DisableStoredProcedureCheck);
|
||||
}
|
||||
|
||||
|
||||
- (int) numberOfRowsInTableView:(NSTableView *)tv
|
||||
{
|
||||
int num = [_bundles count];
|
||||
return num;
|
||||
}
|
||||
|
||||
- (id) tableView:(NSTableView *)tv objectValueForTableColumn:(NSTableColumn *)tc row:(int)rowIndex
|
||||
{
|
||||
id ov = [_bundles objectAtIndex:rowIndex];
|
||||
return ov;
|
||||
}
|
||||
|
||||
- (void) tableView:(NSTableView *)tv
|
||||
setObjectValue:(id)newVal
|
||||
forTableColumn:(NSTableColumn *)tc
|
||||
row:(int)rowIndex
|
||||
{
|
||||
[_bundles replaceObjectAtIndex:rowIndex withObject:newVal];
|
||||
[ud setObject:_bundles forKey:BundlesToLoad];
|
||||
}
|
||||
|
||||
- (void) addBundle:(id)sender
|
||||
{
|
||||
[_bundles addObject:@""];
|
||||
[bundlesToLoad reloadData];
|
||||
[bundlesToLoad selectRow:[_bundles count] - 1 byExtendingSelection:NO];
|
||||
[bundlesToLoad editColumn:0 row:[_bundles count] - 1 withEvent:nil select:YES];
|
||||
}
|
||||
- (void) removeBundle:(id)sender
|
||||
{
|
||||
[_bundles removeObjectAtIndex:[bundlesToLoad selectedRow]];
|
||||
[bundlesToLoad reloadData];
|
||||
[ud setObject:_bundles forKey:BundlesToLoad];
|
||||
}
|
||||
|
||||
@end
|
BIN
DBModeler/Resources/ClassProperty_Header.tiff
Normal file
BIN
DBModeler/Resources/ClassProperty_Header.tiff
Normal file
Binary file not shown.
Binary file not shown.
BIN
DBModeler/Resources/Key_Header.tiff
Normal file
BIN
DBModeler/Resources/Key_Header.tiff
Normal file
Binary file not shown.
Binary file not shown.
BIN
DBModeler/Resources/Locking_On.tiff
Normal file
BIN
DBModeler/Resources/Locking_On.tiff
Normal file
Binary file not shown.
29
DBModeler/Resources/Preferences.gorm/data.classes
Normal file
29
DBModeler/Resources/Preferences.gorm/data.classes
Normal file
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"## Comment" = "Do NOT change this file, Gorm maintains it";
|
||||
DBModelerPrefs = {
|
||||
Actions = (
|
||||
"switchButtonChanged:",
|
||||
"checkOnSaveChanged:",
|
||||
"addBundle:",
|
||||
"removeBundle:"
|
||||
);
|
||||
Outlets = (
|
||||
prefsWindow,
|
||||
consistencyCheckOnSave,
|
||||
bundlesToLoad,
|
||||
addBundleButton,
|
||||
check_matrix,
|
||||
removeBundleButton
|
||||
);
|
||||
Super = NSObject;
|
||||
};
|
||||
FirstResponder = {
|
||||
Actions = (
|
||||
"addBundle:",
|
||||
"checkOnSaveChanged:",
|
||||
"removeBundle:",
|
||||
"switchButtonChanged:"
|
||||
);
|
||||
Super = NSObject;
|
||||
};
|
||||
}
|
BIN
DBModeler/Resources/Preferences.gorm/data.info
Normal file
BIN
DBModeler/Resources/Preferences.gorm/data.info
Normal file
Binary file not shown.
BIN
DBModeler/Resources/Preferences.gorm/objects.gorm
Normal file
BIN
DBModeler/Resources/Preferences.gorm/objects.gorm
Normal file
Binary file not shown.
|
@ -24,6 +24,7 @@
|
|||
**/
|
||||
|
||||
#include "SQLGenerator.h"
|
||||
#include "Modeler.h"
|
||||
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSDictionary.h>
|
||||
|
@ -101,11 +102,23 @@ static NSString *_otherScript;
|
|||
|
||||
- (void) openSQLGenerator:(id)sender;
|
||||
{
|
||||
EOAdaptor *adaptor;
|
||||
|
||||
while (loadedNib && !goodToGo)
|
||||
{
|
||||
/* wait.. */
|
||||
}
|
||||
[_window makeKeyAndOrderFront:self];
|
||||
|
||||
adaptor = [[EOMApp activeDocument] adaptor];
|
||||
if (!adaptor)
|
||||
{
|
||||
[[EOMApp delegate] setAdaptor:self];
|
||||
}
|
||||
|
||||
adaptor = [[EOMApp activeDocument] adaptor];
|
||||
|
||||
if (adaptor)
|
||||
[_window makeKeyAndOrderFront:self];
|
||||
}
|
||||
|
||||
- (IBAction) executeSQL:(id)sender
|
||||
|
@ -120,6 +133,30 @@ static NSString *_otherScript;
|
|||
if ([[_sqlOutput string] length] == 0)
|
||||
return;
|
||||
|
||||
if (!adaptor)
|
||||
{
|
||||
[[EOMApp delegate] setAdaptor:self];
|
||||
adaptor = [[EOMApp activeDocument] adaptor];
|
||||
connDict = [adaptor connectionDictionary];
|
||||
}
|
||||
else if ([[connDict allKeys] count] == 0)
|
||||
{
|
||||
connDict = [adaptor runLoginPanel];
|
||||
|
||||
if (connDict)
|
||||
[adaptor setConnectionDictionary:connDict];
|
||||
}
|
||||
|
||||
if (!adaptor || [[connDict allKeys] count] == 0)
|
||||
{
|
||||
NSRunAlertPanel(@"Error",
|
||||
@"SQL generator requires a valid adaptor and connection dictionary",
|
||||
@"Ok",
|
||||
nil,
|
||||
nil);
|
||||
return;
|
||||
}
|
||||
|
||||
if ([adaptor hasOpenChannels])
|
||||
{
|
||||
NSArray *contexts = [adaptor contexts];
|
||||
|
@ -204,13 +241,13 @@ static NSString *_otherScript;
|
|||
- (IBAction) saveAs:(id)sender
|
||||
{
|
||||
id savePanel = [NSSavePanel savePanel];
|
||||
NSString *path;
|
||||
int result = [savePanel runModal];
|
||||
if (result == NSOKButton)
|
||||
{
|
||||
NSString *path;
|
||||
path = [savePanel filename];
|
||||
[[_sqlOutput string] writeToFile:path atomically:YES];
|
||||
}
|
||||
[[_sqlOutput string] writeToFile:path atomically:YES];
|
||||
}
|
||||
|
||||
- (IBAction) switchChanged:(id)sender
|
||||
|
@ -227,6 +264,13 @@ static NSString *_otherScript;
|
|||
int i, c;
|
||||
NSButton *btn;
|
||||
|
||||
if (!expr)
|
||||
{
|
||||
[[EOMApp delegate] setAdaptor:self];
|
||||
expr = [[[EOMApp activeDocument] adaptor] expressionClass];
|
||||
if (!expr) return;
|
||||
}
|
||||
|
||||
for (i = 0, c = [adminSwitchButtons count]; i < c; i++)
|
||||
{
|
||||
btn = [adminSwitchButtons objectAtIndex:i];
|
||||
|
|
Loading…
Reference in a new issue