Skip to content

Commit

Permalink
Add Confirm Sheet before drop DB or Collection
Browse files Browse the repository at this point in the history
  • Loading branch information
bububa committed Dec 22, 2010
1 parent 4475240 commit 73cdd2c
Show file tree
Hide file tree
Showing 4 changed files with 225 additions and 35 deletions.
1 change: 1 addition & 0 deletions ConnectionWindowController.h
Expand Up @@ -84,4 +84,5 @@
-(void) checkTunnel; -(void) checkTunnel;
- (void) connect:(BOOL)haveHostAddress; - (void) connect:(BOOL)haveHostAddress;
- (void) tunnelStatusChanged: (Tunnel*) tunnel status: (NSString*) status; - (void) tunnelStatusChanged: (Tunnel*) tunnel status: (NSString*) status;
- (void)dropWarning:(NSString *)msg;
@end @end
41 changes: 39 additions & 2 deletions ConnectionWindowController.mm
Expand Up @@ -176,6 +176,7 @@ - (void)reloadSidebar {


- (void)reloadDBList { - (void)reloadDBList {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[loaderIndicator start];
//[selectedDB release]; //[selectedDB release];
selectedDB = nil; selectedDB = nil;
//[selectedCollection release]; //[selectedCollection release];
Expand All @@ -198,6 +199,7 @@ - (void)reloadDBList {
} }
[sidebar reloadData]; [sidebar reloadData];
[sidebar expandItem:@"1"]; [sidebar expandItem:@"1"];
[loaderIndicator stop];
[pool release]; [pool release];
} }


Expand All @@ -219,7 +221,9 @@ - (void)useDB:(id)sender {
} }
[db release]; [db release];
[collections release]; [collections release];
[loaderIndicator start];
collections = [[NSMutableArray alloc] initWithArray:[mongoDB listCollections:dbname user:user password:password]]; collections = [[NSMutableArray alloc] initWithArray:[mongoDB listCollections:dbname user:user password:password]];
[loaderIndicator stop];
[dbname release]; [dbname release];


[sidebar removeItem:@"2"]; [sidebar removeItem:@"2"];
Expand Down Expand Up @@ -267,6 +271,7 @@ - (IBAction)showDBStats:(id)sender
NSRunAlertPanel(@"Error", @"Please specify a database!", @"OK", nil, nil); NSRunAlertPanel(@"Error", @"Please specify a database!", @"OK", nil, nil);
return; return;
} }
[loaderIndicator start];
[resultsTitle setStringValue:[NSString stringWithFormat:@"Database %@ stats", [selectedDB caption]]]; [resultsTitle setStringValue:[NSString stringWithFormat:@"Database %@ stats", [selectedDB caption]]];
NSString *user=nil; NSString *user=nil;
NSString *password=nil; NSString *password=nil;
Expand All @@ -282,6 +287,7 @@ - (IBAction)showDBStats:(id)sender
resultsOutlineViewController.results = results; resultsOutlineViewController.results = results;
[resultsOutlineViewController.myOutlineView reloadData]; [resultsOutlineViewController.myOutlineView reloadData];
[results release]; [results release];
[loaderIndicator stop];
//NSLog(@"STATUS: %@", results); //NSLog(@"STATUS: %@", results);
} }


Expand All @@ -291,6 +297,7 @@ - (IBAction)showCollStats:(id)sender
NSRunAlertPanel(@"Error", @"Please specify a collection!", @"OK", nil, nil); NSRunAlertPanel(@"Error", @"Please specify a collection!", @"OK", nil, nil);
return; return;
} }
[loaderIndicator start];
[resultsTitle setStringValue:[NSString stringWithFormat:@"Collection %@.%@ stats", [selectedDB caption], [selectedCollection caption]]]; [resultsTitle setStringValue:[NSString stringWithFormat:@"Collection %@.%@ stats", [selectedDB caption], [selectedCollection caption]]];
NSString *user=nil; NSString *user=nil;
NSString *password=nil; NSString *password=nil;
Expand All @@ -308,6 +315,7 @@ - (IBAction)showCollStats:(id)sender
resultsOutlineViewController.results = results; resultsOutlineViewController.results = results;
[resultsOutlineViewController.myOutlineView reloadData]; [resultsOutlineViewController.myOutlineView reloadData];
[results release]; [results release];
[loaderIndicator stop];
} }


- (IBAction)createDBorCollection:(id)sender - (IBAction)createDBorCollection:(id)sender
Expand Down Expand Up @@ -394,9 +402,9 @@ - (void)addCollection:(id)sender
- (IBAction)dropDBorCollection:(id)sender - (IBAction)dropDBorCollection:(id)sender
{ {
if (selectedCollection) { if (selectedCollection) {
[self dropCollection:[selectedCollection caption] ForDB:[selectedDB caption]]; [self dropWarning:[NSString stringWithFormat:@"COLLECTION:%@", [selectedCollection caption]]];
}else { }else {
[self dropDB]; [self dropWarning:[NSString stringWithFormat:@"DB:%@", [selectedDB caption]]];
} }
} }


Expand All @@ -411,10 +419,12 @@ - (void)dropCollection:(NSString *)collectionname ForDB:(NSString *)dbname
password = db.password; password = db.password;
} }
[db release]; [db release];
[loaderIndicator start];
[mongoDB dropCollection:collectionname [mongoDB dropCollection:collectionname
forDB:dbname forDB:dbname
user:user user:user
password:password]; password:password];
[loaderIndicator stop];
if ([[selectedDB caption] isEqualToString:dbname]) { if ([[selectedDB caption] isEqualToString:dbname]) {
[sidebar selectItem:[selectedDB nodeKey]]; [sidebar selectItem:[selectedDB nodeKey]];
} }
Expand All @@ -436,9 +446,11 @@ - (void)dropDB
password = db.password; password = db.password;
} }
[db release]; [db release];
[loaderIndicator start];
[mongoDB dropDB:[selectedDB caption] [mongoDB dropDB:[selectedDB caption]
user:user user:user
password:password]; password:password];
[loaderIndicator stop];
[self reloadSidebar]; [self reloadSidebar];
[pool release]; [pool release];
} }
Expand Down Expand Up @@ -523,4 +535,29 @@ - (IBAction)exportToMySQL:(id)sender
[exportWindowController showWindow:self]; [exportWindowController showWindow:self];
} }


- (void)alertDidEnd:(NSAlert *)alert returnCode:(int)returnCode contextInfo:(void *)contextInfo
{
if (returnCode == NSAlertFirstButtonReturn)
{
if (selectedCollection) {
[self dropCollection:[selectedCollection caption] ForDB:[selectedDB caption]];
}else {
[self dropDB];
}
}
}

- (void)dropWarning:(NSString *)msg
{
NSAlert *alert = [[[NSAlert alloc] init] autorelease];
[alert addButtonWithTitle:@"OK"];
[alert addButtonWithTitle:@"Cancel"];
[alert setMessageText:[NSString stringWithFormat:@"Drop this %@?", msg]];
[alert setInformativeText:[NSString stringWithFormat:@"Dropped %@ cannot be restored.", msg]];
[alert setAlertStyle:NSWarningAlertStyle];
[alert beginSheetModalForWindow:[self window] modalDelegate:self
didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:)
contextInfo:nil];
}

@end @end
17 changes: 9 additions & 8 deletions MongoHub.xcodeproj/syd.mode1v3
Expand Up @@ -330,7 +330,7 @@
<key>_historyCapacity</key> <key>_historyCapacity</key>
<integer>0</integer> <integer>0</integer>
<key>bookmark</key> <key>bookmark</key>
<string>1DBFFB4512C207CC00B643CA</string> <string>1DBFFB9812C20F8200B643CA</string>
<key>history</key> <key>history</key>
<array> <array>
<string>1D93C27E11833DE7003216F7</string> <string>1D93C27E11833DE7003216F7</string>
Expand Down Expand Up @@ -417,7 +417,6 @@
<string>1DCC9C7212C0FFB3003B101E</string> <string>1DCC9C7212C0FFB3003B101E</string>
<string>1DBFF8F312C11A3A00B643CA</string> <string>1DBFF8F312C11A3A00B643CA</string>
<string>1DBFF8F412C11A3A00B643CA</string> <string>1DBFF8F412C11A3A00B643CA</string>
<string>1DBFFA5112C1F00E00B643CA</string>
<string>1DBFFA5212C1F00E00B643CA</string> <string>1DBFFA5212C1F00E00B643CA</string>
<string>1DBFFA5B12C1F0E800B643CA</string> <string>1DBFFA5B12C1F0E800B643CA</string>
<string>1DBFFAC012C1F51700B643CA</string> <string>1DBFFAC012C1F51700B643CA</string>
Expand All @@ -426,9 +425,10 @@
<string>1DBFFAF912C1FEE600B643CA</string> <string>1DBFFAF912C1FEE600B643CA</string>
<string>1DBFFAFA12C1FEE600B643CA</string> <string>1DBFFAFA12C1FEE600B643CA</string>
<string>1DBFFAFB12C1FEE600B643CA</string> <string>1DBFFAFB12C1FEE600B643CA</string>
<string>1DBFFB3212C2062100B643CA</string>
<string>1DBFFB4312C207CC00B643CA</string> <string>1DBFFB4312C207CC00B643CA</string>
<string>1DBFFB4412C207CC00B643CA</string> <string>1DBFFB4F12C20A9900B643CA</string>
<string>1DBFFB5012C20A9900B643CA</string>
<string>1DBFFB9312C20F3900B643CA</string>
</array> </array>
</dict> </dict>
<key>SplitCount</key> <key>SplitCount</key>
Expand Down Expand Up @@ -626,12 +626,13 @@
<integer>5</integer> <integer>5</integer>
<key>WindowOrderList</key> <key>WindowOrderList</key>
<array> <array>
<string>1DBFFB9912C20F8200B643CA</string>
<string>1DBFF8D512C118C200B643CA</string> <string>1DBFF8D512C118C200B643CA</string>
<string>1DBFF8D612C118C200B643CA</string> <string>1DBFF8D612C118C200B643CA</string>
<string>1C78EAAD065D492600B07095</string>
<string>1CD10A99069EF8BA00B06720</string> <string>1CD10A99069EF8BA00B06720</string>
<string>1D93C1AB118329FB003216F7</string> <string>1D93C1AB118329FB003216F7</string>
<string>/Users/syd/Documents/Works/codes/MongoHub/MongoHub.xcodeproj</string> <string>/Users/syd/Documents/Works/codes/MongoHub/MongoHub.xcodeproj</string>
<string>1C78EAAD065D492600B07095</string>
</array> </array>
<key>WindowString</key> <key>WindowString</key>
<string>0 73 1129 705 0 0 1280 778 </string> <string>0 73 1129 705 0 0 1280 778 </string>
Expand All @@ -650,12 +651,14 @@
<key>Dock</key> <key>Dock</key>
<array> <array>
<dict> <dict>
<key>BecomeActive</key>
<true/>
<key>ContentConfiguration</key> <key>ContentConfiguration</key>
<dict> <dict>
<key>PBXProjectModuleGUID</key> <key>PBXProjectModuleGUID</key>
<string>1CD0528F0623707200166675</string> <string>1CD0528F0623707200166675</string>
<key>PBXProjectModuleLabel</key> <key>PBXProjectModuleLabel</key>
<string>Tunnel.m</string> <string>ConnectionWindowController.mm</string>
<key>StatusBarVisibility</key> <key>StatusBarVisibility</key>
<true/> <true/>
</dict> </dict>
Expand All @@ -672,8 +675,6 @@
<string>365pt</string> <string>365pt</string>
</dict> </dict>
<dict> <dict>
<key>BecomeActive</key>
<true/>
<key>ContentConfiguration</key> <key>ContentConfiguration</key>
<dict> <dict>
<key>PBXProjectModuleGUID</key> <key>PBXProjectModuleGUID</key>
Expand Down

0 comments on commit 73cdd2c

Please sign in to comment.