Permalink
Browse files

Creating UI for importing/exporting requests. Not yet functional.

  • Loading branch information...
1 parent 7b408e0 commit 89a59d080d254516204c7d75591b8c21f2ebdd51 @mmattozzi committed Jan 15, 2012
View
@@ -0,0 +1,25 @@
+//
+// CheckableRequestWrapper.h
+// CocoaRestClient
+//
+// Created by Michael Mattozzi on 1/15/12.
+// Copyright (c) 2012 Michael Mattozzi. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+@interface CheckableRequestWrapper : NSObject {
+ BOOL enabled;
+ id request;
+ NSString *name;
+ NSButtonCell *cell;
+}
+
+- (CheckableRequestWrapper *) initWithName:(NSString *)name enabled:(BOOL)enabled request:(id)request;
+- (BOOL) enabled;
+- (NSString *) name;
+- (id) request;
+- (void) setEnabled:(BOOL)reqEnabled;
+- (NSButtonCell *) cell;
+
+@end
View
@@ -0,0 +1,50 @@
+//
+// CheckableRequestWrapper.m
+// CocoaRestClient
+//
+// Created by Michael Mattozzi on 1/15/12.
+// Copyright (c) 2012 Michael Mattozzi. All rights reserved.
+//
+
+#import "CheckableRequestWrapper.h"
+
+@implementation CheckableRequestWrapper
+
+- (CheckableRequestWrapper *) initWithName:(NSString *)reqName enabled:(BOOL)reqEnabled request:(id)requestObject {
+ self = [super init];
+
+ if (self) {
+ name = reqName;
+ enabled = reqEnabled;
+ request = requestObject;
+
+ cell=[[NSButtonCell alloc] init];
+ [cell setTitle:name];
+ [cell setAllowsMixedState:YES];
+ [cell setButtonType:NSSwitchButton];
+ }
+
+ return self;
+}
+
+- (BOOL) enabled {
+ return enabled;
+}
+
+- (NSString *) name {
+ return name;
+}
+
+- (id) request {
+ return request;
+}
+
+- (void) setEnabled:(BOOL)reqEnabled {
+ enabled = reqEnabled;
+}
+
+- (NSButtonCell *) cell {
+ return cell;
+}
+
+@end
@@ -19,6 +19,9 @@
AF074F5D10F595AF00EE44D8 /* SBJsonWriter.m in Sources */ = {isa = PBXBuildFile; fileRef = AF074F5710F595AF00EE44D8 /* SBJsonWriter.m */; };
AF1FC48410F435BD00ED5A57 /* CocoaRestClientAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 256AC3D90F4B6AC300CF3369 /* CocoaRestClientAppDelegate.m */; };
AF7A149B113B583A00F0D6F5 /* cocoaRestClient.icns in Resources */ = {isa = PBXBuildFile; fileRef = AF7A149A113B583A00F0D6F5 /* cocoaRestClient.icns */; };
+ AFBF08BD14C1E9BB000E7411 /* ExportRequests.xib in Resources */ = {isa = PBXBuildFile; fileRef = AFBF08BC14C1E9BB000E7411 /* ExportRequests.xib */; };
+ AFBF08C514C32D30000E7411 /* ExportRequestsController.m in Sources */ = {isa = PBXBuildFile; fileRef = AFBF08C414C32D30000E7411 /* ExportRequestsController.m */; };
+ AFBF08CD14C37D3E000E7411 /* CheckableRequestWrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = AFBF08CC14C37D3E000E7411 /* CheckableRequestWrapper.m */; };
AFCE79531419B47900E22468 /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AFCE79521419B47900E22468 /* Sparkle.framework */; };
AFCE79551419B49F00E22468 /* Sparkle.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = AFCE79521419B47900E22468 /* Sparkle.framework */; };
AFCE79571419B54600E22468 /* dsa_pub.pem in Resources */ = {isa = PBXBuildFile; fileRef = AFCE79561419B54600E22468 /* dsa_pub.pem */; };
@@ -73,6 +76,11 @@
AF074F5710F595AF00EE44D8 /* SBJsonWriter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SBJsonWriter.m; sourceTree = "<group>"; };
AF2D9EFF145F908100B8220F /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = SDKs/MacOSX10.6.sdk/System/Library/Frameworks/Security.framework; sourceTree = DEVELOPER_DIR; };
AF7A149A113B583A00F0D6F5 /* cocoaRestClient.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = cocoaRestClient.icns; sourceTree = "<group>"; };
+ AFBF08BC14C1E9BB000E7411 /* ExportRequests.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ExportRequests.xib; sourceTree = "<group>"; };
+ AFBF08C314C32D30000E7411 /* ExportRequestsController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExportRequestsController.h; sourceTree = "<group>"; };
+ AFBF08C414C32D30000E7411 /* ExportRequestsController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ExportRequestsController.m; sourceTree = "<group>"; };
+ AFBF08CB14C37D3E000E7411 /* CheckableRequestWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CheckableRequestWrapper.h; sourceTree = "<group>"; };
+ AFBF08CC14C37D3E000E7411 /* CheckableRequestWrapper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CheckableRequestWrapper.m; sourceTree = "<group>"; };
AFCE79521419B47900E22468 /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Sparkle.framework; sourceTree = "<group>"; };
AFCE79561419B54600E22468 /* dsa_pub.pem */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = dsa_pub.pem; sourceTree = "<group>"; };
AFE1837612E394E5001B1B29 /* LICENSE.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE.txt; sourceTree = "<group>"; };
@@ -134,6 +142,10 @@
D714A0A111E901FB00F5A80B /* CRCRequest.m */,
D7D998B211EAA29B005B8811 /* CRCTopView.h */,
D7D998B311EAA29B005B8811 /* CRCTopView.m */,
+ AFBF08C314C32D30000E7411 /* ExportRequestsController.h */,
+ AFBF08C414C32D30000E7411 /* ExportRequestsController.m */,
+ AFBF08CB14C37D3E000E7411 /* CheckableRequestWrapper.h */,
+ AFBF08CC14C37D3E000E7411 /* CheckableRequestWrapper.m */,
);
name = Classes;
sourceTree = "<group>";
@@ -196,6 +208,7 @@
8D1107310486CEB800E47090 /* CocoaRestClient-Info.plist */,
089C165CFE840E0CC02AAC07 /* InfoPlist.strings */,
1DDD58140DA1D0A300B32029 /* MainMenu.xib */,
+ AFBF08BC14C1E9BB000E7411 /* ExportRequests.xib */,
);
name = Resources;
sourceTree = "<group>";
@@ -264,6 +277,7 @@
D7D998B611EAA2B2005B8811 /* background-header.png in Resources */,
AFE1837712E394E5001B1B29 /* LICENSE.txt in Resources */,
AFCE79571419B54600E22468 /* dsa_pub.pem in Resources */,
+ AFBF08BD14C1E9BB000E7411 /* ExportRequests.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -288,6 +302,8 @@
D714A03111E8F61D00F5A80B /* CRCFileRequest.m in Sources */,
D714A0A211E901FB00F5A80B /* CRCRequest.m in Sources */,
D7D998B411EAA29B005B8811 /* CRCTopView.m in Sources */,
+ AFBF08C514C32D30000E7411 /* ExportRequestsController.m in Sources */,
+ AFBF08CD14C37D3E000E7411 /* CheckableRequestWrapper.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -7,6 +7,7 @@
//
#import <Cocoa/Cocoa.h>
+#import "ExportRequestsController.h"
@class CRCRequest;
@@ -46,6 +47,8 @@
NSInteger timeout;
+ ExportRequestsController *exportRequestsController;
+
BOOL allowSelfSignedCerts;
BOOL followRedirects;
@@ -121,6 +124,8 @@
- (IBAction) reloadLastRequest:(id)sender;
- (IBAction) allowSelfSignedCerts:(id)sender;
- (IBAction) followRedirects:(id)sender;
+- (IBAction) importRequests:(id)sender;
+- (IBAction) exportRequests:(id)sender;
- (void)setRawRequestInput:(BOOL)value;
@@ -103,6 +103,9 @@ - (id) init {
[savedRequestsArray addObject:req1];
*/
[self loadDataFromDisk];
+
+ exportRequestsController = [[ExportRequestsController alloc] initWithWindowNibName:@"ExportRequests"];
+ exportRequestsController.savedRequestsArray = savedRequestsArray;
return self;
}
@@ -866,6 +869,38 @@ - (void) loadDataFromDisk {
savedRequestsArray = [[NSMutableArray alloc] initWithArray:[NSKeyedUnarchiver unarchiveObjectWithFile:path]];
}
+- (IBAction) importRequests:(id)sender {
+
+ NSOpenPanel* picker = [NSOpenPanel openPanel];
+
+ [picker setCanChooseFiles:YES];
+ [picker setCanChooseDirectories:NO];
+ [picker setAllowsMultipleSelection:NO];
+
+ if ( [picker runModalForDirectory:nil file:nil] == NSOKButton )
+ {
+
+ for(NSURL* url in [picker URLs])
+ {
+ NSString *path = [url path];
+ NSLog(@"Loading requests from %@", path);
+ [savedRequestsArray addObjectsFromArray:[NSKeyedUnarchiver unarchiveObjectWithFile:path]];
+ [savedOutlineView reloadItem:nil reloadChildren:YES];
+ }
+
+ }
+
+}
+
+- (IBAction) exportRequests:(id)sender {
+ [exportRequestsController prepareToDisplay];
+ [NSApp beginSheet: [exportRequestsController window]
+ modalForWindow: window
+ modalDelegate: exportRequestsController
+ didEndSelector: @selector(didEndSheet:returnCode:contextInfo:)
+ contextInfo: nil];
+}
+
- (IBAction) handleOpenWindow:(id)sender {
[window makeKeyAndOrderFront:self];
}
Oops, something went wrong.

0 comments on commit 89a59d0

Please sign in to comment.