mirror of
https://github.com/gnustep/libs-gdl2.git
synced 2025-06-03 02:31:00 +00:00
* DBModeler/Modeler.m (_newDocumentWithModel:): Don't release the
model. (-new:): Release the model here. (-newFromDatabase:): Ditto, and add error handling. (-open:): Ditto. (-application:openFile:): New method. * EOModeler/EOModelerDocument.m (-saveAs:): Add error handling, and remove check for an existing name. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@21445 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
e96b810ebf
commit
e6d526b03c
3 changed files with 87 additions and 30 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
2005-07-10 Matt Rice <ratmice@yahoo.com>
|
||||||
|
|
||||||
|
* DBModeler/Modeler.m (_newDocumentWithModel:): Don't release the
|
||||||
|
model.
|
||||||
|
(-new:): Release the model here.
|
||||||
|
(-newFromDatabase:): Ditto, and add error handling.
|
||||||
|
(-open:): Ditto.
|
||||||
|
(-application:openFile:): New method.
|
||||||
|
* EOModeler/EOModelerDocument.m (-saveAs:): Add error handling, and
|
||||||
|
remove check for an existing name.
|
||||||
|
|
||||||
2005-07-10 Peter Cooper <comrade@obverse.com.au>
|
2005-07-10 Peter Cooper <comrade@obverse.com.au>
|
||||||
|
|
||||||
* DBModeler/GNUmakefile: Add Info-gnustep.plist to project.
|
* DBModeler/GNUmakefile: Add Info-gnustep.plist to project.
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
#include <AppKit/NSOpenPanel.h>
|
#include <AppKit/NSOpenPanel.h>
|
||||||
|
|
||||||
#include <Foundation/NSObject.h>
|
#include <Foundation/NSObject.h>
|
||||||
|
#include <Foundation/NSFileManager.h>
|
||||||
|
|
||||||
@interface NSMenu (im_lazy)
|
@interface NSMenu (im_lazy)
|
||||||
-(id <NSMenuItem>) addItemWithTitle: (NSString *)s;
|
-(id <NSMenuItem>) addItemWithTitle: (NSString *)s;
|
||||||
|
@ -227,7 +228,6 @@
|
||||||
EOModelerDocument *newModelerDoc;
|
EOModelerDocument *newModelerDoc;
|
||||||
EOModelerCompoundEditor *editor;
|
EOModelerCompoundEditor *editor;
|
||||||
newModelerDoc = [[EOModelerDocument alloc] initWithModel: newModel];
|
newModelerDoc = [[EOModelerDocument alloc] initWithModel: newModel];
|
||||||
RELEASE(newModel);
|
|
||||||
editor = (EOModelerCompoundEditor*)[newModelerDoc addDefaultEditor];
|
editor = (EOModelerCompoundEditor*)[newModelerDoc addDefaultEditor];
|
||||||
[EOMApp setCurrentEditor: editor];
|
[EOMApp setCurrentEditor: editor];
|
||||||
[EOMApp addDocument: newModelerDoc];
|
[EOMApp addDocument: newModelerDoc];
|
||||||
|
@ -246,29 +246,42 @@
|
||||||
modelName=[NSString stringWithFormat:@"Model_%u",++nDocs];
|
modelName=[NSString stringWithFormat:@"Model_%u",++nDocs];
|
||||||
[newModel setName:modelName];
|
[newModel setName:modelName];
|
||||||
[self _newDocumentWithModel:newModel];
|
[self _newDocumentWithModel:newModel];
|
||||||
|
RELEASE(newModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) newFromDatabase:(id)sender
|
- (void) newFromDatabase:(id)sender
|
||||||
{
|
{
|
||||||
NSString *adaptorName;
|
NSString *adaptorName;
|
||||||
EOAdaptor *adaptor;
|
|
||||||
EOAdaptorChannel *channel;
|
|
||||||
EOAdaptorContext *ctxt;
|
|
||||||
EOModel *newModel;
|
|
||||||
AdaptorsPanel *adaptorsPanel = [[AdaptorsPanel alloc] init];
|
AdaptorsPanel *adaptorsPanel = [[AdaptorsPanel alloc] init];
|
||||||
|
|
||||||
adaptorName = [adaptorsPanel runAdaptorsPanel];
|
adaptorName = [adaptorsPanel runAdaptorsPanel];
|
||||||
RELEASE(adaptorsPanel);
|
RELEASE(adaptorsPanel);
|
||||||
adaptor = [EOAdaptor adaptorWithName:adaptorName];
|
|
||||||
[adaptor setConnectionDictionary:[adaptor runLoginPanel]];
|
if (adaptorName)
|
||||||
ctxt = [adaptor createAdaptorContext];
|
{
|
||||||
channel = [ctxt createAdaptorChannel];
|
EOAdaptor *adaptor;
|
||||||
[channel openChannel];
|
EOAdaptorChannel *channel;
|
||||||
newModel = [channel describeModelWithTableNames:[channel describeTableNames]];
|
EOAdaptorContext *ctxt;
|
||||||
[newModel setConnectionDictionary:[adaptor connectionDictionary]];
|
EOModel *newModel;
|
||||||
[newModel setName: [[adaptor connectionDictionary] objectForKey:@"databaseName"]];
|
NSDictionary *connDict;
|
||||||
[channel closeChannel];
|
|
||||||
[self _newDocumentWithModel:newModel];
|
adaptor = [EOAdaptor adaptorWithName:adaptorName];
|
||||||
|
connDict = [adaptor runLoginPanel];
|
||||||
|
|
||||||
|
if (connDict)
|
||||||
|
{
|
||||||
|
[adaptor setConnectionDictionary:[adaptor runLoginPanel]];
|
||||||
|
ctxt = [adaptor createAdaptorContext];
|
||||||
|
channel = [ctxt createAdaptorChannel];
|
||||||
|
[channel openChannel];
|
||||||
|
newModel = [channel describeModelWithTableNames:[channel describeTableNames]];
|
||||||
|
[newModel setConnectionDictionary:[adaptor connectionDictionary]];
|
||||||
|
[newModel setName: [[adaptor connectionDictionary] objectForKey:@"databaseName"]];
|
||||||
|
[channel closeChannel];
|
||||||
|
[self _newDocumentWithModel:newModel];
|
||||||
|
RELEASE(newModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) validateMenuItem:(NSMenuItem *)menuItem
|
- (BOOL) validateMenuItem:(NSMenuItem *)menuItem
|
||||||
|
@ -299,11 +312,34 @@
|
||||||
[EOMInspectorController showInspector];
|
[EOMInspectorController showInspector];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) 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"]))
|
||||||
|
{
|
||||||
|
EOModel *model;
|
||||||
|
|
||||||
|
NS_DURING
|
||||||
|
model = [[EOModel alloc] initWithContentsOfFile:filename];
|
||||||
|
NS_HANDLER
|
||||||
|
return;
|
||||||
|
NS_ENDHANDLER
|
||||||
|
|
||||||
|
[self _newDocumentWithModel:model];
|
||||||
|
RELEASE(model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (void) open:(id)sender
|
- (void) open:(id)sender
|
||||||
{
|
{
|
||||||
NSOpenPanel *panel = [NSOpenPanel openPanel];
|
NSOpenPanel *panel = [NSOpenPanel openPanel];
|
||||||
|
NSFileManager *fm = [NSFileManager defaultManager];
|
||||||
|
|
||||||
if ([panel runModalForTypes:[NSArray arrayWithObject:@"eomodeld"]] == NSOKButton)
|
if ([panel runModalForTypes:[NSArray arrayWithObjects:@"eomodeld",@"eomodel",nil]] == NSOKButton)
|
||||||
{
|
{
|
||||||
NSArray *modelPaths = [panel filenames];
|
NSArray *modelPaths = [panel filenames];
|
||||||
int i,c;
|
int i,c;
|
||||||
|
@ -311,10 +347,23 @@
|
||||||
for (i = 0, c = [modelPaths count]; i < c; i++)
|
for (i = 0, c = [modelPaths count]; i < c; i++)
|
||||||
{
|
{
|
||||||
NSString *modelPath = [modelPaths objectAtIndex:i];
|
NSString *modelPath = [modelPaths objectAtIndex:i];
|
||||||
EOModel *model = [[EOModel alloc] initWithContentsOfFile:modelPath];
|
NSString *pathExt = [[modelPath pathExtension] lowercaseString];
|
||||||
|
|
||||||
[self _newDocumentWithModel:model];
|
if ([fm isReadableFileAtPath:modelPath] == YES
|
||||||
RELEASE(model);
|
&& ([pathExt isEqual:@"eomodeld"]
|
||||||
|
|| [pathExt isEqual:@"eomodel"]))
|
||||||
|
{
|
||||||
|
EOModel *model;
|
||||||
|
|
||||||
|
NS_DURING
|
||||||
|
model = [[EOModel alloc] initWithContentsOfFile:modelPath];
|
||||||
|
NS_HANDLER
|
||||||
|
return;
|
||||||
|
NS_ENDHANDLER
|
||||||
|
|
||||||
|
[self _newDocumentWithModel:model];
|
||||||
|
RELEASE(model);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -408,18 +408,15 @@ showOnSuccess:(BOOL)bar;
|
||||||
|
|
||||||
- (void)saveAs:(id)sender
|
- (void)saveAs:(id)sender
|
||||||
{
|
{
|
||||||
NSString *path = [_model path];
|
NSString *path;
|
||||||
if (!path)
|
id savePanel = [NSSavePanel savePanel];
|
||||||
{
|
int result = [savePanel runModal];
|
||||||
id savePanel = [NSSavePanel savePanel];
|
|
||||||
int result = [savePanel runModal];
|
|
||||||
|
|
||||||
if (result == NSOKButton)
|
if (result == NSOKButton)
|
||||||
{
|
{
|
||||||
path = [savePanel filename];
|
path = [savePanel filename];
|
||||||
}
|
[self saveToPath: path];
|
||||||
}
|
}
|
||||||
[self saveToPath: path];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)revertToSaved:(id)sender
|
- (void)revertToSaved:(id)sender
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue