Skip to content
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.

Commit

Permalink
Copy and paste, and some bug fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
snej committed Aug 31, 2012
1 parent 24a9a51 commit aed0d31
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 17 deletions.
4 changes: 4 additions & 0 deletions TouchDB Viewer.xcodeproj/project.pbxproj
Expand Up @@ -351,6 +351,7 @@
27A8A791152A008200363704 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "Developer ID Application: CouchOne";
COMBINE_HIDPI_IMAGES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -361,13 +362,15 @@
INFOPLIST_FILE = "TouchDB Viewer/TouchDB Viewer-Info.plist";
LD_RUNPATH_SEARCH_PATHS = "@executable_path/../Frameworks/";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
WRAPPER_EXTENSION = app;
};
name = Debug;
};
27A8A792152A008200363704 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "Developer ID Application: CouchOne";
COMBINE_HIDPI_IMAGES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -378,6 +381,7 @@
INFOPLIST_FILE = "TouchDB Viewer/TouchDB Viewer-Info.plist";
LD_RUNPATH_SEARCH_PATHS = "@executable_path/../Frameworks/";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
WRAPPER_EXTENSION = app;
};
name = Release;
Expand Down
2 changes: 1 addition & 1 deletion TouchDB Viewer/AppDelegate.m
Expand Up @@ -16,7 +16,7 @@ @implementation AppDelegate

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
gRESTLogLevel = kRESTLogRequestHeaders;
//gRESTLogLevel = kRESTLogRequestHeaders;
}

@end
13 changes: 13 additions & 0 deletions TouchDB Viewer/DBWindowController.m
Expand Up @@ -247,4 +247,17 @@ - (void) keyDown: (NSEvent*)ev {
}


- (IBAction) copy:(id)sender {
id focus = self.window.firstResponder;
if ([focus isKindOfClass: [NSTableView class]]) {
focus = [focus delegate];
if ([focus respondsToSelector: @selector(copy:)]) {
[focus copy: sender];
return;
}
}
NSBeep();
}


@end
30 changes: 15 additions & 15 deletions TouchDB Viewer/DBWindowController.xib
Expand Up @@ -901,17 +901,17 @@
<object class="IBOutletConnection" key="connection">
<string key="label">dataSource</string>
<reference key="source" ref="417721070"/>
<reference key="destination" ref="1001"/>
<reference key="destination" ref="572162625"/>
</object>
<int key="connectionID">62</int>
<int key="connectionID">624</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="417721070"/>
<reference key="destination" ref="1001"/>
<reference key="destination" ref="572162625"/>
</object>
<int key="connectionID">61</int>
<int key="connectionID">625</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
Expand Down Expand Up @@ -2067,7 +2067,7 @@
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">623</int>
<int key="maxID">625</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
Expand All @@ -2076,28 +2076,18 @@
<string key="superclassName">NSWindowController</string>
<dictionary class="NSMutableDictionary" key="actions">
<string key="deleteDocument:">id</string>
<string key="hideDocRevisionTree:">id</string>
<string key="newDocument:">id</string>
<string key="pathClicked:">id</string>
<string key="showDocRevisionTree:">id</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="actionInfosByName">
<object class="IBActionInfo" key="deleteDocument:">
<string key="name">deleteDocument:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo" key="hideDocRevisionTree:">
<string key="name">hideDocRevisionTree:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo" key="newDocument:">
<string key="name">newDocument:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo" key="pathClicked:">
<string key="name">pathClicked:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo" key="showDocRevisionTree:">
<string key="name">showDocRevisionTree:</string>
<string key="candidateClassName">id</string>
Expand Down Expand Up @@ -2144,6 +2134,7 @@
<string key="addColumnForSelectedProperty:">id</string>
<string key="addProperty:">id</string>
<string key="cancelOperation:">id</string>
<string key="copy:">id</string>
<string key="removeProperty:">id</string>
<string key="revertDocumentToSaved:">id</string>
<string key="saveDocument:">id</string>
Expand All @@ -2161,6 +2152,10 @@
<string key="name">cancelOperation:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo" key="copy:">
<string key="name">copy:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo" key="removeProperty:">
<string key="name">removeProperty:</string>
<string key="candidateClassName">id</string>
Expand Down Expand Up @@ -2199,10 +2194,15 @@
<string key="className">QueryResultController</string>
<string key="superclassName">NSObject</string>
<dictionary class="NSMutableDictionary" key="actions">
<string key="copy:">id</string>
<string key="deleteDocument:">id</string>
<string key="newDocument:">id</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="actionInfosByName">
<object class="IBActionInfo" key="copy:">
<string key="name">copy:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo" key="deleteDocument:">
<string key="name">deleteDocument:</string>
<string key="candidateClassName">id</string>
Expand Down
1 change: 1 addition & 0 deletions TouchDB Viewer/DocEditor.h
Expand Up @@ -34,5 +34,6 @@

- (BOOL) saveDocument;
- (IBAction) cancelOperation: (id)sender;
- (IBAction) copy:(id)sender;

@end
16 changes: 16 additions & 0 deletions TouchDB Viewer/DocEditor.m
Expand Up @@ -8,6 +8,7 @@

#import "DocEditor.h"
#import "DBWindowController.h"
#import "JSONFormatter.h"


@implementation DocEditor
Expand Down Expand Up @@ -203,6 +204,21 @@ - (IBAction) cancelOperation: (id)sender {
}


- (IBAction) copy:(id)sender {
NSString* prop = self.selectedProperty;
if (!prop) {
NSBeep();
return;
}
id value = _properties[prop];
NSString* json = [JSONFormatter stringForObjectValue: value];

NSPasteboard* pb = [NSPasteboard generalPasteboard];
[pb clearContents];
[pb setString: json forType: NSStringPboardType];
}


- (BOOL) validateUserInterfaceItem: (id <NSValidatedUserInterfaceItem>)item {
NSLog(@"validate %@", item);//TEMP
NSString* property = self.selectedOrClickedProperty;
Expand Down
2 changes: 2 additions & 0 deletions TouchDB Viewer/JSONFormatter.h
Expand Up @@ -10,4 +10,6 @@

@interface JSONFormatter : NSFormatter

+ (NSString*) stringForObjectValue: (id)obj;

@end
7 changes: 6 additions & 1 deletion TouchDB Viewer/JSONFormatter.m
Expand Up @@ -11,7 +11,7 @@
@implementation JSONFormatter


- (NSString *)stringForObjectValue: (id)obj {
+ (NSString*) stringForObjectValue: (id)obj {
if (obj == nil)
return @"";
NSArray* wrapped = @[obj]; // in case obj is a fragment
Expand All @@ -21,6 +21,11 @@ - (NSString *)stringForObjectValue: (id)obj {
}


- (NSString *)stringForObjectValue: (id)obj {
return [[self class] stringForObjectValue: obj];
}


- (BOOL)getObjectValue:(out id *)obj
forString:(NSString *)string
errorDescription:(out NSString **)errorMessage
Expand Down
1 change: 1 addition & 0 deletions TouchDB Viewer/QueryResultController.h
Expand Up @@ -18,5 +18,6 @@

- (IBAction) newDocument: (id)sender;
- (IBAction) deleteDocument: (id)sender;
- (IBAction) copy:(id)sender;

@end
17 changes: 17 additions & 0 deletions TouchDB Viewer/QueryResultController.m
Expand Up @@ -272,6 +272,23 @@ - (IBAction) deleteDocument: (id)sender {
}


- (IBAction) copy:(id)sender {
NSArray* docs = self.selectedDocuments;
if (!docs.count) {
NSBeep();
return;
}
NSMutableArray* docIDs = [NSMutableArray array];
for (CouchDocument* doc in docs)
[docIDs addObject: doc.documentID];
NSString* result = [docIDs componentsJoinedByString: @"\n"];

NSPasteboard* pb = [NSPasteboard generalPasteboard];
[pb clearContents];
[pb setString: result forType: NSStringPboardType];
}


@end


Expand Down
32 changes: 32 additions & 0 deletions TouchDB Viewer/RevTreeController.m
Expand Up @@ -68,6 +68,18 @@ - (void) setDocument:(CouchDocument *)document {
}


- (NSArray*) selectedRevisions {
NSIndexSet* selIndexes = [_docsOutline selectedRowIndexes];
NSUInteger count = selIndexes.count;
NSMutableArray* sel = [NSMutableArray arrayWithCapacity: count];
[selIndexes enumerateIndexesUsingBlock: ^(NSUInteger idx, BOOL *stop) {
CouchRevision* item = [self revisionForItem: [_docsOutline itemAtRow: idx]];
[sel addObject: item];
}];
return sel;
}


#pragma mark - DOCUMENT-LIST VIEW:


Expand Down Expand Up @@ -174,4 +186,24 @@ - (void)outlineViewSelectionDidChange:(NSNotification *)notification {
}


#pragma mark - ACTIONS:


- (IBAction) copy:(id)sender {
NSArray* sel = self.selectedRevisions;
if (!sel.count) {
NSBeep();
return;
}
NSMutableArray* revIDs = [NSMutableArray array];
for (CouchRevision* rev in sel)
[revIDs addObject: rev.revisionID];
NSString* result = [revIDs componentsJoinedByString: @"\n"];

NSPasteboard* pb = [NSPasteboard generalPasteboard];
[pb clearContents];
[pb setString: result forType: NSStringPboardType];
}


@end

0 comments on commit aed0d31

Please sign in to comment.