From 7a5af6632f0c6797466372358327ddd75a4e7f22 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Fri, 3 Sep 2010 21:15:32 +0000 Subject: =?UTF-8?q?=E2=80=A2=20further=20improvements=20for=20CSV=20import?= =?UTF-8?q?=20into=20new=20table=20-=20fixed=20some=20RETURN/ENTER=20logic?= =?UTF-8?q?=20while=20editing=20a=20table=20cell=20-=20added=20context=20m?= =?UTF-8?q?enu=20to=20table=20for:=20--=20'Set=20all=20Field=20Types=20to:?= =?UTF-8?q?'=20which=20sets=20all=20types=20to=20the=20current=20selected?= =?UTF-8?q?=20one=20=E2=8C=98=3D=20--=20'Add=20Column=20to=20Table=20Targe?= =?UTF-8?q?t'=20(not=20yet=20implemented)=20-=20some=20minor=20code=20issu?= =?UTF-8?q?es=20-=20added=20Info=20button=20which=20will=20come=20up=20wit?= =?UTF-8?q?h=20a=20GUI=20for=20setting=20new=20table=20encoding=20and=20en?= =?UTF-8?q?gine=20(not=20yet=20implemented)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Interfaces/English.lproj/DataMigrationDialog.xib | 303 ++++++++++++++++++++++- Source/SPFieldMapperController.h | 9 +- Source/SPFieldMapperController.m | 61 ++++- Source/SPTableView.m | 10 +- 4 files changed, 369 insertions(+), 14 deletions(-) diff --git a/Interfaces/English.lproj/DataMigrationDialog.xib b/Interfaces/English.lproj/DataMigrationDialog.xib index 2d707c4d..ed2db178 100644 --- a/Interfaces/English.lproj/DataMigrationDialog.xib +++ b/Interfaces/English.lproj/DataMigrationDialog.xib @@ -12,8 +12,7 @@ YES - - + YES @@ -151,6 +150,26 @@ + + + 264 + {{400, 51}, {226, 32}} + + YES + + 67239424 + 134217728 + SetAllTypeTo_Dummy_Button + + + -2038284033 + 268435585 + + = + 200 + 25 + + {{1, 1}, {522, 39}} @@ -1392,7 +1411,7 @@ 265 - {{375, 280}, {129, 19}} + {{375, 280}, {106, 19}} YES @@ -1427,6 +1446,30 @@ + + + 265 + {{487, 280}, {20, 20}} + + YES + + 604110336 + 134217728 + + + + -2033958657 + 268435590 + + NSImage + NSInfo + + + i + 400 + 75 + + {522, 348} @@ -1466,12 +1509,14 @@ 256 {311, 111} + YES 256 {311, 17} + @@ -1479,6 +1524,7 @@ -2147483392 {{224, 0}, {16, 17}} + YES @@ -1598,6 +1644,7 @@ {{1, 17}, {311, 111}} + @@ -1608,6 +1655,7 @@ -2147483392 {{-100, -100}, {15, 102}} + _doScroller: 0.99065423011779785 @@ -1617,6 +1665,7 @@ -2147483392 {{-100, -100}, {238, 15}} + 1 _doScroller: @@ -1632,6 +1681,7 @@ {{1, 0}, {311, 17}} + @@ -1641,6 +1691,7 @@ {{-1, 47}, {313, 129}} + 530 @@ -1655,6 +1706,7 @@ 292 {{20, 17}, {20, 23}} + YES -2080244224 @@ -1679,6 +1731,7 @@ -2147483356 {{112, -10}, {20, 23}} + YES -2080244224 @@ -1703,6 +1756,7 @@ 289 {{226, 13}, {70, 28}} + 1 YES @@ -1724,6 +1778,7 @@ 292 {{48, 17}, {40, 23}} + 1 YES @@ -1746,6 +1801,7 @@ 289 {{102, 19}, {120, 18}} + YES -2080244224 @@ -1766,6 +1822,7 @@ {311, 186} + {{0, 0}, {1280, 1002}} {311, 208} @@ -1847,6 +1904,39 @@ NO + + + + YES + + + Set all Field Types to: + = + 1048576 + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + Add Column to Target Table… + + 2147483647 + + + + + @@ -2435,6 +2525,70 @@ 419 + + + dataSource + + + + 420 + + + + delegate + + + + 421 + + + + menu + + + + 427 + + + + setAllTypesToMenuItem + + + + 429 + + + + addNewColumnMenuItem + + + + 430 + + + + setAllTypesTo: + + + + 432 + + + + newTableNameInfoButton + + + + 435 + + + + setAllTypesTo: + + + + 438 + @@ -2501,6 +2655,7 @@ + @@ -2522,6 +2677,7 @@ YES + Header Box (Box) @@ -3400,6 +3556,61 @@ + + 422 + + + YES + + + + + + Context Menu + + + 423 + + + + + 424 + + + + + 426 + + + + + 433 + + + YES + + + + + + 434 + + + + + 436 + + + YES + + + + + + 437 + + + @@ -3455,6 +3666,7 @@ 162.IBPluginDependency 163.IBPluginDependency 164.IBPluginDependency + 165.CustomClassName 165.IBPluginDependency 166.IBPluginDependency 167.IBPluginDependency @@ -3554,8 +3766,18 @@ 42.CustomClassName 42.IBPluginDependency 42.ImportedFromIB2 + 422.IBEditorWindowLastContentRect + 422.IBPluginDependency + 423.IBPluginDependency + 424.IBPluginDependency + 426.IBPluginDependency 43.IBPluginDependency 43.IBShouldRemoveOnLegacySave + 433.IBAttributePlaceholdersKey + 433.IBPluginDependency + 434.IBPluginDependency + 436.IBPluginDependency + 437.IBPluginDependency 44.IBPluginDependency 44.IBShouldRemoveOnLegacySave 45.IBPluginDependency @@ -3582,9 +3804,9 @@ YES com.apple.InterfaceBuilder.CocoaPlugin - {{742, 423}, {522, 348}} + {{353, 46}, {522, 348}} com.apple.InterfaceBuilder.CocoaPlugin - {{742, 423}, {522, 348}} + {{353, 46}, {522, 348}} {{387, 725}, {432, 282}} @@ -3658,6 +3880,7 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + SPTableView com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -3779,7 +4002,7 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{1106, 645}, {215, 6}} + {{431, 379}, {215, 6}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -3816,8 +4039,25 @@ SPTableView com.apple.InterfaceBuilder.CocoaPlugin + {{225, 703}, {284, 53}} + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + + ToolTip + + ToolTip + + Manage table details (⌘I) + + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -3858,7 +4098,7 @@ - 419 + 438 @@ -4524,6 +4764,7 @@ YES addGlobalSourceVariable: addGlobalValue: + addNewColumn: advancedCheckboxValidation: changeFieldAlignment: changeHasHeaderCheckbox: @@ -4535,6 +4776,7 @@ insertNULLValue: openAdvancedSheet: removeGlobalValue: + setAllTypesTo: stepRow: @@ -4553,6 +4795,8 @@ id id id + id + id @@ -4561,6 +4805,7 @@ YES addGlobalSourceVariable: addGlobalValue: + addNewColumn: advancedCheckboxValidation: changeFieldAlignment: changeHasHeaderCheckbox: @@ -4572,6 +4817,7 @@ insertNULLValue: openAdvancedSheet: removeGlobalValue: + setAllTypesTo: stepRow: @@ -4584,6 +4830,10 @@ addGlobalValue: id + + addNewColumn: + id + advancedCheckboxValidation: id @@ -4628,6 +4878,10 @@ removeGlobalValue: id + + setAllTypesTo: + id + stepRow: id @@ -4639,6 +4893,7 @@ YES addGlobalValueButton + addNewColumnMenuItem addRemainingDataSwitch advancedBox advancedButton @@ -4669,6 +4924,7 @@ lowPriorityReplaceCheckBox lowPriorityUpdateCheckBox matchingNameMenuItem + newTableNameInfoButton newTableNameLabel newTableNameTextField onupdateCheckBox @@ -4678,6 +4934,7 @@ replaceAfterSavingCheckBox rowDownButton rowUpButton + setAllTypesToMenuItem skipexistingRowsCheckBox tableTargetPopup tablesListInstance @@ -4687,6 +4944,7 @@ YES NSButton + NSMenuItem id id id @@ -4700,7 +4958,7 @@ id id id - id + SPTableView id NSPathControl id @@ -4717,6 +4975,7 @@ id id NSMenuItem + NSButton NSTextField NSTextField id @@ -4726,6 +4985,7 @@ id id id + NSMenuItem id NSPopUpButton id @@ -4738,6 +4998,7 @@ YES addGlobalValueButton + addNewColumnMenuItem addRemainingDataSwitch advancedBox advancedButton @@ -4768,6 +5029,7 @@ lowPriorityReplaceCheckBox lowPriorityUpdateCheckBox matchingNameMenuItem + newTableNameInfoButton newTableNameLabel newTableNameTextField onupdateCheckBox @@ -4777,6 +5039,7 @@ replaceAfterSavingCheckBox rowDownButton rowUpButton + setAllTypesToMenuItem skipexistingRowsCheckBox tableTargetPopup tablesListInstance @@ -4789,6 +5052,10 @@ addGlobalValueButton NSButton + + addNewColumnMenuItem + NSMenuItem + addRemainingDataSwitch id @@ -4843,7 +5110,7 @@ fieldMapperTableView - id + SPTableView fieldMappingImportArray @@ -4909,6 +5176,10 @@ matchingNameMenuItem NSMenuItem + + newTableNameInfoButton + NSButton + newTableNameLabel NSTextField @@ -4945,6 +5216,10 @@ rowUpButton id + + setAllTypesToMenuItem + NSMenuItem + skipexistingRowsCheckBox id @@ -4972,6 +5247,14 @@ ../../Source/SPFieldMapperController.h + + SPTableView + NSTableView + + IBDocumentRelativeSource + ../../Source/SPTableView.h + + YES @@ -5676,6 +5959,7 @@ NSAddTemplate NSGoLeftTemplate NSGoRightTemplate + NSInfo NSMenuCheckmark NSMenuMixedState NSRemoveTemplate @@ -5686,6 +5970,7 @@ {8, 8} {9, 9} {9, 9} + {32, 32} {9, 8} {7, 2} {8, 8} diff --git a/Source/SPFieldMapperController.h b/Source/SPFieldMapperController.h index b824e3ed..17b6db9a 100644 --- a/Source/SPFieldMapperController.h +++ b/Source/SPFieldMapperController.h @@ -30,7 +30,7 @@ @interface SPFieldMapperController : NSWindowController { - IBOutlet id fieldMapperTableView; + IBOutlet SPTableView *fieldMapperTableView; IBOutlet id fieldMapperTableScrollView; IBOutlet NSTableView *globalValuesTableView; IBOutlet NSPopUpButton *tableTargetPopup; @@ -48,9 +48,12 @@ IBOutlet id importMethodLabel; IBOutlet id advancedLabel; IBOutlet NSMenuItem *matchingNameMenuItem; + IBOutlet NSMenuItem *addNewColumnMenuItem; + IBOutlet NSMenuItem *setAllTypesToMenuItem; IBOutlet NSTextField *newTableNameTextField; IBOutlet NSTextField *newTableNameLabel; + IBOutlet NSButton *newTableNameInfoButton; IBOutlet id globalValuesSheet; IBOutlet NSButton *addGlobalValueButton; @@ -148,6 +151,7 @@ - (NSString*)onupdateString; - (NSString*)importHeaderString; - (BOOL)canBeClosed; +- (BOOL)isGlobalValueSheetOpen; // IBAction methods - (IBAction)changeTableTarget:(id)sender; @@ -166,6 +170,9 @@ - (IBAction)closeGlobalValuesSheet:(id)sender; - (IBAction)advancedCheckboxValidation:(id)sender; +- (IBAction)addNewColumn:(id)sender; +- (IBAction)setAllTypesTo:(id)sender; + // Others - (void)resizeWindowByHeightDelta:(NSInteger)delta; - (void)matchHeaderNames; diff --git a/Source/SPFieldMapperController.m b/Source/SPFieldMapperController.m index dbdf3d31..c7ba8ee7 100644 --- a/Source/SPFieldMapperController.m +++ b/Source/SPFieldMapperController.m @@ -90,7 +90,8 @@ [fieldMapperTableView setDelegate:self]; [fieldMapperTableView setDataSource:self]; - + [[[fieldMapperTableView menu] itemAtIndex:0] setHidden:YES]; + [[[fieldMapperTableView menu] itemAtIndex:1] setHidden:YES]; // Set source path // Note: [fileSourcePath setURL:[NSURL fileWithPath:sourcePath]] does NOT work @@ -108,6 +109,7 @@ [newTableNameTextField setHidden:YES]; [newTableNameLabel setHidden:YES]; + [newTableNameInfoButton setHidden:YES]; // Init table target popup menu [tableTargetPopup removeAllItems]; @@ -348,6 +350,11 @@ return [importButton isEnabled]; } +- (BOOL)isGlobalValueSheetOpen +{ + return addGlobalSheetIsOpen; +} + #pragma mark - #pragma mark IBAction methods @@ -433,6 +440,9 @@ newTableMode = YES; + [[[fieldMapperTableView menu] itemAtIndex:0] setHidden:NO]; + [[[fieldMapperTableView menu] itemAtIndex:1] setHidden:NO]; + [importMethodPopup selectItemWithTitle:@"INSERT"]; [[importMethodPopup itemWithTitle:@"UPDATE"] setEnabled:NO]; [[importMethodPopup itemWithTitle:@"REPLACE"] setEnabled:NO]; @@ -440,7 +450,9 @@ [tableTargetPopup setHidden:YES]; [newTableNameTextField setHidden:NO]; [newTableNameLabel setHidden:NO]; + [newTableNameInfoButton setHidden:NO]; [newTableNameTextField selectText:nil]; + [fieldMappingTableColumnNames removeAllObjects]; [fieldMappingTableDefaultValues removeAllObjects]; [fieldMappingTableTypes removeAllObjects]; @@ -726,6 +738,30 @@ } } +- (IBAction)addNewColumn:(id)sender +{ + +} + +/* + * Set all table target field types to that one of the current selected type + */ +- (IBAction)setAllTypesTo:(id)sender +{ + NSInteger row = [fieldMapperTableView selectedRow]; + if(row<0 || row>=[fieldMappingTableColumnNames count]) { + NSBeep(); + return; + } + NSString *type = [[fieldMappingTableTypes objectAtIndex:row] retain]; + [fieldMappingTableTypes removeAllObjects]; + NSInteger i; + for(i=0; i<[fieldMappingTableColumnNames count]; i++) + [fieldMappingTableTypes addObject:type]; + [fieldMapperTableView reloadData]; + [type release]; +} + #pragma mark - #pragma mark Global Value Sheet @@ -963,9 +999,11 @@ - (void)sheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo { if ([sheet respondsToSelector:@selector(orderOut:)]) [sheet orderOut:nil]; - addGlobalSheetIsOpen = NO; - if (sheet == globalValuesSheet) + + if (sheet == globalValuesSheet) { + addGlobalSheetIsOpen = NO; [self updateFieldMappingButtonCell]; + } } - (void)matchHeaderNames @@ -1134,6 +1172,23 @@ } +/** + * Menu item interface validation + */ +- (BOOL)validateMenuItem:(NSMenuItem *)menuItem +{ + + if (newTableMode && [menuItem action] == @selector(setAllTypesTo:)) { + NSInteger row = [fieldMapperTableView selectedRow]; + NSMenuItem *setAllItem = [[fieldMapperTableView menu] itemAtIndex:0]; + NSString *orgTitle = [[setAllItem title] substringToIndex:[[setAllItem title] rangeOfString:@":"].location]; + [setAllItem setTitle:[NSString stringWithFormat:@"%@: %@", orgTitle, [fieldMappingTableTypes objectAtIndex:row]]]; + } + + return YES; + +} + #pragma mark - #pragma mark Table view datasource methods diff --git a/Source/SPTableView.m b/Source/SPTableView.m index 7e212884..c3f76baf 100644 --- a/Source/SPTableView.m +++ b/Source/SPTableView.m @@ -92,8 +92,15 @@ if([self numberOfSelectedRows] == 1 && ([theEvent keyCode] == 36 || [theEvent keyCode] == 76)) { - // ENTER or RETURN closes the SPFieldMapperController sheet by sending an object with the tag 1 if([[[[self delegate] class] description] isEqualToString:@"SPFieldMapperController"]) { + + if([[self delegate] isGlobalValueSheetOpen]) { + [[self delegate] closeGlobalValuesSheet:nil]; + return; + } + + // ENTER or RETURN closes the SPFieldMapperController sheet + // by sending an object with the tag 1 if no table cell is edited if([[self delegate] canBeClosed]) { NSButton *b = [[[NSButton alloc] init] autorelease]; [b setTag:1]; @@ -117,6 +124,7 @@ [self editColumn:0 row:[self selectedRow] withEvent:nil select:YES]; return; } + } [super keyDown:theEvent]; -- cgit v1.2.3