From 6f267c8d8f6c12663e16d30f4cd4a1a6677fccd5 Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Mon, 15 Jun 2009 19:28:06 +0000 Subject: Replace the change table type button with an edit button that switches the current view to the table info pane. --- Interfaces/English.lproj/DBView.xib | 357 +++++++++--------------------------- Source/TableSource.h | 24 +-- Source/TableSource.m | 67 +------ 3 files changed, 95 insertions(+), 353 deletions(-) diff --git a/Interfaces/English.lproj/DBView.xib b/Interfaces/English.lproj/DBView.xib index 0b503445..9c5155e9 100644 --- a/Interfaces/English.lproj/DBView.xib +++ b/Interfaces/English.lproj/DBView.xib @@ -8,7 +8,7 @@ 353.00 YES - + YES @@ -387,10 +387,7 @@ 1048576 2147483647 - - NSImage - button_action - + _popUpItemAction: @@ -460,7 +457,6 @@ - 4 YES 1 YES @@ -575,7 +571,7 @@ source - + 256 YES @@ -589,124 +585,6 @@ 256 YES - - - 257 - {{538, 4}, {61, 13}} - - YES - - 68288064 - 4457472 - Table Type: - - LucidaGrande - 1.000000e+01 - 16 - - - - - - - - - 257 - {{604, 2}, {79, 17}} - - YES - - -1539178944 - 132096 - - LucidaGrande - 1.100000e+01 - 16 - - - -1232977665 - 45 - - - - - - - - 400 - 75 - - - -- - - 1048576 - 2147483647 - 1 - - - _popUpItemAction: - - - YES - - - OtherViews - - - YES - - - - MyISAM - - 1048576 - 2147483647 - - - _popUpItemAction: - - - - - ISAM - - 1048576 - 2147483647 - - - _popUpItemAction: - - - - - InnoDB - - 1048576 - 2147483647 - - - _popUpItemAction: - - - - - BDB - - 1048576 - 2147483647 - - - _popUpItemAction: - - - - - 3 - YES - YES - 2 - - 4370 @@ -1423,7 +1301,7 @@ NeXT TIFF v4.0 pasteboard type - {{125, 0}, {564, 23}} + {{125, 0}, {532, 23}} YES @@ -1437,6 +1315,30 @@ YES + + + 289 + {{657, -1}, {32, 25}} + + YES + + -1543373312 + 134217728 + + + + -2041822977 + 268435491 + + NSImage + button_edit + + + r + 400 + 75 + + {689, 329} @@ -1930,6 +1832,7 @@ {{10, 7}, {700, 544}} + Structure @@ -1938,7 +1841,7 @@ content - + 256 YES @@ -2075,7 +1978,11 @@ -1539178944 133120 - + + LucidaGrande + 1.100000e+01 + 16 + -2038284033 36 @@ -2541,7 +2448,6 @@ {{10, 7}, {700, 544}} - Content @@ -2964,7 +2870,7 @@ 1048576 2147483647 - + _popUpItemAction: @@ -4379,14 +4285,14 @@ - + 134217731 YES YES YES - + @@ -4984,10 +4890,7 @@ -2042347265 35 - - NSImage - button_edit - + 400 @@ -13573,22 +13476,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 1244 - - - typeChanged: - - - - 1301 - - - - tableTypeButton - - - - 1302 - favoritesController @@ -16137,6 +16024,22 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 6006 + + + viewStatus: + + + + 6011 + + + + editTableButton + + + + 6012 + @@ -20125,35 +20028,16 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 YES - - + - - 1297 - - - YES - - - - - - 1294 - - - YES - - - - 5136 @@ -20409,58 +20293,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 - - 3775 - - - YES - - - - - - 1300 - - - YES - - - - - - - - - - 1299 - - - - - 1298 - - - - - 1296 - - - - - 1295 - - - - - 1293 - - - - - 3776 - - - 5150 @@ -22828,6 +22660,20 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 + + 6009 + + + YES + + + + + + 6010 + + + @@ -22982,23 +22828,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 125.ImportedFromIB2 1277.IBPluginDependency 1277.ImportedFromIB2 - 1293.IBPluginDependency - 1293.ImportedFromIB2 - 1294.IBPluginDependency - 1294.ImportedFromIB2 - 1295.IBPluginDependency - 1295.ImportedFromIB2 - 1296.IBPluginDependency - 1296.ImportedFromIB2 - 1297.IBPluginDependency - 1297.ImportedFromIB2 - 1298.IBPluginDependency - 1298.ImportedFromIB2 - 1299.IBPluginDependency - 1299.ImportedFromIB2 - 1300.IBEditorWindowLastContentRect - 1300.IBPluginDependency - 1300.ImportedFromIB2 1304.IBPluginDependency 1304.ImportedFromIB2 1305.IBPluginDependency @@ -23213,8 +23042,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 3755.IBPluginDependency 3759.IBPluginDependency 3770.IBPluginDependency - 3775.IBPluginDependency - 3776.IBPluginDependency 3779.IBPluginDependency 3780.IBPluginDependency 3781.IBPluginDependency @@ -24193,6 +24020,9 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 6000.IBPluginDependency 6001.IBPluginDependency 6004.IBPluginDependency + 6009.IBAttributePlaceholdersKey + 6009.IBPluginDependency + 6010.IBPluginDependency 604.IBEditorWindowLastContentRect 604.IBWindowTemplateEditedContentRect 604.ImportedFromIB2 @@ -24657,23 +24487,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 com.apple.InterfaceBuilder.CocoaPlugin - {{1058, 508}, {135, 88}} - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -24927,8 +24740,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -25443,7 +25254,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{476, -4}, {175, 113}} + {{188, -4}, {175, 113}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -25465,8 +25276,8 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{467, 84}, {944, 550}} - {{467, 84}, {944, 550}} + {{176, 63}, {944, 550}} + {{176, 63}, {944, 550}} {{62, 352}, {845, 504}} @@ -26107,6 +25918,16 @@ aGUgYWN0aXZlIHNlbGVjdGlvbiAo4oyl4oyYUik com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + + ToolTip + + ToolTip + + UmVmcmVzaCB0YWJsZSBzdHJ1Y3R1cmUgKOKMmFIpA + + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin {{67, 340}, {667, 416}} {{67, 340}, {667, 416}} @@ -26359,7 +26180,7 @@ Y2hhbmdlIHRoZSBvcmRlcg - 6006 + 6012 @@ -27478,7 +27299,6 @@ Y2hhbmdlIHRoZSBvcmRlcg reloadTable: removeField: removeIndex: - typeChanged: YES @@ -27492,7 +27312,6 @@ Y2hhbmdlIHRoZSBvcmRlcg id id id - id @@ -27503,6 +27322,7 @@ Y2hhbmdlIHRoZSBvcmRlcg addIndexButton chooseKeyButton copyFieldButton + editTableButton indexNameField indexSheet indexTypeField @@ -27514,7 +27334,6 @@ Y2hhbmdlIHRoZSBvcmRlcg structureGrabber tableDataInstance tableSourceView - tableTypeButton tableWindow tablesListInstance diff --git a/Source/TableSource.h b/Source/TableSource.h index 66149586..9776620e 100644 --- a/Source/TableSource.h +++ b/Source/TableSource.h @@ -28,9 +28,8 @@ #import "CMMCPConnection.h" #import "CMMCPResult.h" - -@interface TableSource : NSObject { - +@interface TableSource : NSObject +{ IBOutlet id tablesListInstance; IBOutlet id tableDataInstance; @@ -48,15 +47,14 @@ IBOutlet id indexNameField; IBOutlet id indexedColumnsField; IBOutlet id chooseKeyButton; - IBOutlet id tableTypeButton; IBOutlet id structureGrabber; + IBOutlet id editTableButton; CMMCPConnection *mySQLConnection; CMMCPResult *tableSourceResult; CMMCPResult *indexResult; NSString *selectedTable; - NSString *tableType; NSMutableArray *tableFields, *indexes; NSMutableDictionary *oldRow, *enumFields; NSDictionary *defaultValues; @@ -75,7 +73,6 @@ - (IBAction)addIndex:(id)sender; - (IBAction)removeField:(id)sender; - (IBAction)removeIndex:(id)sender; -- (IBAction)typeChanged:(id)sender; //index sheet methods - (IBAction)openIndexSheet:(id)sender; @@ -91,7 +88,6 @@ - (NSArray *)fetchResultAsArray:(CMMCPResult *)theResult; - (BOOL)saveRowOnDeselect; - (BOOL)addRowToDB; -- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(NSString *)contextInfo; //getter methods - (NSString *)defaultValueForField:(NSString *)field; @@ -99,16 +95,6 @@ - (NSDictionary *)enumFields; - (NSArray *)tableStructureForPrint; -//tableView datasource methods -- (int)numberOfRowsInTableView:(NSTableView *)aTableView; -- (id)tableView:(NSTableView *)aTableView - objectValueForTableColumn:(NSTableColumn *)aTableColumn - row:(int)rowIndex; -- (void)tableView:(NSTableView *)aTableView - setObjectValue:(id)anObject - forTableColumn:(NSTableColumn *)aTableColumn - row:(int)rowIndex; - //tableView drag&drop datasource methods - (BOOL)tableView:(NSTableView *)tv writeRows:(NSArray*)rows toPasteboard:(NSPasteboard*)pboard; - (NSDragOperation)tableView:(NSTableView*)tv validateDrop:(id )info proposedRow:(int)row @@ -126,8 +112,4 @@ - (float)splitView:(NSSplitView *)sender constrainMinCoordinate:(float)proposedMin ofSubviewAt:(int)offset; - (NSRect)splitView:(NSSplitView *)splitView additionalEffectiveRectOfDividerAtIndex:(int)dividerIndex; -//last but not least -- (id)init; -- (void)dealloc; - @end diff --git a/Source/TableSource.m b/Source/TableSource.m index cf7a7232..8ed241b8 100644 --- a/Source/TableSource.m +++ b/Source/TableSource.m @@ -70,15 +70,14 @@ loads aTable, put it in an array, update the tableViewColumns and reload the tab [removeFieldButton setEnabled:NO]; [addIndexButton setEnabled:NO]; [removeIndexButton setEnabled:NO]; - - // set the table type menu back to the default, and disable it - [tableTypeButton selectItemAtIndex:0]; - [tableTypeButton setEnabled:NO]; - tableType = nil; + [editTableButton setEnabled:NO]; return; } + // Enable edit table button + [editTableButton setEnabled:YES]; + //query started [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryWillBePerformed" object:self]; @@ -95,10 +94,6 @@ loads aTable, put it in an array, update the tableViewColumns and reload the tab // [indexes setArray:[[self fetchResultAsArray:indexResult] retain]]; [indexes setArray:[self fetchResultAsArray:indexResult]]; [indexResult release]; - - // Retrieve the table type via the table data's status cache (which automatically maps Type to Engine) - [tableType release]; - tableType = [[NSString stringWithString:[tableDataInstance statusValueForKey:@"Engine"]] retain]; //get table default values if ( defaultValues ) { @@ -176,15 +171,6 @@ loads aTable, put it in an array, update the tableViewColumns and reload the tab [field setObject:length forKey:@"Length"]; } - // Determine the table type - if ( ![tableType isKindOfClass:[NSNull class]] && [tablesListInstance tableType] != SP_TABLETYPE_VIEW) { - [tableTypeButton selectItemWithTitle:tableType]; - [tableTypeButton setEnabled:YES]; - } else { - [tableTypeButton selectItemWithTitle:@"--"]; - [tableTypeButton setEnabled:NO]; - } - // If a view is selected, disable the buttons; otherwise enable. BOOL editingEnabled = ([tablesListInstance tableType] == SP_TABLETYPE_TABLE); [addFieldButton setEnabled:editingEnabled]; @@ -398,51 +384,6 @@ reloads the table (performing a new mysql-query) [alert beginSheetModalForWindow:tableWindow modalDelegate:self didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) contextInfo:@"removeindex"]; } -- (IBAction)typeChanged:(id)sender -{ - // Check whether a save of the current row is required. - if ( ![self saveRowOnDeselect] ) { - [sender selectItemWithTitle:tableType]; - return; - } - - NSString* selectedItem = [sender titleOfSelectedItem]; - if([selectedItem isEqualToString:@"--"] || [tableType isEqualToString:selectedItem]) { - [sender selectItemWithTitle:tableType]; - } else { - // alert any listeners that we are about to perform a query. - [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryWillBePerformed" object:self]; - - NSString *query = [NSString stringWithFormat:@"ALTER TABLE %@ TYPE = %@",[selectedTable backtickQuotedString],selectedItem]; - [mySQLConnection queryString:query]; - - // The query is now complete. - [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:self]; - - // Did the alter work? If so, we need to record the new data. If not, we must revert back to - // the previous state. - if([mySQLConnection getLastErrorID] == 0) - { - // Make sure "tableType" is changed and the status tab is flagged for reload... - [tableType release]; - tableType = selectedItem; - [tableType retain]; - -// [[NSNotificationCenter defaultCenter] postNotificationName:@"SelectedTableStatusHasChanged" object:self]; - - // Mark the content table for refresh and update column caches - [tablesListInstance setContentRequiresReload:YES]; - [tableDataInstance resetColumnData]; - } else { - [sender selectItemWithTitle:tableType]; - NSBeginAlertSheet(NSLocalizedString(@"Error changing table type", @"error changing table type message"), - NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, - [NSString stringWithFormat:NSLocalizedString(@"An error occurred when trying to change the table to '%@' from '%@'.\n\nMySQL said: %@", @"error changing table type informative message"), selectedItem, tableType, [mySQLConnection getLastErrorMessage]]); - } - } -} - - #pragma mark Index sheet methods /* -- cgit v1.2.3