aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/SPPrintController.m47
-rw-r--r--Source/SPTableRelations.m9
-rw-r--r--Source/SPTableTriggers.h3
-rw-r--r--Source/SPTableTriggers.m43
4 files changed, 89 insertions, 13 deletions
diff --git a/Source/SPPrintController.m b/Source/SPPrintController.m
index f890ad01..3b0e07c7 100644
--- a/Source/SPPrintController.m
+++ b/Source/SPPrintController.m
@@ -34,6 +34,7 @@
#import "ICUTemplateMatcher.h"
#import "SPConnectionController.h"
#import "SPExtendedTableInfo.h"
+#import "SPTableTriggers.h"
@implementation TableDocument (SPPrintController)
@@ -100,7 +101,6 @@
[[printWebView mainFrame] loadHTMLString:([tableTabView indexOfTabViewItem:[tableTabView selectedTabViewItem]] == 3) ? [self generateTableInfoHTMLForPrinting] :[self generateHTMLForPrinting] baseURL:nil];
}
-
/**
* Generates the HTML for the current view that is being printed.
*/
@@ -146,13 +146,16 @@
}
// Table content view
else if ([tableTabView indexOfTabViewItem:[tableTabView selectedTabViewItem]] == 1) {
- if ([[tableContentInstance currentResult] count] > 1) {
+
+ NSArray *data = [tableContentInstance currentDataResult];
+
+ if ([data count] > 1) {
heading = NSLocalizedString(@"Table Content", @"table content print heading");
rows = [[NSArray alloc] initWithArray:
- [[tableContentInstance currentDataResult] objectsAtIndexes:
- [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(1, [[tableContentInstance currentResult] count] - 1)]]
+ [data objectsAtIndexes:
+ [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(1, [data count] - 1)]]
];
[connection setValue:[tableContentInstance usedQuery] forKey:@"query"];
@@ -160,13 +163,16 @@
}
// Custom query view
else if ([tableTabView indexOfTabViewItem:[tableTabView selectedTabViewItem]] == 2) {
- if ([[customQueryInstance currentResult] count] > 1) {
+
+ NSArray *data = [customQueryInstance currentResult];
+
+ if ([data count] > 1) {
heading = NSLocalizedString(@"Query Result", @"query result print heading");
rows = [[NSArray alloc] initWithArray:
- [[customQueryInstance currentResult] objectsAtIndexes:
- [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(1, [[customQueryInstance currentResult] count] - 1)]]
+ [data objectsAtIndexes:
+ [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(1, [data count] - 1)]]
];
[connection setValue:[customQueryInstance usedQuery] forKey:@"query"];
@@ -174,12 +180,28 @@
}
// Table relations view
else if ([tableTabView indexOfTabViewItem:[tableTabView selectedTabViewItem]] == 4) {
- if ([[tableRelationsInstance relationDataForPrinting] count] > 1) {
+
+ NSArray *data = [tableRelationsInstance relationDataForPrinting];
+
+ if ([data count] > 1) {
heading = NSLocalizedString(@"Table Relations", @"table relations print heading");
- NSArray *data = [tableRelationsInstance relationDataForPrinting];
+ rows = [[NSArray alloc] initWithArray:
+ [data objectsAtIndexes:
+ [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(1, ([data count] - 1))]]
+ ];
+ }
+ }
+ // Table triggers view
+ else if ([tableTabView indexOfTabViewItem:[tableTabView selectedTabViewItem]] == 5) {
+
+ NSArray *data = [tableTriggersInstance triggerDataForPrinting];
+
+ if ([data count] > 1) {
+ heading = NSLocalizedString(@"Table Triggers", @"table triggers print heading");
+
rows = [[NSArray alloc] initWithArray:
[data objectsAtIndexes:
[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(1, ([data count] - 1))]]
@@ -257,6 +279,12 @@
columns = [[NSArray alloc] initWithArray:[[tableRelationsInstance relationDataForPrinting] objectAtIndex:0] copyItems:YES];
}
+ // Table triggers view
+ else if ([tableTabView indexOfTabViewItem:[tableTabView selectedTabViewItem]] == 5
+ && [[tableTriggersInstance triggerDataForPrinting] count] > 0) {
+
+ columns = [[NSArray alloc] initWithArray:[[tableTriggersInstance triggerDataForPrinting] objectAtIndex:0] copyItems:YES];
+ }
if (columns) [columns autorelease];
@@ -285,7 +313,6 @@
[connection setValue:[self table] forKey:@"table"];
}
-
if ([connectionController port] && [[connectionController port] length]) {
[connection setValue:[connectionController port] forKey:@"port"];
}
diff --git a/Source/SPTableRelations.m b/Source/SPTableRelations.m
index a88da5e7..7d8ef9e3 100644
--- a/Source/SPTableRelations.m
+++ b/Source/SPTableRelations.m
@@ -350,8 +350,7 @@
*/
- (NSArray *)relationDataForPrinting
{
- NSMutableArray *headings = [NSMutableArray array];
- NSMutableArray *tempData = [NSMutableArray array];
+ NSMutableArray *headings = [[NSMutableArray alloc] init];
NSMutableArray *data = [NSMutableArray array];
// Get the relations table view's columns
@@ -361,11 +360,13 @@
}
[data addObject:headings];
+
+ [headings release];
// Get the relation data
for (NSDictionary *relation in relationData)
{
- NSMutableArray *temp = [NSMutableArray array];
+ NSMutableArray *temp = [[NSMutableArray alloc] init];
[temp addObject:[relation objectForKey:@"name"]];
[temp addObject:[relation objectForKey:@"columns"]];
@@ -375,6 +376,8 @@
[temp addObject:([relation objectForKey:@"on_delete"]) ? [relation objectForKey:@"on_delete"] : @""];
[data addObject:temp];
+
+ [temp release];
}
return data;
diff --git a/Source/SPTableTriggers.h b/Source/SPTableTriggers.h
index 74e5c9b3..d492253b 100644
--- a/Source/SPTableTriggers.h
+++ b/Source/SPTableTriggers.h
@@ -68,4 +68,7 @@
- (void)startDocumentTaskForTab:(NSNotification *)notification;
- (void)endDocumentTaskForTab:(NSNotification *)notification;
+// Other
+- (NSArray *)triggerDataForPrinting;
+
@end
diff --git a/Source/SPTableTriggers.m b/Source/SPTableTriggers.m
index 5ca424e7..26011044 100644
--- a/Source/SPTableTriggers.m
+++ b/Source/SPTableTriggers.m
@@ -393,6 +393,49 @@
[self _toggleConfirmAddTriggerButtonEnabled];
}
+/**
+ * Returns an array of trigger data to be used for printing purposes. The first element in the array is always
+ * an array of the columns and each subsequent element is an array of trigger data.
+ */
+- (NSArray *)triggerDataForPrinting
+{
+ NSMutableArray *headings = [[NSMutableArray alloc] init];
+ NSMutableArray *data = [NSMutableArray array];
+
+ // Get the relations table view's columns
+ for (NSTableColumn *column in [triggersTableView tableColumns])
+ {
+ [headings addObject:[[column headerCell] stringValue]];
+ }
+
+ // Get rid of the 'Table' column
+ [headings removeObjectAtIndex:0];
+
+ [data addObject:headings];
+
+ [headings release];
+
+ // Get the relation data
+ for (NSDictionary *trigger in triggerData)
+ {
+ NSMutableArray *temp = [[NSMutableArray alloc] init];
+
+ [temp addObject:[trigger objectForKey:@"trigger"]];
+ [temp addObject:[trigger objectForKey:@"event"]];
+ [temp addObject:[trigger objectForKey:@"timing"]];
+ [temp addObject:[trigger objectForKey:@"statement"]];
+ [temp addObject:[trigger objectForKey:@"definer"]];
+ [temp addObject:([trigger objectForKey:@"created"]) ? [trigger objectForKey:@"created"] : @""];
+ [temp addObject:[trigger objectForKey:@"sql_mode"]];
+
+ [data addObject:temp];
+
+ [temp release];
+ }
+
+ return data;
+}
+
#pragma mark -
/*