aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPTableRelations.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2010-03-12 01:02:52 +0000
committerstuconnolly <stuart02@gmail.com>2010-03-12 01:02:52 +0000
commit88f89987a4329b394ee30a2a77705d3afbb35195 (patch)
tree71d53571320669deb0881485fd53dc5062c7ae3f /Source/SPTableRelations.m
parent98af234687c698826817a6c219ce8f731fdfa1e7 (diff)
downloadsequelpro-88f89987a4329b394ee30a2a77705d3afbb35195.tar.gz
sequelpro-88f89987a4329b394ee30a2a77705d3afbb35195.tar.bz2
sequelpro-88f89987a4329b394ee30a2a77705d3afbb35195.zip
Various printing support enhancements, including:
- Splitting out all printing methods to SPPrintController which is category of TableDocument. - The ability to print table relations. - If present the inclusion of table indexes when printing a table's source. - If the user has use monospaced fonts enables, then the print out's tabular data will be in a monospaced font. - Lots of other style enhancements, including page headings and sections headings.
Diffstat (limited to 'Source/SPTableRelations.m')
-rw-r--r--Source/SPTableRelations.m44
1 files changed, 40 insertions, 4 deletions
diff --git a/Source/SPTableRelations.m b/Source/SPTableRelations.m
index 10780fd1..a88da5e7 100644
--- a/Source/SPTableRelations.m
+++ b/Source/SPTableRelations.m
@@ -41,6 +41,7 @@
@implementation SPTableRelations
@synthesize connection;
+@synthesize relationData;
/**
* init
@@ -316,8 +317,7 @@
{
// Only proceed if this view is selected.
- if (![[tableDocumentInstance selectedToolbarItemIdentifier] isEqualToString:SPMainToolbarTableRelations])
- return;
+ if (![[tableDocumentInstance selectedToolbarItemIdentifier] isEqualToString:SPMainToolbarTableRelations]) return;
[addRelationButton setEnabled:NO];
[refreshRelationsButton setEnabled:NO];
@@ -331,13 +331,13 @@
{
// Only proceed if this view is selected.
- if (![[tableDocumentInstance selectedToolbarItemIdentifier] isEqualToString:SPMainToolbarTableRelations])
- return;
+ if (![[tableDocumentInstance selectedToolbarItemIdentifier] isEqualToString:SPMainToolbarTableRelations]) return;
if ([relationsTableView isEnabled]) {
[addRelationButton setEnabled:YES];
[refreshRelationsButton setEnabled:YES];
}
+
[removeRelationButton setEnabled:([relationsTableView numberOfSelectedRows] > 0)];
}
@@ -345,6 +345,42 @@
#pragma mark Other
/**
+ * Returns an array of relation 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 relation data.
+ */
+- (NSArray *)relationDataForPrinting
+{
+ NSMutableArray *headings = [NSMutableArray array];
+ NSMutableArray *tempData = [NSMutableArray array];
+ NSMutableArray *data = [NSMutableArray array];
+
+ // Get the relations table view's columns
+ for (NSTableColumn *column in [relationsTableView tableColumns])
+ {
+ [headings addObject:[[column headerCell] stringValue]];
+ }
+
+ [data addObject:headings];
+
+ // Get the relation data
+ for (NSDictionary *relation in relationData)
+ {
+ NSMutableArray *temp = [NSMutableArray array];
+
+ [temp addObject:[relation objectForKey:@"name"]];
+ [temp addObject:[relation objectForKey:@"columns"]];
+ [temp addObject:[relation objectForKey:@"fk_table"]];
+ [temp addObject:[relation objectForKey:@"fk_columns"]];
+ [temp addObject:([relation objectForKey:@"on_update"]) ? [relation objectForKey:@"on_update"] : @""];
+ [temp addObject:([relation objectForKey:@"on_delete"]) ? [relation objectForKey:@"on_delete"] : @""];
+
+ [data addObject:temp];
+ }
+
+ return data;
+}
+
+/**
* NSAlert didEnd method.
*/
- (void)alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo