aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-06-24 10:26:35 +0000
committerBibiko <bibiko@eva.mpg.de>2009-06-24 10:26:35 +0000
commit37f9a67ef142e498d12e181b029d97a18213b8f0 (patch)
treec6c0d5633d68ca087814faebb34ee05f554b65db
parent6f0f5ec932e7a1697ee344be9526829ec8f90007 (diff)
downloadsequelpro-37f9a67ef142e498d12e181b029d97a18213b8f0.tar.gz
sequelpro-37f9a67ef142e498d12e181b029d97a18213b8f0.tar.bz2
sequelpro-37f9a67ef142e498d12e181b029d97a18213b8f0.zip
• changes in editSheet:
- generate Hex representation on demand (this speeds up the working with images enormously) - added support to paste image data via the pasteboard (data are stored as TIFF LZW compressed) - if user switched to an other view (text/iamge/hex) that view will be become first responder explicity (fixes an issue that the Open button got the focus sometimes)
-rw-r--r--Source/CMImageView.h1
-rw-r--r--Source/CMImageView.m21
-rw-r--r--Source/TableContent.m65
3 files changed, 75 insertions, 12 deletions
diff --git a/Source/CMImageView.h b/Source/CMImageView.h
index 03240395..0982debd 100644
--- a/Source/CMImageView.h
+++ b/Source/CMImageView.h
@@ -28,6 +28,7 @@
@interface NSObject (CMImageViewDelegate)
- (void)processUpdatedImageData:(NSData *)data;
+- (void)processPasteImageData;
@end
diff --git a/Source/CMImageView.m b/Source/CMImageView.m
index 44e9e186..505921f7 100644
--- a/Source/CMImageView.m
+++ b/Source/CMImageView.m
@@ -104,4 +104,25 @@
return NO;
}
+- (void)paste:(id)sender
+{
+
+ // [super paste:sender];
+ id delegateForUse = nil;
+
+ // If the delegate or the delegate's content instance doesn't implement processUpdatedImageData:,
+ // return the super's implementation
+ if (delegate) {
+ if ([delegate respondsToSelector:@selector(processUpdatedImageData:)]) {
+ delegateForUse = delegate;
+ } else if ( [delegate valueForKey:@"tableContentInstance"]
+ && [[delegate valueForKey:@"tableContentInstance"] respondsToSelector:@selector(processUpdatedImageData:)] ) {
+ delegateForUse = [delegate valueForKey:@"tableContentInstance"];
+ }
+ }
+ if (delegateForUse)
+ [delegateForUse processPasteImageData];
+
+}
+
@end \ No newline at end of file
diff --git a/Source/TableContent.m b/Source/TableContent.m
index 7327d8bd..16f86ff1 100644
--- a/Source/TableContent.m
+++ b/Source/TableContent.m
@@ -880,6 +880,8 @@
NSImage *image = [[NSImage alloc] initWithData:editData];
contents = [[NSString alloc] initWithData:editData encoding:[mySQLConnection encoding]];
+ if (contents == nil)
+ contents = [[NSString alloc] initWithData:editData encoding:NSASCIIStringEncoding];
// set the image preview, string contents and hex representation
[editImage setImage:image];
@@ -890,7 +892,9 @@
else
[editTextView setString:@""];
- [hexTextView setString:[editData dataToFormattedHexString]];
+ // Load hex data only if user has already displayed them
+ if(![[hexTextView string] isEqualToString:@""])
+ [hexTextView setString:[editData dataToFormattedHexString]];
// If the image cell now contains a valid image, select the image view
if (image) {
@@ -925,26 +929,34 @@
- (IBAction)segmentControllerChanged:(id)sender
{
switch([sender selectedSegment]){
- case 0:
+ case 0: // text
[editTextView setHidden:NO];
[editTextScrollView setHidden:NO];
[editImage setHidden:YES];
[hexTextView setHidden:YES];
[hexTextScrollView setHidden:YES];
+ [editSheet makeFirstResponder:editTextView];
break;
- case 1:
+ case 1: // image
[editTextView setHidden:YES];
[editTextScrollView setHidden:YES];
[editImage setHidden:NO];
[hexTextView setHidden:YES];
[hexTextScrollView setHidden:YES];
+ [editSheet makeFirstResponder:editImage];
break;
- case 2:
+ case 2: // hex - load on demand
+ if([editData length] && [[hexTextView string] isEqualToString:@""]) {
+ [editSheetProgressBar startAnimation:self];
+ [hexTextView setString:[editData dataToFormattedHexString]];
+ [editSheetProgressBar stopAnimation:self];
+ }
[editTextView setHidden:YES];
[editTextScrollView setHidden:YES];
[editImage setHidden:YES];
[hexTextView setHidden:NO];
[hexTextScrollView setHidden:NO];
+ [editSheet makeFirstResponder:hexTextView];
break;
}
}
@@ -1097,7 +1109,37 @@
}
+-(void)processPasteImageData
+{
+ editSheetWillBeInitialized = YES;
+
+ NSImage *image = nil;
+
+ image = [[[NSImage alloc] initWithPasteboard:[NSPasteboard generalPasteboard]] autorelease];
+ if (image) {
+
+ if (nil != editData) [editData release];
+
+ [editImage setImage:image];
+
+ editData = [[NSData alloc] initWithData:[image TIFFRepresentationUsingCompression:NSTIFFCompressionLZW factor:1]];
+
+ NSString *contents = [[NSString alloc] initWithData:editData encoding:[CMMCPConnection encodingForMySQLEncoding:[[tableDocumentInstance connectionEncoding] UTF8String]]];
+ if (contents == nil)
+ contents = [[NSString alloc] initWithData:editData encoding:NSASCIIStringEncoding];
+ // Set the string contents and hex representation
+ if(contents)
+ [editTextView setString:contents];
+ if(![[hexTextView string] isEqualToString:@""])
+ [hexTextView setString:[editData dataToFormattedHexString]];
+
+ [contents release];
+
+ }
+
+ editSheetWillBeInitialized = NO;
+}
/*
* Invoked when the imageView in the connection sheet has the contents deleted
* or a file dragged and dropped onto it.
@@ -1121,11 +1163,14 @@
// Process the provided image
editData = [[NSData alloc] initWithData:data];
NSString *contents = [[NSString alloc] initWithData:data encoding:[CMMCPConnection encodingForMySQLEncoding:[[tableDocumentInstance connectionEncoding] UTF8String]]];
+ if (contents == nil)
+ contents = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
// Set the string contents and hex representation
if(contents)
[editTextView setString:contents];
- [hexTextView setString:[editData dataToFormattedHexString]];
+ if(![[hexTextView string] isEqualToString:@""])
+ [hexTextView setString:[editData dataToFormattedHexString]];
[contents release];
editSheetWillBeInitialized = NO;
@@ -1701,11 +1746,6 @@
}
if ( [tempValue isKindOfClass:[NSData class]] ) {
- // NSString *tmpString = [[NSString alloc] initWithData:tempValue encoding:[mySQLConnection encoding]];
- // if (tmpString == nil)
- // tmpString = [[NSString alloc] initWithData:tempValue encoding:NSASCIIStringEncoding];
- // [value setString:[NSString stringWithString:tmpString]];
- // [tmpString release];
[value setString:[NSString stringWithFormat:@"X'%@'", [mySQLConnection prepareBinaryData:tempValue]]];
} else {
[value setString:[tempValue description]];
@@ -2279,8 +2319,9 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn
if ( [theValue isKindOfClass:[NSData class]] ) {
image = [[[NSImage alloc] initWithData:theValue] autorelease];
- [hexTextView setString:[theValue dataToFormattedHexString]];
-
+ // Set hex view to "" - load on demand only
+ [hexTextView setString:@""];
+
stringValue = [[NSString alloc] initWithData:theValue encoding:[mySQLConnection encoding]];
if (stringValue == nil)
stringValue = [[NSString alloc] initWithData:theValue encoding:NSASCIIStringEncoding];