Skip to content

Commit

Permalink
fixed several crash bugs;
Browse files Browse the repository at this point in the history
fixed a json parser related bug;
add json object editor.
  • Loading branch information
bububa committed Dec 27, 2010
1 parent e224ebf commit a360773
Show file tree
Hide file tree
Showing 29 changed files with 6,157 additions and 4,295 deletions.
2 changes: 2 additions & 0 deletions Configure.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@
#define kAuthWindowWillClose @"AuthWindowWillClose"
#define kImportWindowWillClose @"ImportWindowWillClose"
#define kExportWindowWillClose @"ExportWindowWillClose"
#define kJsonWindowWillClose @"kJsonWindowWillClose"
#define kJsonWindowSaved @"kJsonWindowSaved"
53 changes: 37 additions & 16 deletions ConnectionWindow.xib
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="192"/>
<integer value="101"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
Expand Down Expand Up @@ -356,7 +357,7 @@
</object>
<string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string>
<object class="NSView" key="NSWindowView" id="1006">
<nil key="NSNextResponder"/>
<reference key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
Expand Down Expand Up @@ -784,7 +785,6 @@
</object>
<int key="NSResizingMask">3</int>
<bool key="NSIsResizeable">YES</bool>
<bool key="NSIsEditable">YES</bool>
<reference key="NSTableView" ref="317356685"/>
</object>
<object class="NSTableColumn" id="930410283">
Expand Down Expand Up @@ -815,7 +815,6 @@
</object>
<int key="NSResizingMask">3</int>
<bool key="NSIsResizeable">YES</bool>
<bool key="NSIsEditable">YES</bool>
<reference key="NSTableView" ref="317356685"/>
</object>
<object class="NSTableColumn" id="161070376">
Expand Down Expand Up @@ -846,22 +845,26 @@
<reference key="NSSupport" ref="669454261"/>
<reference key="NSControlView" ref="317356685"/>
<reference key="NSBackgroundColor" ref="735011394"/>
<object class="NSColor" key="NSTextColor">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MC4yMDAwMDAwMDMgMC4yMDAwMDAwMDMgMC4yMDAwMDAwMDMAA</bytes>
</object>
<reference key="NSTextColor" ref="993397510"/>
</object>
<int key="NSResizingMask">3</int>
<bool key="NSIsResizeable">YES</bool>
<bool key="NSIsEditable">YES</bool>
<reference key="NSTableView" ref="317356685"/>
</object>
</object>
<double key="NSIntercellSpacingWidth">3</double>
<double key="NSIntercellSpacingHeight">2</double>
<reference key="NSBackgroundColor" ref="435123289"/>
<double key="NSIntercellSpacingHeight">0.0</double>
<object class="NSColor" key="NSBackgroundColor">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">_sourceListBackgroundColor</string>
<object class="NSColor" key="NSColor">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MC44MzkyMTU2OTU5IDAuODY2NjY2Njc0NiAwLjg5ODAzOTIyMTgAA</bytes>
</object>
</object>
<reference key="NSGridColor" ref="61944251"/>
<double key="NSRowHeight">17</double>
<double key="NSRowHeight">20</double>
<int key="NSTvFlags">-759169024</int>
<reference key="NSDelegate"/>
<reference key="NSDataSource"/>
Expand All @@ -870,7 +873,9 @@
<int key="NSDraggingSourceMaskForLocal">15</int>
<int key="NSDraggingSourceMaskForNonLocal">0</int>
<bool key="NSAllowsTypeSelect">YES</bool>
<int key="NSTableViewDraggingDestinationStyle">0</int>
<int key="NSTableViewSelectionHighlightStyle">1</int>
<int key="NSTableViewDraggingDestinationStyle">1</int>
<float key="NSOutlineViewIndentationPerLevelKey">14</float>
</object>
</object>
<string key="NSFrame">{{0, 17}, {447, 331}}</string>
Expand Down Expand Up @@ -929,7 +934,7 @@
<reference key="NSContentView" ref="99471935"/>
<reference key="NSHeaderClipView" ref="281002724"/>
<reference key="NSCornerView" ref="985076206"/>
<bytes key="NSScrollAmts">QSAAAEEgAABBmAAAQZgAAA</bytes>
<bytes key="NSScrollAmts">QSAAAEEgAABBoAAAQaAAAA</bytes>
</object>
</object>
<string key="NSFrame">{{155, 0}, {447, 374}}</string>
Expand All @@ -946,6 +951,7 @@
</object>
</object>
<string key="NSFrameSize">{602, 374}</string>
<reference key="NSSuperview"/>
<int key="NSViewLayerContentsRedrawPolicy">2</int>
</object>
<string key="NSScreenRect">{{0, 0}, {1680, 1028}}</string>
Expand Down Expand Up @@ -3515,6 +3521,7 @@ ZQCUhAEqhIQMe19OU1NpemU9ZmZ9moFaAoF2AYaGA</bytes>
<string>1.WindowOrigin</string>
<string>1.editorWindowContentRectSynchronizationRect</string>
<string>101.IBPluginDependency</string>
<string>101.IBViewBoundsToFrameTransform</string>
<string>102.IBPluginDependency</string>
<string>103.IBPluginDependency</string>
<string>104.IBPluginDependency</string>
Expand Down Expand Up @@ -3653,6 +3660,9 @@ ZQCUhAEqhIQMe19OU1NpemU9ZmZ9moFaAoF2AYaGA</bytes>
<string>{196, 240}</string>
<string>{{202, 428}, {480, 270}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSAffineTransform">
<bytes key="NSTransformStruct">P4AAAL+AAAAAAAAAw60AAA</bytes>
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
Expand Down Expand Up @@ -3702,9 +3712,9 @@ ZQCUhAEqhIQMe19OU1NpemU9ZmZ9moFaAoF2AYaGA</bytes>
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.brandonwalkin.BWToolkit</string>
<string>{{85, 420}, {753, 296}}</string>
<string>{{46, 420}, {753, 296}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{85, 420}, {753, 296}}</string>
<string>{{46, 420}, {753, 296}}</string>
<boolean value="YES"/>
<boolean value="NO"/>
<string>{519, 301}</string>
Expand Down Expand Up @@ -3808,7 +3818,7 @@ ZQCUhAEqhIQMe19OU1NpemU9ZmZ9moFaAoF2AYaGA</bytes>
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">277</int>
<int key="maxID">282</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
Expand Down Expand Up @@ -4050,6 +4060,17 @@ ZQCUhAEqhIQMe19OU1NpemU9ZmZ9moFaAoF2AYaGA</bytes>
<object class="IBPartialClassDescription">
<string key="className">ResultsOutlineViewController</string>
<string key="superclassName">NSObject</string>
<object class="NSMutableDictionary" key="actions">
<string key="NS.key.0">showEditWindow:</string>
<string key="NS.object.0">id</string>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
<string key="NS.key.0">showEditWindow:</string>
<object class="IBActionInfo" key="NS.object.0">
<string key="name">showEditWindow:</string>
<string key="candidateClassName">id</string>
</object>
</object>
<object class="NSMutableDictionary" key="outlets">
<string key="NS.key.0">myOutlineView</string>
<string key="NS.object.0">NSOutlineView</string>
Expand Down
13 changes: 9 additions & 4 deletions ConnectionWindowController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@ - (void) connect:(BOOL)haveHostAddress {
return;
}else if (!haveHostAddress && [conn.host isEqualToString:@"flame.mongohq.com"]) {
hostaddress = [NSString stringWithFormat:@"%@:%@/%@", conn.host, conn.hostport, conn.defaultdb];
connected = mongoDB = [[MongoDB alloc] initWithConn:hostaddress];
}else {
if (conn.userepl) {
if ([conn.userepl intValue] == 1) {
hostaddress = conn.repl_name;
NSArray *tmp = [conn.servers componentsSeparatedByString:@","];
NSMutableArray *hosts = [[NSMutableArray alloc] initWithCapacity:[tmp count]];
Expand Down Expand Up @@ -192,6 +193,8 @@ - (void)windowWillClose:(NSNotification *)notification {
//exitThread = YES;
selectedDB = nil;
selectedCollection = nil;
resultsOutlineViewController = nil;
[super release];
}

- (void)reloadSidebar {
Expand Down Expand Up @@ -285,9 +288,11 @@ - (IBAction)showServerStatus:(id)sender
{
[loaderIndicator start];
[resultsTitle setStringValue:[NSString stringWithFormat:@"Server %@:%@ stats", conn.host, conn.hostport]];
NSMutableArray *results = [[NSMutableArray alloc] initWithArray:[mongoDB serverStatus]];
NSArray *serverStats = [[NSArray alloc] initWithArray:[mongoDB serverStatus]];
NSMutableArray *results = [[NSMutableArray alloc] initWithArray:serverStats];
[serverStats release];
resultsOutlineViewController.results = results;
[resultsOutlineViewController.myOutlineView reloadData];//NSLog(@"STATUS: %@", results);
[resultsOutlineViewController.myOutlineView reloadData];
[results release];
[loaderIndicator stop];

Expand Down Expand Up @@ -320,7 +325,7 @@ - (IBAction)showDBStats:(id)sender
}

- (IBAction)showCollStats:(id)sender
{
{NSLog(@"showCollStats");
if (selectedDB==nil || selectedCollection==nil) {
NSRunAlertPanel(@"Error", @"Please specify a collection!", @"OK", nil, nil);
return;
Expand Down
2 changes: 1 addition & 1 deletion ConnectionWindowTitleTransformer.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ - (id)transformedValue:(id)value
{
if (value)
{
if ([value userepl]) {
if ([[value userepl] intValue] == 1) {
return [NSString stringWithFormat:@"%@ [%@]", [value alias], [value repl_name] ];
}else {
return [NSString stringWithFormat:@"%@ [%@:%@]", [value alias], [value host], [value hostport] ];
Expand Down
46 changes: 46 additions & 0 deletions JSON/JsonWindowController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// JsonWindowController.h
// MongoHub
//
// Created by Syd on 10-12-27.
// Copyright 2010 ThePeppersStudio.COM. All rights reserved.
//

#import <Cocoa/Cocoa.h>
#import "UKSyntaxColoredTextViewController.h"
@class DatabasesArrayController;
@class Connection;
@class MongoDB;

#ifndef UKSCTD_DEFAULT_TEXTENCODING
#define UKSCTD_DEFAULT_TEXTENCODING NSUTF8StringEncoding
#endif

@interface JsonWindowController : NSWindowController <UKSyntaxColoredTextViewDelegate>{
NSManagedObjectContext *managedObjectContext;
DatabasesArrayController *databaseArrayController;
Connection *conn;
MongoDB *mongoDB;
NSString *dbname;
NSString *collectionname;
NSDictionary *jsonDict;
IBOutlet NSTextView *myTextView;
IBOutlet NSProgressIndicator *progress;
IBOutlet NSTextField *status;
UKSyntaxColoredTextViewController *syntaxColoringController;
}

@property (nonatomic, retain) NSManagedObjectContext *managedObjectContext;
@property (nonatomic, retain) DatabasesArrayController *databasesArrayController;
@property (nonatomic, retain) MongoDB *mongoDB;
@property (nonatomic, retain) NSString *dbname;
@property (nonatomic, retain) NSString *collectionname;
@property (nonatomic, retain) Connection *conn;
@property (nonatomic, retain) NSDictionary *jsonDict;
@property (nonatomic, retain) NSTextView *myTextView;

-(IBAction) save:(id)sender;
-(void) doSave;
-(IBAction) recolorCompleteFile: (id)sender;

@end
Loading

0 comments on commit a360773

Please sign in to comment.