diff options
author | stuconnolly <stuart02@gmail.com> | 2009-08-03 02:20:12 +0000 |
---|---|---|
committer | stuconnolly <stuart02@gmail.com> | 2009-08-03 02:20:12 +0000 |
commit | 63323b1d133fe3c7ed6c6c9d37d1a28608014938 (patch) | |
tree | 6d110ac5c6ee1c23a4235d3ae5be11d37861e94d | |
parent | ef575afcc1cd8575773176d366da34f39975c118 (diff) | |
download | sequelpro-63323b1d133fe3c7ed6c6c9d37d1a28608014938.tar.gz sequelpro-63323b1d133fe3c7ed6c6c9d37d1a28608014938.tar.bz2 sequelpro-63323b1d133fe3c7ed6c6c9d37d1a28608014938.zip |
In the field editor sheet:
- Make some of the QuickLook format menuitem name's uppercase.
- Run both the save and open panels as sheets to prevent blocking the entire app.
-rw-r--r-- | Interfaces/English.lproj/FieldEditorSheet.xib | 160 | ||||
-rw-r--r-- | Source/SPFieldEditorController.m | 155 |
2 files changed, 228 insertions, 87 deletions
diff --git a/Interfaces/English.lproj/FieldEditorSheet.xib b/Interfaces/English.lproj/FieldEditorSheet.xib index 48eae8ce..a1a1e864 100644 --- a/Interfaces/English.lproj/FieldEditorSheet.xib +++ b/Interfaces/English.lproj/FieldEditorSheet.xib @@ -8,6 +8,7 @@ <string key="IBDocument.HIToolboxVersion">353.00</string> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> + <integer value="23"/> </object> <object class="NSArray" key="IBDocument.PluginDependencies"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -45,7 +46,7 @@ </object> <string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string> <object class="NSView" key="NSWindowView" id="559857537"> - <nil key="NSNextResponder"/> + <reference key="NSNextResponder"/> <int key="NSvFlags">4370</int> <object class="NSMutableArray" key="NSSubviews"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -278,7 +279,7 @@ </object> <object class="NSMenuItem" id="853091810"> <reference key="NSMenu" ref="70895771"/> - <string key="NSTitle">pdf</string> + <string key="NSTitle">PDF</string> <string key="NSKeyEquiv"/> <int key="NSMnemonicLoc">2147483647</int> <reference key="NSOnImage" ref="670969392"/> @@ -289,7 +290,7 @@ </object> <object class="NSMenuItem" id="364525587"> <reference key="NSMenu" ref="70895771"/> - <string key="NSTitle">html</string> + <string key="NSTitle">HTML</string> <string key="NSKeyEquiv"/> <int key="NSMnemonicLoc">2147483647</int> <reference key="NSOnImage" ref="670969392"/> @@ -300,7 +301,7 @@ </object> <object class="NSMenuItem" id="800624537"> <reference key="NSMenu" ref="70895771"/> - <string key="NSTitle">doc</string> + <string key="NSTitle">Doc</string> <string key="NSKeyEquiv"/> <int key="NSMnemonicLoc">2147483647</int> <reference key="NSOnImage" ref="670969392"/> @@ -311,7 +312,7 @@ </object> <object class="NSMenuItem" id="964663224"> <reference key="NSMenu" ref="70895771"/> - <string key="NSTitle">rtf</string> + <string key="NSTitle">RTF</string> <string key="NSKeyEquiv"/> <int key="NSMnemonicLoc">2147483647</int> <reference key="NSOnImage" ref="670969392"/> @@ -322,6 +323,7 @@ </object> </object> </object> + <int key="NSSelectedIndex">7</int> <bool key="NSPullDown">YES</bool> <int key="NSPreferredEdge">1</int> <bool key="NSUsesItemFromMenu">YES</bool> @@ -543,6 +545,29 @@ <object class="NSTextView" id="702566211"> <reference key="NSNextResponder" ref="967441740"/> <int key="NSvFlags">2322</int> + <object class="NSMutableSet" key="NSDragTypes"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSMutableArray" key="set.sortedObjects"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>Apple HTML pasteboard type</string> + <string>Apple PDF pasteboard type</string> + <string>Apple PICT pasteboard type</string> + <string>Apple PNG pasteboard type</string> + <string>Apple URL pasteboard type</string> + <string>CorePasteboardFlavorType 0x6D6F6F76</string> + <string>CorePasteboardFlavorType 0x75726C20</string> + <string>NSColor pasteboard type</string> + <string>NSFilenamesPboardType</string> + <string>NSStringPboardType</string> + <string>NeXT Encapsulated PostScript v1.2 pasteboard type</string> + <string>NeXT RTFD pasteboard type</string> + <string>NeXT Rich Text Format v1.0 pasteboard type</string> + <string>NeXT TIFF v4.0 pasteboard type</string> + <string>NeXT font pasteboard type</string> + <string>NeXT ruler pasteboard type</string> + <string>WebURLsWithTitlesPboardType</string> + </object> + </object> <string key="NSFrameSize">{667, 14}</string> <reference key="NSSuperview" ref="967441740"/> <object class="NSTextContainer" key="NSTextContainer" id="872196016"> @@ -683,6 +708,7 @@ </object> </object> <string key="NSFrameSize">{667, 416}</string> + <reference key="NSSuperview"/> </object> <string key="NSScreenRect">{{0, 0}, {1280, 778}}</string> <string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string> @@ -932,6 +958,14 @@ </object> <int key="connectionID">69</int> </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">window</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="172882781"/> + </object> + <int key="connectionID">70</int> + </object> </object> <object class="IBMutableOrderedSet" key="objectRecords"> <object class="NSArray" key="orderedObjects"> @@ -1308,8 +1342,8 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{452, 157}, {667, 416}}</string> - <string>{{452, 157}, {667, 416}}</string> + <string>{{795, 333}, {667, 416}}</string> + <string>{{795, 333}, {667, 416}}</string> <reference ref="9"/> <integer value="0" id="8"/> <boolean value="NO"/> @@ -1332,7 +1366,7 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <reference ref="9"/> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{769, 16}, {126, 173}}</string> + <string>{{1112, 192}, {126, 173}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> @@ -1401,7 +1435,7 @@ </object> </object> <nil key="sourceID"/> - <int key="maxID">69</int> + <int key="maxID">70</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> @@ -1413,28 +1447,116 @@ <string key="NS.key.0">delegate</string> <string key="NS.object.0">id</string> </object> + <object class="IBClassDescriptionSource" key="sourceIdentifier" id="595945576"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">Source/CMImageView.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">CMImageView</string> + <string key="superclassName">NSImageView</string> <object class="IBClassDescriptionSource" key="sourceIdentifier"> <string key="majorKey">IBUserSource</string> <string key="minorKey"/> </object> </object> <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">Frameworks/MCPKit/MCPFoundationKit/MCPNull.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <reference key="sourceIdentifier" ref="595945576"/> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">Source/SPConnectionController.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="NSMutableDictionary" key="actions"> + <string key="NS.key.0">toggleCollapse:</string> + <string key="NS.object.0">id</string> + </object> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">Source/TablesList.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSTextView</string> + <object class="NSMutableDictionary" key="actions"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSMutableArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>doDecomposedStringWithCanonicalMapping:</string> + <string>doDecomposedStringWithCompatibilityMapping:</string> + <string>doPrecomposedStringWithCanonicalMapping:</string> + <string>doPrecomposedStringWithCompatibilityMapping:</string> + <string>doRemoveDiacritics:</string> + <string>doSelectionLowerCase:</string> + <string>doSelectionTitleCase:</string> + <string>doSelectionUpperCase:</string> + <string>doTranspose:</string> + <string>selectCurrentLine:</string> + <string>selectCurrentWord:</string> + <string>selectEnclosingBrackets:</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + </object> + </object> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">Source/SPTextViewAdditions.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSWindow</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">Source/SPWindowAdditions.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> <string key="className">SPEditSheetTextView</string> <string key="superclassName">NSTextView</string> <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBUserSource</string> - <string key="minorKey"/> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">Source/SPEditSheetTextView.h</string> </object> </object> - </object> - <object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.1+"> - <bool key="EncodedWithXMLCoder">YES</bool> <object class="IBPartialClassDescription"> <string key="className">SPEditSheetTextView</string> <string key="superclassName">NSTextView</string> <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBDocumentRelativeSource</string> - <string key="minorKey">../../Source/SPEditSheetTextView.h</string> + <string key="majorKey">IBUserSource</string> + <string key="minorKey"/> </object> </object> <object class="IBPartialClassDescription"> @@ -1497,14 +1619,14 @@ </object> </object> <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBDocumentRelativeSource</string> - <string key="minorKey">../../Source/SPFieldEditorController.h</string> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">Source/SPFieldEditorController.h</string> </object> </object> </object> </object> <int key="IBDocument.localizationMode">0</int> - <nil key="IBDocument.LastKnownRelativeProjectPath"/> + <string key="IBDocument.LastKnownRelativeProjectPath">../../sequel-pro.xcodeproj</string> <int key="IBDocument.defaultPropertyAccessControl">3</int> </data> </archive> diff --git a/Source/SPFieldEditorController.m b/Source/SPFieldEditorController.m index e62a2beb..9b0eda67 100644 --- a/Source/SPFieldEditorController.m +++ b/Source/SPFieldEditorController.m @@ -195,7 +195,6 @@ return ( code && isEditable ) ? [sheetEditData retain] : nil; } - - (IBAction)closeEditSheet:(id)sender { [NSApp stopModalWithCode:[sender tag]]; @@ -203,67 +202,11 @@ - (IBAction)openEditSheet:(id)sender { - NSOpenPanel *panel = [NSOpenPanel openPanel]; - - if ( [panel runModal] == NSOKButton ) { - NSString *fileName = [panel filename]; - NSString *contents = nil; - - editSheetWillBeInitialized = YES; - - [editSheetProgressBar startAnimation:self]; - - // free old data - if ( sheetEditData != nil ) { - [sheetEditData release]; - } - - // load new data/images - sheetEditData = [[NSData alloc] initWithContentsOfFile:fileName]; - - NSImage *image = [[NSImage alloc] initWithData:sheetEditData]; - contents = [[NSString alloc] initWithData:sheetEditData encoding:encoding]; - if (contents == nil) - contents = [[NSString alloc] initWithData:sheetEditData encoding:NSASCIIStringEncoding]; - - // set the image preview, string contents and hex representation - [editImage setImage:image]; - - - if(contents) - [editTextView setString:contents]; - else - [editTextView setString:@""]; - - // Load hex data only if user has already displayed them - if(![[hexTextView string] isEqualToString:@""]) - [hexTextView setString:[sheetEditData dataToFormattedHexString]]; - - // If the image cell now contains a valid image, select the image view - if (image) { - [editSheetSegmentControl setSelectedSegment:1]; - [hexTextView setHidden:YES]; - [hexTextScrollView setHidden:YES]; - [editImage setHidden:NO]; - [editTextView setHidden:YES]; - [editTextScrollView setHidden:YES]; - - // Otherwise deselect the image view - } else { - [editSheetSegmentControl setSelectedSegment:0]; - [hexTextView setHidden:YES]; - [hexTextScrollView setHidden:YES]; - [editImage setHidden:YES]; - [editTextView setHidden:NO]; - [editTextScrollView setHidden:NO]; - } - - [image release]; - if(contents) - [contents release]; - [editSheetProgressBar stopAnimation:self]; - editSheetWillBeInitialized = NO; - } + [[NSOpenPanel openPanel] beginSheetForDirectory:nil + file:@"" + modalForWindow:[self window] + modalDelegate:self didEndSelector:@selector(openPanelDidEnd:returnCode:contextInfo:) + contextInfo:NULL]; } /* @@ -312,10 +255,21 @@ * Saves a file containing the content of the editSheet */ - (IBAction)saveEditSheet:(id)sender +{ + [[NSSavePanel savePanel] beginSheetForDirectory:nil + file:@"" + modalForWindow:[self window] + modalDelegate:self + didEndSelector:@selector(savePanelDidEnd:returnCode:contextInfo:) + contextInfo:NULL]; +} + +/** + * Save panel didEndSelector. Writes the current content to disk. + */ +- (void)savePanelDidEnd:(NSSavePanel *)panel returnCode:(int)returnCode contextInfo:(void *)contextInfo { - NSSavePanel *panel = [NSSavePanel savePanel]; - - if ( [panel runModal] == NSOKButton ) { + if (returnCode == NSOKButton) { [editSheetProgressBar startAnimation:self]; @@ -324,9 +278,10 @@ // Write binary field types directly to the file if ( [sheetEditData isKindOfClass:[NSData class]] ) { [sheetEditData writeToFile:fileName atomically:YES]; - + // Write other field types' representations to the file via the current encoding - } else { + } + else { [[sheetEditData description] writeToFile:fileName atomically:YES encoding:encoding @@ -334,10 +289,74 @@ } [editSheetProgressBar stopAnimation:self]; - } } +/** + * Open panel didEndSelector. Opens the selected file. + */ +- (void)openPanelDidEnd:(NSOpenPanel *)panel returnCode:(int)returnCode contextInfo:(void *)contextInfo +{ + if (returnCode == NSOKButton) { + NSString *fileName = [panel filename]; + NSString *contents = nil; + + editSheetWillBeInitialized = YES; + + [editSheetProgressBar startAnimation:self]; + + // free old data + if ( sheetEditData != nil ) { + [sheetEditData release]; + } + + // load new data/images + sheetEditData = [[NSData alloc] initWithContentsOfFile:fileName]; + + NSImage *image = [[NSImage alloc] initWithData:sheetEditData]; + contents = [[NSString alloc] initWithData:sheetEditData encoding:encoding]; + if (contents == nil) + contents = [[NSString alloc] initWithData:sheetEditData encoding:NSASCIIStringEncoding]; + + // set the image preview, string contents and hex representation + [editImage setImage:image]; + + + if(contents) + [editTextView setString:contents]; + else + [editTextView setString:@""]; + + // Load hex data only if user has already displayed them + if(![[hexTextView string] isEqualToString:@""]) + [hexTextView setString:[sheetEditData dataToFormattedHexString]]; + + // If the image cell now contains a valid image, select the image view + if (image) { + [editSheetSegmentControl setSelectedSegment:1]; + [hexTextView setHidden:YES]; + [hexTextScrollView setHidden:YES]; + [editImage setHidden:NO]; + [editTextView setHidden:YES]; + [editTextScrollView setHidden:YES]; + + // Otherwise deselect the image view + } else { + [editSheetSegmentControl setSelectedSegment:0]; + [hexTextView setHidden:YES]; + [hexTextScrollView setHidden:YES]; + [editImage setHidden:YES]; + [editTextView setHidden:NO]; + [editTextScrollView setHidden:NO]; + } + + [image release]; + if(contents) + [contents release]; + [editSheetProgressBar stopAnimation:self]; + editSheetWillBeInitialized = NO; + } +} #pragma mark - #pragma mark QuickLook |