├── AddCollectionController.h ├── AddCollectionController.m ├── AddConnectionController.h ├── AddConnectionController.m ├── AddDBController.h ├── AddDBController.m ├── Auth.xib ├── AuthWindowController.h ├── AuthWindowController.m ├── Configure.h ├── Connection.h ├── Connection.m ├── ConnectionWindow.xib ├── ConnectionWindowController.h ├── ConnectionWindowController.mm ├── ConnectionWindowTitleTransformer.h ├── ConnectionWindowTitleTransformer.m ├── ConnectionsArrayController.h ├── ConnectionsArrayController.m ├── ConnectionsCollectionView ├── ConnectionsCollectionView.h ├── ConnectionsCollectionView.m ├── IconCollectionItem.h ├── IconCollectionItem.m ├── IconViewBox.h └── IconViewBox.m ├── Database.h ├── Database.m ├── DatabasesArrayController.h ├── DatabasesArrayController.m ├── EditConnection.xib ├── EditConnectionController.h ├── EditConnectionController.m ├── English.lproj ├── InfoPlist.strings └── MainMenu.xib ├── Export.xib ├── ExportWindowController.h ├── ExportWindowController.mm ├── FieldMapDataObject.h ├── FieldMapDataObject.m ├── FieldMapTableController.h ├── FieldMapTableController.m ├── Import.xib ├── ImportWindowController.h ├── ImportWindowController.mm ├── Importer ├── GetMetadataForFile.c ├── Importer Read Me.txt ├── Importer-Info.plist ├── MySpotlightImporter.h ├── MySpotlightImporter.m └── main.c ├── JSON ├── JsonWindowController.h └── JsonWindowController.mm ├── JsonWindow.xib ├── MongoDB.h ├── MongoDB.mm ├── MongoHub-Info.plist ├── MongoHub.xcodeproj ├── project.pbxproj ├── syd.mode1v3 └── syd.pbxuser ├── MongoHub_AppDelegate.h ├── MongoHub_AppDelegate.m ├── MongoHub_DataModel.xcdatamodeld ├── .xccurrentversion ├── MongoHub_DataModel.xcdatamodel │ ├── elements │ └── layout ├── MongoHub_DataModel1.0.xcdatamodel │ ├── elements │ └── layout └── MongoHub_DataModel2.0.xcdatamodel │ ├── elements │ └── layout ├── MongoHub_Prefix.pch ├── NSArray+Color.h ├── NSArray+Color.m ├── NSProgressIndicator+Extras.h ├── NSProgressIndicator+Extras.m ├── NSScanner+SkipUpToCharset.h ├── NSScanner+SkipUpToCharset.m ├── NSString+Extras.h ├── NSString+Extras.m ├── NewCollection.xib ├── NewConnection.xib ├── NewDB.xib ├── QueryWindow.xib ├── QueryWindowController.h ├── QueryWindowController.mm ├── README.markdown ├── Resourses └── images │ ├── Icon.icns │ ├── collectionicon.png │ ├── collectionmenu.png │ ├── connecticon.png │ ├── database.png │ ├── dbicon.png │ ├── dbmenu.png │ ├── editicon.png │ ├── exportbox.png │ ├── exportmenu.png │ ├── findmenu.png │ ├── importbox.png │ ├── importmenu.png │ ├── indexmenu.png │ ├── insertmenu.png │ ├── key.png │ ├── mapreducemenu.png │ ├── mongohub.ai │ ├── querymenu.png │ ├── removemenu.png │ ├── runmenu.png │ ├── servermenu.png │ ├── supportmenu.png │ └── updatemenu.png ├── ResultsOutlineViewController.h ├── ResultsOutlineViewController.m ├── SSHCommand.sh ├── Sidebar ├── Sidebar.h ├── Sidebar.m ├── SidebarBadgeCell.h ├── SidebarBadgeCell.m ├── SidebarNode.h └── SidebarNode.m ├── StatMonitorTableController.h ├── StatMonitorTableController.m ├── Syntax Definitions ├── CSS 1.plist ├── HTML.plist ├── JSON.plist └── Objective C.plist ├── SyntaxColorDefaults.plist ├── SyntaxDefinition.plist ├── Tunnel.h ├── Tunnel.m ├── UKSyntaxColoredTextViewController.h ├── UKSyntaxColoredTextViewController.m ├── main.m └── screenshots ├── Edit Connection.png ├── Icon.png ├── Icon32.png ├── MongoHubWall.png ├── connections-window.png ├── databases-window.png ├── edit-connection2.png ├── jsoneditor-window.png ├── mongostats-monitor.png ├── query-window.png └── screenshot.pxm /AddCollectionController.h: -------------------------------------------------------------------------------- 1 | // 2 | // AddCollectionController.h 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-4-28. 6 | // Copyright 2010 ThePeppersStudio.COM. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface AddCollectionController : NSWindowController { 13 | IBOutlet NSTextField *collectionname; 14 | NSMutableString *dbname; 15 | NSMutableDictionary *dbInfo; 16 | } 17 | 18 | @property (nonatomic, retain) NSTextField *collectionname; 19 | @property (nonatomic, retain) NSString *dbname; 20 | @property (nonatomic, retain) NSMutableDictionary *dbInfo; 21 | 22 | - (IBAction)add:(id)sender; 23 | - (IBAction)cancel:(id)sender; 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /AddCollectionController.m: -------------------------------------------------------------------------------- 1 | // 2 | // AddCollectionController.m 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-4-28. 6 | // Copyright 2010 ThePeppersStudio.COM. All rights reserved. 7 | // 8 | 9 | #import "Configure.h" 10 | #import "AddCollectionController.h" 11 | 12 | 13 | @implementation AddCollectionController 14 | 15 | @synthesize dbname; 16 | @synthesize collectionname; 17 | @synthesize dbInfo; 18 | 19 | - (id)init { 20 | if (![super initWithWindowNibName:@"NewCollection"]) return nil; 21 | return self; 22 | } 23 | 24 | - (void)dealloc { 25 | [dbname release]; 26 | [collectionname release]; 27 | [dbInfo release]; 28 | [super dealloc]; 29 | } 30 | 31 | - (void)windowWillClose:(NSNotification *)notification { 32 | [[NSNotificationCenter defaultCenter] postNotificationName:kNewCollectionWindowWillClose object:dbInfo]; 33 | dbInfo = nil; 34 | } 35 | 36 | - (IBAction)cancel:(id)sender { 37 | dbInfo = nil; 38 | [self close]; 39 | } 40 | 41 | - (IBAction)add:(id)sender { 42 | if ([ [collectionname stringValue] length] == 0) { 43 | NSRunAlertPanel(@"Error", @"Collection name could not be empty", @"OK", nil, nil); 44 | return; 45 | } 46 | NSArray *keys = [[NSArray alloc] initWithObjects:@"dbname", @"collectionname", nil]; 47 | NSString *colname = [[NSString alloc] initWithString:[collectionname stringValue]]; 48 | NSArray *objs = [[NSArray alloc] initWithObjects:dbname, colname, nil]; 49 | [colname release]; 50 | if (!dbInfo) { 51 | dbInfo = [[NSMutableDictionary alloc] initWithCapacity:2]; 52 | } 53 | dbInfo = [NSMutableDictionary dictionaryWithObjects:objs forKeys:keys]; 54 | [objs release]; 55 | [keys release]; 56 | [self close]; 57 | } 58 | @end 59 | -------------------------------------------------------------------------------- /AddConnectionController.h: -------------------------------------------------------------------------------- 1 | // 2 | // AddConnectionController.h 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-4-24. 6 | // Copyright 2010 MusicPeace.ORG. All rights reserved. 7 | // 8 | 9 | #import 10 | @class ConnectionsArrayController; 11 | 12 | @interface AddConnectionController : NSWindowController { 13 | IBOutlet NSTextField *hostTextField; 14 | IBOutlet NSTextField *hostportTextField; 15 | IBOutlet NSButton *usereplCheckBox; 16 | IBOutlet NSTextField *serversTextField; 17 | IBOutlet NSTextField *replnameTextField; 18 | IBOutlet NSTextField *aliasTextField; 19 | IBOutlet NSTextField *adminuserTextField; 20 | IBOutlet NSSecureTextField *adminpassTextField; 21 | IBOutlet NSTextField *defaultdbTextField; 22 | IBOutlet NSButton *usesshCheckBox; 23 | IBOutlet NSTextField *bindaddressTextField; 24 | IBOutlet NSTextField *bindportTextField; 25 | IBOutlet NSTextField *sshhostTextField; 26 | IBOutlet NSTextField *sshportTextField; 27 | IBOutlet NSTextField *sshuserTextField; 28 | IBOutlet NSSecureTextField *sshpasswordTextField; 29 | IBOutlet NSTextField *sshkeyfileTextField; 30 | IBOutlet ConnectionsArrayController *connectionsArrayController; 31 | NSDictionary *connectionInfo; 32 | NSManagedObjectContext *managedObjectContext; 33 | } 34 | 35 | @property (nonatomic, retain) NSTextField *hostTextField; 36 | @property (nonatomic, retain) NSTextField *hostportTextField; 37 | @property (nonatomic, retain) NSButton *usereplCheckBox; 38 | @property (nonatomic, retain) NSTextField *serversTextField; 39 | @property (nonatomic, retain) NSTextField *replnameTextField; 40 | @property (nonatomic, retain) NSTextField *aliasTextField; 41 | @property (nonatomic, retain) NSTextField *adminuserTextField; 42 | @property (nonatomic, retain) NSSecureTextField *adminpassTextField; 43 | @property (nonatomic, retain) NSTextField *defaultdbTextField; 44 | @property (nonatomic, retain) NSButton *usesshCheckBox; 45 | @property (nonatomic, retain) NSTextField *bindaddressTextField; 46 | @property (nonatomic, retain) NSTextField *bindportTextField; 47 | @property (nonatomic, retain) NSTextField *sshhostTextField; 48 | @property (nonatomic, retain) NSTextField *sshportTextField; 49 | @property (nonatomic, retain) NSTextField *sshuserTextField; 50 | @property (nonatomic, retain) NSSecureTextField *sshpasswordTextField; 51 | @property (nonatomic, retain) NSTextField *sshkeyfileTextField; 52 | @property (nonatomic, retain) NSDictionary *connectionInfo; 53 | @property (nonatomic, retain) ConnectionsArrayController *connectionsArrayController; 54 | @property (nonatomic, retain) NSManagedObjectContext *managedObjectContext; 55 | 56 | - (IBAction)cancel:(id)sender; 57 | - (IBAction)add:(id)sender; 58 | - (IBAction)enableSSH:(id)sender; 59 | - (IBAction)enableRepl:(id)sender; 60 | - (BOOL)validateConnection; 61 | 62 | - (IBAction)chooseKeyPath:(id)sender; 63 | 64 | @end 65 | -------------------------------------------------------------------------------- /AddConnectionController.m: -------------------------------------------------------------------------------- 1 | // 2 | // AddConnectionController.m 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-4-24. 6 | // Copyright 2010 MusicPeace.ORG. All rights reserved. 7 | // 8 | 9 | #import "Configure.h" 10 | #import "AddConnectionController.h" 11 | #import "ConnectionsArrayController.h" 12 | 13 | @implementation AddConnectionController 14 | 15 | @synthesize hostTextField; 16 | @synthesize hostportTextField; 17 | @synthesize usereplCheckBox; 18 | @synthesize serversTextField; 19 | @synthesize replnameTextField; 20 | @synthesize aliasTextField; 21 | @synthesize adminuserTextField; 22 | @synthesize adminpassTextField; 23 | @synthesize defaultdbTextField; 24 | @synthesize usesshCheckBox; 25 | @synthesize bindaddressTextField; 26 | @synthesize bindportTextField; 27 | @synthesize sshhostTextField; 28 | @synthesize sshportTextField; 29 | @synthesize sshuserTextField; 30 | @synthesize sshpasswordTextField; 31 | @synthesize sshkeyfileTextField; 32 | @synthesize connectionInfo; 33 | @synthesize connectionsArrayController; 34 | @synthesize managedObjectContext; 35 | 36 | - (id)init { 37 | if (![super initWithWindowNibName:@"NewConnection"]) return nil; 38 | return self; 39 | } 40 | 41 | - (void)dealloc { 42 | [hostTextField release]; 43 | [hostportTextField release]; 44 | [usereplCheckBox release]; 45 | [serversTextField release]; 46 | [replnameTextField release]; 47 | [aliasTextField release]; 48 | [adminuserTextField release]; 49 | [adminpassTextField release]; 50 | [defaultdbTextField release]; 51 | [usesshCheckBox release]; 52 | [bindaddressTextField release]; 53 | [bindportTextField release]; 54 | [sshhostTextField release]; 55 | [sshportTextField release]; 56 | [sshuserTextField release]; 57 | [sshpasswordTextField release]; 58 | [sshkeyfileTextField release]; 59 | [connectionInfo release]; 60 | [connectionsArrayController release]; 61 | [managedObjectContext release]; 62 | [super dealloc]; 63 | } 64 | 65 | - (void)windowDidLoad { 66 | //NSLog(@"New Connection Window Loaded"); 67 | [super windowDidLoad]; 68 | } 69 | 70 | - (void)windowWillClose:(NSNotification *)notification { 71 | [[NSNotificationCenter defaultCenter] postNotificationName:kNewConnectionWindowWillClose object:connectionInfo]; 72 | } 73 | 74 | - (IBAction)cancel:(id)sender { 75 | connectionInfo = nil; 76 | [self close]; 77 | } 78 | 79 | - (IBAction)add:(id)sender { 80 | NSString *host; 81 | NSUInteger hostport; 82 | NSString *servers; 83 | NSString *repl_name; 84 | NSUInteger userepl = 0; 85 | NSString *alias; 86 | NSString *adminuser = [adminuserTextField stringValue]; 87 | NSString *adminpass = [adminpassTextField stringValue]; 88 | NSString *defaultdb = [defaultdbTextField stringValue]; 89 | NSUInteger usessh = 0; 90 | NSString *bindaddress; 91 | NSUInteger bindport; 92 | NSString *sshhost; 93 | NSUInteger sshport; 94 | NSString *sshuser; 95 | NSString *sshpassword; 96 | NSString *sshkeyfile; 97 | if ([ [hostTextField stringValue] length] == 0) { 98 | host = [[NSString alloc] initWithString:@"localhost"]; 99 | }else{ 100 | host = [[NSString alloc] initWithString:[hostTextField stringValue]]; 101 | } 102 | if ([hostportTextField intValue] == 0) { 103 | hostport = 27017; 104 | }else{ 105 | hostport = [hostportTextField intValue]; 106 | } 107 | 108 | servers = [[NSString alloc] initWithString:[serversTextField stringValue]]; 109 | repl_name = [[NSString alloc] initWithString:[replnameTextField stringValue]]; 110 | if ([usereplCheckBox state]) 111 | { 112 | userepl = 1; 113 | } 114 | 115 | if ([ [aliasTextField stringValue] length] == 0) { 116 | alias = [[NSString alloc] initWithString:@"localhost"]; 117 | }else{ 118 | alias = [[NSString alloc] initWithString:[aliasTextField stringValue]]; 119 | } 120 | if ([ [bindaddressTextField stringValue] length] == 0) { 121 | bindaddress = [[NSString alloc] initWithString:@"127.0.0.1"]; 122 | }else{ 123 | bindaddress = [[NSString alloc] initWithString:[bindaddressTextField stringValue]]; 124 | } 125 | if ([ [bindportTextField stringValue] length] == 0) { 126 | bindport = 8888; 127 | }else{ 128 | bindport = [bindportTextField intValue]; 129 | } 130 | sshhost = [[NSString alloc] initWithString:[sshhostTextField stringValue]]; 131 | if ([[sshportTextField stringValue] length] == 0) { 132 | sshport = 22; 133 | }else { 134 | sshport = [sshportTextField intValue]; 135 | } 136 | 137 | sshuser = [[NSString alloc] initWithString:[sshuserTextField stringValue]]; 138 | sshpassword = [[NSString alloc] initWithString:[sshpasswordTextField stringValue]]; 139 | sshkeyfile = [[NSString alloc] initWithString:[sshkeyfileTextField stringValue]]; 140 | if ([usesshCheckBox state]) 141 | { 142 | usessh = 1; 143 | 144 | } 145 | NSArray *keys = [[NSArray alloc] initWithObjects:@"host", @"hostport", @"userepl", @"servers", @"repl_name", @"alias", @"adminuser", @"adminpass", @"defaultdb", @"usessh", @"bindaddress", @"bindport", @"sshhost", @"sshport", @"sshuser", @"sshpassword", @"sshkeyfile", nil]; 146 | NSArray *objs = [[NSArray alloc] initWithObjects:host, [NSNumber numberWithInt:hostport], [NSNumber numberWithInt:userepl], servers, repl_name, alias, adminuser, adminpass, defaultdb, [NSNumber numberWithInt:usessh], bindaddress, [NSNumber numberWithInt:bindport], sshhost, [NSNumber numberWithInt:sshport], sshuser, sshpassword, sshkeyfile, nil]; 147 | if (!connectionInfo) { 148 | connectionInfo = [[NSMutableDictionary alloc] initWithCapacity:13]; 149 | } 150 | connectionInfo = [NSMutableDictionary dictionaryWithObjects:objs forKeys:keys]; 151 | [keys release]; 152 | [objs release]; 153 | [host release]; 154 | [alias release]; 155 | [servers release]; 156 | [repl_name release]; 157 | [sshhost release]; 158 | [sshuser release]; 159 | [sshpassword release]; 160 | [sshkeyfile release]; 161 | [bindaddress release]; 162 | if ([self validateConnection]) { 163 | [self close]; 164 | } 165 | } 166 | 167 | - (BOOL)validateConnection 168 | { 169 | if ([[connectionInfo objectForKey:@"host"] length] == 0) { 170 | NSRunAlertPanel(@"Error", @"Connection host should not be empty", @"OK", nil, nil); 171 | return NO; 172 | } 173 | if ([[connectionInfo objectForKey:@"host"] isEqualToString:@"flame.mongohq.com"] && [[connectionInfo objectForKey:@"defaultdb"] length] == 0) { 174 | NSRunAlertPanel(@"Error", @"DB should not be empty if you are using mongohq", @"OK", nil, nil); 175 | return NO; 176 | } 177 | if ([[connectionInfo objectForKey:@"alias"] length]<3) { 178 | NSRunAlertPanel(@"Error", @"Connection name should not be less than 3 charaters", @"OK", nil, nil); 179 | return NO; 180 | } 181 | if ([connectionsArrayController checkDuplicate:[connectionInfo objectForKey:@"alias"]]) { 182 | NSRunAlertPanel(@"Error", @"Connection alias name has been existed!", @"OK", nil, nil); 183 | return NO; 184 | } 185 | if ([usesshCheckBox state] == 1 && ([[connectionInfo objectForKey:@"bindaddress"] length] == 0 || [[connectionInfo objectForKey:@"sshhost"] length] == 0)) { 186 | NSRunAlertPanel(@"Error", @"Please full fill ssh information!", @"OK", nil, nil); 187 | return NO; 188 | } 189 | if ([usereplCheckBox state] == 1 && ([[connectionInfo objectForKey:@"servers"] length] == 0 || [[connectionInfo objectForKey:@"repl_name"] length] == 0)) { 190 | NSRunAlertPanel(@"Error", @"Please full fill replica-set information!", @"OK", nil, nil); 191 | return NO; 192 | } 193 | return YES; 194 | } 195 | 196 | - (IBAction)enableSSH:(id)sender 197 | { 198 | if ([usesshCheckBox state] == 1) 199 | { 200 | [bindaddressTextField setEnabled:YES]; 201 | [bindportTextField setEnabled:YES]; 202 | [sshhostTextField setEnabled:YES]; 203 | [sshuserTextField setEnabled:YES]; 204 | [sshpasswordTextField setEnabled:YES]; 205 | [sshportTextField setEnabled:YES]; 206 | [sshkeyfileTextField setEnabled:YES]; 207 | }else { 208 | [bindaddressTextField setEnabled:NO]; 209 | [bindportTextField setEnabled:NO]; 210 | [sshhostTextField setEnabled:NO]; 211 | [sshuserTextField setEnabled:NO]; 212 | [sshpasswordTextField setEnabled:NO]; 213 | [sshportTextField setEnabled:NO]; 214 | [sshkeyfileTextField setEnabled:NO]; 215 | } 216 | 217 | } 218 | 219 | - (IBAction)enableRepl:(id)sender 220 | { 221 | if ([usereplCheckBox state] == 1) 222 | { 223 | [serversTextField setEnabled:YES]; 224 | [replnameTextField setEnabled:YES]; 225 | }else { 226 | [serversTextField setEnabled:NO]; 227 | [replnameTextField setEnabled:NO]; 228 | } 229 | 230 | } 231 | 232 | - (IBAction)chooseKeyPath:(id)sender 233 | { 234 | NSOpenPanel *tvarNSOpenPanelObj = [NSOpenPanel openPanel]; 235 | NSInteger tvarNSInteger = [tvarNSOpenPanelObj runModalForTypes:nil]; 236 | if(tvarNSInteger == NSOKButton){ 237 | NSLog(@"doOpen we have an OK button"); 238 | //NSString * tvarDirectory = [tvarNSOpenPanelObj directory]; 239 | //NSLog(@"doOpen directory = %@",tvarDirectory); 240 | NSString * tvarFilename = [tvarNSOpenPanelObj filename]; 241 | NSLog(@"doOpen filename = %@",tvarFilename); 242 | [sshkeyfileTextField setStringValue:tvarFilename]; 243 | } else if(tvarNSInteger == NSCancelButton) { 244 | NSLog(@"doOpen we have a Cancel button"); 245 | return; 246 | } else { 247 | NSLog(@"doOpen tvarInt not equal 1 or zero = %3d",tvarNSInteger); 248 | return; 249 | } // end if 250 | } 251 | 252 | @end 253 | -------------------------------------------------------------------------------- /AddDBController.h: -------------------------------------------------------------------------------- 1 | // 2 | // AddDBController.h 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-4-28. 6 | // Copyright 2010 ThePeppersStudio.COM. All rights reserved. 7 | // 8 | 9 | #import 10 | @class DatabasesArrayController; 11 | @class Connection; 12 | 13 | @interface AddDBController : NSWindowController { 14 | IBOutlet NSTextField *dbname; 15 | IBOutlet NSTextField *user; 16 | IBOutlet NSSecureTextField *password; 17 | NSMutableDictionary *dbInfo; 18 | Connection *conn; 19 | NSManagedObjectContext *managedObjectContext; 20 | IBOutlet DatabasesArrayController *databasesArrayController; 21 | } 22 | 23 | @property (nonatomic, retain) NSTextField *dbname; 24 | @property (nonatomic, retain) NSTextField *user; 25 | @property (nonatomic, retain) NSSecureTextField *password; 26 | @property (nonatomic, retain) NSMutableDictionary *dbInfo; 27 | @property (nonatomic, retain) Connection *conn; 28 | @property (nonatomic, retain) NSManagedObjectContext *managedObjectContext; 29 | @property (nonatomic, retain) DatabasesArrayController *databasesArrayController; 30 | 31 | - (IBAction)add:(id)sender; 32 | - (IBAction)cancel:(id)sender; 33 | - (void)saveAction; 34 | @end 35 | -------------------------------------------------------------------------------- /AddDBController.m: -------------------------------------------------------------------------------- 1 | // 2 | // AddDBController.m 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-4-28. 6 | // Copyright 2010 ThePeppersStudio.COM. All rights reserved. 7 | // 8 | 9 | #import "Configure.h" 10 | #import "AddDBController.h" 11 | #import "DatabasesArrayController.h" 12 | #import "Database.h" 13 | #import "Connection.h" 14 | #import "NSString+Extras.h" 15 | 16 | @implementation AddDBController 17 | 18 | @synthesize dbname; 19 | @synthesize user; 20 | @synthesize password; 21 | @synthesize dbInfo; 22 | @synthesize conn; 23 | @synthesize managedObjectContext; 24 | @synthesize databasesArrayController; 25 | 26 | - (id)init { 27 | if (![super initWithWindowNibName:@"NewDB"]) return nil; 28 | return self; 29 | } 30 | 31 | - (void)dealloc { 32 | [dbname release]; 33 | [user release]; 34 | [password release]; 35 | [dbInfo release]; 36 | [managedObjectContext release]; 37 | [databasesArrayController release]; 38 | [conn release]; 39 | [super dealloc]; 40 | } 41 | 42 | - (void)windowWillClose:(NSNotification *)notification { 43 | [[NSNotificationCenter defaultCenter] postNotificationName:kNewDBWindowWillClose object:dbInfo]; 44 | dbInfo = nil; 45 | } 46 | 47 | - (IBAction)cancel:(id)sender { 48 | dbInfo = nil; 49 | [self close]; 50 | } 51 | 52 | - (IBAction)add:(id)sender { 53 | if ([ [dbname stringValue] length] == 0) { 54 | NSRunAlertPanel(@"Error", @"Database name could not be empty", @"OK", nil, nil); 55 | return; 56 | } 57 | NSArray *keys = [[NSArray alloc] initWithObjects:@"dbname", @"user", @"password", nil]; 58 | NSString *dbstr = [[NSString alloc] initWithString:[dbname stringValue]]; 59 | NSString *userStr = [[NSString alloc] initWithString:[user stringValue]]; 60 | NSString *passStr = [[NSString alloc] initWithString:[password stringValue]]; 61 | NSArray *objs = [[NSArray alloc] initWithObjects:dbstr, userStr, passStr, nil]; 62 | [dbstr release]; 63 | [userStr release]; 64 | [passStr release]; 65 | if (!dbInfo) { 66 | dbInfo = [[NSMutableDictionary alloc] initWithCapacity:3]; 67 | } 68 | dbInfo = [NSMutableDictionary dictionaryWithObjects:objs forKeys:keys]; 69 | [objs release]; 70 | [keys release]; 71 | if ([[dbInfo objectForKey:@"user"] isPresent] || [[dbInfo objectForKey:@"password"] isPresent]) { 72 | Database *dbobj = [databasesArrayController dbInfo:conn name:[dbname stringValue]]; 73 | if (dbobj==nil) { 74 | //[dbobj release]; 75 | dbobj = [databasesArrayController newObjectWithConn:conn name:[dbname stringValue] user:[dbInfo objectForKey:@"user"] password:[dbInfo objectForKey:@"password"]]; 76 | [databasesArrayController addObject:dbobj]; 77 | [dbobj release]; 78 | } 79 | [self saveAction]; 80 | } 81 | [self close]; 82 | } 83 | 84 | - (void) saveAction { 85 | 86 | NSError *error = nil; 87 | 88 | if (![[self managedObjectContext] commitEditing]) { 89 | NSLog(@"%@:%s unable to commit editing before saving", [self class], _cmd); 90 | } 91 | 92 | if (![[self managedObjectContext] save:&error]) { 93 | [[NSApplication sharedApplication] presentError:error]; 94 | } 95 | } 96 | 97 | @end 98 | -------------------------------------------------------------------------------- /AuthWindowController.h: -------------------------------------------------------------------------------- 1 | // 2 | // AuthWindowController.h 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-5-6. 6 | // Copyright 2010 ThePeppersStudio.COM. All rights reserved. 7 | // 8 | 9 | #import 10 | @class DatabasesArrayController; 11 | @class Connection; 12 | 13 | @interface AuthWindowController : NSWindowController { 14 | IBOutlet NSTextField *userTextField; 15 | IBOutlet NSTextField *passwordTextField; 16 | Connection *conn; 17 | NSManagedObjectContext *managedObjectContext; 18 | NSString *dbname; 19 | IBOutlet DatabasesArrayController *databasesArrayController; 20 | } 21 | 22 | @property (nonatomic, retain) NSTextField *userTextField; 23 | @property (nonatomic, retain) NSTextField *passwordTextField; 24 | @property (nonatomic, retain) Connection *conn; 25 | @property (nonatomic, retain) NSManagedObjectContext *managedObjectContext; 26 | @property (nonatomic, retain) NSString *dbname; 27 | @property (nonatomic, retain) DatabasesArrayController *databasesArrayController; 28 | 29 | - (IBAction)save:(id)sender; 30 | - (IBAction)cancel:(id)sender; 31 | - (void) saveAction; 32 | @end 33 | -------------------------------------------------------------------------------- /AuthWindowController.m: -------------------------------------------------------------------------------- 1 | // 2 | // AuthWindowController.m 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-5-6. 6 | // Copyright 2010 ThePeppersStudio.COM. All rights reserved. 7 | // 8 | 9 | #import "Configure.h" 10 | #import "AuthWindowController.h" 11 | #import "DatabasesArrayController.h" 12 | #import "Database.h" 13 | #import "Connection.h" 14 | 15 | @implementation AuthWindowController 16 | 17 | @synthesize userTextField; 18 | @synthesize passwordTextField; 19 | @synthesize dbname; 20 | @synthesize conn; 21 | @synthesize managedObjectContext; 22 | @synthesize databasesArrayController; 23 | 24 | - (id)init { 25 | if (![super initWithWindowNibName:@"Auth"]) return nil; 26 | return self; 27 | } 28 | 29 | - (void)dealloc { 30 | [userTextField release]; 31 | [passwordTextField release]; 32 | [dbname release]; 33 | [managedObjectContext release]; 34 | [databasesArrayController release]; 35 | [conn release]; 36 | [super dealloc]; 37 | } 38 | 39 | - (void)windowDidLoad { 40 | //NSLog(@"New Connection Window Loaded"); 41 | [super windowDidLoad]; 42 | } 43 | 44 | - (void)windowWillClose:(NSNotification *)notification { 45 | [[NSNotificationCenter defaultCenter] postNotificationName:kAuthWindowWillClose object:nil]; 46 | dbname = nil; 47 | } 48 | 49 | - (IBAction)cancel:(id)sender { 50 | dbname = nil; 51 | [self close]; 52 | } 53 | 54 | - (IBAction)save:(id)sender { 55 | Database *db = [databasesArrayController dbInfo:conn name:dbname]; 56 | if (db) { 57 | db.user = [userTextField stringValue]; 58 | db.password = [passwordTextField stringValue]; 59 | }else { 60 | db = [databasesArrayController newObjectWithConn:conn name:dbname user:[userTextField stringValue] password:[passwordTextField stringValue]]; 61 | [databasesArrayController addObject:db]; 62 | [db release]; 63 | } 64 | [self saveAction]; 65 | [self close]; 66 | } 67 | 68 | - (void) saveAction { 69 | 70 | NSError *error = nil; 71 | 72 | if (![[self managedObjectContext] commitEditing]) { 73 | NSLog(@"%@:%s unable to commit editing before saving", [self class], _cmd); 74 | } 75 | 76 | if (![[self managedObjectContext] save:&error]) { 77 | [[NSApplication sharedApplication] presentError:error]; 78 | } 79 | } 80 | 81 | @end 82 | -------------------------------------------------------------------------------- /Configure.h: -------------------------------------------------------------------------------- 1 | // 2 | // Configure.h 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-4-24. 6 | // Copyright 2010 MusicPeace.ORG. All rights reserved. 7 | // 8 | 9 | #define kNewConnectionWindowWillClose @"NewConnectionWindowWillClose" 10 | #define kEditConnectionWindowWillClose @"EditConnectionWindowWillClose" 11 | #define kNewDBWindowWillClose @"NewDBWindowWillClose" 12 | #define kNewCollectionWindowWillClose @"NewCollectionWindowWillClose" 13 | #define kAuthWindowWillClose @"AuthWindowWillClose" 14 | #define kImportWindowWillClose @"ImportWindowWillClose" 15 | #define kExportWindowWillClose @"ExportWindowWillClose" 16 | #define kJsonWindowWillClose @"kJsonWindowWillClose" 17 | #define kJsonWindowSaved @"kJsonWindowSaved" 18 | -------------------------------------------------------------------------------- /Connection.h: -------------------------------------------------------------------------------- 1 | // 2 | // Database.h 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-4-24. 6 | // Copyright 2010 MusicPeace.ORG. All rights reserved. 7 | // 8 | 9 | #import "Database.h" 10 | 11 | @interface Connection: NSManagedObject { 12 | NSString *host; 13 | NSNumber *hostport; 14 | NSString *servers; 15 | NSString *repl_name; 16 | NSString *alias; 17 | NSString *adminuser; 18 | NSString *adminpass; 19 | NSString *defaultdb; 20 | NSString *sshhost; 21 | NSNumber *sshport; 22 | NSString *sshuser; 23 | NSString *sshpassword; 24 | NSString *sshkeyfile; 25 | NSString *bindaddress; 26 | NSNumber *bindport; 27 | NSSet *databases; 28 | NSNumber *usessh; 29 | NSNumber *userepl; 30 | } 31 | 32 | @property (nonatomic, retain) NSString *host; 33 | @property (nonatomic, retain) NSNumber *hostport; 34 | @property (nonatomic, retain) NSString *servers; 35 | @property (nonatomic, retain) NSString *repl_name; 36 | @property (nonatomic, retain) NSString *alias; 37 | @property (nonatomic, retain) NSString *adminuser; 38 | @property (nonatomic, retain) NSString *adminpass; 39 | @property (nonatomic, retain) NSString *defaultdb; 40 | @property (nonatomic, retain) NSSet *databases; 41 | @property (nonatomic, retain) NSString *sshhost; 42 | @property (nonatomic, retain) NSNumber *sshport; 43 | @property (nonatomic, retain) NSString *sshuser; 44 | @property (nonatomic, retain) NSString *sshpassword; 45 | @property (nonatomic, retain) NSString *sshkeyfile; 46 | @property (nonatomic, retain) NSString *bindaddress; 47 | @property (nonatomic, retain) NSNumber *bindport; 48 | @property (nonatomic, retain) NSNumber *usessh; 49 | @property (nonatomic, retain) NSNumber *userepl; 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /Connection.m: -------------------------------------------------------------------------------- 1 | // 2 | // Database.m 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-4-24. 6 | // Copyright 2010 MusicPeace.ORG. All rights reserved. 7 | // 8 | 9 | #import "Connection.h" 10 | 11 | 12 | @implementation Connection 13 | 14 | @dynamic host; 15 | @dynamic hostport; 16 | @dynamic servers; 17 | @dynamic repl_name; 18 | @dynamic alias; 19 | @dynamic adminuser; 20 | @dynamic adminpass; 21 | @dynamic defaultdb; 22 | @dynamic databases; 23 | @dynamic userepl; 24 | 25 | @dynamic usessh; 26 | @dynamic sshhost; 27 | @dynamic sshport; 28 | @dynamic sshuser; 29 | @dynamic sshpassword; 30 | @dynamic sshkeyfile; 31 | @dynamic bindaddress; 32 | @dynamic bindport; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /ConnectionWindowController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ConnectionWindowController.h 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-4-25. 6 | // Copyright 2010 MusicPeace.ORG. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "Tunnel.h" 11 | @class BWSheetController; 12 | @class DatabasesArrayController; 13 | @class StatMonitorTableController; 14 | @class AddDBController; 15 | @class AddCollectionController; 16 | @class AuthWindowController; 17 | @class ImportWindowController; 18 | @class ExportWindowController; 19 | @class ResultsOutlineViewController; 20 | @class Connection; 21 | @class Sidebar; 22 | @class SidebarNode; 23 | @class MongoDB; 24 | 25 | @interface ConnectionWindowController : NSWindowController { 26 | NSManagedObjectContext *managedObjectContext; 27 | IBOutlet DatabasesArrayController *databaseArrayController; 28 | IBOutlet ResultsOutlineViewController *resultsOutlineViewController; 29 | Connection *conn; 30 | MongoDB *mongoDB; 31 | IBOutlet Sidebar *sidebar; 32 | IBOutlet NSTextField *resultsTitle; 33 | IBOutlet NSProgressIndicator *loaderIndicator; 34 | IBOutlet NSButton *reconnectButton; 35 | IBOutlet NSButton *monitorButton; 36 | IBOutlet BWSheetController *monitorSheetController; 37 | IBOutlet StatMonitorTableController *statMonitorTableController; 38 | NSMutableArray *databases; 39 | NSMutableArray *collections; 40 | SidebarNode *selectedDB; 41 | SidebarNode *selectedCollection; 42 | Tunnel *sshTunnel; 43 | AddDBController *addDBController; 44 | AddCollectionController *addCollectionController; 45 | AuthWindowController *authWindowController; 46 | ImportWindowController *importWindowController; 47 | ExportWindowController *exportWindowController; 48 | IBOutlet NSTextField *bundleVersion; 49 | BOOL exitThread; 50 | BOOL monitorStopped; 51 | } 52 | 53 | @property (nonatomic, retain) NSManagedObjectContext *managedObjectContext; 54 | @property (nonatomic, retain) DatabasesArrayController *databaseArrayController; 55 | @property (nonatomic, retain) ResultsOutlineViewController *resultsOutlineViewController; 56 | @property (nonatomic, retain) Connection *conn; 57 | @property (nonatomic, retain) MongoDB *mongoDB; 58 | @property (nonatomic, retain) Sidebar *sidebar; 59 | @property (nonatomic, retain) NSMutableArray *databases; 60 | @property (nonatomic, retain) NSMutableArray *collections; 61 | @property (nonatomic, retain) SidebarNode *selectedDB; 62 | @property (nonatomic, retain) SidebarNode *selectedCollection; 63 | @property (nonatomic, retain) Tunnel *sshTunnel; 64 | @property (nonatomic, retain) NSTextField *resultsTitle; 65 | @property (nonatomic, retain) NSProgressIndicator *loaderIndicator; 66 | @property (nonatomic, retain) NSButton *monitorButton; 67 | @property (nonatomic, retain) NSButton *reconnectButton; 68 | @property (nonatomic, retain) BWSheetController *monitorSheetController; 69 | @property (nonatomic, retain) StatMonitorTableController *statMonitorTableController; 70 | @property (nonatomic, retain) AddDBController *addDBController; 71 | @property (nonatomic, retain) AddCollectionController *addCollectionController; 72 | @property (nonatomic, retain) NSTextField *bundleVersion; 73 | @property (nonatomic, retain) AuthWindowController *authWindowController; 74 | @property (nonatomic, retain) ImportWindowController *importWindowController; 75 | @property (nonatomic, retain) ExportWindowController *exportWindowController; 76 | 77 | - (void)reloadSidebar; 78 | - (void)reloadDBList; 79 | - (void)useDB:(id)sender; 80 | - (void)useCollection:(id)sender; 81 | - (IBAction)reconnect:(id)sender; 82 | - (IBAction)showServerStatus:(id)sender; 83 | - (IBAction)showDBStats:(id)sender; 84 | - (IBAction)showCollStats:(id)sender; 85 | - (IBAction)createDBorCollection:(id)sender; 86 | - (IBAction)importFromMySQL:(id)sender; 87 | - (IBAction)exportToMySQL:(id)sender; 88 | - (void)dropCollection:(NSString *)collectionname 89 | ForDB:(NSString *)dbname; 90 | - (void)createDB; 91 | - (void)createCollectionForDB:(NSString *)dbname; 92 | - (IBAction)dropDBorCollection:(id)sender; 93 | - (void)dropDB; 94 | - (IBAction)query:(id)sender; 95 | - (IBAction)showAuth:(id)sender; 96 | -(void) checkTunnel; 97 | - (void) connect:(BOOL)haveHostAddress; 98 | - (void) tunnelStatusChanged: (Tunnel*) tunnel status: (NSString*) status; 99 | - (void)dropWarning:(NSString *)msg; 100 | 101 | - (IBAction)startMonitor:(id)sender; 102 | - (IBAction)stopMonitor:(id)sender; 103 | - (void)updateMonitor; 104 | @end 105 | -------------------------------------------------------------------------------- /ConnectionWindowTitleTransformer.h: -------------------------------------------------------------------------------- 1 | // 2 | // ConnectionWindowTitleTransformer.h 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-4-25. 6 | // Copyright 2010 MusicPeace.ORG. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface ConnectionWindowTitleTransformer : NSValueTransformer { 13 | 14 | } 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /ConnectionWindowTitleTransformer.m: -------------------------------------------------------------------------------- 1 | // 2 | // ConnectionWindowTitleTransformer.m 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-4-25. 6 | // Copyright 2010 MusicPeace.ORG. All rights reserved. 7 | // 8 | 9 | #import "ConnectionWindowTitleTransformer.h" 10 | #import "Connection.h" 11 | 12 | @implementation ConnectionWindowTitleTransformer 13 | 14 | + (Class)transformedValueClass { 15 | return [NSString class]; 16 | } 17 | + (BOOL)allowsReverseTransformation { 18 | return NO; 19 | } 20 | - (id)transformedValue:(id)value 21 | { 22 | if (value) 23 | { 24 | if ([[value userepl] intValue] == 1) { 25 | return [NSString stringWithFormat:@"%@ [%@]", [value alias], [value repl_name] ]; 26 | }else { 27 | return [NSString stringWithFormat:@"%@ [%@:%@]", [value alias], [value host], [value hostport] ]; 28 | } 29 | 30 | } 31 | return nil; 32 | } 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /ConnectionsArrayController.h: -------------------------------------------------------------------------------- 1 | // 2 | // DatabasesArrayController.h 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-4-24. 6 | // Copyright 2010 MusicPeace.ORG. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface ConnectionsArrayController : NSArrayController { 13 | 14 | } 15 | 16 | - (BOOL)checkDuplicate:(NSString *)alias; 17 | - (NSArray *)itemsUsingFetchPredicate:(NSPredicate *)fetchPredicate; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /ConnectionsArrayController.m: -------------------------------------------------------------------------------- 1 | // 2 | // DatabasesArrayController.m 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-4-24. 6 | // Copyright 2010 MusicPeace.ORG. All rights reserved. 7 | // 8 | 9 | #import "ConnectionsArrayController.h" 10 | 11 | 12 | @implementation ConnectionsArrayController 13 | 14 | - (void)awakeFromNib 15 | { 16 | if ([NSArrayController instancesRespondToSelector:@selector(awakeFromNib)]) 17 | { 18 | [super awakeFromNib]; 19 | } 20 | [self setClearsFilterPredicateOnInsertion:NO]; 21 | } 22 | 23 | - (id)newObject 24 | { 25 | id newObj = [super newObject]; 26 | //NSDate *now = [NSDate date]; 27 | //[newObj setValue:now forKey:@"createdDatetime"]; 28 | return newObj; 29 | } 30 | 31 | - (void)remove:(id)sender 32 | { 33 | if (![self selectedObjects]){ 34 | return; 35 | } 36 | [super remove:sender]; 37 | } 38 | 39 | - (BOOL)checkDuplicate:(NSString *)alias 40 | { 41 | NSPredicate *predicate = [NSPredicate predicateWithFormat:@"alias=%@", alias]; 42 | if ([[self itemsUsingFetchPredicate:predicate] count]>0) { 43 | return YES; 44 | }else { 45 | return NO; 46 | } 47 | } 48 | 49 | - (NSArray *)itemsUsingFetchPredicate:(NSPredicate *)fetchPredicate 50 | { 51 | NSError *error = nil; 52 | NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease]; 53 | [request setEntity:[NSEntityDescription entityForName:[self entityName] 54 | inManagedObjectContext:[self managedObjectContext]]]; 55 | NSArray *objects = [[self managedObjectContext] 56 | executeFetchRequest:request error:&error]; 57 | if (error) { 58 | NSLog(@"Fetch error! In AWViewPositionArrayController:itemsUseingFetchPredicate"); 59 | } 60 | return [objects filteredArrayUsingPredicate:fetchPredicate]; 61 | } 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /ConnectionsCollectionView/ConnectionsCollectionView.h: -------------------------------------------------------------------------------- 1 | // 2 | // ProjectsCollectionView.h 3 | // SEOBox 4 | // 5 | // Created by Syd on 10-2-28. 6 | // Copyright 2010 MusicPeace.ORG. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface ConnectionsCollectionView : NSCollectionView { 13 | 14 | } 15 | -(void)setSubviewSize:(CGFloat)theSubviewSize; 16 | @end 17 | -------------------------------------------------------------------------------- /ConnectionsCollectionView/ConnectionsCollectionView.m: -------------------------------------------------------------------------------- 1 | // 2 | // ProjectsCollectionView.m 3 | // SEOBox 4 | // 5 | // Created by Syd on 10-2-28. 6 | // Copyright 2010 MusicPeace.ORG. All rights reserved. 7 | // 8 | 9 | #import "ConnectionsCollectionView.h" 10 | 11 | 12 | @implementation ConnectionsCollectionView 13 | 14 | -(void)setSubviewSize:(CGFloat)theSubviewSize { 15 | [self setMaxItemSize:NSMakeSize(theSubviewSize,theSubviewSize)]; 16 | [self setMinItemSize:NSMakeSize(theSubviewSize,theSubviewSize)]; 17 | } 18 | 19 | -(void)drawRect:(NSRect)rect { 20 | [[NSColor colorWithCalibratedHue: 0 saturation: 0 brightness: 0.13 alpha: 1.0] set]; 21 | NSRectFill([self frame]); 22 | } 23 | @end 24 | -------------------------------------------------------------------------------- /ConnectionsCollectionView/IconCollectionItem.h: -------------------------------------------------------------------------------- 1 | // 2 | // IconCollectionItem.h 3 | // SEOBox 4 | // 5 | // Created by Syd on 10-2-28. 6 | // Copyright 2010 MusicPeace.ORG. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface IconCollectionItem : NSCollectionViewItem { 13 | 14 | } 15 | 16 | - (void)doubleClick:(id)sender; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /ConnectionsCollectionView/IconCollectionItem.m: -------------------------------------------------------------------------------- 1 | // 2 | // IconCollectionItem.m 3 | // SEOBox 4 | // 5 | // Created by Syd on 10-2-28. 6 | // Copyright 2010 MusicPeace.ORG. All rights reserved. 7 | // 8 | 9 | #import "IconCollectionItem.h" 10 | #import "IconViewBox.h" 11 | 12 | @implementation IconCollectionItem 13 | 14 | -(void)setSelected:(BOOL)flag { 15 | [super setSelected:flag]; 16 | 17 | // tell the view that it has been selected 18 | IconViewBox* theView = (IconViewBox* )[self view]; 19 | if([theView isKindOfClass:[IconViewBox class]]) { 20 | [theView setSelected:flag]; 21 | [theView setNeedsDisplay:YES]; 22 | } 23 | } 24 | 25 | - (void)doubleClick:(id)sender { 26 | if([self collectionView] && [[self collectionView] delegate] && [[[self collectionView] delegate] respondsToSelector:@selector(doubleClick:)]) { 27 | [[[self collectionView] delegate] performSelector:@selector(doubleClick:) withObject:self]; 28 | } 29 | } 30 | @end 31 | -------------------------------------------------------------------------------- /ConnectionsCollectionView/IconViewBox.h: -------------------------------------------------------------------------------- 1 | // 2 | // IconViewBox.h 3 | // SEOBox 4 | // 5 | // Created by Syd on 10-2-28. 6 | // Copyright 2010 MusicPeace.ORG. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface IconViewBox : NSBox 13 | { 14 | BOOL selectedFlag; 15 | IBOutlet id delegate; 16 | } 17 | 18 | @property (nonatomic, assign) id delegate; 19 | @property (nonatomic, assign) BOOL selectedFlag; 20 | 21 | -(void)setSelected:(BOOL)flag; 22 | -(BOOL)selected; 23 | @end 24 | -------------------------------------------------------------------------------- /ConnectionsCollectionView/IconViewBox.m: -------------------------------------------------------------------------------- 1 | // 2 | // IconViewBox.m 3 | // SEOBox 4 | // 5 | // Created by Syd on 10-2-28. 6 | // Copyright 2010 MusicPeace.ORG. All rights reserved. 7 | // 8 | 9 | #import "IconViewBox.h" 10 | 11 | 12 | @implementation IconViewBox 13 | @synthesize delegate; 14 | @synthesize selectedFlag; 15 | 16 | 17 | -(void)setSelected:(BOOL)flag { 18 | selectedFlag = flag; 19 | } 20 | 21 | -(BOOL)selected { 22 | return selectedFlag; 23 | } 24 | 25 | -(void)drawRect:(NSRect)rect { 26 | if([self selected]) { 27 | NSColor *bgColor = [NSColor colorWithCalibratedWhite:0.0 alpha:0.35]; 28 | NSRect bgRect = rect; 29 | int minX = NSMinX(bgRect); 30 | int midX = NSMidX(bgRect); 31 | int maxX = NSMaxX(bgRect); 32 | int minY = NSMinY(bgRect); 33 | int midY = NSMidY(bgRect); 34 | int maxY = NSMaxY(bgRect); 35 | float radius = 25.0; // correct value to duplicate Panther's App Switcher 36 | NSBezierPath *bgPath = [NSBezierPath bezierPath]; 37 | 38 | // Bottom edge and bottom-right curve 39 | [bgPath moveToPoint:NSMakePoint(midX, minY)]; 40 | [bgPath appendBezierPathWithArcFromPoint:NSMakePoint(maxX, minY) 41 | toPoint:NSMakePoint(maxX, midY) 42 | radius:radius]; 43 | 44 | // Right edge and top-right curve 45 | [bgPath appendBezierPathWithArcFromPoint:NSMakePoint(maxX, maxY) 46 | toPoint:NSMakePoint(midX, maxY) 47 | radius:radius]; 48 | 49 | // Top edge and top-left curve 50 | [bgPath appendBezierPathWithArcFromPoint:NSMakePoint(minX, maxY) 51 | toPoint:NSMakePoint(minX, midY) 52 | radius:radius]; 53 | 54 | // Left edge and bottom-left curve 55 | [bgPath appendBezierPathWithArcFromPoint:bgRect.origin 56 | toPoint:NSMakePoint(midX, minY) 57 | radius:radius]; 58 | [bgPath closePath]; 59 | 60 | [bgColor set]; 61 | [bgPath fill]; 62 | }else { 63 | [self setWantsLayer:NO]; 64 | } 65 | 66 | [super drawRect:rect]; 67 | } 68 | 69 | // ------------------------------------------------------------------------------- 70 | // hitTest:aPoint 71 | // ------------------------------------------------------------------------------- 72 | - (NSView *)hitTest:(NSPoint)aPoint 73 | { 74 | // don't allow any mouse clicks for subviews in this view 75 | if(NSPointInRect(aPoint,[self convertRect:[self bounds] toView:[self superview]])) { 76 | return self; 77 | } else { 78 | return nil; 79 | } 80 | } 81 | 82 | -(void)mouseDown:(NSEvent *)theEvent { 83 | [super mouseDown:theEvent]; 84 | // check for click count above one, which we assume means it's a double click 85 | if([theEvent clickCount] > 1) { 86 | if(delegate && [delegate respondsToSelector:@selector(doubleClick:)]) { 87 | [delegate performSelector:@selector(doubleClick:) withObject:self]; 88 | } 89 | } 90 | } 91 | 92 | @end 93 | -------------------------------------------------------------------------------- /Database.h: -------------------------------------------------------------------------------- 1 | // 2 | // Database.h 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-4-24. 6 | // Copyright 2010 MusicPeace.ORG. All rights reserved. 7 | // 8 | 9 | @class Connection; 10 | 11 | @interface Database : NSManagedObject { 12 | NSString *name; 13 | NSString *user; 14 | NSString *password; 15 | Connection *connection; 16 | } 17 | @property (nonatomic, retain) NSString *name; 18 | @property (nonatomic, retain) NSString *user; 19 | @property (nonatomic, retain) NSString *password; 20 | @property (nonatomic, retain) Connection *connection; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /Database.m: -------------------------------------------------------------------------------- 1 | // 2 | // Database.m 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-4-24. 6 | // Copyright 2010 MusicPeace.ORG. All rights reserved. 7 | // 8 | 9 | #import "Database.h" 10 | 11 | 12 | @implementation Database 13 | 14 | @dynamic name; 15 | @dynamic user; 16 | @dynamic password; 17 | @dynamic connection; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /DatabasesArrayController.h: -------------------------------------------------------------------------------- 1 | // 2 | // DatabasesArrayCollection.h 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-4-25. 6 | // Copyright 2010 MusicPeace.ORG. All rights reserved. 7 | // 8 | 9 | #import 10 | @class Connection; 11 | @class Database; 12 | 13 | @interface DatabasesArrayController : NSArrayController { 14 | 15 | } 16 | 17 | - (id)newObjectWithConn:(Connection *)conn name:(NSString *)name user:(NSString *)user password:(NSString *)password; 18 | - (void)clean:(Connection *)conn databases:(NSArray *)databases; 19 | - (BOOL)checkDuplicate:(Connection *) conn name:(NSString *)name; 20 | - (NSArray *)itemsUsingFetchPredicate:(NSPredicate *)fetchPredicate; 21 | - (Database *)dbInfo:(Connection *) conn name:(NSString *)name; 22 | @end 23 | -------------------------------------------------------------------------------- /DatabasesArrayController.m: -------------------------------------------------------------------------------- 1 | // 2 | // DatabasesArrayCollection.m 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-4-25. 6 | // Copyright 2010 MusicPeace.ORG. All rights reserved. 7 | // 8 | 9 | #import "DatabasesArrayController.h" 10 | #import "Connection.h" 11 | #import "Database.h" 12 | 13 | @implementation DatabasesArrayController 14 | 15 | - (void)awakeFromNib 16 | { 17 | if ([NSArrayController instancesRespondToSelector:@selector(awakeFromNib)]) 18 | { 19 | [super awakeFromNib]; 20 | } 21 | [self setClearsFilterPredicateOnInsertion:NO]; 22 | } 23 | 24 | - (id)newObjectWithConn:(Connection *) conn name:(NSString *)name user:(NSString *)user password:(NSString *)password 25 | { 26 | id newObj = [super newObject]; 27 | [newObj setValue:conn forKey:@"connection"]; 28 | [newObj setValue:name forKey:@"name"]; 29 | [newObj setValue:user forKey:@"user"]; 30 | [newObj setValue:password forKey:@"password"]; 31 | return newObj; 32 | } 33 | 34 | - (void)clean:(Connection *)conn databases:(NSArray *)databases 35 | { 36 | NSPredicate *predicate = [NSPredicate predicateWithFormat:@"connection=%@", conn]; 37 | NSArray *dblist = [self itemsUsingFetchPredicate:predicate]; 38 | for (Database *db in dblist) { 39 | bool exist = false; 40 | for (NSString *d in databases) { 41 | if (db.name == d) { 42 | exist = true; 43 | break; 44 | } 45 | } 46 | if (!exist) { 47 | [super remove:db]; 48 | } 49 | } 50 | } 51 | 52 | - (Database *)dbInfo:(Connection *) conn name:(NSString *)name 53 | { 54 | NSPredicate *predicate = [NSPredicate predicateWithFormat:@"connection=%@ AND name=%@", conn, name]; 55 | if ([[self itemsUsingFetchPredicate:predicate] count]>0) { 56 | return [[self itemsUsingFetchPredicate:predicate] objectAtIndex:0]; 57 | } 58 | return nil; 59 | } 60 | 61 | - (BOOL)checkDuplicate:(Connection *) conn name:(NSString *)name 62 | { 63 | NSPredicate *predicate = [NSPredicate predicateWithFormat:@"connection=%@ AND name=%@", conn, name]; 64 | if ([[self itemsUsingFetchPredicate:predicate] count]>0) { 65 | return YES; 66 | }else { 67 | return NO; 68 | } 69 | } 70 | 71 | - (NSArray *)itemsUsingFetchPredicate:(NSPredicate *)fetchPredicate 72 | { 73 | NSError *error = nil; 74 | NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease]; 75 | [request setEntity:[NSEntityDescription entityForName:[self entityName] 76 | inManagedObjectContext:[self managedObjectContext]]]; 77 | NSArray *objects = [[self managedObjectContext] 78 | executeFetchRequest:request error:&error]; 79 | if (error) { 80 | NSLog(@"Fetch error! In AWViewPositionArrayController:itemsUseingFetchPredicate"); 81 | } 82 | return [objects filteredArrayUsingPredicate:fetchPredicate]; 83 | } 84 | 85 | @end 86 | -------------------------------------------------------------------------------- /EditConnectionController.h: -------------------------------------------------------------------------------- 1 | // 2 | // EditConnectionController.h 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-4-25. 6 | // Copyright 2010 MusicPeace.ORG. All rights reserved. 7 | // 8 | 9 | #import 10 | @class ConnectionsArrayController; 11 | @class Connection; 12 | 13 | @interface EditConnectionController : NSWindowController { 14 | IBOutlet NSTextField *hostTextField; 15 | IBOutlet NSTextField *hostportTextField; 16 | IBOutlet NSButton *usereplCheckBox; 17 | IBOutlet NSTextField *serversTextField; 18 | IBOutlet NSTextField *replnameTextField; 19 | IBOutlet NSTextField *aliasTextField; 20 | IBOutlet NSTextField *adminuserTextField; 21 | IBOutlet NSSecureTextField *adminpassTextField; 22 | IBOutlet NSTextField *defaultdbTextField; 23 | IBOutlet NSButton *usesshCheckBox; 24 | IBOutlet NSTextField *bindaddressTextField; 25 | IBOutlet NSTextField *bindportTextField; 26 | IBOutlet NSTextField *sshhostTextField; 27 | IBOutlet NSTextField *sshportTextField; 28 | IBOutlet NSTextField *sshuserTextField; 29 | IBOutlet NSSecureTextField *sshpasswordTextField; 30 | IBOutlet NSTextField *sshkeyfileTextField; 31 | IBOutlet ConnectionsArrayController *connectionsArrayController; 32 | Connection *connection; 33 | NSManagedObjectContext *managedObjectContext; 34 | } 35 | 36 | @property (nonatomic, retain) NSTextField *hostTextField; 37 | @property (nonatomic, retain) NSTextField *hostportTextField; 38 | @property (nonatomic, retain) NSButton *usereplCheckBox; 39 | @property (nonatomic, retain) NSTextField *serversTextField; 40 | @property (nonatomic, retain) NSTextField *replnameTextField; 41 | @property (nonatomic, retain) NSTextField *aliasTextField; 42 | @property (nonatomic, retain) NSTextField *adminuserTextField; 43 | @property (nonatomic, retain) NSSecureTextField *adminpassTextField; 44 | @property (nonatomic, retain) NSTextField *defaultdbTextField; 45 | @property (nonatomic, retain) NSButton *usesshCheckBox; 46 | @property (nonatomic, retain) NSTextField *bindaddressTextField; 47 | @property (nonatomic, retain) NSTextField *bindportTextField; 48 | @property (nonatomic, retain) NSTextField *sshhostTextField; 49 | @property (nonatomic, retain) NSTextField *sshportTextField; 50 | @property (nonatomic, retain) NSTextField *sshuserTextField; 51 | @property (nonatomic, retain) NSSecureTextField *sshpasswordTextField; 52 | @property (nonatomic, retain) NSTextField *sshkeyfileTextField; 53 | @property (nonatomic, retain) Connection *connection; 54 | @property (nonatomic, retain) ConnectionsArrayController *connectionsArrayController; 55 | @property (nonatomic, retain) NSManagedObjectContext *managedObjectContext; 56 | 57 | - (IBAction)cancel:(id)sender; 58 | - (IBAction)save:(id)sender; 59 | - (IBAction)enableSSH:(id)sender; 60 | - (IBAction)enableRepl:(id)sender; 61 | - (BOOL)validateConnection:(NSDictionary *)connectionInfo; 62 | 63 | - (IBAction)chooseKeyPath:(id)sender; 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /English.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/English.lproj/InfoPlist.strings -------------------------------------------------------------------------------- /ExportWindowController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ExportWindowController.h 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-6-22. 6 | // Copyright 2010 ThePeppersStudio.COM. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | @class Connection; 12 | @class DatabasesArrayController; 13 | @class MCPConnection; 14 | @class MongoDB; 15 | @class FieldMapTableController; 16 | 17 | @interface ExportWindowController : NSWindowController { 18 | NSManagedObjectContext *managedObjectContext; 19 | DatabasesArrayController *databasesArrayController; 20 | NSString *dbname; 21 | Connection *conn; 22 | MongoDB *mongoDB; 23 | MCPConnection *db; 24 | IBOutlet NSArrayController *dbsArrayController; 25 | IBOutlet NSArrayController *tablesArrayController; 26 | IBOutlet NSTextField *hostTextField; 27 | IBOutlet NSTextField *portTextField; 28 | IBOutlet NSTextField *userTextField; 29 | IBOutlet NSSecureTextField *passwdTextField; 30 | IBOutlet NSTextField *collectionTextField; 31 | IBOutlet NSProgressIndicator *progressIndicator; 32 | IBOutlet NSPopUpButton *tablesPopUpButton; 33 | IBOutlet FieldMapTableController *fieldMapTableController; 34 | } 35 | 36 | @property (nonatomic, retain) Connection *conn; 37 | @property (nonatomic, retain) MCPConnection *db; 38 | @property (nonatomic, retain) MongoDB *mongoDB; 39 | @property (nonatomic, retain) DatabasesArrayController *databasesArrayController; 40 | @property (nonatomic, retain) NSManagedObjectContext *managedObjectContext; 41 | @property (nonatomic, retain) NSString *dbname; 42 | @property (nonatomic, retain) NSArrayController *dbsArrayController; 43 | @property (nonatomic, retain) NSArrayController *tablesArrayController; 44 | @property (nonatomic, retain) NSTextField *hostTextField; 45 | @property (nonatomic, retain) NSTextField *portTextField; 46 | @property (nonatomic, retain) NSTextField *userTextField; 47 | @property (nonatomic, retain) NSSecureTextField *passwdTextField; 48 | @property (nonatomic, retain) NSTextField *collectionTextField; 49 | @property (nonatomic, retain) NSProgressIndicator *progressIndicator; 50 | @property (nonatomic, retain) NSPopUpButton *tablesPopUpButton; 51 | @property (nonatomic, retain) FieldMapTableController *fieldMapTableController; 52 | 53 | - (void)initInterface; 54 | - (IBAction)connect:(id)sender; 55 | - (IBAction)export:(id)sender; 56 | - (IBAction)showTables:(id)sender; 57 | - (IBAction)showFields:(id)sender; 58 | - (long long int)exportCount:(NSString *)collection user:(NSString *)user password:(NSString *)password; 59 | - (void)doExportToTable:(NSString *)tableName data:(mongo::BSONObj) bsonObj fieldTypes:(NSDictionary *)fieldTypes; 60 | @end 61 | -------------------------------------------------------------------------------- /ExportWindowController.mm: -------------------------------------------------------------------------------- 1 | // 2 | // ExportWindowController.m 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-6-22. 6 | // Copyright 2010 ThePeppersStudio.COM. All rights reserved. 7 | // 8 | 9 | #import "ExportWindowController.h" 10 | #import "Configure.h" 11 | #import "DatabasesArrayController.h" 12 | #import "Database.h" 13 | #import "Connection.h" 14 | #import "NSString+Extras.h" 15 | #import "MongoDB.h" 16 | #import 17 | #import "FieldMapTableController.h" 18 | #import "FieldMapDataObject.h" 19 | 20 | @implementation ExportWindowController 21 | 22 | @synthesize dbname; 23 | @synthesize conn; 24 | @synthesize db; 25 | @synthesize mongoDB; 26 | @synthesize databasesArrayController; 27 | @synthesize managedObjectContext; 28 | @synthesize dbsArrayController; 29 | @synthesize tablesArrayController; 30 | @synthesize hostTextField; 31 | @synthesize portTextField; 32 | @synthesize userTextField; 33 | @synthesize passwdTextField; 34 | @synthesize collectionTextField; 35 | @synthesize progressIndicator; 36 | @synthesize tablesPopUpButton; 37 | @synthesize fieldMapTableController; 38 | 39 | - (id)init { 40 | if (![super initWithWindowNibName:@"Export"]) return nil; 41 | return self; 42 | } 43 | 44 | - (void)dealloc { 45 | [dbname release]; 46 | [managedObjectContext release]; 47 | [databasesArrayController release]; 48 | [conn release]; 49 | [db release]; 50 | [mongoDB release]; 51 | [dbsArrayController release]; 52 | [tablesArrayController release]; 53 | [hostTextField release]; 54 | [portTextField release]; 55 | [userTextField release]; 56 | [passwdTextField release]; 57 | [collectionTextField release]; 58 | [progressIndicator release]; 59 | [tablesPopUpButton release]; 60 | [fieldMapTableController release]; 61 | [super dealloc]; 62 | } 63 | 64 | - (void)windowDidLoad { 65 | //NSLog(@"New Connection Window Loaded"); 66 | [super windowDidLoad]; 67 | } 68 | 69 | - (void)windowWillClose:(NSNotification *)notification { 70 | [[NSNotificationCenter defaultCenter] postNotificationName:kExportWindowWillClose object:dbname]; 71 | dbname = nil; 72 | db = nil; 73 | [self initInterface]; 74 | } 75 | 76 | - (IBAction)export:(id)sender { 77 | [progressIndicator setUsesThreadedAnimation:YES]; 78 | [progressIndicator startAnimation: self]; 79 | [progressIndicator setDoubleValue:0]; 80 | NSString *collection = [[NSString alloc] initWithString:[collectionTextField stringValue]]; 81 | if (![collection isPresent]) { 82 | NSRunAlertPanel(@"Error", @"Collection name could not be empty!", @"OK", nil, nil); 83 | return; 84 | } 85 | NSString *tablename = [[NSString alloc] initWithString:[tablesPopUpButton titleOfSelectedItem]]; 86 | 87 | NSString *user=nil; 88 | NSString *password=nil; 89 | Database *mongodb = [databasesArrayController dbInfo:conn name:dbname]; 90 | if (mongodb) { 91 | user = mongodb.user; 92 | password = mongodb.password; 93 | } 94 | [mongodb release]; 95 | long long int total = [self exportCount:collection user:user password:password]; 96 | if (total == 0) { 97 | return; 98 | } 99 | NSString *query = [[NSString alloc] initWithFormat:@"select * from %@ limit 1", tablename]; 100 | MCPResult *theResult = [db queryString:query]; 101 | [query release]; 102 | NSDictionary *fieldTypes = [theResult fetchTypesAsDictionary]; 103 | 104 | mongo::BSONObjBuilder fieldsBSONBuilder; 105 | for(FieldMapDataObject *field in fieldMapTableController.nsMutaryDataObj) 106 | { 107 | fieldsBSONBuilder.append([field.mongoKey UTF8String], 1); 108 | } 109 | mongo::BSONObj fieldsBSONObj = fieldsBSONBuilder.obj(); 110 | std::auto_ptr cursor = [mongoDB findAllCursorInDB:dbname collection:collection user:user password:password fields:fieldsBSONObj]; 111 | int i = 1; 112 | while( cursor->more() ) 113 | { 114 | mongo::BSONObj b = cursor->next(); 115 | [self doExportToTable:tablename data:b fieldTypes:fieldTypes]; 116 | [progressIndicator setDoubleValue:(double)i/total]; 117 | i ++; 118 | } 119 | [progressIndicator stopAnimation: self]; 120 | [tablename release]; 121 | [collection release]; 122 | } 123 | 124 | - (long long int)exportCount:(NSString *)collection user:(NSString *)user password:(NSString *)password 125 | { 126 | long long int result = [mongoDB countInDB:dbname collection:collection user:user password:password critical:nil]; 127 | return result; 128 | } 129 | 130 | - (void)doExportToTable:(NSString *)tableName data:(mongo::BSONObj) bsonObj fieldTypes:(NSDictionary *)fieldTypes 131 | { 132 | int fieldsCount = [fieldMapTableController.nsMutaryDataObj count]; 133 | NSMutableArray *fields = [[NSMutableArray alloc] initWithCapacity:fieldsCount]; 134 | NSMutableArray *values = [[NSMutableArray alloc] initWithCapacity:fieldsCount]; 135 | for(FieldMapDataObject *field in fieldMapTableController.nsMutaryDataObj) 136 | { 137 | id value; 138 | mongo::BSONElement e = bsonObj.getFieldDotted([field.mongoKey UTF8String]); 139 | if (e.eoo() == true) { 140 | continue; 141 | } 142 | if (e.type() == mongo::jstNULL) { 143 | continue; 144 | }else if (e.type() == mongo::Array) { 145 | continue; 146 | }else if (e.type() == mongo::Object) { 147 | continue; 148 | }else if (e.type() == mongo::Bool) { 149 | if (e.boolean()) { 150 | value = [[NSString alloc] initWithString:@"1" ]; 151 | }else { 152 | value = [[NSString alloc] initWithString:@"0"]; 153 | } 154 | }else if (e.type() == mongo::NumberDouble) { 155 | value = [[NSNumber alloc] initWithDouble: e.numberDouble()]; 156 | }else if (e.type() == mongo::NumberInt) { 157 | NSString *ft = [fieldTypes objectForKey:field.sqlKey]; 158 | if ([ft isEqualToString:@"date"] || [ft isEqualToString:@"datetime"]) { 159 | value = [[NSDate alloc] initWithTimeIntervalSince1970:e.numberInt()]; 160 | }else { 161 | value = [[NSNumber alloc] initWithInt: e.numberInt()]; 162 | } 163 | }else if (e.type() == mongo::Date) { 164 | mongo::Date_t dt = (time_t)e.date(); 165 | time_t timestamp = dt / 1000; 166 | value = [[NSDate alloc] initWithTimeIntervalSince1970:timestamp]; 167 | }else if (e.type() == mongo::Timestamp) { 168 | time_t timestamp = (time_t)e.timestampTime(); 169 | value = [[NSDate alloc] initWithTimeIntervalSince1970:timestamp]; 170 | }else if (e.type() == mongo::BinData) { 171 | int binlen; 172 | const char* data = e.binData(binlen); 173 | value = [[NSData alloc] initWithBytes:data length:binlen]; 174 | }else if (e.type() == mongo::NumberLong) { 175 | NSString *ft = [fieldTypes objectForKey:field.sqlKey]; 176 | if ([ft isEqualToString:@"date"] || [ft isEqualToString:@"datetime"]) { 177 | value = [[NSDate alloc] initWithTimeIntervalSince1970:e.numberLong()]; 178 | }else { 179 | value = [[NSNumber alloc] initWithLong: e.numberLong()]; 180 | } 181 | }else if ([field.mongoKey isEqualToString:@"_id" ]) { 182 | if (e.type() == mongo::jstOID) 183 | { 184 | value = [[NSString alloc] initWithUTF8String: e.__oid().str().c_str()]; 185 | }else { 186 | value = [[NSString alloc] initWithUTF8String: e.str().c_str()]; 187 | } 188 | }else { 189 | value = [[NSString alloc] initWithUTF8String:e.str().c_str()]; 190 | } 191 | NSString *sqlKey = [[NSString alloc] initWithString:field.sqlKey]; 192 | NSString *quotedValue = [[NSString alloc] initWithString:[db quoteObject:value]]; 193 | [value release]; 194 | [fields addObject:sqlKey]; 195 | [values addObject:quotedValue]; 196 | [quotedValue release]; 197 | [sqlKey release]; 198 | } 199 | if ([fields count] > 0) { 200 | NSString *query = [[NSString alloc] initWithFormat:@"INSERT INTO %@ (%@) values (%@)", tableName, [fields componentsJoinedByString:@","], [values componentsJoinedByString:@","]]; 201 | //NSLog(@"query: %@", query); 202 | [db queryString:query]; 203 | [query release]; 204 | } 205 | [fields release]; 206 | [values release]; 207 | } 208 | 209 | - (IBAction)connect:(id)sender { 210 | if (db) { 211 | [self initInterface]; 212 | [db release]; 213 | } 214 | db = [[MCPConnection alloc] initToHost:[hostTextField stringValue] withLogin:[userTextField stringValue] password:[passwdTextField stringValue] usingPort:[portTextField intValue] ]; 215 | NSLog(@"Connect: %d", [db isConnected]); 216 | if (![db isConnected]) 217 | { 218 | NSRunAlertPanel(@"Error", @"Could not connect to the mysql server!", @"OK", nil, nil); 219 | } 220 | [db queryString:@"SET NAMES utf8"]; 221 | [db queryString:@"SET CHARACTER SET utf8"]; 222 | [db queryString:@"SET COLLATION_CONNECTION='utf8_general_ci'"]; 223 | [db setEncoding:NSUTF8StringEncoding]; 224 | MCPResult *dbs = [db listDBs]; 225 | NSArray *row; 226 | NSMutableArray *databases = [[NSMutableArray alloc] initWithCapacity:[dbs numOfRows]]; 227 | while (row = [dbs fetchRowAsArray]) { 228 | NSDictionary *database = [[NSDictionary alloc] initWithObjectsAndKeys:[row objectAtIndex:0], @"name", nil]; 229 | [databases addObject:database]; 230 | [database release]; 231 | } 232 | [dbsArrayController setContent:databases]; 233 | [databases release]; 234 | //[self showTables:nil]; 235 | } 236 | 237 | - (IBAction)showTables:(id)sender 238 | { 239 | NSString *dbn; 240 | if (sender == nil && [[dbsArrayController arrangedObjects] count] > 0) { 241 | dbn = [[[dbsArrayController arrangedObjects] objectAtIndex:0] objectForKey:@"name"]; 242 | }else { 243 | NSPopUpButton *pb = sender; 244 | dbn = [[NSString alloc] initWithString:[pb titleOfSelectedItem]]; 245 | } 246 | if (![dbn isPresent]) { 247 | [dbn release]; 248 | return; 249 | } 250 | [db selectDB:dbn]; 251 | [dbn release]; 252 | MCPResult *tbs = [db listTables]; 253 | NSArray *row; 254 | NSMutableArray *tables = [[NSMutableArray alloc] initWithCapacity:[tbs numOfRows]]; 255 | while (row = [tbs fetchRowAsArray]) { 256 | NSDictionary *table = [[NSDictionary alloc] initWithObjectsAndKeys:[row objectAtIndex:0], @"name", nil]; 257 | [tables addObject:table]; 258 | [table release]; 259 | } 260 | [tablesArrayController setContent:tables]; 261 | [tables release]; 262 | [self showFields:nil]; 263 | } 264 | 265 | - (IBAction)showFields:(id)sender 266 | { 267 | NSString *tablename = [[NSString alloc] initWithString:[tablesPopUpButton titleOfSelectedItem]]; 268 | MCPResult *theResult = [db queryString:[NSString stringWithFormat:@"select * from %@ limit 1", tablename]]; 269 | [tablename release]; 270 | NSArray *theFields = [theResult fetchFieldNames]; 271 | NSMutableArray *fields = [[NSMutableArray alloc] initWithCapacity:[theFields count] ]; 272 | for (int i=0; i<[theFields count]; i++) { 273 | NSString *fieldName = [theFields objectAtIndex:i]; 274 | FieldMapDataObject *fd = [[FieldMapDataObject alloc] initWithSqlKey:fieldName andMongoKey:fieldName]; 275 | [fields addObject:fd]; 276 | [fd release]; 277 | } 278 | [fieldMapTableController setNsMutaryDataObj:fields]; 279 | [fieldMapTableController.idTableView reloadData]; 280 | [fields release]; 281 | } 282 | 283 | - (void)initInterface 284 | { 285 | [dbsArrayController setContent:nil]; 286 | [tablesArrayController setContent:nil]; 287 | [progressIndicator setDoubleValue:0.0]; 288 | [fieldMapTableController.nsMutaryDataObj removeAllObjects]; 289 | [fieldMapTableController.idTableView reloadData]; 290 | } 291 | 292 | @end 293 | -------------------------------------------------------------------------------- /FieldMapDataObject.h: -------------------------------------------------------------------------------- 1 | // 2 | // fieldMapDataObject.h 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-6-22. 6 | // Copyright 2010 ThePeppersStudio.COM. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface FieldMapDataObject : NSObject { 13 | NSString *sqlKey; 14 | NSString *mongoKey; 15 | } 16 | 17 | @property (nonatomic, retain) NSString *sqlKey; 18 | @property (nonatomic, retain) NSString *mongoKey; 19 | 20 | - (id)initWithSqlKey:(NSString *)pStr1 andMongoKey:(NSString *)pStr2; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /FieldMapDataObject.m: -------------------------------------------------------------------------------- 1 | // 2 | // fieldMapDataObject.m 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-6-22. 6 | // Copyright 2010 ThePeppersStudio.COM. All rights reserved. 7 | // 8 | 9 | #import "FieldMapDataObject.h" 10 | 11 | 12 | @implementation FieldMapDataObject 13 | 14 | @synthesize sqlKey; 15 | @synthesize mongoKey; 16 | 17 | - (id)initWithSqlKey:(NSString *)pStr1 andMongoKey:(NSString *)pStr2 { 18 | if (! (self = [super init])) { 19 | NSLog(@"MyDataObject **** ERROR : [super init] failed ***"); 20 | return self; 21 | } // end if 22 | 23 | self.sqlKey = pStr1; 24 | self.mongoKey = pStr2; 25 | 26 | return self; 27 | 28 | } 29 | 30 | - (void) dealloc { 31 | [sqlKey release]; 32 | [mongoKey release]; 33 | [super dealloc]; 34 | } 35 | @end 36 | -------------------------------------------------------------------------------- /FieldMapTableController.h: -------------------------------------------------------------------------------- 1 | // 2 | // fieldMapTableController.h 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-6-22. 6 | // Copyright 2010 ThePeppersStudio.COM. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "FieldMapDataObject.h" 11 | 12 | @interface FieldMapTableController : NSControl { 13 | NSMutableArray * nsMutaryDataObj; 14 | IBOutlet NSTableView * idTableView; 15 | } 16 | 17 | @property (nonatomic, retain) NSMutableArray * nsMutaryDataObj; 18 | @property (nonatomic, retain) NSTableView * idTableView; 19 | 20 | - (IBAction)addAtSelectedRow:(id)pId; 21 | - (IBAction)deleteSelectedRow:(id)pId; 22 | 23 | - (void)addRow:(FieldMapDataObject *)pDataObj; 24 | 25 | - (int)numberOfRowsInTableView:(NSTableView *)pTableViewObj; 26 | 27 | - (id) tableView:(NSTableView *)pTableViewObj 28 | objectValueForTableColumn:(NSTableColumn *)pTableColumn 29 | row:(int)pRowIndex; 30 | 31 | - (void)tableView:(NSTableView *)pTableViewObj 32 | setObjectValue:(id)pObject 33 | forTableColumn:(NSTableColumn *)pTableColumn 34 | row:(int)pRowIndex; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /FieldMapTableController.m: -------------------------------------------------------------------------------- 1 | // 2 | // fieldMapTableController.m 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-6-22. 6 | // Copyright 2010 ThePeppersStudio.COM. All rights reserved. 7 | // 8 | 9 | #import "FieldMapTableController.h" 10 | 11 | 12 | @implementation FieldMapTableController 13 | @synthesize nsMutaryDataObj; 14 | @synthesize idTableView; 15 | 16 | - (void)dealloc { 17 | [nsMutaryDataObj release]; 18 | [idTableView release]; 19 | [super dealloc]; 20 | } 21 | 22 | - (IBAction)addAtSelectedRow:(id)pId { 23 | if ([idTableView selectedRow] > -1) { 24 | NSString * zStr1 = @"Text Cell 1"; 25 | NSString * zStr2 = @"Text Cell 2"; 26 | FieldMapDataObject * zDataObject = [[FieldMapDataObject alloc]initWithSqlKey:zStr1 27 | andMongoKey:zStr2 ]; 28 | [self.nsMutaryDataObj insertObject:zDataObject 29 | atIndex:[idTableView selectedRow]]; 30 | [zDataObject release]; 31 | [idTableView reloadData]; 32 | } // end if 33 | 34 | } // end deleteSelectedRow 35 | 36 | 37 | - (IBAction)deleteSelectedRow:(id)pId { 38 | if ([idTableView selectedRow] > -1) { 39 | [self.nsMutaryDataObj removeObjectAtIndex:[idTableView selectedRow]]; 40 | [idTableView reloadData]; 41 | } // end if 42 | } // end deleteSelectedRow 43 | 44 | 45 | - (void)addRow:(FieldMapDataObject *)pDataObj { 46 | [self.nsMutaryDataObj addObject:pDataObj]; 47 | [idTableView reloadData]; 48 | } // end addRow 49 | 50 | 51 | - (int)numberOfRowsInTableView:(NSTableView *)pTableViewObj { 52 | return [self.nsMutaryDataObj count]; 53 | } // end numberOfRowsInTableView 54 | 55 | 56 | - (id) tableView:(NSTableView *)pTableViewObj 57 | objectValueForTableColumn:(NSTableColumn *)pTableColumn 58 | row:(int)pRowIndex { 59 | FieldMapDataObject * zDataObject = (FieldMapDataObject *)[self.nsMutaryDataObj objectAtIndex:pRowIndex]; 60 | if (! zDataObject) { 61 | NSLog(@"tableView: objectAtIndex:%d = NULL",pRowIndex); 62 | return NULL; 63 | } // end if 64 | //NSLog(@"pTableColumn identifier = %@",[pTableColumn identifier]); 65 | 66 | if ([[pTableColumn identifier] isEqualToString:@"Col_ID1"]) { 67 | return [zDataObject sqlKey]; 68 | } 69 | 70 | if ([[pTableColumn identifier] isEqualToString:@"Col_ID2"]) { 71 | return [zDataObject mongoKey]; 72 | } 73 | 74 | NSLog(@"***ERROR** dropped through pTableColumn identifiers"); 75 | return NULL; 76 | 77 | } // end tableView:objectValueForTableColumn:row: 78 | 79 | 80 | - (void)tableView:(NSTableView *)pTableViewObj 81 | setObjectValue:(id)pObject 82 | forTableColumn:(NSTableColumn *)pTableColumn 83 | row:(int)pRowIndex { 84 | 85 | FieldMapDataObject * zDataObject = (FieldMapDataObject *)[self.nsMutaryDataObj objectAtIndex:pRowIndex]; 86 | 87 | if ([[pTableColumn identifier] isEqualToString:@"Col_ID1"]) { 88 | [zDataObject setSqlKey:(NSString *)pObject]; 89 | } 90 | 91 | if ([[pTableColumn identifier] isEqualToString:@"Col_ID2"]) { 92 | [zDataObject setMongoKey:(NSString *)pObject]; 93 | } 94 | } // end tableView:setObjectValue:forTableColumn:row: 95 | 96 | @end 97 | -------------------------------------------------------------------------------- /ImportWindowController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ImportWindowController.h 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-6-16. 6 | // Copyright 2010 ThePeppersStudio.COM. All rights reserved. 7 | // 8 | 9 | #import 10 | @class Connection; 11 | @class DatabasesArrayController; 12 | @class MCPConnection; 13 | @class MongoDB; 14 | 15 | @interface ImportWindowController : NSWindowController { 16 | NSManagedObjectContext *managedObjectContext; 17 | DatabasesArrayController *databasesArrayController; 18 | NSString *dbname; 19 | Connection *conn; 20 | MongoDB *mongoDB; 21 | MCPConnection *db; 22 | IBOutlet NSArrayController *dbsArrayController; 23 | IBOutlet NSArrayController *tablesArrayController; 24 | IBOutlet NSTextField *hostTextField; 25 | IBOutlet NSTextField *portTextField; 26 | IBOutlet NSTextField *userTextField; 27 | IBOutlet NSSecureTextField *passwdTextField; 28 | IBOutlet NSTextField *chunkSizeTextField; 29 | IBOutlet NSTextField *collectionTextField; 30 | IBOutlet NSProgressIndicator *progressIndicator; 31 | IBOutlet NSPopUpButton *tablesPopUpButton; 32 | } 33 | 34 | @property (nonatomic, retain) Connection *conn; 35 | @property (nonatomic, retain) MCPConnection *db; 36 | @property (nonatomic, retain) MongoDB *mongoDB; 37 | @property (nonatomic, retain) DatabasesArrayController *databasesArrayController; 38 | @property (nonatomic, retain) NSManagedObjectContext *managedObjectContext; 39 | @property (nonatomic, retain) NSString *dbname; 40 | @property (nonatomic, retain) NSArrayController *dbsArrayController; 41 | @property (nonatomic, retain) NSArrayController *tablesArrayController; 42 | @property (nonatomic, retain) NSTextField *hostTextField; 43 | @property (nonatomic, retain) NSTextField *portTextField; 44 | @property (nonatomic, retain) NSTextField *userTextField; 45 | @property (nonatomic, retain) NSSecureTextField *passwdTextField; 46 | @property (nonatomic, retain) NSTextField *chunkSizeTextField; 47 | @property (nonatomic, retain) NSTextField *collectionTextField; 48 | @property (nonatomic, retain) NSProgressIndicator *progressIndicator; 49 | @property (nonatomic, retain) NSPopUpButton *tablesPopUpButton; 50 | 51 | - (IBAction)connect:(id)sender; 52 | - (IBAction)import:(id)sender; 53 | - (IBAction)showTables:(id)sender; 54 | - (long long int)importCount:(NSString *)tableName; 55 | - (void)doImportFromTable:(NSString *)tableName toCollection:(NSString *)collection withChunkSize:(int)chunkSize fromId:(int)fromId totalResults:(int)total user:(NSString *)user password:(NSString *)password; 56 | 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /ImportWindowController.mm: -------------------------------------------------------------------------------- 1 | // 2 | // ImportWindowController.m 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-6-16. 6 | // Copyright 2010 ThePeppersStudio.COM. All rights reserved. 7 | // 8 | 9 | #import "ImportWindowController.h" 10 | #import "Configure.h" 11 | #import "DatabasesArrayController.h" 12 | #import "Database.h" 13 | #import "Connection.h" 14 | #import "NSString+Extras.h" 15 | #import "MongoDB.h" 16 | #import 17 | 18 | @implementation ImportWindowController 19 | @synthesize dbname; 20 | @synthesize conn; 21 | @synthesize db; 22 | @synthesize mongoDB; 23 | @synthesize databasesArrayController; 24 | @synthesize managedObjectContext; 25 | @synthesize dbsArrayController; 26 | @synthesize tablesArrayController; 27 | @synthesize hostTextField; 28 | @synthesize portTextField; 29 | @synthesize userTextField; 30 | @synthesize passwdTextField; 31 | @synthesize chunkSizeTextField; 32 | @synthesize collectionTextField; 33 | @synthesize progressIndicator; 34 | @synthesize tablesPopUpButton; 35 | 36 | - (id)init { 37 | if (![super initWithWindowNibName:@"Import"]) return nil; 38 | return self; 39 | } 40 | 41 | - (void)dealloc { 42 | [dbname release]; 43 | [managedObjectContext release]; 44 | [databasesArrayController release]; 45 | [conn release]; 46 | [db release]; 47 | [mongoDB release]; 48 | [dbsArrayController release]; 49 | [tablesArrayController release]; 50 | [hostTextField release]; 51 | [portTextField release]; 52 | [userTextField release]; 53 | [passwdTextField release]; 54 | [chunkSizeTextField release]; 55 | [collectionTextField release]; 56 | [progressIndicator release]; 57 | [tablesPopUpButton release]; 58 | [super dealloc]; 59 | } 60 | 61 | - (void)windowDidLoad { 62 | //NSLog(@"New Connection Window Loaded"); 63 | [super windowDidLoad]; 64 | } 65 | 66 | - (void)windowWillClose:(NSNotification *)notification { 67 | [[NSNotificationCenter defaultCenter] postNotificationName:kImportWindowWillClose object:dbname]; 68 | dbname = nil; 69 | db = nil; 70 | [dbsArrayController setContent:nil]; 71 | [tablesArrayController setContent:nil]; 72 | [progressIndicator setDoubleValue:0.0]; 73 | } 74 | 75 | - (IBAction)import:(id)sender { 76 | [progressIndicator setUsesThreadedAnimation:YES]; 77 | [progressIndicator startAnimation: self]; 78 | [progressIndicator setDoubleValue:0]; 79 | NSString *collection = [[NSString alloc] initWithString:[collectionTextField stringValue]]; 80 | int chunkSize = [chunkSizeTextField intValue]; 81 | if (![collection isPresent]) { 82 | NSRunAlertPanel(@"Error", @"Collection name could not be empty!", @"OK", nil, nil); 83 | return; 84 | } 85 | if (chunkSize == 0) { 86 | NSRunAlertPanel(@"Error", @"Chunk Size could not be 0!", @"OK", nil, nil); 87 | return; 88 | } 89 | NSString *tablename = [[NSString alloc] initWithString:[tablesPopUpButton titleOfSelectedItem]]; 90 | int total = [self importCount:tablename]; 91 | NSString *user=nil; 92 | NSString *password=nil; 93 | Database *mongodb = [databasesArrayController dbInfo:conn name:dbname]; 94 | if (mongodb) { 95 | user = mongodb.user; 96 | password = mongodb.password; 97 | } 98 | [mongodb release]; 99 | [self doImportFromTable:tablename toCollection:collection withChunkSize:chunkSize fromId:0 totalResults:total user:user password:password]; 100 | [progressIndicator stopAnimation: self]; 101 | [tablename release]; 102 | [collection release]; 103 | } 104 | 105 | - (long long int)importCount:(NSString *)tableName 106 | { 107 | NSString *query = [[NSString alloc] initWithFormat:@"select count(*) counter from %@", tableName]; 108 | MCPResult *theResult = [db queryString:query]; 109 | [query release]; 110 | NSArray *row = [theResult fetchRowAsArray]; 111 | NSLog(@"count: %@", [row objectAtIndex:0]); 112 | return [[row objectAtIndex:0] intValue]; 113 | } 114 | 115 | - (void)doImportFromTable:(NSString *)tableName toCollection:(NSString *)collection withChunkSize:(int)chunkSize fromId:(int)fromId totalResults:(int)total user:(NSString *)user password:(NSString *)password 116 | { 117 | if (total == 0) return; 118 | NSString *query = [[NSString alloc] initWithFormat:@"select * from %@ limit %d, %d", tableName, fromId, chunkSize]; 119 | NSLog(@"query: %@", query); 120 | MCPResult *theResult = [db queryString:query]; 121 | [query release]; 122 | if ([theResult numOfRows] == 0) { 123 | return; 124 | } 125 | NSArray *theFields = [theResult fetchFieldNames]; 126 | NSDictionary *fieldTypes = [theResult fetchTypesAsDictionary]; 127 | int i = 1; 128 | while (NSDictionary *row = [theResult fetchRowAsDictionary]) { 129 | [progressIndicator setDoubleValue:(double)(fromId+i)/total]; 130 | [mongoDB insertInDB:dbname 131 | collection:collection 132 | user:user 133 | password:password 134 | data:row 135 | fields:theFields 136 | fieldTypes:(NSDictionary *)fieldTypes]; 137 | i++; 138 | } 139 | if ([theResult numOfRows] < chunkSize) { 140 | return; 141 | } 142 | [self doImportFromTable:tableName toCollection:collection withChunkSize:chunkSize fromId:(fromId + chunkSize) totalResults:total user:user password:password]; 143 | } 144 | 145 | - (IBAction)connect:(id)sender { 146 | if (db) { 147 | [dbsArrayController setContent:nil]; 148 | [tablesArrayController setContent:nil]; 149 | [progressIndicator setDoubleValue:0.0]; 150 | [db release]; 151 | } 152 | db = [[MCPConnection alloc] initToHost:[hostTextField stringValue] withLogin:[userTextField stringValue] password:[passwdTextField stringValue] usingPort:[portTextField intValue] ]; 153 | NSLog(@"Connect: %d", [db isConnected]); 154 | if (![db isConnected]) 155 | { 156 | NSRunAlertPanel(@"Error", @"Could not connect to the mysql server!", @"OK", nil, nil); 157 | } 158 | [db queryString:@"SET NAMES utf8"]; 159 | [db queryString:@"SET CHARACTER SET utf8"]; 160 | [db queryString:@"SET COLLATION_CONNECTION='utf8_general_ci'"]; 161 | [db setEncoding:NSUTF8StringEncoding]; 162 | MCPResult *dbs = [db listDBs]; 163 | NSArray *row; 164 | NSMutableArray *databases = [[NSMutableArray alloc] initWithCapacity:[dbs numOfRows]]; 165 | while (row = [dbs fetchRowAsArray]) { 166 | NSDictionary *database = [[NSDictionary alloc] initWithObjectsAndKeys:[row objectAtIndex:0], @"name", nil]; 167 | [databases addObject:database]; 168 | [database release]; 169 | } 170 | [dbsArrayController setContent:databases]; 171 | [databases release]; 172 | } 173 | 174 | - (IBAction)showTables:(id)sender 175 | { 176 | NSString *dbn; 177 | if (sender == nil && [[dbsArrayController arrangedObjects] count] > 0) { 178 | dbn = [[[dbsArrayController arrangedObjects] objectAtIndex:0] objectForKey:@"name"]; 179 | }else { 180 | NSPopUpButton *pb = sender; 181 | dbn = [[NSString alloc] initWithString:[pb titleOfSelectedItem]]; 182 | } 183 | if (![dbn isPresent]) { 184 | [dbn release]; 185 | return; 186 | } 187 | [db selectDB:dbn]; 188 | [dbn release]; 189 | MCPResult *tbs = [db listTables]; 190 | NSArray *row; 191 | NSMutableArray *tables = [[NSMutableArray alloc] initWithCapacity:[tbs numOfRows]]; 192 | while (row = [tbs fetchRowAsArray]) { 193 | NSDictionary *table = [[NSDictionary alloc] initWithObjectsAndKeys:[row objectAtIndex:0], @"name", nil]; 194 | [tables addObject:table]; 195 | [table release]; 196 | } 197 | [tablesArrayController setContent:tables]; 198 | [tables release]; 199 | } 200 | 201 | @end 202 | -------------------------------------------------------------------------------- /Importer/GetMetadataForFile.c: -------------------------------------------------------------------------------- 1 | // 2 | // GetMetadataForFile.c 3 | // MongoHub Spotlight Importer 4 | // 5 | // Created by Syd on 10-4-24. 6 | // Copyright (c) 2010 MusicPeace.ORG. All rights reserved. 7 | // 8 | 9 | #include 10 | #import 11 | 12 | #import "MySpotlightImporter.h" 13 | 14 | 15 | //============================================================================== 16 | // 17 | // Get metadata attributes from document files 18 | // 19 | // The purpose of this function is to extract useful information from the 20 | // file formats for your document, and set the values into the attribute 21 | // dictionary for Spotlight to include. 22 | // 23 | //============================================================================== 24 | 25 | 26 | Boolean GetMetadataForFile(void* thisInterface, 27 | CFMutableDictionaryRef attributes, 28 | CFStringRef contentTypeUTI, 29 | CFStringRef pathToFile) 30 | { 31 | /* Pull any available metadata from the file at the specified path */ 32 | /* Return the attribute keys and attribute values in the dict */ 33 | /* Return TRUE if successful, FALSE if there was no data provided */ 34 | /* The path could point to either a Core Data store file in which */ 35 | /* case we import the store's metadata, or it could point to a Core */ 36 | /* Data external record file for a specific record instances */ 37 | 38 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 39 | NSError *error = nil; 40 | Boolean ok = FALSE; 41 | 42 | if ([(NSString *)contentTypeUTI isEqualToString:@"YOUR_STORE_FILE_UTI"]) { 43 | 44 | // import from store file metadata 45 | 46 | // Create the URL, then attempt to get the meta-data from the store 47 | NSURL *url = [NSURL fileURLWithPath: (NSString *)pathToFile]; 48 | NSDictionary *metadata = [NSPersistentStoreCoordinator 49 | metadataForPersistentStoreOfType:nil URL:url error:&error]; 50 | 51 | // If there is no error, add the info 52 | if ( error == NULL ) { 53 | 54 | // Get the information you are interested in from the dictionary 55 | // "YOUR_INFO" should be replaced by key(s) you are interested in 56 | 57 | NSObject *contentToIndex = [metadata objectForKey: @"YOUR_INFO"]; 58 | if ( contentToIndex != nil ) { 59 | 60 | // Add the metadata to the text content for indexing 61 | [(NSMutableDictionary *)attributes setObject:contentToIndex 62 | forKey:(NSString *)kMDItemTextContent]; 63 | ok = TRUE; 64 | } 65 | } 66 | 67 | } else if ([(NSString *)contentTypeUTI isEqualToString:@"YOUR_EXTERNAL_RECORD_UTI"]) { 68 | 69 | // import from an external record file 70 | 71 | MySpotlightImporter *importer = [[MySpotlightImporter alloc] init]; 72 | 73 | ok = [importer importFileAtPath:(NSString *)pathToFile attributes:(NSMutableDictionary *)attributes error:&error]; 74 | [importer release]; 75 | 76 | } 77 | 78 | 79 | // Return the status 80 | [pool drain]; 81 | 82 | return ok; 83 | } 84 | -------------------------------------------------------------------------------- /Importer/Importer Read Me.txt: -------------------------------------------------------------------------------- 1 | 2 | //============================================================================== 3 | // Core Data Application Spotlight Importer 4 | //============================================================================== 5 | 6 | Spotlight importers should be provided by all applications that support custom 7 | document formats. A Spotlight importer parses your document format for relevant 8 | information and assigning that information to the appropriate metadata keys. 9 | 10 | The bundle target in this project creates a Spotlight importer bundle installed 11 | inside of the wrapper of the application target. This bundle includes all of 12 | the code necessary to import two types of information into Spotlight: 13 | 14 | 1) The metadata information from Core Data stores. 15 | 16 | The only default metadata for a Core Data store is the store ID and store type, 17 | neither of which is imported. To have metadata from your stores imported, you 18 | must first add the information you are interested to the metadata for your 19 | store (see the NSPersistentStoreCoordinator setMetadataForPersistentStore: API) 20 | and then pull the information for import in the GetMetadataForFile function in 21 | the 'GetMetadataForFile.c' file. 22 | 23 | 2) Instance Level indexing information 24 | 25 | For each instance of an entity that contains properties indexed by Spotlight 26 | (defined in your Core Data Model), the importer will extract the values. This 27 | extraction is done in MySpotlightImporter.m 28 | 29 | Additionally, the importer must contain a list of the Uniform Type Identifiers 30 | (UTI) for your application in order to import the data. (The UTI information is 31 | used by Spotlight to know which importer to invoke for a given file.) If the 32 | UTI is not already registered by your application, you will need to register it 33 | in the importer bundle. (For more information on registering UTIs for 34 | applications, consult the documentation at http://developer.apple.com) 35 | 36 | ----------------------------------------------------------------------------- 37 | 38 | To configure this project 39 | 40 | Search for all occurrences of the string YOUR_ and replace with the appropriate 41 | values 42 | 43 | When importing store file metadata 44 | 45 | YOUR_STORE_FILE_UTI - UTI of your store file 46 | YOUR_INFO - metadata information you want Spotlight to have for 47 | your store file 48 | 49 | when importing record level information 50 | 51 | YOUR_EXTERNAL_RECORD_UTI - UTI of the Core Data Spotlight external record file 52 | YOUR_EXTERNAL_RECORD_EXTENSION - extension of the Core Data external record file 53 | YOUR_STORE_TYPE - type of your persistent store 54 | 55 | Replace occurences of the above strings in the following files 56 | 57 | 58 | GetMetadataForFile.c 59 | MySpotlightImporter.m 60 | Importer-Info.plist 61 | Info.plist 62 | 63 | 64 | ----------------------------------------------------------------------------- 65 | -------------------------------------------------------------------------------- /Importer/Importer-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 14 | 15 | UTExportedTypeDeclarations 16 | 17 | 18 | UTTypeIdentifier 19 | YOUR_EXTERNAL_RECORD_UTI 20 | UTTypeReferenceURL 21 | http://www.company.com/yourproduct 22 | UTTypeDescription 23 | Your Document Kind String 24 | UTTypeConformsTo 25 | 26 | public.data 27 | public.content 28 | 29 | UTTypeTagSpecification 30 | 31 | com.apple.ostype 32 | XXXX 33 | public.filename-extension 34 | 35 | YOUR_EXTERNAL_RECORD_EXTENSION 36 | 37 | 38 | 39 | 40 | 64 | 65 | 66 | CFBundleDevelopmentRegion 67 | English 68 | CFBundleDocumentTypes 69 | 70 | 71 | CFBundleTypeRole 72 | MDImporter 73 | LSItemContentTypes 74 | 75 | YOUR_EXTERNAL_RECORD_UTI 76 | 77 | 78 | 79 | CFBundleExecutable 80 | ${EXECUTABLE_NAME} 81 | CFBundleName 82 | ${PRODUCT_NAME} 83 | CFBundleIconFile 84 | 85 | CFBundleIdentifier 86 | com.yourcompany.${PRODUCT_NAME:rfc1034identifier}.spotlightimporter 87 | CFBundleInfoDictionaryVersion 88 | 6.0 89 | CFBundleVersion 90 | 1.0 91 | CFPlugInDynamicRegisterFunction 92 | 93 | CFPlugInDynamicRegistration 94 | NO 95 | CFPlugInFactories 96 | 97 | E0C38F20-64C0-4B5E-98E5-834069A86AD4 98 | MetadataImporterPluginFactory 99 | 100 | CFPlugInTypes 101 | 102 | 8B08C4BF-415B-11D8-B3F9-0003936726FC 103 | 104 | E0C38F20-64C0-4B5E-98E5-834069A86AD4 105 | 106 | 107 | CFPlugInUnloadFunction 108 | 109 | LSMinimumSystemVersion 110 | ${MACOSX_DEPLOYMENT_TARGET} 111 | 112 | 113 | -------------------------------------------------------------------------------- /Importer/MySpotlightImporter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MySpotlightImporter.h 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-4-24. 6 | // Copyright MusicPeace.ORG 2010 . All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface MySpotlightImporter : NSObject { 13 | 14 | NSPersistentStoreCoordinator *persistentStoreCoordinator; 15 | NSManagedObjectModel *managedObjectModel; 16 | NSManagedObjectContext *managedObjectContext; 17 | 18 | NSURL *modelURL; 19 | NSURL *storeURL; 20 | } 21 | 22 | @property (nonatomic, readonly) NSPersistentStoreCoordinator *persistentStoreCoordinator; 23 | @property (nonatomic, readonly) NSManagedObjectModel *managedObjectModel; 24 | @property (nonatomic, readonly) NSManagedObjectContext *managedObjectContext; 25 | 26 | - (BOOL)importFileAtPath:(NSString *)filePath attributes:(NSMutableDictionary *)attributes error:(NSError **)error; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /Importer/MySpotlightImporter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MySpotlightImporter.m 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-4-24. 6 | // Copyright MusicPeace.ORG 2010 . All rights reserved. 7 | // 8 | 9 | #import "MySpotlightImporter.h" 10 | 11 | #define YOUR_STORE_TYPE NSXMLStoreType 12 | 13 | @interface MySpotlightImporter () 14 | @property (nonatomic, retain) NSURL *modelURL; 15 | @property (nonatomic, retain) NSURL *storeURL; 16 | @end 17 | 18 | @implementation MySpotlightImporter 19 | 20 | @synthesize modelURL, storeURL; 21 | 22 | - (BOOL)importFileAtPath:(NSString *)filePath attributes:(NSMutableDictionary *)spotlightData error:(NSError **)error { 23 | 24 | NSDictionary *pathInfo = [NSPersistentStoreCoordinator elementsDerivedFromExternalRecordURL:[NSURL fileURLWithPath:filePath]]; 25 | 26 | self.modelURL = [NSURL fileURLWithPath:[pathInfo valueForKey:NSModelPathKey]]; 27 | self.storeURL = [NSURL fileURLWithPath:[pathInfo valueForKey:NSStorePathKey]]; 28 | 29 | 30 | NSURL *objectURI = [pathInfo valueForKey:NSObjectURIKey]; 31 | NSManagedObjectID *oid = [[self persistentStoreCoordinator] managedObjectIDForURIRepresentation:objectURI]; 32 | 33 | if (!oid) { 34 | NSLog(@"%@:%s to find object id from path %@", [self class], _cmd, filePath); 35 | return NO; 36 | } 37 | 38 | NSManagedObject *instance = [[self managedObjectContext] objectWithID:oid]; 39 | 40 | // how you process each instance will depend on the entity that the instance belongs to 41 | 42 | if ([[[instance entity] name] isEqualToString:@"YOUR_ENTITY_NAME"]) { 43 | 44 | // set the display name for Spotlight search result 45 | 46 | NSString *yourDisplayString = [NSString stringWithFormat:@"YOUR_DISPLAY_STRING %@",[instance valueForKey:@"SOME_KEY"]]; 47 | [spotlightData setObject: yourDisplayString forKey:(NSString *)kMDItemDisplayName]; 48 | 49 | /* 50 | Determine how you want to store the instance information in 'spotlightData' dictionary. 51 | For each property, pick the key kMDItem... from MDItem.h that best fits its content. 52 | If appropriate, aggregate the values of multiple properties before setting them in the dictionary. 53 | For relationships, you may want to flatten values. 54 | 55 | id YOUR_FIELD_VALUE = [instance valueForKey: ATTRIBUTE_NAME]; 56 | [spotlightData setObject: YOUR_FIELD_VALUE forKey: (NSString *) kMDItem...]; 57 | ... more property values; 58 | To determine if a property should be indexed, call isIndexedBySpotlight 59 | 60 | */ 61 | 62 | } 63 | 64 | return YES; 65 | } 66 | 67 | - (void)dealloc { 68 | 69 | [managedObjectContext release]; 70 | [persistentStoreCoordinator release]; 71 | [managedObjectModel release]; 72 | [modelURL release]; 73 | [storeURL release]; 74 | 75 | [super dealloc]; 76 | } 77 | 78 | /** 79 | Returns the managed object model. 80 | The last read model is cached in a global variable and reused 81 | if the URL and modification date are identical 82 | */ 83 | static NSURL *cachedModelURL = nil; 84 | static NSManagedObjectModel *cachedModel = nil; 85 | static NSDate *cachedModelModificationDate =nil; 86 | 87 | - (NSManagedObjectModel *)managedObjectModel { 88 | 89 | if (managedObjectModel != nil) return managedObjectModel; 90 | 91 | NSDictionary *modelFileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:[modelURL path] error:nil]; 92 | NSDate *modelModificationDate = [modelFileAttributes objectForKey:NSFileModificationDate]; 93 | 94 | if ([cachedModelURL isEqual:modelURL] && [modelModificationDate isEqualToDate:cachedModelModificationDate]) { 95 | managedObjectModel = [cachedModel retain]; 96 | } 97 | 98 | if (!managedObjectModel) { 99 | managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL]; 100 | 101 | if (!managedObjectModel) { 102 | NSLog(@"%@:%s unable to load model at URL %@", [self class], _cmd, modelURL); 103 | return nil; 104 | } 105 | 106 | // Clear out all custom classes used by the model to avoid having to link them 107 | // with the importer. Remove this code if you need to access your custom logic. 108 | NSString *managedObjectClassName = [NSManagedObject className]; 109 | for (NSEntityDescription *entity in managedObjectModel) { 110 | [entity setManagedObjectClassName:managedObjectClassName]; 111 | } 112 | 113 | // cache last loaded model 114 | 115 | [cachedModelURL release]; 116 | cachedModelURL = [modelURL retain]; 117 | [cachedModel release]; 118 | cachedModel = [managedObjectModel retain]; 119 | [cachedModelModificationDate release]; 120 | cachedModelModificationDate = [modelModificationDate retain]; 121 | } 122 | 123 | return managedObjectModel; 124 | } 125 | 126 | /** 127 | Returns the persistent store coordinator for the importer. 128 | */ 129 | 130 | - (NSPersistentStoreCoordinator *) persistentStoreCoordinator { 131 | 132 | if (persistentStoreCoordinator) return persistentStoreCoordinator; 133 | 134 | NSError *error = nil; 135 | 136 | persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel: [self managedObjectModel]]; 137 | if (![persistentStoreCoordinator addPersistentStoreWithType:YOUR_STORE_TYPE 138 | configuration:nil 139 | URL:storeURL 140 | options:nil 141 | error:&error]){ 142 | NSLog(@"%@:%s unable to add persistent store coordinator - %@", [self class], _cmd, error); 143 | } 144 | 145 | return persistentStoreCoordinator; 146 | } 147 | 148 | /** 149 | Returns the managed object context for the importer; already 150 | bound to the persistent store coordinator. 151 | */ 152 | 153 | - (NSManagedObjectContext *) managedObjectContext { 154 | 155 | if (managedObjectContext) return managedObjectContext; 156 | 157 | NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator]; 158 | if (!coordinator) { 159 | NSLog(@"%@:%s unable to get persistent store coordinator", [self class], _cmd); 160 | return nil; 161 | } 162 | 163 | managedObjectContext = [[NSManagedObjectContext alloc] init]; 164 | [managedObjectContext setPersistentStoreCoordinator: coordinator]; 165 | 166 | return managedObjectContext; 167 | } 168 | 169 | @end 170 | -------------------------------------------------------------------------------- /Importer/main.c: -------------------------------------------------------------------------------- 1 | // 2 | // main.c 3 | // MongoHub Spotlight Importer 4 | // 5 | // Created by Syd on 10-4-24. 6 | // Copyright (c) 2010 MusicPeace.ORG. All rights reserved. 7 | // 8 | 9 | 10 | 11 | 12 | 13 | //============================================================================== 14 | // 15 | // DO NO MODIFY THE CONTENT OF THIS FILE 16 | // 17 | // This file contains the generic CFPlug-in code necessary for your importer 18 | // To complete your importer implement the function in GetMetadataForFile.c 19 | // 20 | //============================================================================== 21 | 22 | 23 | 24 | 25 | 26 | #import 27 | #import 28 | #import 29 | 30 | // ----------------------------------------------------------------------------- 31 | // constants 32 | // ----------------------------------------------------------------------------- 33 | 34 | 35 | #define PLUGIN_ID "E0C38F20-64C0-4B5E-98E5-834069A86AD4" 36 | 37 | // 38 | // Below is the generic glue code for all plug-ins. 39 | // 40 | // You should not have to modify this code aside from changing 41 | // names if you decide to change the names defined in the Info.plist 42 | // 43 | 44 | 45 | // ----------------------------------------------------------------------------- 46 | // typedefs 47 | // ----------------------------------------------------------------------------- 48 | 49 | // The import function to be implemented in GetMetadataForFile.c 50 | Boolean GetMetadataForFile(void *thisInterface, 51 | CFMutableDictionaryRef attributes, 52 | CFStringRef contentTypeUTI, 53 | CFStringRef pathToFile); 54 | 55 | // The layout for an instance of MetaDataImporterPlugIn 56 | typedef struct __MetadataImporterPluginType 57 | { 58 | MDImporterInterfaceStruct *conduitInterface; 59 | CFUUIDRef factoryID; 60 | UInt32 refCount; 61 | } MetadataImporterPluginType; 62 | 63 | // ----------------------------------------------------------------------------- 64 | // prototypes 65 | // ----------------------------------------------------------------------------- 66 | // Forward declaration for the IUnknown implementation. 67 | // 68 | 69 | MetadataImporterPluginType *AllocMetadataImporterPluginType(CFUUIDRef inFactoryID); 70 | void DeallocMetadataImporterPluginType(MetadataImporterPluginType *thisInstance); 71 | HRESULT MetadataImporterQueryInterface(void *thisInstance,REFIID iid,LPVOID *ppv); 72 | void *MetadataImporterPluginFactory(CFAllocatorRef allocator,CFUUIDRef typeID); 73 | ULONG MetadataImporterPluginAddRef(void *thisInstance); 74 | ULONG MetadataImporterPluginRelease(void *thisInstance); 75 | // ----------------------------------------------------------------------------- 76 | // testInterfaceFtbl definition 77 | // ----------------------------------------------------------------------------- 78 | // The TestInterface function table. 79 | // 80 | 81 | static MDImporterInterfaceStruct testInterfaceFtbl = { 82 | NULL, 83 | MetadataImporterQueryInterface, 84 | MetadataImporterPluginAddRef, 85 | MetadataImporterPluginRelease, 86 | GetMetadataForFile 87 | }; 88 | 89 | 90 | // ----------------------------------------------------------------------------- 91 | // AllocMetadataImporterPluginType 92 | // ----------------------------------------------------------------------------- 93 | // Utility function that allocates a new instance. 94 | // You can do some initial setup for the importer here if you wish 95 | // like allocating globals etc... 96 | // 97 | MetadataImporterPluginType *AllocMetadataImporterPluginType(CFUUIDRef inFactoryID) 98 | { 99 | MetadataImporterPluginType *theNewInstance; 100 | 101 | theNewInstance = (MetadataImporterPluginType *)malloc(sizeof(MetadataImporterPluginType)); 102 | memset(theNewInstance,0,sizeof(MetadataImporterPluginType)); 103 | 104 | /* Point to the function table */ 105 | theNewInstance->conduitInterface = &testInterfaceFtbl; 106 | 107 | /* Retain and keep an open instance refcount for each factory. */ 108 | theNewInstance->factoryID = CFRetain(inFactoryID); 109 | CFPlugInAddInstanceForFactory(inFactoryID); 110 | 111 | /* This function returns the IUnknown interface so set the refCount to one. */ 112 | theNewInstance->refCount = 1; 113 | return theNewInstance; 114 | } 115 | 116 | // ----------------------------------------------------------------------------- 117 | // DeallocMongoHubMDImporterPluginType 118 | // ----------------------------------------------------------------------------- 119 | // Utility function that deallocates the instance when 120 | // the refCount goes to zero. 121 | // In the current implementation importer interfaces are never deallocated 122 | // but implement this as this might change in the future 123 | // 124 | void DeallocMetadataImporterPluginType(MetadataImporterPluginType *thisInstance) 125 | { 126 | CFUUIDRef theFactoryID; 127 | 128 | theFactoryID = thisInstance->factoryID; 129 | free(thisInstance); 130 | if (theFactoryID){ 131 | CFPlugInRemoveInstanceForFactory(theFactoryID); 132 | CFRelease(theFactoryID); 133 | } 134 | } 135 | 136 | // ----------------------------------------------------------------------------- 137 | // MetadataImporterQueryInterface 138 | // ----------------------------------------------------------------------------- 139 | // Implementation of the IUnknown QueryInterface function. 140 | // 141 | HRESULT MetadataImporterQueryInterface(void *thisInstance,REFIID iid,LPVOID *ppv) 142 | { 143 | CFUUIDRef interfaceID; 144 | 145 | interfaceID = CFUUIDCreateFromUUIDBytes(kCFAllocatorDefault,iid); 146 | 147 | if (CFEqual(interfaceID,kMDImporterInterfaceID)){ 148 | /* If the Right interface was requested, bump the ref count, 149 | * set the ppv parameter equal to the instance, and 150 | * return good status. 151 | */ 152 | ((MetadataImporterPluginType*)thisInstance)->conduitInterface->AddRef(thisInstance); 153 | *ppv = thisInstance; 154 | CFRelease(interfaceID); 155 | return S_OK; 156 | }else{ 157 | if (CFEqual(interfaceID,IUnknownUUID)){ 158 | /* If the IUnknown interface was requested, same as above. */ 159 | ((MetadataImporterPluginType*)thisInstance )->conduitInterface->AddRef(thisInstance); 160 | *ppv = thisInstance; 161 | CFRelease(interfaceID); 162 | return S_OK; 163 | }else{ 164 | /* Requested interface unknown, bail with error. */ 165 | *ppv = NULL; 166 | CFRelease(interfaceID); 167 | return E_NOINTERFACE; 168 | } 169 | } 170 | } 171 | 172 | // ----------------------------------------------------------------------------- 173 | // MetadataImporterPluginAddRef 174 | // ----------------------------------------------------------------------------- 175 | // Implementation of reference counting for this type. Whenever an interface 176 | // is requested, bump the refCount for the instance. NOTE: returning the 177 | // refcount is a convention but is not required so don't rely on it. 178 | // 179 | ULONG MetadataImporterPluginAddRef(void *thisInstance) 180 | { 181 | ((MetadataImporterPluginType *)thisInstance )->refCount += 1; 182 | return ((MetadataImporterPluginType*) thisInstance)->refCount; 183 | } 184 | 185 | // ----------------------------------------------------------------------------- 186 | // SampleCMPluginRelease 187 | // ----------------------------------------------------------------------------- 188 | // When an interface is released, decrement the refCount. 189 | // If the refCount goes to zero, deallocate the instance. 190 | // 191 | ULONG MetadataImporterPluginRelease(void *thisInstance) 192 | { 193 | ((MetadataImporterPluginType*)thisInstance)->refCount -= 1; 194 | if (((MetadataImporterPluginType*)thisInstance)->refCount == 0){ 195 | DeallocMetadataImporterPluginType((MetadataImporterPluginType*)thisInstance ); 196 | return 0; 197 | }else{ 198 | return ((MetadataImporterPluginType*) thisInstance )->refCount; 199 | } 200 | } 201 | 202 | // ----------------------------------------------------------------------------- 203 | // MongoHubMDImporterPluginFactory 204 | // ----------------------------------------------------------------------------- 205 | // Implementation of the factory function for this type. 206 | // 207 | void *MetadataImporterPluginFactory(CFAllocatorRef allocator,CFUUIDRef typeID) 208 | { 209 | MetadataImporterPluginType *result; 210 | CFUUIDRef uuid; 211 | 212 | /* If correct type is being requested, allocate an 213 | * instance of TestType and return the IUnknown interface. 214 | */ 215 | if (CFEqual(typeID,kMDImporterTypeID)){ 216 | uuid = CFUUIDCreateFromString(kCFAllocatorDefault,CFSTR(PLUGIN_ID)); 217 | result = AllocMetadataImporterPluginType(uuid); 218 | CFRelease(uuid); 219 | return result; 220 | } 221 | /* If the requested type is incorrect, return NULL. */ 222 | return NULL; 223 | } 224 | 225 | -------------------------------------------------------------------------------- /JSON/JsonWindowController.h: -------------------------------------------------------------------------------- 1 | // 2 | // JsonWindowController.h 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-12-27. 6 | // Copyright 2010 ThePeppersStudio.COM. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "UKSyntaxColoredTextViewController.h" 11 | @class DatabasesArrayController; 12 | @class Connection; 13 | @class MongoDB; 14 | 15 | #ifndef UKSCTD_DEFAULT_TEXTENCODING 16 | #define UKSCTD_DEFAULT_TEXTENCODING NSUTF8StringEncoding 17 | #endif 18 | 19 | @interface JsonWindowController : NSWindowController { 20 | NSManagedObjectContext *managedObjectContext; 21 | DatabasesArrayController *databaseArrayController; 22 | Connection *conn; 23 | MongoDB *mongoDB; 24 | NSString *dbname; 25 | NSString *collectionname; 26 | NSDictionary *jsonDict; 27 | IBOutlet NSTextView *myTextView; 28 | IBOutlet NSProgressIndicator *progress; 29 | IBOutlet NSTextField *status; 30 | UKSyntaxColoredTextViewController *syntaxColoringController; 31 | } 32 | 33 | @property (nonatomic, retain) NSManagedObjectContext *managedObjectContext; 34 | @property (nonatomic, retain) DatabasesArrayController *databasesArrayController; 35 | @property (nonatomic, retain) MongoDB *mongoDB; 36 | @property (nonatomic, retain) NSString *dbname; 37 | @property (nonatomic, retain) NSString *collectionname; 38 | @property (nonatomic, retain) Connection *conn; 39 | @property (nonatomic, retain) NSDictionary *jsonDict; 40 | @property (nonatomic, retain) NSTextView *myTextView; 41 | 42 | -(IBAction) save:(id)sender; 43 | -(void) doSave; 44 | -(IBAction) recolorCompleteFile: (id)sender; 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /JSON/JsonWindowController.mm: -------------------------------------------------------------------------------- 1 | // 2 | // JsonWindowController.m 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-12-27. 6 | // Copyright 2010 ThePeppersStudio.COM. All rights reserved. 7 | // 8 | 9 | #import "JsonWindowController.h" 10 | #import "Configure.h" 11 | #import "NSProgressIndicator+Extras.h" 12 | #import "DatabasesArrayController.h" 13 | #import "Connection.h" 14 | #import "MongoDB.h" 15 | #import "NSString+Extras.h" 16 | 17 | @implementation JsonWindowController 18 | @synthesize managedObjectContext; 19 | @synthesize databasesArrayController; 20 | @synthesize mongoDB; 21 | @synthesize conn; 22 | @synthesize dbname; 23 | @synthesize collectionname; 24 | @synthesize jsonDict; 25 | @synthesize myTextView; 26 | 27 | - (id)init { 28 | if (![super initWithWindowNibName:@"JsonWindow"]) return nil; 29 | return self; 30 | } 31 | 32 | - (void)dealloc { 33 | [managedObjectContext release]; 34 | [databasesArrayController release]; 35 | [conn release]; 36 | [mongoDB release]; 37 | [dbname release]; 38 | [collectionname release]; 39 | [jsonDict release]; 40 | [myTextView release]; 41 | [syntaxColoringController setDelegate: nil]; 42 | [syntaxColoringController release]; 43 | syntaxColoringController = nil; 44 | [progress release]; 45 | [super dealloc]; 46 | } 47 | 48 | - (void)windowWillClose:(NSNotification *)notification { 49 | [[NSNotificationCenter defaultCenter] postNotificationName:kJsonWindowWillClose object:nil]; 50 | [super release]; 51 | } 52 | 53 | - (void)windowDidLoad { 54 | [super windowDidLoad]; 55 | NSString *title = [[NSString alloc] initWithFormat:@"%@.%@ _id:%@", dbname, collectionname, [jsonDict objectForKey:@"value"]]; 56 | [self.window setTitle:title]; 57 | [title release]; 58 | [myTextView setString:[jsonDict objectForKey:@"beautified"]]; 59 | syntaxColoringController = [[UKSyntaxColoredTextViewController alloc] init]; 60 | [syntaxColoringController setDelegate: self]; 61 | [syntaxColoringController setView: myTextView]; 62 | } 63 | 64 | 65 | -(void) textViewControllerWillStartSyntaxRecoloring: (UKSyntaxColoredTextViewController*)sender 66 | { 67 | // Show your progress indicator. 68 | [progress startAnimation: self]; 69 | [progress display]; 70 | } 71 | 72 | 73 | -(void) textViewControllerDidFinishSyntaxRecoloring: (UKSyntaxColoredTextViewController*)sender 74 | { 75 | // Hide your progress indicator. 76 | [progress stopAnimation: self]; 77 | [progress display]; 78 | } 79 | 80 | -(NSString *)syntaxDefinitionFilenameForTextViewController: (UKSyntaxColoredTextViewController*)sender 81 | { 82 | return @"JSON"; 83 | } 84 | 85 | -(void) selectionInTextViewController: (UKSyntaxColoredTextViewController*)sender // Update any selection status display. 86 | changedToStartCharacter: (NSUInteger)startCharInLine endCharacter: (NSUInteger)endCharInLine 87 | inLine: (NSUInteger)lineInDoc startCharacterInDocument: (NSUInteger)startCharInDoc 88 | endCharacterInDocument: (NSUInteger)endCharInDoc; 89 | { 90 | NSString* statusMsg = nil; 91 | 92 | if( startCharInDoc < endCharInDoc ) 93 | { 94 | statusMsg = NSLocalizedString(@"character %lu to %lu of line %lu (%lu to %lu in document).",@"selection description in syntax colored text documents."); 95 | statusMsg = [NSString stringWithFormat: statusMsg, startCharInLine +1, endCharInLine +1, lineInDoc +1, startCharInDoc +1, endCharInDoc +1]; 96 | } 97 | else 98 | { 99 | statusMsg = NSLocalizedString(@"character %lu of line %lu (%lu in document).",@"insertion mark description in syntax colored text documents."); 100 | statusMsg = [NSString stringWithFormat: statusMsg, startCharInLine +1, lineInDoc +1, startCharInDoc +1]; 101 | } 102 | 103 | [status setStringValue: statusMsg]; 104 | [status display]; 105 | } 106 | 107 | /* ----------------------------------------------------------------------------- 108 | recolorCompleteFile: 109 | IBAction to do a complete recolor of the whole friggin' document. 110 | -------------------------------------------------------------------------- */ 111 | 112 | -(IBAction) recolorCompleteFile: (id)sender 113 | { 114 | [syntaxColoringController recolorCompleteFile: sender]; 115 | } 116 | 117 | -(IBAction) save:(id)sender 118 | { 119 | [NSThread detachNewThreadSelector:@selector(doSave) toTarget:self withObject:nil]; 120 | } 121 | 122 | -(void) doSave 123 | { 124 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 125 | [status setStringValue: @"Saving..."]; 126 | [status display]; 127 | [progress startAnimation: self]; 128 | [progress display]; 129 | NSString *user=nil; 130 | NSString *password=nil; 131 | Database *db = [databasesArrayController dbInfo:conn name:dbname]; 132 | if (db) { 133 | user = db.user; 134 | password = db.password; 135 | } 136 | [db release]; 137 | NSString *_id = nil; 138 | if ([[jsonDict objectForKey:@"type"] isEqualToString:@"ObjectId"]) { 139 | _id = [NSString stringWithFormat:@"ObjectId(\"%@\")", [jsonDict objectForKey:@"value"]]; 140 | }else { 141 | _id = [NSString stringWithFormat:@"\"%@\"", [jsonDict objectForKey:@"value"]]; 142 | } 143 | NSMutableString *json = [[NSMutableString alloc] initWithString:[myTextView string]]; 144 | [mongoDB saveInDB:dbname collection:collectionname user:user password:password jsonString:json _id:_id]; 145 | [json release]; 146 | [progress stopAnimation: self]; 147 | [progress display]; 148 | [status setStringValue: @"Saved"]; 149 | [status display]; 150 | [[NSNotificationCenter defaultCenter] postNotificationName:kJsonWindowSaved object:nil]; 151 | [pool release]; 152 | } 153 | @end 154 | -------------------------------------------------------------------------------- /MongoDB.h: -------------------------------------------------------------------------------- 1 | // 2 | // Mongo.h 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-4-25. 6 | // Copyright 2010 MusicPeace.ORG. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface MongoDB : NSObject { 13 | mongo::DBClientConnection *conn; 14 | mongo::DBClientReplicaSet::DBClientReplicaSet *repl_conn; 15 | BOOL isRepl; 16 | } 17 | - (mongo::DBClientConnection *)mongoConnection; 18 | - (mongo::DBClientReplicaSet::DBClientReplicaSet *)mongoReplConnection; 19 | 20 | - (id)initWithConn:(NSString *)host; 21 | - (id)initWithConn:(NSString *)name 22 | hosts:(NSArray *)hosts; 23 | - (bool)connect:(NSString *)host; 24 | - (bool)connect:(NSString *)name 25 | hosts:(NSArray *)hosts; 26 | - (bool)authUser:(NSString *)user 27 | pass:(NSString *)pass 28 | database:(NSString *)db; 29 | - (NSArray *)listDatabases; 30 | - (NSArray *)listCollections:(NSString *)db 31 | user:(NSString *)user 32 | password:(NSString *)password; 33 | - (NSMutableArray *) serverStatus; 34 | - (NSMutableArray *) dbStats:(NSString *)dbname 35 | user:(NSString *)user 36 | password:(NSString *)password; 37 | - (void) dropDB:(NSString *)dbname 38 | user:(NSString *)user 39 | password:(NSString *)password; 40 | - (NSMutableArray *) collStats:(NSString *)collectionname 41 | forDB:(NSString *)dbname 42 | user:(NSString *)user 43 | password:(NSString *)password; 44 | - (void) createCollection:(NSString *)collectionname 45 | forDB:(NSString *)dbname 46 | user:(NSString *)user 47 | password:(NSString *)password; 48 | - (void) dropCollection:(NSString *)collectionname 49 | forDB:(NSString *)dbname 50 | user:(NSString *)user 51 | password:(NSString *)password; 52 | - (NSMutableArray *) findInDB:(NSString *)dbname 53 | collection:(NSString *)collectionname 54 | user:(NSString *)user 55 | password:(NSString *)password 56 | critical:(NSString *)critical 57 | fields:(NSString *)fields 58 | skip:(NSNumber *)skip 59 | limit:(NSNumber *)limit 60 | sort:(NSString *)sort; 61 | - (void) saveInDB:(NSString *)dbname 62 | collection:(NSString *)collectionname 63 | user:(NSString *)user 64 | password:(NSString *)password 65 | jsonString:(NSString *)jsonString 66 | _id:(NSString *)_id; 67 | - (void) updateInDB:(NSString *)dbname 68 | collection:(NSString *)collectionname 69 | user:(NSString *)user 70 | password:(NSString *)password 71 | critical:(NSString *)critical 72 | fields:(NSString *)fields 73 | upset:(NSNumber *)upset; 74 | - (void) removeInDB:(NSString *)dbname 75 | collection:(NSString *)collectionname 76 | user:(NSString *)user 77 | password:(NSString *)password 78 | critical:(NSString *)critical; 79 | - (void) insertInDB:(NSString *)dbname 80 | collection:(NSString *)collectionname 81 | user:(NSString *)user 82 | password:(NSString *)password 83 | insertData:(NSString *)insertData; 84 | - (void) insertInDB:(NSString *)dbname 85 | collection:(NSString *)collectionname 86 | user:(NSString *)user 87 | password:(NSString *)password 88 | data:(NSDictionary *)insertData 89 | fields:(NSArray *)fields 90 | fieldTypes:(NSDictionary *)fieldTypes; 91 | - (NSMutableArray *) indexInDB:(NSString *)dbname 92 | collection:(NSString *)collectionname 93 | user:(NSString *)user 94 | password:(NSString *)password; 95 | - (void) ensureIndexInDB:(NSString *)dbname 96 | collection:(NSString *)collectionname 97 | user:(NSString *)user 98 | password:(NSString *)password 99 | indexData:(NSString *)indexData; 100 | - (void) reIndexInDB:(NSString *)dbname 101 | collection:(NSString *)collectionname 102 | user:(NSString *)user 103 | password:(NSString *)password; 104 | - (void) dropIndexInDB:(NSString *)dbname 105 | collection:(NSString *)collectionname 106 | user:(NSString *)user 107 | password:(NSString *)password 108 | indexName:(NSString *)indexName; 109 | - (long long int) countInDB:(NSString *)dbname 110 | collection:(NSString *)collectionname 111 | user:(NSString *)user 112 | password:(NSString *)password 113 | critical:(NSString *)critical; 114 | - (NSMutableArray *)mapReduceInDB:dbname 115 | collection:collectionname 116 | user:user 117 | password:password 118 | mapJs:mapFunction 119 | reduceJs:reduceFunction 120 | critical:critical 121 | output:output; 122 | - (NSMutableArray *) bsonDictWrapper:(mongo::BSONObj)retval; 123 | - (NSMutableArray *) bsonArrayWrapper:(mongo::BSONObj)retval; 124 | 125 | - (std::auto_ptr) findAllCursorInDB:(NSString *)dbname collection:(NSString *)collectionname user:(NSString *)user password:(NSString *)password fields:(mongo::BSONObj) fields; 126 | 127 | - (std::auto_ptr) findCursorInDB:(NSString *)dbname collection:(NSString *)collectionname user:(NSString *)user password:(NSString *)password critical:(NSString *)critical fields:(NSString *)fields skip:(NSNumber *)skip limit:(NSNumber *)limit sort:(NSString *)sort; 128 | 129 | - (void) updateBSONInDB:(NSString *)dbname 130 | collection:(NSString *)collectionname 131 | user:(NSString *)user 132 | password:(NSString *)password 133 | critical:(mongo::Query)critical 134 | fields:(mongo::BSONObj)fields 135 | upset:(bool)upset; 136 | 137 | - (mongo::BSONObj) serverStat; 138 | - (NSDictionary *) serverMonitor:(mongo::BSONObj)a second:(mongo::BSONObj)b currentDate:(NSDate *)now previousDate:(NSDate *)previous; 139 | - (double) diff:(NSString *)aName first:(mongo::BSONObj)a second:(mongo::BSONObj)b timeInterval:(NSTimeInterval)interval; 140 | - (double) percent:(NSString *)aOut value:(NSString *)aVal first:(mongo::BSONObj)a second:(mongo::BSONObj)b; 141 | @end 142 | -------------------------------------------------------------------------------- /MongoHub-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleDocumentTypes 8 | 9 | 10 | CFBundleTypeExtensions 11 | 12 | YOUR_EXTERNAL_RECORD_EXTENSION 13 | 14 | CFBundleTypeName 15 | External Record Support 16 | CFBundleTypeRole 17 | Editor 18 | LSItemContentTypes 19 | 20 | YOUR_EXTERNAL_RECORD_UTI 21 | 22 | LSTypeIsPackage 23 | 24 | NSPersistentStoreTypeKey 25 | XML 26 | 27 | 28 | CFBundleExecutable 29 | ${EXECUTABLE_NAME} 30 | CFBundleIconFile 31 | Icon.icns 32 | CFBundleIdentifier 33 | com.thepeppersstudio.${PRODUCT_NAME:rfc1034identifier} 34 | CFBundleInfoDictionaryVersion 35 | 6.0 36 | CFBundleName 37 | ${PRODUCT_NAME} 38 | CFBundlePackageType 39 | APPL 40 | CFBundleShortVersionString 41 | 2.3.2 42 | CFBundleSignature 43 | ???? 44 | CFBundleVersion 45 | 73 46 | LSMinimumSystemVersion 47 | ${MACOSX_DEPLOYMENT_TARGET} 48 | NSMainNibFile 49 | MainMenu 50 | NSPrincipalClass 51 | NSApplication 52 | NSHumanReadableCopyright 53 | © 2010, The Peppers Studio 54 | SUPublicDSAKeyFile 55 | dsa_pub.pem 56 | SUFeedURL 57 | http://mongohub.todayclose.com/appcast.xml 58 | 59 | 60 | -------------------------------------------------------------------------------- /MongoHub_AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // MongoHub_AppDelegate.h 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-4-24. 6 | // Copyright MusicPeace.ORG 2010 . All rights reserved. 7 | // 8 | 9 | #import 10 | @class ConnectionsCollectionView; 11 | @class ConnectionsArrayController; 12 | @class Connection; 13 | @class AddConnectionController; 14 | @class EditConnectionController; 15 | 16 | @interface MongoHub_AppDelegate : NSObject 17 | { 18 | NSWindow *window; 19 | 20 | NSPersistentStoreCoordinator *persistentStoreCoordinator; 21 | NSManagedObjectModel *managedObjectModel; 22 | NSManagedObjectContext *managedObjectContext; 23 | 24 | IBOutlet ConnectionsCollectionView *connectionsCollectionView; 25 | IBOutlet ConnectionsArrayController *connectionsArrayController; 26 | AddConnectionController *addConnectionController; 27 | EditConnectionController *editConnectionController; 28 | IBOutlet NSTextField *bundleVersion; 29 | } 30 | 31 | @property (nonatomic, retain) IBOutlet NSWindow *window; 32 | 33 | @property (nonatomic, retain, readonly) NSPersistentStoreCoordinator *persistentStoreCoordinator; 34 | @property (nonatomic, retain, readonly) NSManagedObjectModel *managedObjectModel; 35 | @property (nonatomic, retain, readonly) NSManagedObjectContext *managedObjectContext; 36 | 37 | @property (nonatomic, retain) ConnectionsCollectionView *connectionsCollectionView; 38 | @property (nonatomic, retain) ConnectionsArrayController *connectionsArrayController; 39 | @property (nonatomic, retain) AddConnectionController *addConnectionController; 40 | @property (nonatomic, retain) EditConnectionController *editConnectionController; 41 | @property (nonatomic, retain) NSTextField *bundleVersion; 42 | 43 | - (IBAction)saveAction:sender; 44 | - (IBAction)showAddConnectionPanel:(id)sender; 45 | - (IBAction)addConection:(id)sender; 46 | - (IBAction)showEditConnectionPanel:(id)sender; 47 | - (IBAction)editConnection:(id)sender; 48 | - (IBAction)deleteConnection:(id)sender; 49 | - (IBAction)resizeConnectionItemView:(id)sender; 50 | - (IBAction)showConnectionWindow:(id)sender; 51 | - (BOOL)isOpenedConnection:(Connection *)aConnection; 52 | - (void)doubleClick:(id)sender; 53 | @end 54 | -------------------------------------------------------------------------------- /MongoHub_DataModel.xcdatamodeld/.xccurrentversion: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | _XCCurrentVersionName 6 | MongoHub_DataModel.xcdatamodel 7 | 8 | 9 | -------------------------------------------------------------------------------- /MongoHub_DataModel.xcdatamodeld/MongoHub_DataModel.xcdatamodel/elements: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/MongoHub_DataModel.xcdatamodeld/MongoHub_DataModel.xcdatamodel/elements -------------------------------------------------------------------------------- /MongoHub_DataModel.xcdatamodeld/MongoHub_DataModel.xcdatamodel/layout: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/MongoHub_DataModel.xcdatamodeld/MongoHub_DataModel.xcdatamodel/layout -------------------------------------------------------------------------------- /MongoHub_DataModel.xcdatamodeld/MongoHub_DataModel1.0.xcdatamodel/elements: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/MongoHub_DataModel.xcdatamodeld/MongoHub_DataModel1.0.xcdatamodel/elements -------------------------------------------------------------------------------- /MongoHub_DataModel.xcdatamodeld/MongoHub_DataModel1.0.xcdatamodel/layout: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/MongoHub_DataModel.xcdatamodeld/MongoHub_DataModel1.0.xcdatamodel/layout -------------------------------------------------------------------------------- /MongoHub_DataModel.xcdatamodeld/MongoHub_DataModel2.0.xcdatamodel/elements: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/MongoHub_DataModel.xcdatamodeld/MongoHub_DataModel2.0.xcdatamodel/elements -------------------------------------------------------------------------------- /MongoHub_DataModel.xcdatamodeld/MongoHub_DataModel2.0.xcdatamodel/layout: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/MongoHub_DataModel.xcdatamodeld/MongoHub_DataModel2.0.xcdatamodel/layout -------------------------------------------------------------------------------- /MongoHub_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'MongoHub' target in the 'MongoHub' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /NSArray+Color.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+Color.h 3 | // CocoaTADS 4 | // 5 | // Created by Uli Kusterer on Mon Jun 02 2003. 6 | // Copyright (c) 2003 Uli Kusterer. 7 | // 8 | // This software is provided 'as-is', without any express or implied 9 | // warranty. In no event will the authors be held liable for any damages 10 | // arising from the use of this software. 11 | // 12 | // Permission is granted to anyone to use this software for any purpose, 13 | // including commercial applications, and to alter it and redistribute it 14 | // freely, subject to the following restrictions: 15 | // 16 | // 1. The origin of this software must not be misrepresented; you must not 17 | // claim that you wrote the original software. If you use this software 18 | // in a product, an acknowledgment in the product documentation would be 19 | // appreciated but is not required. 20 | // 21 | // 2. Altered source versions must be plainly marked as such, and must not be 22 | // misrepresented as being the original software. 23 | // 24 | // 3. This notice may not be removed or altered from any source 25 | // distribution. 26 | // 27 | 28 | // ----------------------------------------------------------------------------- 29 | // Headers: 30 | // ----------------------------------------------------------------------------- 31 | 32 | #import 33 | 34 | 35 | // ----------------------------------------------------------------------------- 36 | // Category: 37 | // ----------------------------------------------------------------------------- 38 | 39 | // Methods to treat an NSArray with three/four elements as an RGB/RGBA color. 40 | // Useful for storing colors in NSUserDefaults and other Property Lists. 41 | // Note that this isn't quite the same as storing an NSData of the color, as 42 | // some colors can't be correctly represented in RGB, but this makes for more 43 | // readable property lists than NSData. 44 | // If we wanted to get fancy, we could use an NSDictionary instead and save 45 | // different color types in different ways. 46 | 47 | @interface NSArray (UKColor) 48 | 49 | +(NSArray*) arrayWithColor: (NSColor*) col; 50 | -(NSColor*) colorValue; 51 | 52 | @end -------------------------------------------------------------------------------- /NSArray+Color.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+Color.m 3 | // CocoaTADS 4 | // 5 | // Created by Uli Kusterer on Mon Jun 02 2003. 6 | // Copyright (c) 2003 Uli Kusterer. 7 | // 8 | // This software is provided 'as-is', without any express or implied 9 | // warranty. In no event will the authors be held liable for any damages 10 | // arising from the use of this software. 11 | // 12 | // Permission is granted to anyone to use this software for any purpose, 13 | // including commercial applications, and to alter it and redistribute it 14 | // freely, subject to the following restrictions: 15 | // 16 | // 1. The origin of this software must not be misrepresented; you must not 17 | // claim that you wrote the original software. If you use this software 18 | // in a product, an acknowledgment in the product documentation would be 19 | // appreciated but is not required. 20 | // 21 | // 2. Altered source versions must be plainly marked as such, and must not be 22 | // misrepresented as being the original software. 23 | // 24 | // 3. This notice may not be removed or altered from any source 25 | // distribution. 26 | // 27 | 28 | // ----------------------------------------------------------------------------- 29 | // Headers: 30 | // ----------------------------------------------------------------------------- 31 | 32 | #import "NSArray+Color.h" 33 | 34 | 35 | @implementation NSArray (UKColor) 36 | 37 | // ----------------------------------------------------------------------------- 38 | // arrayWithColor: 39 | // Converts the color to an RGB color if needed, and then creates an array 40 | // with its red, green, blue and alpha components (in that order). 41 | // 42 | // REVISIONS: 43 | // 2004-05-18 witness documented. 44 | // ----------------------------------------------------------------------------- 45 | 46 | +(NSArray*) arrayWithColor: (NSColor*) col 47 | { 48 | CGFloat fRed = 1, fGreen = 1, fBlue = 1, fAlpha = 1.0; 49 | 50 | col = [col colorUsingColorSpaceName: NSCalibratedRGBColorSpace]; 51 | [col getRed: &fRed green: &fGreen blue: &fBlue alpha: &fAlpha]; 52 | 53 | return [self arrayWithObjects: [NSNumber numberWithFloat:fRed], [NSNumber numberWithFloat:fGreen], 54 | [NSNumber numberWithFloat:fBlue], [NSNumber numberWithFloat:fAlpha], nil]; 55 | } 56 | 57 | 58 | // ----------------------------------------------------------------------------- 59 | // colorValue: 60 | // Converts an NSArray with three (or four) NSValues into an RGB Color 61 | // (plus alpha, if specified). 62 | // 63 | // REVISIONS: 64 | // 2004-05-18 witness documented. 65 | // ----------------------------------------------------------------------------- 66 | 67 | -(NSColor*) colorValue 68 | { 69 | float fRed = 1, fGreen = 1, fBlue = 1, fAlpha = 1.0; 70 | 71 | if( [self count] >= 3 ) 72 | { 73 | fRed = [[self objectAtIndex:0] floatValue]; 74 | fGreen = [[self objectAtIndex:1] floatValue]; 75 | fBlue = [[self objectAtIndex:2] floatValue]; 76 | } 77 | if( [self count] > 3 ) // Have alpha info? 78 | fAlpha = [[self objectAtIndex:3] floatValue]; 79 | 80 | return [NSColor colorWithCalibratedRed: fRed green: fGreen blue: fBlue alpha: fAlpha]; 81 | } 82 | 83 | @end 84 | -------------------------------------------------------------------------------- /NSProgressIndicator+Extras.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSProgressIndicator+Extras.h 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-12-22. 6 | // Copyright 2010 ThePeppersStudio.COM. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface NSProgressIndicator (Extras) 13 | 14 | - (void)start; 15 | - (void)stop; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /NSProgressIndicator+Extras.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSProgressIndicator+Extras.m 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-12-22. 6 | // Copyright 2010 ThePeppersStudio.COM. All rights reserved. 7 | // 8 | 9 | #import "NSProgressIndicator+Extras.h" 10 | 11 | 12 | @implementation NSProgressIndicator (Extras) 13 | 14 | - (void)start { 15 | [self startAnimation:self]; 16 | [self setHidden:NO]; 17 | } 18 | 19 | - (void)stop { 20 | [self setHidden:YES]; 21 | [self stopAnimation:self]; 22 | } 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /NSScanner+SkipUpToCharset.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSScanner+SkipUpToCharset.h 3 | // UKSyntaxColoredDocument 4 | // 5 | // Created by Uli Kusterer on Sat Dec 13 2003. 6 | // Copyright (c) 2003 Uli Kusterer. 7 | // 8 | // This software is provided 'as-is', without any express or implied 9 | // warranty. In no event will the authors be held liable for any damages 10 | // arising from the use of this software. 11 | // 12 | // Permission is granted to anyone to use this software for any purpose, 13 | // including commercial applications, and to alter it and redistribute it 14 | // freely, subject to the following restrictions: 15 | // 16 | // 1. The origin of this software must not be misrepresented; you must not 17 | // claim that you wrote the original software. If you use this software 18 | // in a product, an acknowledgment in the product documentation would be 19 | // appreciated but is not required. 20 | // 21 | // 2. Altered source versions must be plainly marked as such, and must not be 22 | // misrepresented as being the original software. 23 | // 24 | // 3. This notice may not be removed or altered from any source 25 | // distribution. 26 | // 27 | 28 | #import 29 | 30 | 31 | @interface NSScanner (UKSkipUpToCharset) 32 | 33 | -(BOOL) skipUpToCharactersFromSet:(NSCharacterSet*)set; 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /NSScanner+SkipUpToCharset.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSScanner+SkipUpToCharset.m 3 | // UKSyntaxColoredDocument 4 | // 5 | // Created by Uli Kusterer on Sat Dec 13 2003. 6 | // Copyright (c) 2003 M. Uli Kusterer. All rights reserved. 7 | // 8 | 9 | #import "NSScanner+SkipUpToCharset.h" 10 | 11 | 12 | @implementation NSScanner (UKSkipUpToCharset) 13 | 14 | -(BOOL) skipUpToCharactersFromSet:(NSCharacterSet*)set 15 | { 16 | NSString* vString = [self string]; 17 | int x = [self scanLocation]; 18 | 19 | while( x < [vString length] ) 20 | { 21 | if( ![set characterIsMember: [vString characterAtIndex: x]] ) 22 | x++; 23 | else 24 | break; 25 | } 26 | 27 | if( x > [self scanLocation] ) 28 | { 29 | [self setScanLocation: x]; 30 | return YES; 31 | } 32 | else 33 | return NO; 34 | } 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /NSString+Extras.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+Extras.h 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-4-28. 6 | // Copyright 2010 ThePeppersStudio.COM. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface NSString (Extras) 13 | 14 | + (NSString*)stringFromResource:(NSString*)resourceName; 15 | - (BOOL)startsWithString:(NSString*)otherString; 16 | - (BOOL)endsWithString:(NSString*)otherString; 17 | - (BOOL)isPresent; 18 | - (NSComparisonResult)compareCaseInsensitive:(NSString*)other; 19 | - (NSString*)stringByPercentEscapingCharacters:(NSString*)characters; 20 | - (NSString*)stringByEscapingURL; 21 | - (NSString*)stringByUnescapingURL; 22 | - (BOOL) containsString:(NSString *)aString; 23 | - (BOOL) containsString:(NSString *)aString ignoringCase:(BOOL)flag; 24 | - (int)countSubstring:(NSString *)aString ignoringCase:(BOOL)flag; 25 | - (NSString *)stringByTrimmingWhitespace; 26 | 27 | + (NSNull *)nullValue; 28 | + (NSString*)UUIDString; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /NSString+Extras.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+Extras.m 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-4-28. 6 | // Copyright 2010 ThePeppersStudio.COM. All rights reserved. 7 | // 8 | 9 | #import "NSString+Extras.h" 10 | 11 | 12 | @implementation NSString (Extras) 13 | 14 | 15 | + (NSString*)stringFromResource:(NSString*)resourceName { 16 | NSString *path = [[NSBundle mainBundle] pathForResource:resourceName ofType:nil]; 17 | return [NSString stringWithContentsOfFile:path usedEncoding:nil error:nil]; 18 | } 19 | 20 | # pragma Comparing 21 | 22 | - (BOOL)startsWithString:(NSString*)otherString { 23 | return [self rangeOfString:otherString].location == 0; 24 | } 25 | 26 | - (BOOL)endsWithString:(NSString*)otherString { 27 | return [self rangeOfString:otherString].location == [self length]-[otherString length]; 28 | } 29 | 30 | - (BOOL)isPresent { 31 | return ![self isEqualToString:@""]; 32 | } 33 | 34 | - (NSComparisonResult)compareCaseInsensitive:(NSString*)other { 35 | NSString *selfString = [self lowercaseString]; 36 | NSString *otherString = [other lowercaseString]; 37 | return [selfString compare:otherString]; 38 | } 39 | 40 | - (NSString*)stringByPercentEscapingCharacters:(NSString*)characters { 41 | return [(NSString*)CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)self, NULL, (CFStringRef)characters, kCFStringEncodingUTF8) autorelease]; 42 | } 43 | 44 | - (NSString*)stringByEscapingURL { 45 | return [self stringByPercentEscapingCharacters:@";/?:@&=+$,"]; 46 | } 47 | 48 | - (NSString*)stringByUnescapingURL { 49 | return [(NSString*)CFURLCreateStringByReplacingPercentEscapes(NULL, (CFStringRef)self, CFSTR("")) autorelease]; 50 | } 51 | 52 | - (BOOL)containsString:(NSString *)aString { 53 | return [self containsString:aString ignoringCase:NO]; 54 | } 55 | 56 | - (BOOL)containsString:(NSString *)aString ignoringCase:(BOOL)flag { 57 | unsigned mask = (flag ? NSCaseInsensitiveSearch : 0); 58 | return [self rangeOfString:aString options:mask].length > 0; 59 | } 60 | 61 | - (int)countSubstring:(NSString *)aString ignoringCase:(BOOL)flag { 62 | unsigned mask = (flag ? NSCaseInsensitiveSearch : 0); 63 | return [self rangeOfString:aString options:mask].length; 64 | } 65 | 66 | - (NSString *)stringByTrimmingWhitespace 67 | { 68 | return [self stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; 69 | } 70 | 71 | + (NSNull *)nullValue 72 | { 73 | return [NSNull null]; 74 | } 75 | 76 | + (NSString*)UUIDString { 77 | CFUUIDRef theUUID = CFUUIDCreate(NULL); 78 | CFStringRef string = CFUUIDCreateString(NULL, theUUID); 79 | CFRelease(theUUID); 80 | return [(NSString *)string autorelease]; 81 | } 82 | 83 | 84 | @end 85 | -------------------------------------------------------------------------------- /QueryWindowController.h: -------------------------------------------------------------------------------- 1 | // 2 | // QueryWindowController.h 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-4-28. 6 | // Copyright 2010 ThePeppersStudio.COM. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | @class DatabasesArrayController; 13 | @class ResultsOutlineViewController; 14 | @class Connection; 15 | @class MongoDB; 16 | 17 | @interface QueryWindowController : NSWindowController { 18 | NSManagedObjectContext *managedObjectContext; 19 | DatabasesArrayController *databasesArrayController; 20 | IBOutlet ResultsOutlineViewController *findResultsViewController; 21 | IBOutlet NSOutlineView *findResultsOutlineView; 22 | MongoDB *mongoDB; 23 | NSString *dbname; 24 | NSString *collectionname; 25 | Connection *conn; 26 | 27 | IBOutlet NSTextField *criticalTextField; 28 | IBOutlet NSTokenField *fieldsTextField; 29 | IBOutlet NSTextField *skipTextField; 30 | IBOutlet NSTextField *limitTextField; 31 | IBOutlet NSTextField *sortTextField; 32 | IBOutlet BWInsetTextField *totalResultsTextField; 33 | IBOutlet NSTextField *findQueryTextField; 34 | IBOutlet NSProgressIndicator *findQueryLoaderIndicator; 35 | 36 | IBOutlet NSTextField *updateCriticalTextField; 37 | IBOutlet NSTextField *updateSetTextField; 38 | IBOutlet NSButton *upsetCheckBox; 39 | IBOutlet BWInsetTextField *updateResultsTextField; 40 | IBOutlet NSTextField *updateQueryTextField; 41 | IBOutlet NSProgressIndicator *updateQueryLoaderIndicator; 42 | 43 | IBOutlet NSTextField *removeCriticalTextField; 44 | IBOutlet BWInsetTextField *removeResultsTextField; 45 | IBOutlet NSTextField *removeQueryTextField; 46 | IBOutlet NSProgressIndicator *removeQueryLoaderIndicator; 47 | 48 | IBOutlet NSTextView *insertDataTextView; 49 | IBOutlet BWInsetTextField *insertResultsTextField; 50 | IBOutlet NSProgressIndicator *insertLoaderIndicator; 51 | 52 | IBOutlet NSTextField *indexTextField; 53 | IBOutlet ResultsOutlineViewController *indexesOutlineViewController; 54 | IBOutlet NSProgressIndicator *indexLoaderIndicator; 55 | 56 | IBOutlet NSTextView *mapFunctionTextView; 57 | IBOutlet NSTextView *reduceFunctionTextView; 58 | IBOutlet NSTextField *mrcriticalTextField; 59 | IBOutlet NSTextField *mroutputTextField; 60 | IBOutlet NSProgressIndicator *mrLoaderIndicator; 61 | IBOutlet ResultsOutlineViewController *mrOutlineViewController; 62 | 63 | IBOutlet NSTextField *expCriticalTextField; 64 | IBOutlet NSTokenField *expFieldsTextField; 65 | IBOutlet NSTextField *expSkipTextField; 66 | IBOutlet NSTextField *expLimitTextField; 67 | IBOutlet NSTextField *expSortTextField; 68 | IBOutlet BWInsetTextField *expResultsTextField; 69 | IBOutlet NSTextField *expPathTextField; 70 | IBOutlet NSPopUpButton *expTypePopUpButton; 71 | IBOutlet NSTextField *expQueryTextField; 72 | IBOutlet NSButton *expJsonArrayCheckBox; 73 | IBOutlet NSProgressIndicator *expProgressIndicator; 74 | 75 | IBOutlet NSButton *impIgnoreBlanksCheckBox; 76 | IBOutlet NSButton *impDropCheckBox; 77 | IBOutlet NSButton *impHeaderlineCheckBox; 78 | IBOutlet NSTokenField *impFieldsTextField; 79 | IBOutlet BWInsetTextField *impResultsTextField; 80 | IBOutlet NSTextField *impPathTextField; 81 | IBOutlet NSPopUpButton *impTypePopUpButton; 82 | IBOutlet NSButton *impJsonArrayCheckBox; 83 | IBOutlet NSButton *impStopOnErrorCheckBox; 84 | IBOutlet NSProgressIndicator *impProgressIndicator; 85 | } 86 | 87 | @property (nonatomic, retain) NSManagedObjectContext *managedObjectContext; 88 | @property (nonatomic, retain) DatabasesArrayController *databasesArrayController; 89 | @property (nonatomic, retain) ResultsOutlineViewController *findResultsViewController; 90 | @property (nonatomic, retain) MongoDB *mongoDB; 91 | @property (nonatomic, retain) NSString *dbname; 92 | @property (nonatomic, retain) NSString *collectionname; 93 | @property (nonatomic, retain) Connection *conn; 94 | 95 | @property (nonatomic, retain) NSTextField *criticalTextField; 96 | @property (nonatomic, retain) NSTokenField *fieldsTextField; 97 | @property (nonatomic, retain) NSTextField *skipTextField; 98 | @property (nonatomic, retain) NSTextField *limitTextField; 99 | @property (nonatomic, retain) NSTextField *sortTextField; 100 | @property (nonatomic, retain) BWInsetTextField *totalResultsTextField; 101 | @property (nonatomic, retain) NSTextField *findQueryTextField; 102 | @property (nonatomic, retain) NSOutlineView *findResultsOutlineView; 103 | @property (nonatomic, retain) NSProgressIndicator *findQueryLoaderIndicator; 104 | 105 | @property (nonatomic, retain) NSTextField *updateCriticalTextField; 106 | @property (nonatomic, retain) NSTextField *updateSetTextField; 107 | @property (nonatomic, retain) NSButton *upsetCheckBox; 108 | @property (nonatomic, retain) BWInsetTextField *updateResultsTextField; 109 | @property (nonatomic, retain) NSTextField *updateQueryTextField; 110 | @property (nonatomic, retain) NSProgressIndicator *updateQueryLoaderIndicator; 111 | 112 | @property (nonatomic, retain) NSTextField *removeCriticalTextField; 113 | @property (nonatomic, retain) BWInsetTextField *removeResultsTextField; 114 | @property (nonatomic, retain) NSTextField *removeQueryTextField; 115 | @property (nonatomic, retain) NSProgressIndicator *removeQueryLoaderIndicator; 116 | 117 | @property (nonatomic, retain) NSTextView *insertDataTextView; 118 | @property (nonatomic, retain) BWInsetTextField *insertResultsTextField; 119 | @property (nonatomic, retain) NSProgressIndicator *insertLoaderIndicator; 120 | 121 | @property (nonatomic, retain) NSTextField *indexTextField; 122 | @property (nonatomic, retain) ResultsOutlineViewController *indexesOutlineViewController; 123 | @property (nonatomic, retain) NSProgressIndicator *indexLoaderIndicator; 124 | 125 | @property (nonatomic, retain) NSTextView *mapFunctionTextView; 126 | @property (nonatomic, retain) NSTextView *reduceFunctionTextView; 127 | @property (nonatomic, retain) NSTextField *mrcriticalTextField; 128 | @property (nonatomic, retain) NSTextField *mroutputTextField; 129 | @property (nonatomic, retain) ResultsOutlineViewController *mrOutlineViewController; 130 | @property (nonatomic, retain) NSProgressIndicator *mrLoaderIndicator; 131 | 132 | @property (nonatomic, retain) NSTextField *expCriticalTextField; 133 | @property (nonatomic, retain) NSTokenField *expFieldsTextField; 134 | @property (nonatomic, retain) NSTextField *expSkipTextField; 135 | @property (nonatomic, retain) NSTextField *expLimitTextField; 136 | @property (nonatomic, retain) NSTextField *expSortTextField; 137 | @property (nonatomic, retain) BWInsetTextField *expResultsTextField; 138 | @property (nonatomic, retain) NSTextField *expPathTextField; 139 | @property (nonatomic, retain) NSPopUpButton *expTypePopUpButton; 140 | @property (nonatomic, retain) NSTextField *expQueryTextField; 141 | @property (nonatomic, retain) NSButton *expJsonArrayCheckBox; 142 | @property (nonatomic, retain) NSProgressIndicator *expProgressIndicator; 143 | 144 | @property (nonatomic, retain) NSButton *impIgnoreBlanksCheckBox; 145 | @property (nonatomic, retain) NSButton *impDropCheckBox; 146 | @property (nonatomic, retain) NSButton *impHeaderlineCheckBox; 147 | @property (nonatomic, retain) NSTokenField *impFieldsTextField; 148 | @property (nonatomic, retain) BWInsetTextField *impResultsTextField; 149 | @property (nonatomic, retain) NSTextField *impPathTextField; 150 | @property (nonatomic, retain) NSPopUpButton *impTypePopUpButton; 151 | @property (nonatomic, retain) NSButton *impJsonArrayCheckBox; 152 | @property (nonatomic, retain) NSButton *impStopOnErrorCheckBox; 153 | @property (nonatomic, retain) NSProgressIndicator *impProgressIndicator; 154 | 155 | - (IBAction)findQuery:(id)sender; 156 | - (void)doFindQuery; 157 | - (IBAction)expandFindResults:(id)sender; 158 | - (IBAction)collapseFindResults:(id)sender; 159 | - (IBAction)updateQuery:(id)sender; 160 | - (void)doUpdateQuery; 161 | - (IBAction)removeQuery:(id)sender; 162 | - (void)doRemoveQuery; 163 | - (IBAction)insertQuery:(id)sender; 164 | - (void)doInsertQuery; 165 | - (IBAction)indexQuery:(id)sender; 166 | - (void)doIndexQuery; 167 | - (IBAction)ensureIndex:(id)sender; 168 | - (void)doEnsureIndex; 169 | - (IBAction)reIndex:(id)sender; 170 | - (void)doReIndex; 171 | - (IBAction)dropIndex:(id)sender; 172 | - (void)doDropIndex; 173 | - (IBAction) mapReduce:(id)sender; 174 | - (void)doMapReduce; 175 | - (IBAction) export:(id)sender; 176 | - (void)doExport; 177 | - (IBAction) import:(id)sender; 178 | - (void)doImport; 179 | - (IBAction)removeRecord:(id)sender; 180 | - (void)doRemoveRecord; 181 | 182 | - (IBAction)findQueryComposer:(id)sender; 183 | - (IBAction)updateQueryComposer:(id)sender; 184 | - (IBAction)removeQueryComposer:(id)sender; 185 | - (IBAction) exportQueryComposer:(id)sender; 186 | 187 | - (void)showEditWindow:(id)sender; 188 | - (void)jsonWindowWillClose:(id)sender; 189 | 190 | - (IBAction)chooseExportPath:(id)sender; 191 | - (IBAction)chooseImportPath:(id)sender; 192 | - (mongo::BSONObj)parseCSVLine:(char *)line type:(int)_type sep:(const char *)_sep headerLine:(bool)_headerLine ignoreBlanks:(bool)_ignoreBlanks fields:(std::vector &)_fields; 193 | @end 194 | -------------------------------------------------------------------------------- /README.markdown: -------------------------------------------------------------------------------- 1 | # MongoHub [![stillmaintained](http://stillmaintained.com/bububa/MongoHub-Mac.png)](http://stillmaintained.com/bububa/MongoHub-Mac) 2 | 3 | ## What is MongoHub 4 | **[MongoHub](http://mongohub.todayclose.com/)** is a **[mongodb](http://mongodb.org)** GUI application. 5 | This repository is a mac native version of MongoHub. If you are using windows or linux please download use the source from [http://github.com/bububa/MongoHub](http://github.com/bububa/MongoHub) which is made by Titanium Desktop. 6 | 7 | ![mongohub splash](https://github.com/downloads/bububa/MongoHub-Mac/MongoHubWall.png) 8 | 9 | ## System Requirements 10 | 11 | Mac OS X(10.6.x), intel(64bit) based. 12 | 13 | ## Installation 14 | 15 | You can either download the compiled executable file from [here](https://github.com/downloads/bububa/MongoHub-Mac/MongoHub.zip) 16 | or clone the source code and compile it on your own system. 17 | 18 | ## Build 19 | 20 | Before builing ensure the following frameworks are present: 21 | /Library/PrivateFrameworks 22 | BWToolkitFramework.framework 23 | Sparkle.framework 24 | MCPKit_bundled.framework 25 | RegexKit.framework 26 | 27 | The project also expects Boost libraries and the MongoDB client libraries. 28 | 29 | The following Xcode project settings were changed from the master project: 30 | Header Search Paths: /usr/local/include/ 31 | Library Search Paths: /opt/local/lib ~/source/mongo (path to mongo source) 32 | User Header Search Paths: /opt/local/include ~/source (path to source projects) 33 | 34 | Thanks [HybridDBA](https://github.com/HybridDBA) add this build guide. 35 | 36 | ## Current Status 37 | 38 | This project is very new. Any issues or bug reports are welcome. And I still don't have time to write a **usage guide**. 39 | 40 | ## History 41 | 42 | ** [Last Update 2.3.2] ** 43 | 44 | - Fixed a bug in jsoneditor related to Date() object; 45 | - Add import/export to JSON/CSV functions; 46 | - Add support for ssh access use public key; 47 | - Add a function to remove single record in find query window; 48 | - Fixed a bug to create collection in a database which doesn't have collection; 49 | 50 | ** [Last Update 2.3.1] ** 51 | 52 | - Fixed a bug in jsoneditor related to Date() object; 53 | - Add execution time in find panel; 54 | - Add reconnect support; 55 | - Fixed a bug in remove function. 56 | 57 | ** [2.3.0] ** 58 | 59 | - Add mongo stat monitor; 60 | - Add replica set connection support; 61 | - Add reconnect support; 62 | - Add an JSON editor for found results with syntax highlight; 63 | - More flexible query style in find window; 64 | - Fixed long long int value overflow; 65 | - Fixed application crash during open/close connection window. 66 | 67 | ** [2.2.0] ** 68 | 69 | - SSH Tunnel connection support; 70 | - Fixed a bug in display ObjectID type fields; 71 | - Fixed some UI bugs; 72 | - Fixed some memory leaks and random crashes; 73 | - Add confirm panel before drop database or collection; 74 | - Run queries in a seperate thread so that won't block the UI; 75 | - Fixed a bug to install on some 10.6.x(64bit) system. 76 | 77 | ** [2.1.0] ** 78 | 79 | - Auto expand and collaspe finding results; 80 | - Display Date_t or Timestamp as GMT time format; 81 | - Fixed a bug in display ObjectIds in Array element; 82 | - Import data from mysql database to mongodb; 83 | - Export data from mongodb to mysql database. 84 | 85 | ** [2.0.9] ** 86 | 87 | - Add support for mongohq.com; 88 | - Changed update behavior; 89 | - Fixed a bug to detect NumberLong type of BSONElement; 90 | - Fixed a bug in Array type of BSONElement. 91 | 92 | ** [2.0.8] ** 93 | 94 | - Fix several UI bugs in Query Window; 95 | - Fix bugs in Find Query and Update Query; 96 | - Fix bugs related to ObjectId; 97 | - Fix copy&paste bugs. 98 | 99 | ** [2.0.7] ** 100 | 101 | - Add sparkle framework to check application updates. 102 | 103 | ** [2.0.6] ** 104 | 105 | - fixed some UI bugs; 106 | - add admin auth support. 107 | 108 | ## Contribute 109 | 110 | I'd love to include your contributions, friend. Make sure your methods are 111 | [TomDoc](http://tomdoc.org)'d properly, that existing tests pass, and 112 | that any new functionality includes appropriate tests. 113 | 114 | Then [send me a pull request](https://github.com/bububa/MongoHub-Mac/pull/new/master)! 115 | 116 | ## Contact Me 117 | 118 | [Syd](mailto:prof.syd.xu@gmail.com) made this. Ping me on Twitter —[@bububa](http://twitter.com/bububa) — or [email](mailto:prof.syd.xu@gmail.com) me if you're having issues, or want me to merge in your pull request. -------------------------------------------------------------------------------- /Resourses/images/Icon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/Resourses/images/Icon.icns -------------------------------------------------------------------------------- /Resourses/images/collectionicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/Resourses/images/collectionicon.png -------------------------------------------------------------------------------- /Resourses/images/collectionmenu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/Resourses/images/collectionmenu.png -------------------------------------------------------------------------------- /Resourses/images/connecticon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/Resourses/images/connecticon.png -------------------------------------------------------------------------------- /Resourses/images/database.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/Resourses/images/database.png -------------------------------------------------------------------------------- /Resourses/images/dbicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/Resourses/images/dbicon.png -------------------------------------------------------------------------------- /Resourses/images/dbmenu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/Resourses/images/dbmenu.png -------------------------------------------------------------------------------- /Resourses/images/editicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/Resourses/images/editicon.png -------------------------------------------------------------------------------- /Resourses/images/exportbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/Resourses/images/exportbox.png -------------------------------------------------------------------------------- /Resourses/images/exportmenu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/Resourses/images/exportmenu.png -------------------------------------------------------------------------------- /Resourses/images/findmenu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/Resourses/images/findmenu.png -------------------------------------------------------------------------------- /Resourses/images/importbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/Resourses/images/importbox.png -------------------------------------------------------------------------------- /Resourses/images/importmenu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/Resourses/images/importmenu.png -------------------------------------------------------------------------------- /Resourses/images/indexmenu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/Resourses/images/indexmenu.png -------------------------------------------------------------------------------- /Resourses/images/insertmenu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/Resourses/images/insertmenu.png -------------------------------------------------------------------------------- /Resourses/images/key.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/Resourses/images/key.png -------------------------------------------------------------------------------- /Resourses/images/mapreducemenu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/Resourses/images/mapreducemenu.png -------------------------------------------------------------------------------- /Resourses/images/mongohub.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/Resourses/images/mongohub.ai -------------------------------------------------------------------------------- /Resourses/images/querymenu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/Resourses/images/querymenu.png -------------------------------------------------------------------------------- /Resourses/images/removemenu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/Resourses/images/removemenu.png -------------------------------------------------------------------------------- /Resourses/images/runmenu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/Resourses/images/runmenu.png -------------------------------------------------------------------------------- /Resourses/images/servermenu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/Resourses/images/servermenu.png -------------------------------------------------------------------------------- /Resourses/images/supportmenu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/Resourses/images/supportmenu.png -------------------------------------------------------------------------------- /Resourses/images/updatemenu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/Resourses/images/updatemenu.png -------------------------------------------------------------------------------- /ResultsOutlineViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ResultsOutlineViewController.h 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-4-26. 6 | // Copyright 2010 MusicPeace.ORG. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface ResultsOutlineViewController : NSObject{ 13 | IBOutlet NSOutlineView *myOutlineView; 14 | NSMutableArray *results; 15 | } 16 | 17 | @property (nonatomic, retain) NSOutlineView *myOutlineView; 18 | @property (nonatomic, retain) NSMutableArray *results; 19 | 20 | - (id)rootForItem:(id)item; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /ResultsOutlineViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ResultsOutlineViewController.m 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-4-26. 6 | // Copyright 2010 MusicPeace.ORG. All rights reserved. 7 | // 8 | 9 | #import "ResultsOutlineViewController.h" 10 | 11 | @implementation ResultsOutlineViewController 12 | 13 | @synthesize myOutlineView; 14 | @synthesize results; 15 | 16 | - (id)init 17 | { 18 | if (self = [super init]) { 19 | results = [[NSMutableArray alloc] init]; 20 | } 21 | 22 | return self; 23 | } 24 | 25 | - (void)dealloc { 26 | [myOutlineView deselectAll:nil]; 27 | [myOutlineView release]; 28 | [results release]; 29 | [super dealloc]; 30 | } 31 | 32 | - (void)awakeFromNib 33 | { 34 | [myOutlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:0] byExtendingSelection:NO]; 35 | } 36 | 37 | #pragma mark - 38 | #pragma mark NSOutlineView dataSource methods 39 | 40 | // Returns the child item at the specified index of a given item. 41 | - (id)outlineView:(NSOutlineView *)outlineView 42 | child:(int)index 43 | ofItem:(id)item 44 | { 45 | // If the item is the root item, return the corresponding mailbox object 46 | if([outlineView levelForItem:item] == -1) 47 | { 48 | return [results objectAtIndex:index]; 49 | } 50 | 51 | // If the item is a root-level item (ie mailbox) 52 | return [[item objectForKey:@"child" ] objectAtIndex:index]; 53 | } 54 | 55 | // Returns a Boolean value that indicates wheter a given item is expandable. 56 | - (BOOL)outlineView:(NSOutlineView *)outlineView 57 | isItemExpandable:(id)item 58 | { 59 | // If the item is a root-level item (ie mailbox) and it has emails in it, return true 60 | if(([[item objectForKey:@"child"] count] != 0)) 61 | return true; 62 | 63 | else 64 | return false; 65 | } 66 | 67 | // Returns the number of child items encompassed by a given item. 68 | - (int)outlineView:(NSOutlineView *)outlineView 69 | numberOfChildrenOfItem:(id)item 70 | { 71 | // If the item is the root item, return the number of mailboxes 72 | if([outlineView levelForItem:item] == -1) 73 | { 74 | return [results count]; 75 | } 76 | // If the item is a root-level item (ie mailbox) 77 | return [[item objectForKey:@"child" ] count]; 78 | } 79 | 80 | // Return the data object associated with the specified item. 81 | - (id)outlineView:(NSOutlineView *)outlineView 82 | objectValueForTableColumn:(NSTableColumn *)tableColumn 83 | byItem:(id)item 84 | { 85 | if([[tableColumn identifier] isEqualToString:@"name"]) 86 | { 87 | return [item objectForKey:@"name"]; 88 | } 89 | 90 | else if([[tableColumn identifier] isEqualToString:@"value"]) 91 | return [item objectForKey:@"value"]; 92 | else if([[tableColumn identifier] isEqualToString:@"type"]) 93 | return [item objectForKey:@"type"]; 94 | /*switch([outlineView levelForItem:item]) 95 | { 96 | // If the item is a root-level item 97 | case 0: 98 | if([[tableColumn identifier] isEqualToString:@"name"]) 99 | return [item objectForKey:@"name" ]; 100 | break; 101 | 102 | case 1: 103 | if([[tableColumn identifier] isEqualToString:@"name"]) 104 | { 105 | return [item objectForKey:@"name"]; 106 | } 107 | 108 | else if([[tableColumn identifier] isEqualToString:@"value"]) 109 | return [item objectForKey:@"value"]; 110 | else if([[tableColumn identifier] isEqualToString:@"type"]) 111 | return [item objectForKey:@"type"]; 112 | break; 113 | }*/ 114 | 115 | return nil; 116 | } 117 | 118 | #pragma mark - 119 | #pragma mark NSOutlineView delegate methods 120 | - (void)outlineViewSelectionDidChange:(NSNotification *)notification 121 | { 122 | switch([myOutlineView selectedRow]) 123 | { 124 | case -1: 125 | break; 126 | default:{ 127 | id currentItem = [myOutlineView itemAtRow:[myOutlineView selectedRow]]; 128 | if ([myOutlineView isItemExpanded:currentItem]) { 129 | [myOutlineView collapseItem:currentItem collapseChildren:YES]; 130 | }else { 131 | [myOutlineView expandItem:currentItem expandChildren:YES]; 132 | } 133 | break; 134 | } 135 | } 136 | } 137 | 138 | 139 | #pragma mark helper methods 140 | - (id)rootForItem:(id)item 141 | { 142 | id parentItem = [myOutlineView parentForItem:item]; 143 | if (parentItem) { 144 | return [self rootForItem:parentItem]; 145 | }else { 146 | return item; 147 | } 148 | 149 | } 150 | 151 | @end 152 | -------------------------------------------------------------------------------- /SSHCommand.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/expect -f 2 | #!/bin/sh 3 | 4 | # Copyright (C) 2008 Antoine Mercadal 5 | # 6 | # This program is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License 8 | # as published by the Free Software Foundation; either version 2 9 | # of the License, or (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | 20 | set arguments [lindex $argv 0] 21 | set password [lindex $argv 1] 22 | 23 | eval spawn $arguments 24 | 25 | match_max 100000 26 | 27 | set timeout 1 28 | #expect "*yes/no*" {send "yes\r"; exp_continue}; 29 | 30 | set timeout 30 31 | expect { 32 | "?sh: Error*" {puts "CONNECTION_ERROR"; exit}; 33 | "*yes/no*" {send "yes\r"; exp_continue}; 34 | "*Could not resolve hostname*" {puts "CONNECTION_REFUSED"; exit}; 35 | "*Operation timed out*" {puts "CONNECTION_REFUSED"; exit}; 36 | "*Connection refused*" {puts "CONNECTION_REFUSED"; exit}; 37 | "*?assword:*" { send "$password\r"; set timeout 4; 38 | expect "*?assword:*" {puts "WRONG_PASSWORD"; exit;} 39 | }; 40 | } 41 | 42 | puts "CONNECTED"; 43 | set timeout -1 44 | expect eof; 45 | 46 | -------------------------------------------------------------------------------- /Sidebar/Sidebar.h: -------------------------------------------------------------------------------- 1 | // 2 | // SidebarNode.m 3 | // Sidebar 4 | // 5 | // Created by Matteo Bertozzi on 3/8/09. 6 | // Copyright 2009 Matteo Bertozzi. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface Sidebar : NSOutlineView 12 | { 13 | @private 14 | NSArray *dragNodesArray; 15 | 16 | id _defaultActionTarget; 17 | SEL _defaultAction; 18 | 19 | NSMutableDictionary *_contents; 20 | NSMutableArray *_roots; 21 | } 22 | 23 | // Set Default Item Clicked Handler 24 | - (void)setDefaultAction:(SEL)action target:(id)target; 25 | 26 | 27 | // Add Root Folder Methods 28 | - (void)addSection:(id)key 29 | caption:(NSString *)folderCaption; 30 | 31 | // Add Child Methods 32 | - (void)addChild:(id)parentKey 33 | key:(id)key 34 | url:(NSString *)url; 35 | 36 | - (void)addChild:(id)parentKey 37 | key:(id)key 38 | url:(NSString *)url 39 | action:(SEL)aSelector 40 | target:(id)target; 41 | 42 | - (void)addChild:(id)parentKey 43 | key:(id)key 44 | caption:(NSString *)childCaption 45 | icon:(NSImage *)childIcon; 46 | 47 | - (void)addChild:(id)parentKey 48 | key:(id)key 49 | caption:(NSString *)childCaption 50 | icon:(NSImage *)childIcon 51 | action:(SEL)aSelector 52 | target:(id)target; 53 | 54 | - (void)addChild:(id)parentKey 55 | key:(id)key 56 | caption:(NSString *)childCaption 57 | icon:(NSImage *)childIcon 58 | data:(id)data; 59 | 60 | - (void)addChild:(id)parentKey 61 | key:(id)key 62 | caption:(NSString *)childCaption 63 | icon:(NSImage *)childIcon 64 | data:(id)data 65 | action:(SEL)aSelector 66 | target:(id)target; 67 | 68 | // Insert Child Methods 69 | - (void)insertChild:(id)parentKey 70 | key:(id)key 71 | atIndex:(NSUInteger)index 72 | url:(NSString *)url 73 | action:(SEL)aSelector 74 | target:(id)target; 75 | 76 | - (void)insertChild:(id)parentKey 77 | key:(id)key 78 | atIndex:(NSUInteger)index 79 | caption:(NSString *)childCaption 80 | icon:(NSImage *)childIcon 81 | action:(SEL)aSelector 82 | target:(id)target; 83 | 84 | - (void)insertChild:(id)parentKey 85 | key:(id)key 86 | atIndex:(NSUInteger)index 87 | caption:(NSString *)childCaption 88 | icon:(NSImage *)childIcon 89 | data:(id)data 90 | action:(SEL)aSelector 91 | target:(id)target; 92 | 93 | // Remove Methods 94 | - (void)removeItem:(id)key; 95 | - (void)removeChild:(id)key; 96 | - (void)removeFolder:(id)key; 97 | - (void)removeSection:(id)key; 98 | 99 | // Selection Methods 100 | - (void)selectItem:(id)key; 101 | - (void)unselectItem; 102 | 103 | // Expand/Collapse Metods 104 | - (void)expandAll; 105 | - (void)expandItem:(id)key; 106 | - (void)expandItem:(id)key expandChildren:(BOOL)expandChildren; 107 | 108 | - (void)collapseAll; 109 | - (void)collapseItem:(id)key; 110 | - (void)collapseItem:(id)key expandChildren:(BOOL)collapseChildren; 111 | 112 | // Set Badge 113 | - (void)setBadge:(id)key count:(NSInteger)badgeValue; 114 | - (void)unsetBadge:(id)key; 115 | 116 | @end 117 | 118 | -------------------------------------------------------------------------------- /Sidebar/SidebarBadgeCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // TSBadgeCell.h 3 | // Tahsis 4 | // 5 | // Created by Matteo Bertozzi on 11/29/08. 6 | // Copyright 2008 Matteo Bertozzi. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SidebarBadgeCell : NSTextFieldCell { 12 | @private 13 | NSUInteger _badgeCount; 14 | NSImage *_icon; 15 | BOOL _hasBadge; 16 | } 17 | 18 | @property (readwrite) NSUInteger badgeCount; 19 | @property (readwrite) BOOL hasBadge; 20 | @property (readonly) NSImage *icon; 21 | 22 | - (void)setIcon:(NSImage *)icon; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Sidebar/SidebarBadgeCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // TSBadgeCell.m 3 | // Tahsis 4 | // 5 | // Created by Matteo Bertozzi on 11/29/08. 6 | // Copyright 2008 Matteo Bertozzi. All rights reserved. 7 | // 8 | 9 | #import "SidebarBadgeCell.h" 10 | 11 | @interface SidebarBadgeCell (Private) 12 | - (CGFloat)drawBadge:(NSRect)cellFrame; 13 | @end 14 | 15 | @implementation SidebarBadgeCell 16 | 17 | #define TSBADGECELL_BUFFER_LEFT_SMALL 2 18 | #define TSBADGECELL_BUFFER_LEFT 4 19 | #define TSBADGECELL_BUFFER_SIDE 3 20 | #define TSBADGECELL_BUFFER_TOP 3 21 | #define TSBADGECELL_PADDING 6 22 | 23 | #define TSBADGECELL_CIRCLE_BUFFER_RIGHT 5 24 | 25 | #define TSBADGECELL_RADIUS_X 7 26 | #define TSBADGECELL_RADIUS_Y 8 27 | 28 | #define TSBADGECELL_TEXT_HEIGHT 14 29 | #define TSBADGECELL_TEXT_MINI 8 30 | #define TSBADGECELL_TEXT_SMALL 20 31 | 32 | #define TSBADGECELL_ICON_SIZE 16 33 | #define TSBADGECELL_ICON_HEIGHT_OFFSET 2 34 | 35 | @synthesize badgeCount = _badgeCount; 36 | @synthesize hasBadge = _hasBadge; 37 | @synthesize icon = _icon; 38 | 39 | - (void)dealloc { 40 | [_icon release]; 41 | [super dealloc]; 42 | } 43 | 44 | - (void)awakeFromNib { 45 | [self setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; 46 | _badgeCount = 0; 47 | _hasBadge = NO; 48 | _icon = nil; 49 | } 50 | 51 | - (id)copyWithZone:(NSZone*)zone { 52 | SidebarBadgeCell *cell = [super copyWithZone:zone]; 53 | cell->_icon = [_icon retain]; 54 | return cell; 55 | } 56 | 57 | - (void)setIcon:(NSImage *)icon { 58 | if (_icon != icon) { 59 | [_icon release]; 60 | _icon = [icon retain]; 61 | [_icon setFlipped:YES]; 62 | [_icon setSize:NSMakeSize(TSBADGECELL_ICON_SIZE, TSBADGECELL_ICON_SIZE)]; 63 | } 64 | } 65 | 66 | - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView*)controlView { 67 | bool drawBadge = (_hasBadge && cellFrame.size.width > TSBADGECELL_TEXT_SMALL * 3); 68 | CGFloat badgeWidth = (drawBadge ? [self drawBadge:cellFrame] : 0); 69 | 70 | if (_icon != nil) { 71 | // Draw Icon 72 | NSRect iconRect = cellFrame; 73 | iconRect.origin.y += TSBADGECELL_ICON_HEIGHT_OFFSET; 74 | iconRect.size.height = TSBADGECELL_ICON_SIZE; 75 | iconRect.size.width = TSBADGECELL_ICON_SIZE; 76 | [_icon drawInRect:iconRect fromRect:NSZeroRect 77 | operation:NSCompositeSourceOver fraction:1.0]; 78 | 79 | // Draw Rect 80 | NSRect labelRect = cellFrame; 81 | labelRect.origin.x += TSBADGECELL_ICON_SIZE + TSBADGECELL_BUFFER_LEFT; 82 | labelRect.size.width -= (badgeWidth + TSBADGECELL_ICON_SIZE + TSBADGECELL_BUFFER_LEFT); 83 | [super drawInteriorWithFrame:labelRect inView:controlView]; 84 | } else { 85 | NSRect labelRect = cellFrame; 86 | labelRect.size.width -= badgeWidth; 87 | [super drawInteriorWithFrame:labelRect inView:controlView]; 88 | } 89 | } 90 | 91 | - (CGFloat)drawBadge:(NSRect)cellFrame { 92 | // Setup Badge String and Size 93 | NSString *badge = [[NSString alloc] initWithFormat:@"%d", _badgeCount]; 94 | NSSize badgeNumSize = [badge sizeWithAttributes:nil]; 95 | NSFont *badgeFont = [self font]; 96 | 97 | // Calculate the Badge's coordinate 98 | CGFloat badgeWidth = badgeNumSize.width + TSBADGECELL_BUFFER_SIDE * 2; 99 | if (badgeNumSize.width < TSBADGECELL_TEXT_MINI) 100 | badgeWidth = TSBADGECELL_TEXT_SMALL; 101 | 102 | CGFloat badgeY = cellFrame.origin.y + TSBADGECELL_BUFFER_TOP; 103 | CGFloat badgeX = cellFrame.origin.x + cellFrame.size.width - 104 | TSBADGECELL_CIRCLE_BUFFER_RIGHT - badgeWidth; 105 | CGFloat badgeNumX = badgeX + TSBADGECELL_BUFFER_LEFT; 106 | if (badgeNumSize.width < TSBADGECELL_TEXT_MINI) 107 | badgeNumX += TSBADGECELL_BUFFER_LEFT_SMALL; 108 | 109 | // Draw the badge and number 110 | NSRect badgeRect = NSMakeRect(badgeX, badgeY, badgeWidth, TSBADGECELL_TEXT_HEIGHT); 111 | NSBezierPath *badgePath = [NSBezierPath bezierPathWithRoundedRect:badgeRect 112 | xRadius:TSBADGECELL_RADIUS_X 113 | yRadius:TSBADGECELL_RADIUS_Y]; 114 | 115 | BOOL isWindowFront = [[NSApp mainWindow] isVisible]; 116 | BOOL isViewInFocus = [[[[self controlView] window] firstResponder] isEqual:[self controlView]]; 117 | BOOL isCellHighlighted = [self isHighlighted]; 118 | 119 | NSDictionary *dict = [[NSMutableDictionary alloc] init]; 120 | [dict setValue:badgeFont forKey:NSFontAttributeName]; 121 | 122 | if (isWindowFront && isViewInFocus && isCellHighlighted) { 123 | [[NSColor whiteColor] set]; 124 | [dict setValue:[NSColor alternateSelectedControlColor] forKey:NSForegroundColorAttributeName]; 125 | } else if (isWindowFront && isViewInFocus && !isCellHighlighted) { 126 | [[NSColor colorWithCalibratedRed:0.53 green:0.60 blue:0.74 alpha:1.0] set]; 127 | [dict setValue:[NSColor whiteColor] forKey:NSForegroundColorAttributeName]; 128 | } else if (isWindowFront && isCellHighlighted) { 129 | [[NSColor whiteColor] set]; 130 | [dict setValue:[NSColor colorWithCalibratedRed:0.51 green:0.58 blue:0.72 alpha:1.0] forKey:NSForegroundColorAttributeName]; 131 | } else if (!isWindowFront && isCellHighlighted) { 132 | [[NSColor whiteColor] set]; 133 | [dict setValue:[NSColor disabledControlTextColor] forKey:NSForegroundColorAttributeName]; 134 | } else { 135 | [[NSColor disabledControlTextColor] set]; 136 | [dict setValue:[NSColor whiteColor] forKey:NSForegroundColorAttributeName]; 137 | } 138 | 139 | [badgePath fill]; 140 | [badge drawAtPoint:NSMakePoint(badgeNumX, badgeY) withAttributes:dict]; 141 | 142 | [badge release]; 143 | [dict release]; 144 | return badgeWidth + TSBADGECELL_PADDING; 145 | } 146 | 147 | @end 148 | -------------------------------------------------------------------------------- /Sidebar/SidebarNode.h: -------------------------------------------------------------------------------- 1 | // 2 | // SidebarNode.h 3 | // Sidebar 4 | // 5 | // Created by Matteo Bertozzi on 3/8/09. 6 | // Copyright 2009 Matteo Bertozzi. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #define kSidebarNodeTypeSection 0x01 12 | #define kSidebarNodeTypeFolder 0x02 13 | #define kSidebarNodeTypeItem 0x03 14 | 15 | @interface SidebarNode : NSObject { 16 | NSMutableArray *children; 17 | id parentKey; 18 | id nodeKey; 19 | 20 | NSString *caption; 21 | NSImage *icon; 22 | int nodeType; 23 | id data; 24 | 25 | NSInteger badgeValue; 26 | BOOL hasBadge; 27 | 28 | id actionTarget; 29 | SEL action; 30 | } 31 | 32 | @property (assign, readonly) id actionTarget; 33 | @property (assign, readonly) SEL action; 34 | 35 | @property (assign, readonly) NSInteger badgeValue; 36 | @property (assign, readonly) BOOL hasBadge; 37 | 38 | @property (retain) NSString *caption; 39 | @property (retain) NSImage *icon; 40 | @property (assign) id parentKey; 41 | @property (assign) int nodeType; 42 | @property (assign) id nodeKey; 43 | @property (retain) id data; 44 | 45 | - (void)setAction:(SEL)aSelector target:(id)target; 46 | - (BOOL)hasAction; 47 | 48 | - (void)setBadgeValue:(NSInteger)value; 49 | - (void)unsetBadgeValue; 50 | 51 | - (void)addChild:(SidebarNode *)node; 52 | - (void)insertChild:(SidebarNode *)node atIndex:(NSUInteger)index; 53 | - (void)removeChild:(SidebarNode *)node; 54 | - (NSInteger)indexOfChild:(SidebarNode *)node; 55 | 56 | - (SidebarNode *)childAtIndex:(int)index; 57 | 58 | - (NSUInteger)numberOfChildren; 59 | 60 | - (BOOL)isDraggable; 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /Sidebar/SidebarNode.m: -------------------------------------------------------------------------------- 1 | // 2 | // SidebarNode.m 3 | // Sidebar 4 | // 5 | // Created by Matteo Bertozzi on 3/8/09. 6 | // Copyright 2009 Matteo Bertozzi. All rights reserved. 7 | // 8 | 9 | #import "SidebarNode.h" 10 | 11 | @implementation SidebarNode 12 | 13 | @synthesize actionTarget; 14 | @synthesize action; 15 | 16 | @synthesize badgeValue; 17 | @synthesize hasBadge; 18 | 19 | @synthesize parentKey; 20 | @synthesize nodeType; 21 | @synthesize nodeKey; 22 | @synthesize caption; 23 | @synthesize icon; 24 | @synthesize data; 25 | 26 | - (id)init { 27 | if ((self = [super init])) { 28 | children = [[NSMutableArray alloc] init]; 29 | hasBadge = NO; 30 | } 31 | 32 | return self; 33 | } 34 | 35 | - (void)dealloc { 36 | [children release]; 37 | 38 | [caption release]; 39 | [icon release]; 40 | [data release]; 41 | 42 | [super dealloc]; 43 | } 44 | 45 | - (void)setAction:(SEL)aSelector target:(id)target { 46 | actionTarget = target; 47 | action = aSelector; 48 | } 49 | 50 | - (BOOL)hasAction { 51 | return(action != NULL); 52 | } 53 | 54 | - (void)setBadgeValue:(NSInteger)value { 55 | hasBadge = YES; 56 | badgeValue = value; 57 | } 58 | 59 | - (void)unsetBadgeValue { 60 | hasBadge = NO; 61 | } 62 | 63 | - (void)addChild:(SidebarNode *)node { 64 | [children addObject:node]; 65 | } 66 | 67 | - (void)insertChild:(SidebarNode *)node atIndex:(NSUInteger)index { 68 | [children insertObject:node atIndex:index]; 69 | } 70 | 71 | - (void)removeChild:(SidebarNode *)node { 72 | [children removeObject:node]; 73 | } 74 | 75 | - (NSInteger)indexOfChild:(SidebarNode *)node { 76 | return [children indexOfObject:node]; 77 | } 78 | 79 | - (SidebarNode *)childAtIndex:(int)index { 80 | return([children objectAtIndex:index]); 81 | } 82 | 83 | - (NSUInteger)numberOfChildren { 84 | return([children count]); 85 | } 86 | 87 | - (BOOL)isDraggable { 88 | return(nodeType != kSidebarNodeTypeSection); 89 | } 90 | 91 | @end 92 | -------------------------------------------------------------------------------- /StatMonitorTableController.h: -------------------------------------------------------------------------------- 1 | // 2 | // statMonitorArrayController.h 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-12-23. 6 | // Copyright 2010 ThePeppersStudio.COM. All rights reserved. 7 | // 8 | 9 | #import 10 | @class BWTransparentTableView; 11 | 12 | @interface StatMonitorTableController : NSControl { 13 | NSMutableArray * nsMutaryDataObj; 14 | IBOutlet BWTransparentTableView *nsTableView; 15 | } 16 | 17 | @property (nonatomic, retain) NSMutableArray * nsMutaryDataObj; 18 | @property (nonatomic, retain) BWTransparentTableView *nsTableView; 19 | 20 | - (void)addObject:(NSDictionary *)item; 21 | - (int)numberOfRowsInTableView:(NSTableView *)pTableViewObj; 22 | 23 | - (id) tableView:(NSTableView *)pTableViewObj 24 | objectValueForTableColumn:(NSTableColumn *)pTableColumn 25 | row:(int)pRowIndex; 26 | 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /StatMonitorTableController.m: -------------------------------------------------------------------------------- 1 | // 2 | // statMonitorArrayController.m 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-12-23. 6 | // Copyright 2010 ThePeppersStudio.COM. All rights reserved. 7 | // 8 | 9 | #import "StatMonitorTableController.h" 10 | #import 11 | 12 | @implementation StatMonitorTableController 13 | @synthesize nsMutaryDataObj; 14 | @synthesize nsTableView; 15 | 16 | 17 | - (void)dealloc { 18 | [nsMutaryDataObj release]; 19 | [nsTableView release]; 20 | [super dealloc]; 21 | } 22 | 23 | - (void)addObject:(NSDictionary *)item { 24 | if (!nsMutaryDataObj) 25 | nsMutaryDataObj = [[NSMutableArray alloc] initWithObjects:item, nil]; 26 | else 27 | [nsMutaryDataObj addObject:item]; 28 | [nsTableView reloadData]; 29 | NSInteger numberOfRows = [nsTableView numberOfRows]; 30 | 31 | if (numberOfRows > 0) 32 | [nsTableView scrollRowToVisible:numberOfRows - 1]; 33 | } 34 | 35 | - (int)numberOfRowsInTableView:(NSTableView *)pTableViewObj { 36 | return [self.nsMutaryDataObj count]; 37 | } // end numberOfRowsInTableView 38 | 39 | 40 | - (id) tableView:(NSTableView *)pTableViewObj 41 | objectValueForTableColumn:(NSTableColumn *)pTableColumn 42 | row:(int)pRowIndex { 43 | NSDictionary * zDataObject = [self.nsMutaryDataObj objectAtIndex:pRowIndex]; 44 | if (! zDataObject) { 45 | NSLog(@"tableView: objectAtIndex:%d = NULL",pRowIndex); 46 | return NULL; 47 | } // end if 48 | return [zDataObject objectForKey:[pTableColumn identifier]]; 49 | 50 | } // end tableView:objectValueForTableColumn:row: 51 | 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /Syntax Definitions/CSS 1.plist: -------------------------------------------------------------------------------- 1 | Components Color 0.349020 0.521569 0.784314 Start { End } IgnoredComponent Strings Name Tags Type Tag Color 0.349020 0.521569 0.784314 Start " End " EscapeChar Name Strings Type String Color 0.894118 0.015686 0.015686 Keywords background: background-attachment: background-color: background-image: background-position: background-repeat: border: border-bottom: border-bottom-color: border-bottom-style: border-bottom-width: border-color: border-left: border-left-color: border-left-style: border-left-width: border-right: border-right-color: border-right-style: border-right-width: border-style: border-top: border-top-color: border-top-style: border-top-width: border-width: clear: cursor: display: float: position: visibility: height: line-height: max-height: min-height: min-width: width: font: font-family: font-size: font-size-adjust: font-strech: font-style: font-variant: font-weight: content: counter-increment: counter-reset: quotes: list-style: list-style-image: list-style-position: list-style-type: marker-offset: margin: margin-bottom: margin-left: margin-right: margin-top: outline: outline-color: outline-style: outline-width: padding: padding-bottom: padding-left: padding-right: padding-top: bottom: clip: left: overflow: right: top: vertical-align: z-index: border-collapse: border-spacing: caption-side: empty-cells: table-layout: color: direction: letter-spacing: text-align: text-decoration: text-indent: text-shadow: text-transform: unicode-bidi: white-space: word-spacing: Name Identifiers Type Keywords Color 0.137255 0.431373 0.145098 Start /* End */ Name Comments Type BlockComment FileNameSuffixes css -------------------------------------------------------------------------------- /Syntax Definitions/HTML.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Components 6 | 7 | 8 | Color 9 | 10 | 1 11 | 1 12 | 1 13 | 14 | End 15 | " 16 | EscapeChar 17 | 18 | Name 19 | Strings 20 | Start 21 | " 22 | Type 23 | String 24 | 25 | 26 | Color 27 | 28 | 0 29 | 0 30 | 1 31 | 32 | End 33 | > 34 | IgnoredComponent 35 | Strings 36 | Name 37 | Tags 38 | Start 39 | < 40 | Type 41 | Tag 42 | 43 | 44 | Color 45 | 46 | 0.29999999999999999 47 | 0.29999999999999999 48 | 0.29999999999999999 49 | 50 | End 51 | " 52 | EscapeChar 53 | 54 | Name 55 | Strings 56 | Start 57 | " 58 | Type 59 | String 60 | 61 | 62 | Color 63 | 64 | 0.20000000000000001 65 | 0.5 66 | 0.20000000000000001 67 | 68 | Keywords 69 | 70 | &lt; 71 | &gt; 72 | &amp; 73 | &auml; 74 | &uuml; 75 | &ouml; 76 | 77 | Name 78 | Identifiers 79 | Type 80 | Keywords 81 | 82 | 83 | Color 84 | 85 | 1 86 | 0 87 | 0 88 | 89 | End 90 | --> 91 | Name 92 | Comments 93 | Start 94 | <!-- 95 | Type 96 | BlockComment 97 | 98 | 99 | FileNameSuffixes 100 | 101 | htm 102 | html 103 | phtm 104 | phtml 105 | 106 | 107 | 108 | -------------------------------------------------------------------------------- /Syntax Definitions/JSON.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Components 6 | 7 | 8 | Color 9 | 10 | 1 11 | 1 12 | 1 13 | 14 | End 15 | " 16 | EscapeChar 17 | 18 | Name 19 | QuoteStringsValue 20 | Start 21 | " 22 | Type 23 | String 24 | 25 | 26 | Color 27 | 28 | 0 29 | 1 30 | 0 31 | 32 | Keywords 33 | 34 | :true 35 | : true 36 | 37 | Name 38 | IdentifiersTrue 39 | Type 40 | Keywords 41 | 42 | 43 | Color 44 | 45 | 1 46 | 0 47 | 0 48 | 49 | Keywords 50 | 51 | :null 52 | : null 53 | :false 54 | : false 55 | 56 | Name 57 | IdentifiersFalse 58 | Type 59 | Keywords 60 | 61 | 62 | Color 63 | 64 | 1 65 | 1 66 | 0 67 | 68 | Keywords 69 | 70 | { 71 | } 72 | [ 73 | ] 74 | " 75 | , 76 | : 77 | 78 | Name 79 | IdentifiersMark 80 | Type 81 | Keywords 82 | 83 | 84 | Color 85 | 86 | 0.2627450980392157 87 | 0.66666666666666663 88 | 1 89 | 90 | Keywords 91 | 92 | "_id" 93 | 94 | Name 95 | IdentifiersID 96 | Type 97 | Keywords 98 | 99 | 100 | Color 101 | 102 | 0.2627450980392157 103 | 0.66666666666666663 104 | 1 105 | 106 | End 107 | " 108 | Name 109 | Operator 110 | Start 111 | "$ 112 | Type 113 | String 114 | 115 | 116 | Color 117 | 118 | 1 119 | 0.56470588235294117 120 | 0 121 | 122 | End 123 | ) 124 | Name 125 | JSONObj 126 | Start 127 | Date( 128 | Type 129 | String 130 | 131 | 132 | Color 133 | 134 | 1 135 | 0.56470588235294117 136 | 0 137 | 138 | End 139 | ) 140 | Name 141 | JSONObj 142 | Start 143 | ObjectId( 144 | Type 145 | String 146 | 147 | 148 | Color 149 | 150 | 1 151 | 0.56470588235294117 152 | 0 153 | 154 | End 155 | ) 156 | Name 157 | JSONObj 158 | Start 159 | Def( 160 | Type 161 | String 162 | 163 | 164 | 165 | 166 | -------------------------------------------------------------------------------- /Syntax Definitions/Objective C.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | OneLineCommentPrefix 6 | // 7 | Components 8 | 9 | 10 | Color 11 | 12 | 1 13 | 1 14 | 1 15 | 16 | End 17 | " 18 | EscapeChar 19 | \ 20 | Name 21 | Strings 22 | Start 23 | " 24 | Type 25 | String 26 | 27 | 28 | Charset 29 | ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz@_1234567890 30 | Color 31 | 32 | 0.2 33 | 0.5 34 | 0.2 35 | 36 | Keywords 37 | 38 | super 39 | id 40 | void 41 | self 42 | return 43 | @selector 44 | @encode 45 | @interface 46 | @implementation 47 | @protocol 48 | @end 49 | @property 50 | @synthesize 51 | @synchronized 52 | @class 53 | @try 54 | @catch 55 | @finally 56 | @private 57 | @protected 58 | @required 59 | @optional 60 | enum 61 | in 62 | typedef 63 | unsigned 64 | signed 65 | char 66 | unichar 67 | long 68 | int 69 | short 70 | float 71 | double 72 | nil 73 | else 74 | if 75 | do 76 | while 77 | for 78 | break 79 | case 80 | default 81 | continue 82 | goto 83 | switch 84 | const 85 | static 86 | volatile 87 | extern 88 | IBAction 89 | IBOutlet 90 | BOOL 91 | YES 92 | NO 93 | NS_DURING 94 | NS_HANDLER 95 | NS_ENDHANDLER 96 | NS_VOIDRETURN 97 | NS_VALUERETURN 98 | Class 99 | SEL 100 | 101 | Name 102 | Identifiers 103 | Type 104 | Keywords 105 | 106 | 107 | Charset 108 | ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz@_1234567890 109 | Name 110 | UserIdentifiers 111 | Type 112 | Keywords 113 | 114 | 115 | Name 116 | Preprocessor 117 | Start 118 | #define 119 | Type 120 | OneLineComment 121 | 122 | 123 | Name 124 | Preprocessor 125 | Start 126 | #include 127 | Type 128 | OneLineComment 129 | 130 | 131 | Name 132 | Preprocessor 133 | Start 134 | #import 135 | Type 136 | OneLineComment 137 | 138 | 139 | Name 140 | Preprocessor 141 | Start 142 | #if 143 | Type 144 | OneLineComment 145 | 146 | 147 | Name 148 | Preprocessor 149 | Start 150 | #else 151 | Type 152 | OneLineComment 153 | 154 | 155 | Name 156 | Preprocessor 157 | Start 158 | #elif 159 | Type 160 | OneLineComment 161 | 162 | 163 | Name 164 | Preprocessor 165 | Start 166 | #endif 167 | Type 168 | OneLineComment 169 | 170 | 171 | Name 172 | Preprocessor 173 | Start 174 | #undef 175 | Type 176 | OneLineComment 177 | 178 | 179 | Name 180 | Preprocessor 181 | Start 182 | #pragma 183 | Type 184 | OneLineComment 185 | 186 | 187 | Name 188 | Comments 189 | Start 190 | // 191 | Type 192 | OneLineComment 193 | 194 | 195 | Color 196 | 197 | 1 198 | 0 199 | 0 200 | 201 | End 202 | */ 203 | Name 204 | Comments 205 | Start 206 | /* 207 | Type 208 | BlockComment 209 | 210 | 211 | FileNameSuffixes 212 | 213 | m 214 | mm 215 | h 216 | 217 | 218 | 219 | -------------------------------------------------------------------------------- /SyntaxColorDefaults.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SyntaxColoring:Color:Comments 6 | 7 | 1 8 | 0 9 | 0 10 | 11 | SyntaxColoring:Color:Comments2 12 | 13 | 0.80000000000000004 14 | 0 15 | 0 16 | 17 | SyntaxColoring:Color:Identifiers 18 | 19 | 0 20 | 0 21 | 1 22 | 23 | SyntaxColoring:Color:Identifiers2 24 | 25 | 0.0 26 | 0.25097999999999998 27 | 0.50196099999999999 28 | 29 | SyntaxColoring:Color:Preprocessor 30 | 31 | 0 32 | 0.40000000000000002 33 | 0 34 | 35 | SyntaxColoring:Color:Strings 36 | 37 | 0.40000000596046448 38 | 0.40000000596046448 39 | 0.40000000596046448 40 | 41 | SyntaxColoring:Color:Tags 42 | 43 | 0 44 | 0 45 | 0.59999999999999998 46 | 47 | SyntaxColoring:Color:UserIdentifiers 48 | 49 | 1.0 50 | 0.95097999999999998 51 | 0.50196099999999999 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /SyntaxDefinition.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Components 6 | 7 | 8 | Color 9 | 10 | 1 11 | 1 12 | 1 13 | 14 | End 15 | " 16 | EscapeChar 17 | 18 | Name 19 | Strings 20 | Start 21 | " 22 | Type 23 | String 24 | 25 | 26 | Color 27 | 28 | 0 29 | 0 30 | 1 31 | 32 | End 33 | > 34 | IgnoredComponent 35 | Strings 36 | Name 37 | Tags 38 | Start 39 | < 40 | Type 41 | Tag 42 | 43 | 44 | Color 45 | 46 | 0.29999999999999999 47 | 0.29999999999999999 48 | 0.29999999999999999 49 | 50 | End 51 | " 52 | EscapeChar 53 | 54 | Name 55 | Strings 56 | Start 57 | " 58 | Type 59 | String 60 | 61 | 62 | Color 63 | 64 | 0.20000000000000001 65 | 0.5 66 | 0.20000000000000001 67 | 68 | Keywords 69 | 70 | &lt; 71 | &gt; 72 | &amp; 73 | &auml; 74 | &uuml; 75 | &ouml; 76 | 77 | Name 78 | Identifiers 79 | Type 80 | Keywords 81 | 82 | 83 | Color 84 | 85 | 1 86 | 0 87 | 0 88 | 89 | End 90 | --> 91 | Name 92 | Comments 93 | Start 94 | <!-- 95 | Type 96 | BlockComment 97 | 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /Tunnel.h: -------------------------------------------------------------------------------- 1 | // 2 | // Tunnel.h 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-12-15. 6 | // Copyright 2010 ThePeppersStudio.COM. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface Tunnel : NSObject { 12 | id delegate; 13 | 14 | NSLock* lock; 15 | NSTask* task; 16 | NSPipe* pipe; 17 | NSString* pipeData; 18 | NSDate* startDate; 19 | NSString* retStatus; 20 | BOOL isRunning; 21 | 22 | NSString* uid; 23 | NSString* name; 24 | NSString* host; 25 | int port; 26 | NSString* user; 27 | NSString* password; 28 | NSString* keyfile; 29 | int aliveInterval; 30 | int aliveCountMax; 31 | BOOL tcpKeepAlive; 32 | BOOL compression; 33 | NSString* additionalArgs; 34 | NSMutableArray* portForwardings; 35 | } 36 | 37 | @property(retain) NSString* uid; 38 | @property(retain) NSString* name; 39 | @property(retain) NSString* host; 40 | @property(assign) int port; 41 | @property(retain) NSString* user; 42 | @property(retain) NSString* password; 43 | @property(retain) NSString* keyfile; 44 | @property(assign) int aliveInterval; 45 | @property(assign) int aliveCountMax; 46 | @property(assign) BOOL tcpKeepAlive; 47 | @property(assign) BOOL compression; 48 | @property(retain) NSString* additionalArgs; 49 | @property(retain) NSMutableArray* portForwardings; 50 | 51 | - (void)setDelegate:(id)val; 52 | - (id)delegate; 53 | 54 | -(BOOL) running; 55 | -(BOOL) checkProcess; 56 | -(void) start; 57 | -(void) stop; 58 | -(void) readStatus; 59 | -(NSArray*) prepareSSHCommandArgs; 60 | 61 | -(void) tunnelLoaded; 62 | -(void) tunnelSaved; 63 | -(void) tunnelRemoved; 64 | 65 | -(BOOL) keychainItemExists; 66 | -(BOOL) keychainAddItem; 67 | -(BOOL) keychainModifyItem; 68 | -(BOOL) keychainDeleteItem; 69 | -(NSString*) keychainGetPassword; 70 | -(NSString*) keychainGetPasswordFromItemRef: (SecKeychainItemRef)item; 71 | 72 | @end 73 | 74 | @interface NSObject (Tunnel) 75 | 76 | - (void) tunnelStatusChanged: (Tunnel*) tunnel status: (NSString*) status; 77 | 78 | @end -------------------------------------------------------------------------------- /UKSyntaxColoredTextViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // UKSyntaxColoredTextViewController.h 3 | // UKSyntaxColoredDocument 4 | // 5 | // Created by Uli Kusterer on 13.03.10. 6 | // Copyright 2010 Uli Kusterer. 7 | // 8 | // This software is provided 'as-is', without any express or implied 9 | // warranty. In no event will the authors be held liable for any damages 10 | // arising from the use of this software. 11 | // 12 | // Permission is granted to anyone to use this software for any purpose, 13 | // including commercial applications, and to alter it and redistribute it 14 | // freely, subject to the following restrictions: 15 | // 16 | // 1. The origin of this software must not be misrepresented; you must not 17 | // claim that you wrote the original software. If you use this software 18 | // in a product, an acknowledgment in the product documentation would be 19 | // appreciated but is not required. 20 | // 21 | // 2. Altered source versions must be plainly marked as such, and must not be 22 | // misrepresented as being the original software. 23 | // 24 | // 3. This notice may not be removed or altered from any source 25 | // distribution. 26 | // 27 | 28 | // ----------------------------------------------------------------------------- 29 | // Headers: 30 | // ----------------------------------------------------------------------------- 31 | 32 | #import 33 | 34 | 35 | // ----------------------------------------------------------------------------- 36 | // Constants: 37 | // ----------------------------------------------------------------------------- 38 | 39 | #define TD_USER_DEFINED_IDENTIFIERS @"SyntaxColoring:UserIdentifiers" // Key in user defaults holding user-defined identifiers to colorize. 40 | #define TD_SYNTAX_COLORING_MODE_ATTR @"UKTextDocumentSyntaxColoringMode" // Anything we colorize gets this attribute. 41 | 42 | 43 | @class UKSyntaxColoredTextViewController; 44 | 45 | @protocol UKSyntaxColoredTextViewDelegate 46 | 47 | @optional 48 | -(void) textViewControllerWillStartSyntaxRecoloring: (UKSyntaxColoredTextViewController*)sender; // Show your progress indicator. 49 | -(void) textViewControllerProgressedWhileSyntaxRecoloring: (UKSyntaxColoredTextViewController*)sender; // Make sure it gets redrawn. 50 | -(void) textViewControllerDidFinishSyntaxRecoloring: (UKSyntaxColoredTextViewController*)sender; // Hide your progress indicator. 51 | 52 | -(void) selectionInTextViewController: (UKSyntaxColoredTextViewController*)sender // Update any selection status display. 53 | changedToStartCharacter: (NSUInteger)startCharInLine endCharacter: (NSUInteger)endCharInLine 54 | inLine: (NSUInteger)lineInDoc startCharacterInDocument: (NSUInteger)startCharInDoc 55 | endCharacterInDocument: (NSUInteger)endCharInDoc; 56 | 57 | -(NSString*) syntaxDefinitionFilenameForTextViewController: (UKSyntaxColoredTextViewController*)sender; 58 | -(NSDictionary*) syntaxDefinitionDictionaryForTextViewController: (UKSyntaxColoredTextViewController*)sender; 59 | 60 | @end 61 | 62 | 63 | 64 | // ----------------------------------------------------------------------------- 65 | // Class: 66 | // ----------------------------------------------------------------------------- 67 | 68 | @interface UKSyntaxColoredTextViewController : NSViewController 69 | { 70 | BOOL autoSyntaxColoring; // Automatically refresh syntax coloring when text is changed? 71 | BOOL maintainIndentation; // Keep new lines indented at same depth as their predecessor? 72 | NSTimer* recolorTimer; // Timer used to do the actual recoloring a little while after the last keypress. 73 | BOOL syntaxColoringBusy; // Set while recolorRange is busy, so we don't recursively call recolorRange. 74 | NSRange affectedCharRange; 75 | NSString* replacementString; 76 | id delegate; 77 | } 78 | 79 | +(void) makeSurePrefsAreInited; // No need to call this. 80 | 81 | -(void) setDelegate: (id)delegate; 82 | -(id) delegate; 83 | 84 | -(IBAction) recolorCompleteFile: (id)sender; 85 | -(IBAction) toggleAutoSyntaxColoring: (id)sender; 86 | -(IBAction) toggleMaintainIndentation: (id)sender; 87 | -(IBAction) indentSelection: (id)sender; 88 | -(IBAction) unindentSelection: (id)sender; 89 | -(IBAction) toggleCommentForSelection: (id)sender; 90 | 91 | -(void) setAutoSyntaxColoring: (BOOL)state; 92 | -(BOOL) autoSyntaxColoring; 93 | 94 | -(void) setMaintainIndentation: (BOOL)state; 95 | -(BOOL) maintainIndentation; 96 | 97 | -(void) goToLine: (int)lineNum; 98 | -(void) goToCharacter: (int)charNum; 99 | -(void) goToRangeFrom: (int)startCh toChar: (int)endCh; 100 | 101 | // Override any of the following in one of your subclasses to customize this object further: 102 | -(NSString*) syntaxDefinitionFilename; // Defaults to "SyntaxDefinition.plist" in the app bundle's "Resources" directory. 103 | -(NSDictionary*) syntaxDefinitionDictionary; // Defaults to loading from -syntaxDefinitionFilename. 104 | 105 | -(NSDictionary*) defaultTextAttributes; // Style attributes dictionary for an NSAttributedString. 106 | 107 | // Private: 108 | -(void) turnOffWrapping; 109 | 110 | -(void) recolorRange: (NSRange) range; 111 | 112 | -(void) colorOneLineComment: (NSString*) startCh inString: (NSMutableAttributedString*) s 113 | withColor: (NSColor*) col andMode:(NSString*)attr; 114 | -(void) colorCommentsFrom: (NSString*) startCh to: (NSString*) endCh inString: (NSMutableAttributedString*) s 115 | withColor: (NSColor*) col andMode:(NSString*)attr; 116 | -(void) colorIdentifier: (NSString*) ident inString: (NSMutableAttributedString*) s 117 | withColor: (NSColor*) col andMode:(NSString*)attr charset: (NSCharacterSet*)cset; 118 | -(void) colorStringsFrom: (NSString*) startCh to: (NSString*) endCh inString: (NSMutableAttributedString*) s 119 | withColor: (NSColor*) col andMode:(NSString*)attr andEscapeChar: (NSString*)vStringEscapeCharacter; 120 | -(void) colorTagFrom: (NSString*) startCh to: (NSString*)endCh inString: (NSMutableAttributedString*) s 121 | withColor: (NSColor*) col andMode:(NSString*)attr exceptIfMode: (NSString*)ignoreAttr; 122 | 123 | @end 124 | -------------------------------------------------------------------------------- /main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // MongoHub 4 | // 5 | // Created by Syd on 10-4-24. 6 | // Copyright MusicPeace.ORG 2010. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | return NSApplicationMain(argc, (const char **) argv); 14 | } 15 | -------------------------------------------------------------------------------- /screenshots/Edit Connection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/screenshots/Edit Connection.png -------------------------------------------------------------------------------- /screenshots/Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/screenshots/Icon.png -------------------------------------------------------------------------------- /screenshots/Icon32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/screenshots/Icon32.png -------------------------------------------------------------------------------- /screenshots/MongoHubWall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/screenshots/MongoHubWall.png -------------------------------------------------------------------------------- /screenshots/connections-window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/screenshots/connections-window.png -------------------------------------------------------------------------------- /screenshots/databases-window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/screenshots/databases-window.png -------------------------------------------------------------------------------- /screenshots/edit-connection2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/screenshots/edit-connection2.png -------------------------------------------------------------------------------- /screenshots/jsoneditor-window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/screenshots/jsoneditor-window.png -------------------------------------------------------------------------------- /screenshots/mongostats-monitor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/screenshots/mongostats-monitor.png -------------------------------------------------------------------------------- /screenshots/query-window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/screenshots/query-window.png -------------------------------------------------------------------------------- /screenshots/screenshot.pxm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub-Mac/304eeae7c9d3bd6e0053f8af209ca88c86f921c4/screenshots/screenshot.pxm --------------------------------------------------------------------------------