From dbefc2d0e374b9279289b313adf814187b26882c Mon Sep 17 00:00:00 2001 From: Bibiko Date: Fri, 17 Jul 2009 15:53:59 +0000 Subject: =?UTF-8?q?=E2=80=A2=20Field=20Editor=20Sheet=20class=20-=20added?= =?UTF-8?q?=20the=20feature=20to=20set=20"isEditable";=20according=20to=20?= =?UTF-8?q?"isEditable"=20GUI=20elements=20will=20be=20hidden=20or=20renam?= =?UTF-8?q?ed=20-=20if=20no=20blob=20data=20reduce=20the=20minimal=20sheet?= =?UTF-8?q?=20size=20since=20no=20segment=20or=20quicklook=20control=20is?= =?UTF-8?q?=20needed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPFieldEditorController.h | 5 ++++- Source/SPFieldEditorController.m | 24 ++++++++++++++++++++++-- Source/TableContent.m | 2 +- 3 files changed, 27 insertions(+), 4 deletions(-) (limited to 'Source') diff --git a/Source/SPFieldEditorController.h b/Source/SPFieldEditorController.h index f369951f..1b54cfab 100644 --- a/Source/SPFieldEditorController.h +++ b/Source/SPFieldEditorController.h @@ -36,6 +36,9 @@ IBOutlet id editTextScrollView; IBOutlet id hexTextScrollView; IBOutlet id editSheet; + IBOutlet id editSheetCancelButton; + IBOutlet id editSheetOkButton; + IBOutlet id editSheetOpenButton; id sheetEditData; BOOL editSheetWillBeInitialized; @@ -58,7 +61,7 @@ - (IBAction)quickLookFormatButton:(id)sender; - (IBAction)dropImage:(id)sender; -- (id)editWithObject:(id)data usingEncoding:(NSStringEncoding)anEncoding isObjectBlob:(BOOL)isFieldBlob withWindow:(NSWindow *)tableWindow; +- (id)editWithObject:(id)data usingEncoding:(NSStringEncoding)anEncoding isObjectBlob:(BOOL)isFieldBlob isEditable:(BOOL)isEditable withWindow:(NSWindow *)tableWindow; - (void)processPasteImageData; - (void)processUpdatedImageData:(NSData *)data; diff --git a/Source/SPFieldEditorController.m b/Source/SPFieldEditorController.m index 1a5a19a3..af5addf9 100644 --- a/Source/SPFieldEditorController.m +++ b/Source/SPFieldEditorController.m @@ -50,7 +50,7 @@ } - (id)editWithObject:(id)data usingEncoding:(NSStringEncoding)anEncoding - isObjectBlob:(BOOL)isFieldBlob withWindow:(NSWindow *)tableWindow + isObjectBlob:(BOOL)isFieldBlob isEditable:(BOOL)isEditable withWindow:(NSWindow *)tableWindow { prefs = [NSUserDefaults standardUserDefaults]; @@ -70,6 +70,16 @@ [editTextView setHidden:YES]; [editTextScrollView setHidden:YES]; + if(!isEditable) { + [editSheetOkButton setTitle:NSLocalizedString(@"Close", @"close button title")]; + [editSheetCancelButton setHidden:YES]; + [editSheetOpenButton setEnabled:NO]; + } else { + [editSheetOkButton setTitle:NSLocalizedString(@"OK", @"ok button title")]; + [editSheetCancelButton setHidden:NO]; + [editSheetOpenButton setEnabled:YES]; + } + editSheetWillBeInitialized = YES; encoding = anEncoding; @@ -88,6 +98,15 @@ // Hide QuickLook button and text/iamge/hex control for text data [editSheetQuickLookButton setHidden:(!isBlob)]; [editSheetSegmentControl setHidden:(!isBlob)]; + + // Set window's min size since no segment and quicklook buttons are hidden + if(isBlob) + [editSheet setMinSize:NSMakeSize(560, 200)]; + else + [editSheet setMinSize:NSMakeSize(340, 150)]; + + [editTextView setEditable:isEditable]; + [editImage setEditable:isEditable]; [NSApp beginSheet:editSheet modalForWindow:tableWindow modalDelegate:self didEndSelector:nil contextInfo:nil]; @@ -173,7 +192,7 @@ // For safety reasons inform QuickLook to quit quickLookCloseMarker = 1; - return ( code ) ? [sheetEditData retain] : nil; + return ( code && isEditable ) ? [sheetEditData retain] : nil; } @@ -473,6 +492,7 @@ -(void)processPasteImageData { + editSheetWillBeInitialized = YES; NSImage *image = nil; diff --git a/Source/TableContent.m b/Source/TableContent.m index e6381555..e5dc4141 100644 --- a/Source/TableContent.m +++ b/Source/TableContent.m @@ -1934,7 +1934,7 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn SPFieldEditorController *fieldEditor = [[SPFieldEditorController alloc] init]; id editData = [[fieldEditor editWithObject:[[filteredResult objectAtIndex:rowIndex] objectAtIndex:[[aTableColumn identifier] intValue]] - usingEncoding:[mySQLConnection encoding] isObjectBlob:isBlob withWindow:tableWindow] retain]; + usingEncoding:[mySQLConnection encoding] isObjectBlob:isBlob isEditable:YES withWindow:tableWindow] retain]; if ( editData ) { if ( !isEditingRow ) { -- cgit v1.2.3