Skip to content
Browse files

added support for exporting results to file; still missing tab delimi…

…ted output
  • Loading branch information...
1 parent ae9f35e commit fe7c2c55ee8f0eb703f35df946ca1606c03b8230 Mike Jones committed
Showing with 135 additions and 37 deletions.
  1. +32 −0 AppController.h
  2. +42 −29 AppController.m
  3. +55 −5 English.lproj/MainMenu.xib
  4. +6 −3 LinkedDataViewer.xcodeproj/project.pbxproj
View
32 AppController.h
@@ -38,6 +38,34 @@
#import "SyntaxHighlighting.h"
#import "ResultsTableDelegate.h"
+#define CONTENT_LENGTH @"Content-Length"
+#define CONTENT_TYPE @"Content-Type"
+#define HEADER_ACCEPT @"accept"
+#define USER_AGENT @"User-Agent"
+
+#define APPLICATION_FORM @"application/x-www-form-urlencoded"
+#define APPLICATION_RESULTS_JSON @"application/sparql-results+json"
+#define APPLICATION_RESULTS_XML @"application/sparql-results+xml"
+#define APPLICATION_RESULTS_RDF_XML @"application/rdf+xml"
+#define APPLICATION_RESULTS_N3 @"text/n3"
+#define APPLICATION_RESULTS_TEXT @"text/plain"
+//#define APPLICATION_RESULTS_TURTLE @"text/turtle"
+#define APPLICATION_RESULTS_TURTLE @"application/x-turtle"
+
+#define RESULT_FORMAT_TABLE @"Table View"
+#define RESULT_FORMAT_JSON @"JSON"
+#define RESULT_FORMAT_XML @"XML"
+#define RESULT_FORMAT_RDF_XML @"RDF/XML"
+#define RESULT_FORMAT_N3 @"N3"
+#define RESULT_FORMAT_NTRIPLES @"N-Triples"
+#define RESULT_FORMAT_TURTLE @"Turtle"
+
+#define USER_AGENT_NAME @"LinkedDataViewer/0.4"
+
+#define MAIN_WINDOW_MENU_ITEM_TAG 200
+#define EDIT_ENDPOINT_TAG 300
+#define EXPORT_RESULTS_TAG 400
+
@interface AppController : NSObject <AddEndPointDelegate> {
IBOutlet NSWindow *mainWindow;
@@ -60,6 +88,7 @@
AddEndPointController *addEndPointController; // controller for adding endpoints
NSMutableData *receivedData;
+ NSString *results;
NSArray *constructArray;
NSArray *selectArray;
@@ -107,6 +136,8 @@
- (IBAction)removeEndpoint:(id)sender;
+- (IBAction)exportResults:(id)sender;
+
- (void)saveEndPointList;
- (NSString *)storagePath;
@@ -115,4 +146,5 @@
- (void)parseData:(NSData *)d;
+
@end
View
71 AppController.m
@@ -37,33 +37,6 @@ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
#import "EndPoint.h"
#import "AddEndPointController.h"
-#define CONTENT_LENGTH @"Content-Length"
-#define CONTENT_TYPE @"Content-Type"
-#define HEADER_ACCEPT @"accept"
-#define USER_AGENT @"User-Agent"
-
-#define APPLICATION_FORM @"application/x-www-form-urlencoded"
-#define APPLICATION_RESULTS_JSON @"application/sparql-results+json"
-#define APPLICATION_RESULTS_XML @"application/sparql-results+xml"
-#define APPLICATION_RESULTS_RDF_XML @"application/rdf+xml"
-#define APPLICATION_RESULTS_N3 @"text/n3"
-#define APPLICATION_RESULTS_TEXT @"text/plain"
-//#define APPLICATION_RESULTS_TURTLE @"text/turtle"
-#define APPLICATION_RESULTS_TURTLE @"application/x-turtle"
-
-#define RESULT_FORMAT_TABLE @"Table View"
-#define RESULT_FORMAT_JSON @"JSON"
-#define RESULT_FORMAT_XML @"XML"
-#define RESULT_FORMAT_RDF_XML @"RDF/XML"
-#define RESULT_FORMAT_N3 @"N3"
-#define RESULT_FORMAT_NTRIPLES @"N-Triples"
-#define RESULT_FORMAT_TURTLE @"Turtle"
-
-#define USER_AGENT_NAME @"LinkedDataViewer/0.4"
-
-#define MAIN_WINDOW_MENU_ITEM_TAG 200
-#define EDIT_ENDPOINT_TAG 300
-
@implementation AppController
@synthesize endPointListTableView;
@@ -155,6 +128,7 @@ - (void)dealloc {
//[whitespaceSet release];
[syntaxHighlighting release];
//[resultsTableDelegate release];
+ [results release];
}
- (IBAction)runquery:(id)sender {
@@ -322,6 +296,40 @@ - (IBAction)removeEndpoint:(id)sender {
}
}
+- (IBAction)exportResults:(id)sender {
+
+ NSLog(@"exportResults called");
+
+ NSSavePanel *exportPanel = [NSSavePanel savePanel];
+ [exportPanel setCanCreateDirectories:YES];
+ [exportPanel setTitle:@"Export results"];
+
+ NSString *fileName;
+
+ if ([[resultsFormat titleOfSelectedItem] isEqualToString:RESULT_FORMAT_TABLE]) {
+ fileName = @"untitled.csv";
+ } else if ([[resultsFormat titleOfSelectedItem] isEqualToString:RESULT_FORMAT_JSON]) {
+ fileName = @"untitled.json";
+ } else if ([[resultsFormat titleOfSelectedItem] isEqualToString:RESULT_FORMAT_N3] ||
+ [[resultsFormat titleOfSelectedItem] isEqualToString:RESULT_FORMAT_NTRIPLES]) {
+ fileName = @"untitled.n3";
+ } else if([[resultsFormat titleOfSelectedItem] isEqualToString:RESULT_FORMAT_RDF_XML] ||
+ [[resultsFormat titleOfSelectedItem] isEqualToString:RESULT_FORMAT_XML]) {
+ fileName = @"untitled.xml";
+ } else if ([[resultsFormat titleOfSelectedItem] isEqualToString:RESULT_FORMAT_TURTLE]) {
+ fileName = @"untitled.ttl";
+ } else {
+ fileName = @"untiled.txt";
+ }
+
+ [exportPanel runModalForDirectory:nil file:fileName];
+
+ [results writeToURL:[exportPanel URL] atomically:NO encoding:NSUTF8StringEncoding error:nil];
+
+ NSLog(@"File: %@", [[exportPanel URL] description]);
+
+}
+
-(void)addEndPointToArrayList:(EndPoint *)endPoint {
if (endPoint != nil) {
@@ -394,6 +402,10 @@ - (BOOL)validateMenuItem:(NSMenuItem *)item {
return [endPointListTableView selectedRow] >= 0;
}
+ if ([item tag] == EXPORT_RESULTS_TAG) {
+ return results != nil;
+ }
+
return TRUE;
}
@@ -470,8 +482,9 @@ - (void)connectionDidFinishLoading:(NSURLConnection *)connection {
NSLog(@"%d", responseCode);
- NSString *results = [[[NSString alloc] initWithData:receivedData
- encoding:NSUTF8StringEncoding] autorelease];
+ [results release];
+ results = [[[NSString alloc] initWithData:receivedData
+ encoding:NSUTF8StringEncoding] retain];
if (responseCode == 404) {
View
60 English.lproj/MainMenu.xib
@@ -21,8 +21,8 @@
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="783"/>
<integer value="841"/>
+ <integer value="783"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -1264,6 +1264,25 @@
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSMixedImage" ref="502551668"/>
</object>
+ <object class="NSMenuItem" id="431543548">
+ <reference key="NSMenu" ref="641619104"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="35465992"/>
+ <reference key="NSMixedImage" ref="502551668"/>
+ </object>
+ <object class="NSMenuItem" id="1025598588">
+ <reference key="NSMenu" ref="641619104"/>
+ <string key="NSTitle">Export Results</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="35465992"/>
+ <reference key="NSMixedImage" ref="502551668"/>
+ <int key="NSTag">400</int>
+ </object>
</object>
</object>
</object>
@@ -3289,6 +3308,14 @@ cCA/bwpXSEVSRSB7CiAgICA/cyA/cCA/bwp9CkxJTUlUIDEwA</bytes>
</object>
<int key="connectionID">876</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">exportResults:</string>
+ <reference key="source" ref="414729294"/>
+ <reference key="destination" ref="1025598588"/>
+ </object>
+ <int key="connectionID">882</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -4374,6 +4401,8 @@ cCA/bwpXSEVSRSB7CiAgICA/cyA/cCA/bwp9CkxJTUlUIDEwA</bytes>
<reference ref="368705818"/>
<reference ref="589192354"/>
<reference ref="450437133"/>
+ <reference ref="1025598588"/>
+ <reference ref="431543548"/>
</object>
<reference key="parent" ref="49375688"/>
</object>
@@ -4788,6 +4817,16 @@ cCA/bwpXSEVSRSB7CiAgICA/cyA/cCA/bwp9CkxJTUlUIDEwA</bytes>
<reference key="object" ref="902192190"/>
<reference key="parent" ref="147303779"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">881</int>
+ <reference key="object" ref="1025598588"/>
+ <reference key="parent" ref="641619104"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">883</int>
+ <reference key="object" ref="431543548"/>
+ <reference key="parent" ref="641619104"/>
+ </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -5108,6 +5147,8 @@ cCA/bwpXSEVSRSB7CiAgICA/cyA/cCA/bwp9CkxJTUlUIDEwA</bytes>
<string>869.IBPluginDependency</string>
<string>872.IBPluginDependency</string>
<string>875.IBPluginDependency</string>
+ <string>881.IBPluginDependency</string>
+ <string>883.IBPluginDependency</string>
<string>92.IBPluginDependency</string>
<string>92.ImportedFromIB2</string>
</object>
@@ -5242,9 +5283,9 @@ cCA/bwpXSEVSRSB7CiAgICA/cyA/cCA/bwp9CkxJTUlUIDEwA</bytes>
<integer value="1"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
- <string>{{175, 176}, {962, 577}}</string>
+ <string>{{1, 176}, {962, 577}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{175, 176}, {962, 577}}</string>
+ <string>{{1, 176}, {962, 577}}</string>
<integer value="1"/>
<string>{{33, 99}, {480, 360}}</string>
<boolean value="YES"/>
@@ -5376,7 +5417,7 @@ cCA/bwpXSEVSRSB7CiAgICA/cyA/cCA/bwp9CkxJTUlUIDEwA</bytes>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{520, 743}, {224, 93}}</string>
+ <string>{{520, 713}, {224, 123}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -5428,6 +5469,8 @@ cCA/bwpXSEVSRSB7CiAgICA/cyA/cCA/bwp9CkxJTUlUIDEwA</bytes>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
</object>
</object>
@@ -5447,7 +5490,7 @@ cCA/bwpXSEVSRSB7CiAgICA/cyA/cCA/bwp9CkxJTUlUIDEwA</bytes>
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">880</int>
+ <int key="maxID">883</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -5462,6 +5505,7 @@ cCA/bwpXSEVSRSB7CiAgICA/cyA/cCA/bwp9CkxJTUlUIDEwA</bytes>
<string>addEndpoint:</string>
<string>cancelQuery:</string>
<string>editEndpoint:</string>
+ <string>exportResults:</string>
<string>handleMainWindow:</string>
<string>removeEndpoint:</string>
<string>runquery:</string>
@@ -5474,6 +5518,7 @@ cCA/bwpXSEVSRSB7CiAgICA/cyA/cCA/bwp9CkxJTUlUIDEwA</bytes>
<string>id</string>
<string>id</string>
<string>id</string>
+ <string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
@@ -5483,6 +5528,7 @@ cCA/bwpXSEVSRSB7CiAgICA/cyA/cCA/bwp9CkxJTUlUIDEwA</bytes>
<string>addEndpoint:</string>
<string>cancelQuery:</string>
<string>editEndpoint:</string>
+ <string>exportResults:</string>
<string>handleMainWindow:</string>
<string>removeEndpoint:</string>
<string>runquery:</string>
@@ -5502,6 +5548,10 @@ cCA/bwpXSEVSRSB7CiAgICA/cyA/cCA/bwp9CkxJTUlUIDEwA</bytes>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
+ <string key="name">exportResults:</string>
+ <string key="candidateClassName">id</string>
+ </object>
+ <object class="IBActionInfo">
<string key="name">handleMainWindow:</string>
<string key="candidateClassName">id</string>
</object>
View
9 LinkedDataViewer.xcodeproj/project.pbxproj
@@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
- objectVersion = 45;
+ objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
@@ -201,7 +201,7 @@
29B97313FDCFA39411CA2CEA /* Project object */ = {
isa = PBXProject;
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "LinkedDataViewer" */;
- compatibilityVersion = "Xcode 3.1";
+ compatibilityVersion = "Xcode 3.2";
hasScannedForEncodings = 1;
mainGroup = 29B97314FDCFA39411CA2CEA /* LinkedDataViewer */;
projectDirPath = "";
@@ -314,9 +314,10 @@
GCC_OPTIMIZATION_LEVEL = 0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
+ MACOSX_DEPLOYMENT_TARGET = 10.5;
ONLY_ACTIVE_ARCH = YES;
PREBINDING = NO;
- SDKROOT = macosx10.5;
+ SDKROOT = macosx10.6;
};
name = Debug;
};
@@ -327,6 +328,8 @@
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
+ MACOSX_DEPLOYMENT_TARGET = 10.5;
+ ONLY_ACTIVE_ARCH = NO;
PREBINDING = NO;
SDKROOT = macosx10.6;
};

0 comments on commit fe7c2c5

Please sign in to comment.
Something went wrong with that request. Please try again.