diff options
author | stuconnolly <stuart02@gmail.com> | 2009-10-21 22:51:27 +0000 |
---|---|---|
committer | stuconnolly <stuart02@gmail.com> | 2009-10-21 22:51:27 +0000 |
commit | 20baed5257ce1152c1f25c5a953ca821b50050db (patch) | |
tree | c0d1f218f1f7c4f1f89591c4f89072f66e72e329 /Source/SPUserManager.m | |
parent | 8e298ebb3805b4357d8388de4f5e82158df19cb9 (diff) | |
download | sequelpro-20baed5257ce1152c1f25c5a953ca821b50050db.tar.gz sequelpro-20baed5257ce1152c1f25c5a953ca821b50050db.tar.bz2 sequelpro-20baed5257ce1152c1f25c5a953ca821b50050db.zip |
- Display the user accounts manager as a sheet
- Tidy up a bunch of interface controls and bahaviour
Diffstat (limited to 'Source/SPUserManager.m')
-rw-r--r-- | Source/SPUserManager.m | 97 |
1 files changed, 60 insertions, 37 deletions
diff --git a/Source/SPUserManager.m b/Source/SPUserManager.m index 4b7863e1..870f35a8 100644 --- a/Source/SPUserManager.m +++ b/Source/SPUserManager.m @@ -47,35 +47,27 @@ @synthesize mySqlConnection; -- (id)init -{ - [self dealloc]; - @throw [NSException exceptionWithName:@"BadInitCall" reason:@"Can't call init here" userInfo:nil]; - return nil; -} - - (id)initWithConnection:(MCPConnection*) connection { - if (![super init]) { - return nil; - } + if ((self = [super initWithWindowNibName:@"UserManagerView"])) { - self.mySqlConnection = connection; - - // When reading privileges from the database, they are converted automatically to a - // lowercase key used in the user privileges stores, from which a GRANT syntax - // is derived automatically. While most keys can be automatically converted without - // any difficulty, some keys differ slightly in mysql column storage to GRANT syntax; - // this dictionary provides mappings for those values to ensure consistency. - privColumnToGrantMap = [[NSDictionary alloc] initWithObjectsAndKeys: - @"Grant_option_priv", @"Grant_priv", - @"Show_databases_priv", @"Show_db_priv", - @"Create_temporary_tables_priv", @"Create_tmp_table_priv", - @"Replication_slave_priv", @"Repl_slave_priv", - @"Replication_client_priv", @"Repl_client_priv", - nil]; - - privsSupportedByServer = [[NSMutableDictionary alloc] init]; + self.mySqlConnection = connection; + + // When reading privileges from the database, they are converted automatically to a + // lowercase key used in the user privileges stores, from which a GRANT syntax + // is derived automatically. While most keys can be automatically converted without + // any difficulty, some keys differ slightly in mysql column storage to GRANT syntax; + // this dictionary provides mappings for those values to ensure consistency. + privColumnToGrantMap = [[NSDictionary alloc] initWithObjectsAndKeys: + @"Grant_option_priv", @"Grant_priv", + @"Show_databases_priv", @"Show_db_priv", + @"Create_temporary_tables_priv", @"Create_tmp_table_priv", + @"Replication_slave_priv", @"Repl_slave_priv", + @"Replication_client_priv", @"Repl_client_priv", + nil]; + + privsSupportedByServer = [[NSMutableDictionary alloc] init]; + } return self; } @@ -109,7 +101,6 @@ [tableColumn setDataCell:imageAndTextCell]; [self _initializeUsers]; - [[self window] makeKeyAndOrderFront:nil]; } - (void)_initializeUsers @@ -316,14 +307,14 @@ return mySqlConnection; } -- (void)show +/*- (void)show { // [NSThread detachNewThreadSelector:@selector(_initializeUsers) toTarget:self withObject:nil]; if (!outlineView) { [NSBundle loadNibNamed:@"UserManagerView" owner:self]; } [[self window] makeKeyAndOrderFront:nil]; -} +}*/ #pragma mark - #pragma mark OutlineView Delegate Methods @@ -383,26 +374,37 @@ } } -// General Action Methods +#pragma mark - +#pragma mark General IBAction methods + +/** + * Closes the user manager and reverts any changes made. + */ - (IBAction)doCancel:(id)sender { [[self managedObjectContext] rollback]; - [[self window] close]; + + // Close sheet + [NSApp endSheet:[self window] returnCode:0]; + [[self window] orderOut:self]; } +/** + * Closes the user manager and applies any changes made. + */ - (IBAction)doApply:(id)sender { NSError *error = nil; [[self managedObjectContext] save:&error]; - if (error != nil) - { + + if (error != nil) { [[NSApplication sharedApplication] presentError:error]; } - else - { - [[self window] close]; + else { + // Close sheet + [NSApp endSheet:[self window] returnCode:0]; + [[self window] orderOut:self]; } -// [self _clearData]; } - (IBAction)checkAllPrivileges:(id)sender @@ -713,6 +715,7 @@ #pragma mark - #pragma mark Tab View Delegate methods + - (BOOL)tabView:(NSTabView *)tabView shouldSelectTabViewItem:(NSTabViewItem *)tabViewItem { if ([[treeController selectedObjects] count] == 0) @@ -727,4 +730,24 @@ return TRUE; } + +#pragma mark - +#pragma mark SplitView delegate methods + +/** + * Return the maximum possible size of the splitview. + */ +- (float)splitView:(NSSplitView *)sender constrainMaxCoordinate:(float)proposedMax ofSubviewAt:(int)offset +{ + return (proposedMax - 220); +} + +/** + * Return the minimum possible size of the splitview. + */ +- (float)splitView:(NSSplitView *)sender constrainMinCoordinate:(float)proposedMin ofSubviewAt:(int)offset +{ + return (proposedMin + 120); +} + @end |