aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPTableStructure.m
diff options
context:
space:
mode:
Diffstat (limited to 'Source/SPTableStructure.m')
-rw-r--r--Source/SPTableStructure.m73
1 files changed, 63 insertions, 10 deletions
diff --git a/Source/SPTableStructure.m b/Source/SPTableStructure.m
index dd05f1e3..f9c56eb9 100644
--- a/Source/SPTableStructure.m
+++ b/Source/SPTableStructure.m
@@ -45,6 +45,15 @@
@implementation SPTableStructure
+#ifdef SP_REFACTOR
+@synthesize indexesController;
+@synthesize indexesTableView;
+@synthesize addFieldButton;
+@synthesize duplicateFieldButton;
+@synthesize removeFieldButton;
+@synthesize reloadFieldsButton;
+#endif
+
#pragma mark -
#pragma mark Initialization
@@ -172,9 +181,11 @@
[prefs addObserver:indexesController forKeyPath:SPUseMonospacedFonts options:NSKeyValueObservingOptionNew context:NULL];
#endif
+#ifndef SP_REFACTOR
// Init the view column submenu according to saved hidden status;
// menu items are identified by their tag number which represents the initial column index
for (NSMenuItem *item in [viewColumnsMenu itemArray]) [item setState:NSOnState]; // Set all items to NSOnState
+#endif
#ifndef SP_REFACTOR /* patch */
for (NSTableColumn *col in [tableSourceView tableColumns])
@@ -191,6 +202,7 @@
}
}
#else
+/*
for (NSTableColumn *col in [tableSourceView tableColumns])
{
if ([col isHidden]) {
@@ -204,6 +216,7 @@
[[viewColumnsMenu itemAtIndex:[viewColumnsMenu indexOfItemWithTag:12]] setState:NSOffState];
}
}
+*/
#endif
[tableSourceView reloadData];
@@ -284,16 +297,16 @@
// Set up the encoding PopUpButtonCell
NSArray *encodings = [databaseDataInstance getDatabaseCharacterSetEncodings];
if ([encodings count]) {
- [encodingPopupCell removeAllItems];
- [encodingPopupCell addItemWithTitle:@""];
+ [[encodingPopupCell onMainThread] removeAllItems];
+ [[encodingPopupCell onMainThread] addItemWithTitle:@""];
// Populate encoding popup button
for (NSDictionary *encoding in encodings)
- [encodingPopupCell addItemWithTitle:(![encoding objectForKey:@"DESCRIPTION"]) ? [encoding objectForKey:@"CHARACTER_SET_NAME"] : [NSString stringWithFormat:@"%@ (%@)", [encoding objectForKey:@"DESCRIPTION"], [encoding objectForKey:@"CHARACTER_SET_NAME"]]];
+ [[encodingPopupCell onMainThread] addItemWithTitle:(![encoding objectForKey:@"DESCRIPTION"]) ? [encoding objectForKey:@"CHARACTER_SET_NAME"] : [NSString stringWithFormat:@"%@ (%@)", [encoding objectForKey:@"DESCRIPTION"], [encoding objectForKey:@"CHARACTER_SET_NAME"]]];
}
else {
- [encodingPopupCell addItemWithTitle:NSLocalizedString(@"Not available", @"not available label")];
+ [[encodingPopupCell onMainThread] addItemWithTitle:NSLocalizedString(@"Not available", @"not available label")];
}
// Process all the fields to normalise keys and add additional information
@@ -427,11 +440,13 @@
[enumFields removeAllObjects];
[indexesTableView deselectAll:self];
[addFieldButton setEnabled:NO];
- [copyFieldButton setEnabled:NO];
+ [duplicateFieldButton setEnabled:NO];
[removeFieldButton setEnabled:NO];
+#ifndef SP_REFACTOR
[addIndexButton setEnabled:NO];
[removeIndexButton setEnabled:NO];
[editTableButton setEnabled:NO];
+#endif
// If no table is selected, refresh the table/index display to blank and return
if (!selectedTable) {
@@ -458,14 +473,18 @@
defaultValues = [[NSDictionary dictionaryWithDictionary:newDefaultValues] retain];
+#ifndef SP_REFACTOR
// Enable the edit table button
[editTableButton setEnabled:enableInteraction];
+#endif
// If a view is selected, disable the buttons; otherwise enable.
BOOL editingEnabled = ([tablesListInstance tableType] == SPTableTypeTable) && enableInteraction;
[addFieldButton setEnabled:editingEnabled];
+#ifndef SP_REFACTOR
[addIndexButton setEnabled:editingEnabled];
+#endif
// Reload the views
[indexesTableView reloadData];
@@ -600,7 +619,7 @@
/**
* Copies a field and goes in edit mode for the new field
*/
-- (IBAction)copyField:(id)sender
+- (IBAction)duplicateField:(id)sender
{
NSMutableDictionary *tempRow;
NSUInteger rowToCopy;
@@ -700,6 +719,7 @@
*/
- (IBAction)resetAutoIncrement:(id)sender
{
+#ifndef SP_REFACTOR
if ([sender tag] == 1) {
[resetAutoIncrementLine setHidden:YES];
@@ -719,6 +739,7 @@
else if ([sender tag] == 2) {
[self setAutoIncrementTo:@"1"];
}
+#endif
}
/**
@@ -726,12 +747,14 @@
*/
- (void)resetAutoincrementSheetDidEnd:(NSWindow *)theSheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
{
+#ifndef SP_REFACTOR
// Order out current sheet to suppress overlapping of sheets
[theSheet orderOut:nil];
if (returnCode == NSAlertDefaultReturn) {
[self setAutoIncrementTo:[[resetAutoIncrementValue stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]];
}
+#endif
}
/**
@@ -787,7 +810,9 @@
- (IBAction)unhideIndexesView:(id)sender
{
+#ifndef SP_REFACTOR
[tablesIndexesSplitView setPosition:[tablesIndexesSplitView frame].size.height-130 ofDividerAtIndex:0];
+#endif
}
@@ -1196,11 +1221,13 @@
[tableSourceView reloadData];
[indexesTableView reloadData];
[addFieldButton setEnabled:NO];
- [copyFieldButton setEnabled:NO];
+ [duplicateFieldButton setEnabled:NO];
[removeFieldButton setEnabled:NO];
+#ifndef SP_REFACTOR
[addIndexButton setEnabled:NO];
[removeIndexButton setEnabled:NO];
[editTableButton setEnabled:NO];
+#endif
[tablesListInstance updateTables:self];
return NO;
}
@@ -1225,6 +1252,7 @@
}
#ifdef SP_REFACTOR /* glue */
+
- (void)setDatabaseDocument:(SPDatabaseDocument*)doc
{
tableDocumentInstance = doc;
@@ -1240,6 +1268,21 @@
tableDataInstance = data;
}
+- (void)setDatabaseDataInstance:(SPDatabaseData*)data
+{
+ databaseDataInstance = data;
+}
+
+- (void)setTableSourceView:(SPTableView*)tv
+{
+ tableSourceView = tv;
+}
+
+- (void)setEncodingPopupCell:(NSPopUpButtonCell*)cell
+{
+ encodingPopupCell = cell;
+}
+
#endif
/**
@@ -1275,7 +1318,7 @@
}
// Duplicate field
- if ([menuItem action] == @selector(copyField:)) {
+ if ([menuItem action] == @selector(duplicateField:)) {
return ([tableSourceView numberOfSelectedRows] == 1);
}
@@ -1295,6 +1338,7 @@
*/
- (void)sheetDidEnd:(id)sheet returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo
{
+#ifndef SP_REFACTOR
// Order out current sheet to suppress overlapping of sheets
if ([sheet respondsToSelector:@selector(orderOut:)])
@@ -1325,6 +1369,7 @@
isCurrentExtraAutoIncrement = NO;
}
}
+#endif
}
/**
@@ -1532,14 +1577,18 @@
[tableSourceView setEnabled:NO];
[addFieldButton setEnabled:NO];
[removeFieldButton setEnabled:NO];
- [copyFieldButton setEnabled:NO];
+ [duplicateFieldButton setEnabled:NO];
[reloadFieldsButton setEnabled:NO];
+#ifndef SP_REFACTOR
[editTableButton setEnabled:NO];
+#endif
[indexesTableView setEnabled:NO];
+#ifndef SP_REFACTOR
[addIndexButton setEnabled:NO];
[removeIndexButton setEnabled:NO];
[refreshIndexesButton setEnabled:NO];
+#endif
}
/**
@@ -1560,18 +1609,22 @@
if (editingEnabled && [tableSourceView numberOfSelectedRows] > 0) {
[removeFieldButton setEnabled:YES];
- [copyFieldButton setEnabled:YES];
+ [duplicateFieldButton setEnabled:YES];
}
[reloadFieldsButton setEnabled:YES];
+#ifndef SP_REFACTOR
[editTableButton setEnabled:YES];
+#endif
[indexesTableView setEnabled:YES];
[indexesTableView displayIfNeeded];
+#ifndef SP_REFACTOR
[addIndexButton setEnabled:editingEnabled];
[removeIndexButton setEnabled:(editingEnabled && ([indexesTableView numberOfSelectedRows] > 0))];
[refreshIndexesButton setEnabled:YES];
+#endif
}
#pragma mark -