aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorMax <post@wickenrode.com>2014-11-23 15:06:59 +0100
committerMax <post@wickenrode.com>2014-11-23 15:06:59 +0100
commitefe07637acb069eb0ad68b4ae230f28875024907 (patch)
tree3dd0added15316365e50917b9712b29580f9a058 /Source
parentd2919fcd86cb110a3a7bc04a563c7a302e2c3b1c (diff)
downloadsequelpro-efe07637acb069eb0ad68b4ae230f28875024907.tar.gz
sequelpro-efe07637acb069eb0ad68b4ae230f28875024907.tar.bz2
sequelpro-efe07637acb069eb0ad68b4ae230f28875024907.zip
Add a "Open Table in New Window" menu action
This is implemented as an alternate menu item, ie. it will appear when holding down the Option (alt) key instead of the normal "Open Table in new Tab" item. Fixes #2015
Diffstat (limited to 'Source')
-rw-r--r--Source/SPTablesList.h3
-rw-r--r--Source/SPTablesList.m59
2 files changed, 49 insertions, 13 deletions
diff --git a/Source/SPTablesList.h b/Source/SPTablesList.h
index 59824990..a8d9ab91 100644
--- a/Source/SPTablesList.h
+++ b/Source/SPTablesList.h
@@ -95,6 +95,7 @@
IBOutlet NSMenuItem *duplicateTableMenuItem;
IBOutlet NSMenuItem *renameTableMenuItem;
IBOutlet NSMenuItem *openTableInNewTabMenuItem;
+ IBOutlet NSMenuItem *openTableInNewWindowMenuItem;
IBOutlet NSMenuItem *separatorTableMenuItem;
IBOutlet NSMenuItem *showCreateSyntaxMenuItem;
IBOutlet NSMenuItem *copyCreateSyntaxMenuItem;
@@ -111,6 +112,7 @@
IBOutlet NSMenuItem *truncateTableContextMenuItem;
IBOutlet NSMenuItem *renameTableContextMenuItem;
IBOutlet NSMenuItem *openTableInNewTabContextMenuItem;
+ IBOutlet NSMenuItem *openTableInNewWindowContextMenuItem;
IBOutlet NSMenuItem *separatorTableContextMenuItem;
IBOutlet NSMenuItem *showCreateSyntaxContextMenuItem;
IBOutlet NSMenuItem *copyCreateSyntaxContextMenuItem;
@@ -151,6 +153,7 @@
- (IBAction)renameTable:(id)sender;
- (IBAction)truncateTable:(id)sender;
- (IBAction)openTableInNewTab:(id)sender;
+- (IBAction)openTableInNewWindow:(id)sender;
- (IBAction)togglePaneCollapse:(id)sender;
#endif
diff --git a/Source/SPTablesList.m b/Source/SPTablesList.m
index 35b40a66..fdabd3af 100644
--- a/Source/SPTablesList.m
+++ b/Source/SPTablesList.m
@@ -66,6 +66,8 @@
#import "SPCharsetCollationHelper.h"
+#import "SPWindowManagement.h"
+
#import <SPMySQL/SPMySQL.h>
// Constants
@@ -88,7 +90,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable";
- (void)_copyTable;
#endif
- (void)_renameTableOfType:(SPTableType)tableType from:(NSString *)oldTableName to:(NSString *)newTableName;
-
+- (void)_duplicateConnectionToFrontTab;
@end
@implementation SPTablesList
@@ -693,27 +695,39 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable";
*/
- (IBAction)openTableInNewTab:(id)sender
{
-
// Add a new tab to the window
[[[tableDocumentInstance parentWindow] windowController] addNewConnection:self];
+
+ [self _duplicateConnectionToFrontTab];
+}
+- (void)_duplicateConnectionToFrontTab
+{
// Get the state of the document
NSDictionary *allStateDetails = [NSDictionary dictionaryWithObjectsAndKeys:
- [NSNumber numberWithBool:YES], @"connection",
- [NSNumber numberWithBool:YES], @"history",
- [NSNumber numberWithBool:YES], @"session",
- [NSNumber numberWithBool:YES], @"query",
- [NSNumber numberWithBool:YES], @"password",
- nil];
+ [NSNumber numberWithBool:YES], @"connection",
+ [NSNumber numberWithBool:YES], @"history",
+ [NSNumber numberWithBool:YES], @"session",
+ [NSNumber numberWithBool:YES], @"query",
+ [NSNumber numberWithBool:YES], @"password",
+ nil];
NSMutableDictionary *documentState = [NSMutableDictionary dictionaryWithDictionary:[tableDocumentInstance stateIncludingDetails:allStateDetails]];
-
+
// Ensure it's set to autoconnect
[documentState setObject:[NSNumber numberWithBool:YES] forKey:@"auto_connect"];
-
+
// Set the connection on the new tab
[[[NSApp delegate] frontDocument] setState:documentState];
}
+- (IBAction)openTableInNewWindow:(id)sender
+{
+ //create new window
+ [(SPAppController *)[NSApp delegate] newWindow:self];
+
+ [self _duplicateConnectionToFrontTab];
+}
+
/**
* Toggle whether the splitview is collapsed.
*/
@@ -911,6 +925,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable";
// Context menu
[renameTableContextMenuItem setHidden:YES];
[openTableInNewTabContextMenuItem setHidden:YES];
+ [openTableInNewWindowContextMenuItem setHidden:YES];
[separatorTableContextMenuItem3 setHidden:YES];
[duplicateTableContextMenuItem setHidden:YES];
[separatorTableContextMenuItem setHidden:YES];
@@ -923,6 +938,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable";
// 'Gear' menu
[renameTableMenuItem setHidden:YES];
[openTableInNewTabMenuItem setHidden:YES];
+ [openTableInNewWindowMenuItem setHidden:YES];
[separatorTableMenuItem3 setHidden:YES];
[duplicateTableMenuItem setHidden:YES];
[separatorTableMenuItem setHidden:YES];
@@ -1015,8 +1031,10 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable";
[truncateTableButton setHidden:YES];
[removeTableMenuItem setTitle:NSLocalizedString(@"Delete View", @"delete view menu title")];
[openTableInNewTabMenuItem setHidden:NO];
+ [openTableInNewWindowMenuItem setHidden:NO];
[separatorTableMenuItem3 setHidden:NO];
[openTableInNewTabMenuItem setTitle:NSLocalizedString(@"Open View in New Tab", @"open view in new table title")];
+ [openTableInNewWindowMenuItem setTitle:NSLocalizedString(@"Open View in New Window", @"Tables List : Gear Menu : Duplicate connection to new window")];
[showCreateSyntaxMenuItem setHidden:NO];
[showCreateSyntaxMenuItem setTitle:NSLocalizedString(@"Show Create View Syntax...", @"show create view syntax menu item")];
[copyCreateSyntaxMenuItem setHidden:NO];
@@ -1029,8 +1047,10 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable";
[truncateTableContextMenuItem setHidden:YES];
[removeTableContextMenuItem setTitle:NSLocalizedString(@"Delete View", @"delete view menu title")];
[openTableInNewTabContextMenuItem setHidden:NO];
+ [openTableInNewWindowContextMenuItem setHidden:NO];
[separatorTableContextMenuItem3 setHidden:NO];
- [openTableInNewTabContextMenuItem setTitle:NSLocalizedString(@"Open View in New Tab", @"open view in new table title")];
+ [openTableInNewTabContextMenuItem setTitle:NSLocalizedString(@"Open View in New Tab", @"open view in new tab title")];
+ [openTableInNewWindowContextMenuItem setTitle:NSLocalizedString(@"Open View in New Window", @"Tables List : Context Menu : Duplicate connection to new window")];
[showCreateSyntaxContextMenuItem setHidden:NO];
[showCreateSyntaxContextMenuItem setTitle:NSLocalizedString(@"Show Create View Syntax...", @"show create view syntax menu item")];
[copyCreateSyntaxContextMenuItem setHidden:NO];
@@ -1062,7 +1082,9 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable";
[truncateTableButton setTitle:NSLocalizedString(@"Truncate Table", @"truncate table menu title")];
[removeTableMenuItem setTitle:NSLocalizedString(@"Delete Table", @"delete table menu title")];
[openTableInNewTabMenuItem setHidden:NO];
+ [openTableInNewWindowMenuItem setHidden:NO];
[openTableInNewTabMenuItem setTitle:NSLocalizedString(@"Open Table in New Tab", @"open table in new table title")];
+ [openTableInNewWindowMenuItem setTitle:NSLocalizedString(@"Open Table in New Window", @"Table List : Gear Menu : Duplicate connection to new window")];
[separatorTableMenuItem3 setHidden:NO];
[showCreateSyntaxMenuItem setHidden:NO];
[showCreateSyntaxMenuItem setTitle:NSLocalizedString(@"Show Create Table Syntax...", @"show create table syntax menu item")];
@@ -1077,8 +1099,10 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable";
[truncateTableContextMenuItem setTitle:NSLocalizedString(@"Truncate Table", @"truncate table menu title")];
[removeTableContextMenuItem setTitle:NSLocalizedString(@"Delete Table", @"delete table menu title")];
[openTableInNewTabContextMenuItem setHidden:NO];
+ [openTableInNewWindowContextMenuItem setHidden:NO];
[separatorTableContextMenuItem3 setHidden:NO];
- [openTableInNewTabContextMenuItem setTitle:NSLocalizedString(@"Open Table in New Tab", @"open table in new table title")];
+ [openTableInNewTabContextMenuItem setTitle:NSLocalizedString(@"Open Table in New Tab", @"open table in new tab title")];
+ [openTableInNewWindowContextMenuItem setTitle:NSLocalizedString(@"Open Table in New Window", @"Table List : Context Menu : Duplicate connection to new window")];
[showCreateSyntaxContextMenuItem setHidden:NO];
[showCreateSyntaxContextMenuItem setTitle:NSLocalizedString(@"Show Create Table Syntax...", @"show create table syntax menu item")];
[copyCreateSyntaxContextMenuItem setHidden:NO];
@@ -1103,7 +1127,9 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable";
[truncateTableButton setHidden:YES];
[removeTableMenuItem setTitle:NSLocalizedString(@"Delete Procedure", @"delete proc menu title")];
[openTableInNewTabMenuItem setHidden:NO];
+ [openTableInNewWindowMenuItem setHidden:NO];
[openTableInNewTabMenuItem setTitle:NSLocalizedString(@"Open Procedure in New Tab", @"open procedure in new table title")];
+ [openTableInNewWindowMenuItem setTitle:NSLocalizedString(@"Open Procedure in New Window", @"Table List : Gear Menu : duplicate connection to new window")];
[separatorTableMenuItem3 setHidden:NO];
[showCreateSyntaxMenuItem setHidden:NO];
[showCreateSyntaxMenuItem setTitle:NSLocalizedString(@"Show Create Procedure Syntax...", @"show create proc syntax menu item")];
@@ -1117,8 +1143,10 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable";
[truncateTableContextMenuItem setHidden:YES];
[removeTableContextMenuItem setTitle:NSLocalizedString(@"Delete Procedure", @"delete proc menu title")];
[openTableInNewTabContextMenuItem setHidden:NO];
+ [openTableInNewWindowContextMenuItem setHidden:NO];
[separatorTableContextMenuItem3 setHidden:NO];
[openTableInNewTabContextMenuItem setTitle:NSLocalizedString(@"Open Procedure in New Tab", @"open procedure in new table title")];
+ [openTableInNewWindowContextMenuItem setTitle:NSLocalizedString(@"Open Procedure in New Window", @"Table List : Context Menu : duplicate connection to new window")];
[showCreateSyntaxContextMenuItem setHidden:NO];
[showCreateSyntaxContextMenuItem setTitle:NSLocalizedString(@"Show Create Procedure Syntax...", @"show create proc syntax menu item")];
[copyCreateSyntaxContextMenuItem setHidden:NO];
@@ -1143,8 +1171,10 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable";
[truncateTableButton setHidden:YES];
[removeTableMenuItem setTitle:NSLocalizedString(@"Delete Function", @"delete func menu title")];
[openTableInNewTabMenuItem setHidden:NO];
+ [openTableInNewWindowMenuItem setHidden:NO];
[separatorTableMenuItem3 setHidden:NO];
[openTableInNewTabMenuItem setTitle:NSLocalizedString(@"Open Function in New Tab", @"open function in new table title")];
+ [openTableInNewWindowMenuItem setTitle:NSLocalizedString(@"Open Function in New Window", @"Table List : Gear Menu : duplicate connection to new window")];
[showCreateSyntaxMenuItem setHidden:NO];
[showCreateSyntaxMenuItem setTitle:NSLocalizedString(@"Show Create Function Syntax...", @"show create func syntax menu item")];
[copyCreateSyntaxMenuItem setHidden:NO];
@@ -1157,8 +1187,10 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable";
[truncateTableContextMenuItem setHidden:YES];
[removeTableContextMenuItem setTitle:NSLocalizedString(@"Delete Function", @"delete func menu title")];
[openTableInNewTabContextMenuItem setHidden:NO];
+ [openTableInNewWindowContextMenuItem setHidden:NO];
[separatorTableContextMenuItem3 setHidden:NO];
[openTableInNewTabContextMenuItem setTitle:NSLocalizedString(@"Open Function in New Tab", @"open function in new table title")];
+ [openTableInNewWindowContextMenuItem setTitle:NSLocalizedString(@"Open Function in New Window", @"Table List : Context Menu : duplicate connection to new window")];
[showCreateSyntaxContextMenuItem setHidden:NO];
[showCreateSyntaxContextMenuItem setTitle:NSLocalizedString(@"Show Create Function Syntax...", @"show create func syntax menu item")];
[copyCreateSyntaxContextMenuItem setHidden:NO];
@@ -1854,7 +1886,8 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable";
if (action == @selector(copyTable:) ||
action == @selector(renameTable:) ||
- action == @selector(openTableInNewTab:))
+ action == @selector(openTableInNewTab:) ||
+ action == @selector(openTableInNewWindow:))
{
return selectedRows == 1 && [[self tableName] length];
}