aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-09-03 21:15:32 +0000
committerBibiko <bibiko@eva.mpg.de>2010-09-03 21:15:32 +0000
commit7a5af6632f0c6797466372358327ddd75a4e7f22 (patch)
treeb1b802ca9a165c16968d7f6c794b95b9aa61fb0a /Source
parent61adeb9f4ad973a93ce35ac4ebf6068f2beac6ca (diff)
downloadsequelpro-7a5af6632f0c6797466372358327ddd75a4e7f22.tar.gz
sequelpro-7a5af6632f0c6797466372358327ddd75a4e7f22.tar.bz2
sequelpro-7a5af6632f0c6797466372358327ddd75a4e7f22.zip
• further improvements for CSV import into new table
- fixed some RETURN/ENTER logic while editing a table cell - added context menu to table for: -- 'Set all Field Types to:' which sets all types to the current selected one ⌘= -- 'Add Column to Table Target' (not yet implemented) - some minor code issues - added Info button which will come up with a GUI for setting new table encoding and engine (not yet implemented)
Diffstat (limited to 'Source')
-rw-r--r--Source/SPFieldMapperController.h9
-rw-r--r--Source/SPFieldMapperController.m61
-rw-r--r--Source/SPTableView.m10
3 files changed, 75 insertions, 5 deletions
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];