diff options
author | Bibiko <bibiko@eva.mpg.de> | 2009-07-16 21:21:48 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2009-07-16 21:21:48 +0000 |
commit | e924f11978d280345572960636e5ffc42b53b5b2 (patch) | |
tree | fc8f25b1caab34cab21277e6c3228d88c77ecc19 | |
parent | 6f637e7b2b68de486c8fb5cd2e6ac5c0dd59c8c6 (diff) | |
download | sequelpro-e924f11978d280345572960636e5ffc42b53b5b2.tar.gz sequelpro-e924f11978d280345572960636e5ffc42b53b5b2.tar.bz2 sequelpro-e924f11978d280345572960636e5ffc42b53b5b2.zip |
• some further progress on outsourcing the Field Editor sheet for Content and Custom Query Tab
-rw-r--r-- | Interfaces/English.lproj/FieldEditorSheet.xib | 247 | ||||
-rw-r--r-- | Source/SPFieldEditor.h | 58 | ||||
-rw-r--r-- | Source/SPFieldEditorController.h | 73 | ||||
-rw-r--r-- | Source/SPFieldEditorController.m (renamed from Source/SPFieldEditor.m) | 297 | ||||
-rw-r--r-- | sequel-pro.xcodeproj/project.pbxproj | 12 |
5 files changed, 449 insertions, 238 deletions
diff --git a/Interfaces/English.lproj/FieldEditorSheet.xib b/Interfaces/English.lproj/FieldEditorSheet.xib index 71414e99..f4c44148 100644 --- a/Interfaces/English.lproj/FieldEditorSheet.xib +++ b/Interfaces/English.lproj/FieldEditorSheet.xib @@ -8,7 +8,6 @@ <string key="IBDocument.HIToolboxVersion">353.00</string> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> - <integer value="2"/> </object> <object class="NSArray" key="IBDocument.PluginDependencies"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -26,7 +25,7 @@ <object class="NSMutableArray" key="IBDocument.RootObjects" id="1000"> <bool key="EncodedWithXMLCoder">YES</bool> <object class="NSCustomObject" id="1001"> - <string key="NSClassName">SPFieldEditor</string> + <string key="NSClassName">SPFieldEditorController</string> </object> <object class="NSCustomObject" id="1003"> <string key="NSClassName">FirstResponder</string> @@ -37,17 +36,17 @@ <object class="NSWindowTemplate" id="172882781"> <int key="NSWindowStyleMask">9</int> <int key="NSWindowBacking">2</int> - <string key="NSWindowRect">{{115, 389}, {667, 416}}</string> - <int key="NSWTFlags">1886912512</int> + <string key="NSWindowRect">{{364, 195}, {667, 416}}</string> + <int key="NSWTFlags">1618477056</int> <string key="NSWindowTitle">Field Editor</string> - <string key="NSWindowClass">NSWindow</string> + <string key="NSWindowClass">NSPanel</string> <object class="NSMutableString" key="NSViewClass"> <characters key="NS.bytes">View</characters> </object> <string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string> <string key="NSWindowContentMinSize">{560, 200}</string> <object class="NSView" key="NSWindowView" id="559857537"> - <reference key="NSNextResponder"/> + <nil key="NSNextResponder"/> <int key="NSvFlags">4370</int> <object class="NSMutableArray" key="NSSubviews"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -465,7 +464,6 @@ </object> <string key="NSFrameSize">{667, 370}</string> <reference key="NSSuperview" ref="983787914"/> - <reference key="NSNextKeyView" ref="459839028"/> <reference key="NSDocView" ref="459839028"/> <reference key="NSBGColor" ref="940290613"/> <object class="NSCursor" key="NSCursor" id="956874367"> @@ -498,7 +496,6 @@ </object> <string key="NSFrame">{{0, 39}, {667, 370}}</string> <reference key="NSSuperview" ref="559857537"/> - <reference key="NSNextKeyView" ref="1068411389"/> <int key="NSsFlags">528</int> <reference key="NSVScroller" ref="977735067"/> <reference key="NSHScroller" ref="426249328"/> @@ -545,29 +542,6 @@ <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"> @@ -638,7 +612,6 @@ </object> <string key="NSFrameSize">{667, 370}</string> <reference key="NSSuperview" ref="604699677"/> - <reference key="NSNextKeyView" ref="702566211"/> <reference key="NSDocView" ref="702566211"/> <reference key="NSBGColor" ref="940290613"/> <reference key="NSCursor" ref="956874367"/> @@ -668,7 +641,6 @@ </object> <string key="NSFrame">{{0, 39}, {667, 370}}</string> <reference key="NSSuperview" ref="559857537"/> - <reference key="NSNextKeyView" ref="967441740"/> <int key="NSsFlags">528</int> <reference key="NSVScroller" ref="699979333"/> <reference key="NSHScroller" ref="393370468"/> @@ -708,7 +680,6 @@ </object> </object> <string key="NSFrameSize">{667, 416}</string> - <reference key="NSSuperview"/> </object> <string key="NSScreenRect">{{0, 0}, {1280, 778}}</string> <string key="NSMinSize">{560, 222}</string> @@ -719,6 +690,198 @@ <object class="IBObjectContainer" key="IBDocument.Objects"> <object class="NSMutableArray" key="connectionRecords"> <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">closeEditSheet:</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="315097820"/> + </object> + <int key="connectionID">40</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">closeEditSheet:</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="760872156"/> + </object> + <int key="connectionID">41</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">saveEditSheet:</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="212849560"/> + </object> + <int key="connectionID">42</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">openEditSheet:</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="16151679"/> + </object> + <int key="connectionID">43</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">segmentControllerChanged:</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="13679998"/> + </object> + <int key="connectionID">44</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">quickLookFormatButton:</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="657320705"/> + </object> + <int key="connectionID">45</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">quickLookFormatButton:</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="331580392"/> + </object> + <int key="connectionID">46</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">quickLookFormatButton:</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="350758430"/> + </object> + <int key="connectionID">47</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">quickLookFormatButton:</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="231072377"/> + </object> + <int key="connectionID">48</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">quickLookFormatButton:</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="254749674"/> + </object> + <int key="connectionID">49</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">quickLookFormatButton:</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="853091810"/> + </object> + <int key="connectionID">50</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">editSheetProgressBar</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="450296515"/> + </object> + <int key="connectionID">51</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">editTextView</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="702566211"/> + </object> + <int key="connectionID">52</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">editTextScrollView</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="604699677"/> + </object> + <int key="connectionID">53</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">hexTextView</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="459839028"/> + </object> + <int key="connectionID">54</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">hexTextScrollView</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="983787914"/> + </object> + <int key="connectionID">55</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">editImage</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="189033461"/> + </object> + <int key="connectionID">56</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">editSheetQuickLookButton</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="766971294"/> + </object> + <int key="connectionID">57</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">dropImage:</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="189033461"/> + </object> + <int key="connectionID">58</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">delegate</string> + <reference key="source" ref="189033461"/> + <reference key="destination" ref="1001"/> + </object> + <int key="connectionID">59</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">delegate</string> + <reference key="source" ref="702566211"/> + <reference key="destination" ref="1001"/> + </object> + <int key="connectionID">60</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">editSheetSegmentControl</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="13679998"/> + </object> + <int key="connectionID">61</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">delegate</string> + <reference key="source" ref="172882781"/> + <reference key="destination" ref="1001"/> + </object> + <int key="connectionID">62</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">editSheet</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="172882781"/> + </object> + <int key="connectionID">63</int> + </object> </object> <object class="IBMutableOrderedSet" key="objectRecords"> <object class="NSArray" key="orderedObjects"> @@ -1095,8 +1258,8 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{226, 92}, {667, 416}}</string> - <string>{{226, 92}, {667, 416}}</string> + <string>{{232, 340}, {667, 416}}</string> + <string>{{232, 340}, {667, 416}}</string> <reference ref="9"/> <integer value="0" id="8"/> <reference ref="9"/> @@ -1119,7 +1282,7 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <reference ref="9"/> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{705, 112}, {126, 173}}</string> + <string>{{543, -49}, {126, 173}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> @@ -1188,7 +1351,7 @@ </object> </object> <nil key="sourceID"/> - <int key="maxID">39</int> + <int key="maxID">63</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> @@ -1217,8 +1380,8 @@ <object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.1+"> <bool key="EncodedWithXMLCoder">YES</bool> <object class="IBPartialClassDescription"> - <string key="className">SPFieldEditor</string> - <string key="superclassName">NSWindow</string> + <string key="className">SPFieldEditorController</string> + <string key="superclassName">NSWindowController</string> <object class="NSMutableDictionary" key="actions"> <bool key="EncodedWithXMLCoder">YES</bool> <object class="NSMutableArray" key="dict.sortedKeys"> @@ -1245,6 +1408,7 @@ <object class="NSMutableArray" key="dict.sortedKeys"> <bool key="EncodedWithXMLCoder">YES</bool> <string>editImage</string> + <string>editSheet</string> <string>editSheetProgressBar</string> <string>editSheetQuickLookButton</string> <string>editSheetSegmentControl</string> @@ -1265,11 +1429,12 @@ <string>id</string> <string>id</string> <string>id</string> + <string>id</string> </object> </object> <object class="IBClassDescriptionSource" key="sourceIdentifier"> <string key="majorKey">IBDocumentRelativeSource</string> - <string key="minorKey">../../Source/SPFieldEditor.h</string> + <string key="minorKey">../../Source/SPFieldEditorController.h</string> </object> </object> </object> diff --git a/Source/SPFieldEditor.h b/Source/SPFieldEditor.h deleted file mode 100644 index 1271b483..00000000 --- a/Source/SPFieldEditor.h +++ /dev/null @@ -1,58 +0,0 @@ -// -// SPFieldEditor.h -// sequel-pro -// -// Created by Bibiko on 25.06.09. -// Copyright 2009 __MyCompanyName__. All rights reserved. -// - -#import <Cocoa/Cocoa.h> - - -@interface SPFieldEditor : NSWindow { - - IBOutlet id editSheetProgressBar; - IBOutlet id editSheetSegmentControl; - IBOutlet id editSheetQuickLookButton; - IBOutlet id editImage; - IBOutlet id editTextView; - IBOutlet id hexTextView; - IBOutlet id editTextScrollView; - IBOutlet id hexTextScrollView; - - id sheetEditData; - - NSString *stringValue; - - BOOL editSheetWillBeInitialized; - BOOL isBlob; - int quickLookCloseMarker; - NSStringEncoding encoding; - - -} - -- (IBAction)closeEditSheet:(id)sender; -- (IBAction)openEditSheet:(id)sender; -- (IBAction)saveEditSheet:(id)sender; -- (IBAction)dropImage:(id)sender; -- (IBAction)segmentControllerChanged:(id)sender; -- (IBAction)quickLookFormatButton:(id)sender; -- (IBAction)dropImage:(id)sender; - -- (void)initWithObject:(id)data usingEncoding:(NSStringEncoding)anEncoding isObjectBlob:(BOOL)isFieldBlob; - -- (void)processPasteImageData; -- (void)processUpdatedImageData:(NSData *)data; - -- (id)editData; - -- (void)invokeQuickLookOfType:(NSString *)type treatAsText:(BOOL)isText; -- (void)removeQuickLooksTempFile:(NSString*)aPath; - -- (BOOL)textView:(NSTextView *)aTextView doCommandBySelector:(SEL)aSelector; -- (void)textViewDidChangeSelection:(NSNotification *)notification; - -- (void)clean; - -@end diff --git a/Source/SPFieldEditorController.h b/Source/SPFieldEditorController.h new file mode 100644 index 00000000..4867276f --- /dev/null +++ b/Source/SPFieldEditorController.h @@ -0,0 +1,73 @@ +// +// $Id: SPFieldEditorController.h 802 2009-06-03 20:46:57Z bibiko $ +// +// SPFieldEditorController.m +// sequel-pro +// +// Created by Hans-Jörg Bibiko on July 16, 2009 +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// More info at <http://code.google.com/p/sequel-pro/> + +#import <Cocoa/Cocoa.h> + + +@interface SPFieldEditorController : NSWindowController { + + IBOutlet id editSheetProgressBar; + IBOutlet id editSheetSegmentControl; + IBOutlet id editSheetQuickLookButton; + IBOutlet id editImage; + IBOutlet id editTextView; + IBOutlet id hexTextView; + IBOutlet id editTextScrollView; + IBOutlet id hexTextScrollView; + IBOutlet id editSheet; + + id sheetEditData; + + NSString *stringValue; + + BOOL editSheetWillBeInitialized; + BOOL isBlob; + int quickLookCloseMarker; + NSStringEncoding encoding; + + +} + +- (IBAction)closeEditSheet:(id)sender; +- (IBAction)openEditSheet:(id)sender; +- (IBAction)saveEditSheet:(id)sender; +- (IBAction)dropImage:(id)sender; +- (IBAction)segmentControllerChanged:(id)sender; +- (IBAction)quickLookFormatButton:(id)sender; +- (IBAction)dropImage:(id)sender; + +- (id)editWithObject:(id)data usingEncoding:(NSStringEncoding)anEncoding isObjectBlob:(BOOL)isFieldBlob withWindow:(NSWindow *)tableWindow; + +- (void)processPasteImageData; +- (void)processUpdatedImageData:(NSData *)data; + +- (void)invokeQuickLookOfType:(NSString *)type treatAsText:(BOOL)isText; +- (void)removeQuickLooksTempFile:(NSString*)aPath; + +- (BOOL)textView:(NSTextView *)aTextView doCommandBySelector:(SEL)aSelector; +- (void)textViewDidChangeSelection:(NSNotification *)notification; + +- (void)clean; + +@end diff --git a/Source/SPFieldEditor.m b/Source/SPFieldEditorController.m index e8ac915f..ed2f941e 100644 --- a/Source/SPFieldEditor.m +++ b/Source/SPFieldEditorController.m @@ -1,12 +1,28 @@ // -// SPFieldEditor.m +// $Id: SPFieldEditorController.m 802 2009-06-03 20:46:57Z bibiko $ +// +// SPFieldEditorController.m // sequel-pro // -// Created by Bibiko on 25.06.09. -// Copyright 2009 __MyCompanyName__. All rights reserved. +// Created by Hans-Jörg Bibiko on July 16, 2009 +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. // +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// More info at <http://code.google.com/p/sequel-pro/> -#import "SPFieldEditor.h" +#import "SPFieldEditorController.h" #import "SPStringAdditions.h" #import "SPArrayAdditions.h" #import "SPTextViewAdditions.h" @@ -14,60 +30,69 @@ #import "QLPreviewPanel.h" -@implementation SPFieldEditor +@implementation SPFieldEditorController -// - (id) init -// { -// [self clean]; -// self = [super init]; -// return self; -// } +- (id) init +{ + if ((self = [super initWithWindowNibName:@"FieldEditorSheet"])) { + // force the nib to be loaded + (void) [self window]; + } + return self; + +} -- (void)initWithObject:(id)data usingEncoding:(NSStringEncoding)anEncoding isObjectBlob:(BOOL)isFieldBlob +- (void) dealloc { + [super dealloc]; +} +- (id)editWithObject:(id)data usingEncoding:(NSStringEncoding)anEncoding isObjectBlob:(BOOL)isFieldBlob withWindow:(NSWindow *)tableWindow +{ + [self clean]; - // hide all views in editSheet [hexTextView setHidden:YES]; [hexTextScrollView setHidden:YES]; [editImage setHidden:YES]; [editTextView setHidden:YES]; [editTextScrollView setHidden:YES]; - + editSheetWillBeInitialized = YES; - + encoding = anEncoding; - + isBlob = isFieldBlob; - + // sheetEditData = data; sheetEditData = [data copy]; - NSLog(@"bbb:%@", sheetEditData); - + // hide all views in editSheet [hexTextView setHidden:YES]; [hexTextScrollView setHidden:YES]; [editImage setHidden:YES]; [editTextView setHidden:YES]; [editTextScrollView setHidden:YES]; - + // Hide QuickLook button and text/iamge/hex control for text data [editSheetQuickLookButton setHidden:(!isBlob)]; [editSheetSegmentControl setHidden:(!isBlob)]; - + + [NSApp beginSheet:editSheet modalForWindow:tableWindow modalDelegate:self didEndSelector:nil contextInfo:nil]; + [editSheetProgressBar startAnimation:self]; + NSImage *image = nil; if ( [sheetEditData isKindOfClass:[NSData class]] ) { image = [[[NSImage alloc] initWithData:sheetEditData] autorelease]; - + // Set hex view to "" - load on demand only [hexTextView setString:@""]; stringValue = [[NSString alloc] initWithData:sheetEditData encoding:encoding]; if (stringValue == nil) stringValue = [[NSString alloc] initWithData:sheetEditData encoding:NSASCIIStringEncoding]; - + [hexTextView setHidden:NO]; [hexTextScrollView setHidden:NO]; [editImage setHidden:YES]; @@ -76,9 +101,9 @@ [editSheetSegmentControl setSelectedSegment:2]; } else { stringValue = [sheetEditData retain]; - + [hexTextView setString:@""]; - + [hexTextView setHidden:YES]; [hexTextScrollView setHidden:YES]; [editImage setHidden:YES]; @@ -86,10 +111,10 @@ [editTextScrollView setHidden:NO]; [editSheetSegmentControl setSelectedSegment:0]; } - + if (image) { [editImage setImage:image]; - + [hexTextView setHidden:YES]; [hexTextScrollView setHidden:YES]; [editImage setHidden:NO]; @@ -101,8 +126,7 @@ } if (stringValue) { [editTextView setString:stringValue]; - NSLog(@"tv:%@", [editTextView class]); - + if(image == nil) { [hexTextView setHidden:YES]; [hexTextScrollView setHidden:YES]; @@ -110,34 +134,48 @@ [editTextView setHidden:NO]; [editTextScrollView setHidden:NO]; [editSheetSegmentControl setSelectedSegment:0]; - } - + } + // Locate the caret in editTextView // (to select all takes a bit time for large data) [editTextView setSelectedRange:NSMakeRange(0,0)]; - + // Set focus if(image == nil) - [self makeFirstResponder:editTextView]; + [editSheet makeFirstResponder:editTextView]; else - [self makeFirstResponder:editImage]; - + [editSheet makeFirstResponder:editImage]; + [stringValue release]; } editSheetWillBeInitialized = NO; - + [editSheetProgressBar stopAnimation:self]; - - + + // wait for editSheet + int code = [NSApp runModalForWindow:editSheet]; + + [NSApp endSheet:editSheet]; + [editSheet orderOut:nil]; + + + // For safety reasons inform QuickLook to quit + quickLookCloseMarker = 1; + + if ( code ) return [sheetEditData autorelease]; + + [self clean]; + + return nil; } - (void)clean { [hexTextView setString:@""]; - [editTextView setString:@"AA"]; + [editTextView setString:@""]; [editImage setImage:nil]; if ( sheetEditData ) { [sheetEditData release]; @@ -145,13 +183,6 @@ } -- (id)editData -{ - NSLog(@"aa:%@", sheetEditData); - return [sheetEditData copy]; -} - - - (IBAction)closeEditSheet:(id)sender { [NSApp stopModalWithCode:[sender tag]]; @@ -164,11 +195,11 @@ if ( [panel runModal] == NSOKButton ) { NSString *fileName = [panel filename]; NSString *contents = nil; - + editSheetWillBeInitialized = YES; - + [editSheetProgressBar startAnimation:self]; - + // free old data if ( sheetEditData != nil ) { [sheetEditData release]; @@ -176,15 +207,15 @@ // 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]; @@ -194,7 +225,7 @@ // 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]; @@ -203,8 +234,8 @@ [editImage setHidden:NO]; [editTextView setHidden:YES]; [editTextScrollView setHidden:YES]; - - // Otherwise deselect the image view + + // Otherwise deselect the image view } else { [editSheetSegmentControl setSelectedSegment:0]; [hexTextView setHidden:YES]; @@ -229,34 +260,34 @@ { switch([sender selectedSegment]){ case 0: // text - [editTextView setHidden:NO]; - [editTextScrollView setHidden:NO]; - [editImage setHidden:YES]; - [hexTextView setHidden:YES]; - [hexTextScrollView setHidden:YES]; - // [self makeFirstResponder:editTextView]; - break; + [editTextView setHidden:NO]; + [editTextScrollView setHidden:NO]; + [editImage setHidden:YES]; + [hexTextView setHidden:YES]; + [hexTextScrollView setHidden:YES]; + // [self makeFirstResponder:editTextView]; + break; case 1: // image - [editTextView setHidden:YES]; - [editTextScrollView setHidden:YES]; - [editImage setHidden:NO]; - [hexTextView setHidden:YES]; - [hexTextScrollView setHidden:YES]; - // [self makeFirstResponder:editImage]; - break; + [editTextView setHidden:YES]; + [editTextScrollView setHidden:YES]; + [editImage setHidden:NO]; + [hexTextView setHidden:YES]; + [hexTextScrollView setHidden:YES]; + // [self makeFirstResponder:editImage]; + break; case 2: // hex - load on demand - if([sheetEditData length] && [[hexTextView string] isEqualToString:@""]) { - [editSheetProgressBar startAnimation:self]; - [hexTextView setString:[sheetEditData dataToFormattedHexString]]; - [editSheetProgressBar stopAnimation:self]; - } - [editTextView setHidden:YES]; - [editTextScrollView setHidden:YES]; - [editImage setHidden:YES]; - [hexTextView setHidden:NO]; - [hexTextScrollView setHidden:NO]; - // [self makeFirstResponder:hexTextView]; - break; + if([sheetEditData length] && [[hexTextView string] isEqualToString:@""]) { + [editSheetProgressBar startAnimation:self]; + [hexTextView setString:[sheetEditData dataToFormattedHexString]]; + [editSheetProgressBar stopAnimation:self]; + } + [editTextView setHidden:YES]; + [editTextScrollView setHidden:YES]; + [editImage setHidden:YES]; + [hexTextView setHidden:NO]; + [hexTextScrollView setHidden:NO]; + // [self makeFirstResponder:hexTextView]; + break; } } @@ -268,26 +299,26 @@ NSSavePanel *panel = [NSSavePanel savePanel]; if ( [panel runModal] == NSOKButton ) { - + [editSheetProgressBar startAnimation:self]; - + NSString *fileName = [panel filename]; // Write binary field types directly to the file //// || [editSheetBinaryButton state] == NSOnState if ( [sheetEditData isKindOfClass:[NSData class]] ) { [sheetEditData writeToFile:fileName atomically:YES]; - - // Write other field types' representations to the file via the current encoding + + // Write other field types' representations to the file via the current encoding } else { [[sheetEditData description] writeToFile:fileName - atomically:YES - encoding:encoding - error:NULL]; + atomically:YES + encoding:encoding + error:NULL]; } - + [editSheetProgressBar stopAnimation:self]; - + } } @@ -315,34 +346,34 @@ */ - (void)invokeQuickLookOfType:(NSString *)type treatAsText:(BOOL)isText { - + // Load private framework if([[NSBundle bundleWithPath:@"/System/Library/PrivateFrameworks/QuickLookUI.framework"] load]) { - + [editSheetProgressBar startAnimation:self]; - + // Create a temporary file name to store the data as file // since QuickLook only works on files. NSString *tmpFileName = [NSString stringWithFormat:@"/tmp/SequelProQuickLook.%@", type]; - + // if data are binary if ( [sheetEditData isKindOfClass:[NSData class]] || !isText) { [sheetEditData writeToFile:tmpFileName atomically:YES]; - - // write other field types' representations to the file via the current encoding + + // write other field types' representations to the file via the current encoding } else { [[sheetEditData description] writeToFile:tmpFileName - atomically:YES - encoding:encoding - error:NULL]; + atomically:YES + encoding:encoding + error:NULL]; } - + id ql = [NSClassFromString(@"QLPreviewPanel") sharedPreviewPanel]; - + // Init QuickLook [[ql delegate] setDelegate:self]; [ql setURLs:[NSArray arrayWithObject: - [NSURL fileURLWithPath:tmpFileName]] currentIndex:0 preservingDisplayState:YES]; + [NSURL fileURLWithPath:tmpFileName]] currentIndex:0 preservingDisplayState:YES]; // TODO: No interaction with iChat and iPhoto due to .scriptSuite warning: // for superclass of class 'MainController' in suite 'Sequel Pro': 'NSCoreSuite.NSAbstractObject' is not a valid class name. [ql setShowsAddToiPhotoButton:NO]; @@ -353,12 +384,12 @@ [ql setEnableDragNDrop:NO]; // Order out QuickLook with animation effect according to self:previewPanel:frameForURL: [ql makeKeyAndOrderFrontWithEffect:2]; // 1 = fade in - + // quickLookCloseMarker == 1 break the modal session quickLookCloseMarker = 0; - + [editSheetProgressBar stopAnimation:self]; - + // Run QuickLook in its own modal seesion for event handling NSModalSession session = [NSApp beginModalSessionForWindow:ql]; for (;;) { @@ -368,11 +399,11 @@ || ![ql isVisible]) break; [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode - beforeDate:[NSDate distantFuture]]; - + beforeDate:[NSDate distantFuture]]; + } [NSApp endModalSession:session]; - + // Remove temp file after closing the sheet to allow double-click event at the QuickLook preview. // The afterDelay: time is a kind of dummy, because after double-clicking the model session loop // will break (ql not visible) and returns the event handling back to the editSheet which by itself @@ -380,9 +411,9 @@ [self performSelector:@selector(removeQuickLooksTempFile:) withObject:tmpFileName afterDelay:2]; // [[NSFileManager defaultManager] removeItemAtPath:tmpFileName error:NULL]; - + } - + } - (void)removeQuickLooksTempFile:(NSString*)aPath @@ -395,49 +426,49 @@ // If an empty frame is returned then the panel will fade in/out instead - (NSRect)previewPanel:(NSPanel*)panel frameForURL:(NSURL*)URL { - + // Close modal session defined in invokeQuickLookOfType: // if user closes the QuickLook view quickLookCloseMarker = 1; - + // Return the App's middle point NSRect mwf = [[NSApp mainWindow] frame]; return NSMakeRect( - mwf.origin.x+mwf.size.width/2, - mwf.origin.y+mwf.size.height/2, - 5, 5); - + mwf.origin.x+mwf.size.width/2, + mwf.origin.y+mwf.size.height/2, + 5, 5); + } -(void)processPasteImageData { editSheetWillBeInitialized = YES; - + NSImage *image = nil; image = [[[NSImage alloc] initWithPasteboard:[NSPasteboard generalPasteboard]] autorelease]; if (image) { - + if (nil != sheetEditData) [sheetEditData release]; - + [editImage setImage:image]; - + sheetEditData = [[NSData alloc] initWithData:[image TIFFRepresentationUsingCompression:NSTIFFCompressionLZW factor:1]]; - + NSString *contents = [[NSString alloc] initWithData:sheetEditData encoding:encoding]; if (contents == nil) contents = [[NSString alloc] initWithData:sheetEditData encoding:NSASCIIStringEncoding]; - + // Set the string contents and hex representation if(contents) [editTextView setString:contents]; if(![[hexTextView string] isEqualToString:@""]) [hexTextView setString:[sheetEditData dataToFormattedHexString]]; - + [contents release]; } - + editSheetWillBeInitialized = NO; } /* @@ -446,11 +477,11 @@ */ - (void)processUpdatedImageData:(NSData *)data { - + editSheetWillBeInitialized = YES; - + if (nil != sheetEditData) [sheetEditData release]; - + // If the image was not processed, set a blank string as the contents of the edit and hex views. if ( data == nil ) { sheetEditData = [[NSData alloc] init]; @@ -459,13 +490,13 @@ editSheetWillBeInitialized = NO; return; } - + // Process the provided image sheetEditData = [[NSData alloc] initWithData:data]; NSString *contents = [[NSString alloc] initWithData:data encoding:encoding]; if (contents == nil) contents = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]; - + // Set the string contents and hex representation if(contents) [editTextView setString:contents]; @@ -478,7 +509,7 @@ - (IBAction)dropImage:(id)sender { - + // If the image was deleted, set a blank string as the contents of the edit and hex views. // The actual dropped image processing is handled by processUpdatedImageData:. if ( [editImage image] == nil ) { @@ -495,11 +526,11 @@ invoked when the user changes the string in the editSheet */ { - + // Do nothing if user really didn't changed text (e.g. for font size changing return) if(editSheetWillBeInitialized || ([[[notification object] textStorage] changeInLength]==0)) return; - + // clear the image and hex (since i doubt someone can "type" a gif) [editImage setImage:nil]; [hexTextView setString:@""]; @@ -511,7 +542,7 @@ // set edit data to text sheetEditData = [[editTextView string] retain]; - + } // TextView delegate methods diff --git a/sequel-pro.xcodeproj/project.pbxproj b/sequel-pro.xcodeproj/project.pbxproj index 5746922d..dc874a9f 100644 --- a/sequel-pro.xcodeproj/project.pbxproj +++ b/sequel-pro.xcodeproj/project.pbxproj @@ -160,7 +160,7 @@ BC2C16D40FEBEDF10003993B /* SPDataAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = BC2C16D30FEBEDF10003993B /* SPDataAdditions.m */; }; BC2C8E220FA8C2DB008468C7 /* sequel-pro-mysql-help-template.html in Resources */ = {isa = PBXBuildFile; fileRef = BC2C8E210FA8C2DB008468C7 /* sequel-pro-mysql-help-template.html */; }; BC8C8532100E0A8000D7A129 /* SPTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = BC8C8531100E0A8000D7A129 /* SPTableView.m */; }; - BC99296E0FF3D001008B79AB /* SPFieldEditor.m in Sources */ = {isa = PBXBuildFile; fileRef = BC99296D0FF3D001008B79AB /* SPFieldEditor.m */; }; + BC9F0881100FCF2C00A80D32 /* SPFieldEditorController.m in Sources */ = {isa = PBXBuildFile; fileRef = BC9F0880100FCF2C00A80D32 /* SPFieldEditorController.m */; }; BCA6F631100FA7D700E80253 /* FieldEditorSheet.xib in Resources */ = {isa = PBXBuildFile; fileRef = BCA6F62F100FA7D700E80253 /* FieldEditorSheet.xib */; }; BCD0AD490FBBFC340066EA5C /* SPSQLTokenizer.l in Sources */ = {isa = PBXBuildFile; fileRef = BCD0AD480FBBFC340066EA5C /* SPSQLTokenizer.l */; }; /* End PBXBuildFile section */ @@ -457,8 +457,8 @@ BC2C8E210FA8C2DB008468C7 /* sequel-pro-mysql-help-template.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "sequel-pro-mysql-help-template.html"; sourceTree = "<group>"; }; BC8C8530100E0A8000D7A129 /* SPTableView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPTableView.h; sourceTree = "<group>"; }; BC8C8531100E0A8000D7A129 /* SPTableView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPTableView.m; sourceTree = "<group>"; }; - BC99296C0FF3D001008B79AB /* SPFieldEditor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPFieldEditor.h; sourceTree = "<group>"; }; - BC99296D0FF3D001008B79AB /* SPFieldEditor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPFieldEditor.m; sourceTree = "<group>"; }; + BC9F087F100FCF2C00A80D32 /* SPFieldEditorController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPFieldEditorController.h; sourceTree = "<group>"; }; + BC9F0880100FCF2C00A80D32 /* SPFieldEditorController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPFieldEditorController.m; sourceTree = "<group>"; }; BCA6F630100FA7D700E80253 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/FieldEditorSheet.xib; sourceTree = "<group>"; }; BCD0AD480FBBFC340066EA5C /* SPSQLTokenizer.l */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.lex; path = SPSQLTokenizer.l; sourceTree = "<group>"; }; BCD0AD4A0FBBFC480066EA5C /* SPSQLTokenizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPSQLTokenizer.h; sourceTree = "<group>"; }; @@ -671,6 +671,8 @@ 170088CD0F5870E200DD6B51 /* SPQueryConsole.m */, B57747D50F7A8978003B34F9 /* SPPreferenceController.h */, B57747D30F7A8974003B34F9 /* SPPreferenceController.m */, + BC9F087F100FCF2C00A80D32 /* SPFieldEditorController.h */, + BC9F0880100FCF2C00A80D32 /* SPFieldEditorController.m */, ); name = Controllers; sourceTree = "<group>"; @@ -757,8 +759,6 @@ 5841423E0F97E11000A34B47 /* NoodleLineNumberView.m */, BC1847E80FE6EC8400094BFB /* SPEditSheetTextView.h */, BC1847E90FE6EC8400094BFB /* SPEditSheetTextView.m */, - BC99296C0FF3D001008B79AB /* SPFieldEditor.h */, - BC99296D0FF3D001008B79AB /* SPFieldEditor.m */, ); name = GUI; sourceTree = "<group>"; @@ -1275,9 +1275,9 @@ 29A1B7E50FD1293A000B88E8 /* SPPrintAccessory.m in Sources */, BC1847EA0FE6EC8400094BFB /* SPEditSheetTextView.m in Sources */, BC2C16D40FEBEDF10003993B /* SPDataAdditions.m in Sources */, - BC99296E0FF3D001008B79AB /* SPFieldEditor.m in Sources */, 5822C9B51000DB2400DCC3D6 /* SPConnectionController.m in Sources */, BC8C8532100E0A8000D7A129 /* SPTableView.m in Sources */, + BC9F0881100FCF2C00A80D32 /* SPFieldEditorController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; |