aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Interfaces/English.lproj/MainMenu.xib78
-rw-r--r--Source/SPAppController.m101
-rw-r--r--Source/SPConstants.h5
-rw-r--r--Source/SPTextView.m12
-rw-r--r--Source/SPTextViewAdditions.m27
5 files changed, 138 insertions, 85 deletions
diff --git a/Interfaces/English.lproj/MainMenu.xib b/Interfaces/English.lproj/MainMenu.xib
index 6204e5d7..681cba8f 100644
--- a/Interfaces/English.lproj/MainMenu.xib
+++ b/Interfaces/English.lproj/MainMenu.xib
@@ -12,7 +12,7 @@
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="29"/>
+ <integer value="1178"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -1746,37 +1746,11 @@
<reference key="NSOnImage" ref="625762401"/>
<reference key="NSMixedImage" ref="315854375"/>
<string key="NSAction">submenuAction:</string>
+ <int key="NSTag">6</int>
<object class="NSMenu" key="NSSubmenu" id="893886621">
<string key="NSTitle">Bundles</string>
<object class="NSMutableArray" key="NSMenuItems">
<bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSMenuItem" id="397365423">
- <reference key="NSMenu" ref="893886621"/>
- <string key="NSTitle">Open Bundle Editor</string>
- <string key="NSKeyEquiv">b</string>
- <int key="NSKeyEquivModMask">1835008</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="625762401"/>
- <reference key="NSMixedImage" ref="315854375"/>
- </object>
- <object class="NSMenuItem" id="340987940">
- <reference key="NSMenu" ref="893886621"/>
- <string key="NSTitle">Reload Bundles</string>
- <string key="NSKeyEquiv"/>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="625762401"/>
- <reference key="NSMixedImage" ref="315854375"/>
- </object>
- <object class="NSMenuItem" id="834721625">
- <reference key="NSMenu" ref="893886621"/>
- <bool key="NSIsDisabled">YES</bool>
- <bool key="NSIsSeparator">YES</bool>
- <string key="NSTitle"/>
- <string key="NSKeyEquiv"/>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="625762401"/>
- <reference key="NSMixedImage" ref="315854375"/>
- </object>
</object>
</object>
</object>
@@ -1789,7 +1763,7 @@
<reference key="NSOnImage" ref="625762401"/>
<reference key="NSMixedImage" ref="315854375"/>
<string key="NSAction">submenuAction:</string>
- <int key="NSTag">6</int>
+ <int key="NSTag">7</int>
<object class="NSMenu" key="NSSubmenu" id="850647710">
<object class="NSMutableString" key="NSTitle">
<characters key="NS.bytes">Window</characters>
@@ -1881,7 +1855,7 @@
<reference key="NSOnImage" ref="625762401"/>
<reference key="NSMixedImage" ref="315854375"/>
<string key="NSAction">submenuAction:</string>
- <int key="NSTag">7</int>
+ <int key="NSTag">8</int>
<object class="NSMenu" key="NSSubmenu" id="1021151289">
<object class="NSMutableString" key="NSTitle">
<characters key="NS.bytes">Help</characters>
@@ -3092,22 +3066,6 @@
</object>
<int key="connectionID">1175</int>
</object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">reloadBundles:</string>
- <reference key="source" ref="63651044"/>
- <reference key="destination" ref="340987940"/>
- </object>
- <int key="connectionID">1184</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">openBundleEditor:</string>
- <reference key="source" ref="63651044"/>
- <reference key="destination" ref="397365423"/>
- </object>
- <int key="connectionID">1185</int>
- </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -4526,27 +4484,9 @@
<reference key="object" ref="893886621"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
- <reference ref="397365423"/>
- <reference ref="340987940"/>
- <reference ref="834721625"/>
</object>
<reference key="parent" ref="558064231"/>
</object>
- <object class="IBObjectRecord">
- <int key="objectID">1180</int>
- <reference key="object" ref="397365423"/>
- <reference key="parent" ref="893886621"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">1181</int>
- <reference key="object" ref="340987940"/>
- <reference key="parent" ref="893886621"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">1183</int>
- <reference key="object" ref="834721625"/>
- <reference key="parent" ref="893886621"/>
- </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -4620,9 +4560,6 @@
<string>1178.IBPluginDependency</string>
<string>1179.IBEditorWindowLastContentRect</string>
<string>1179.IBPluginDependency</string>
- <string>1180.IBPluginDependency</string>
- <string>1181.IBPluginDependency</string>
- <string>1183.IBPluginDependency</string>
<string>129.IBPluginDependency</string>
<string>129.ImportedFromIB2</string>
<string>130.IBEditorWindowLastContentRect</string>
@@ -4938,7 +4875,7 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{781, 372}, {271, 173}}</string>
+ <string>{{578, 550}, {271, 173}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>{{561, 605}, {181, 43}}</string>
@@ -5010,10 +4947,7 @@
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{435, 670}, {234, 53}}</string>
- <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>{{435, 717}, {64, 6}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
diff --git a/Source/SPAppController.m b/Source/SPAppController.m
index ba0257e1..d64b5183 100644
--- a/Source/SPAppController.m
+++ b/Source/SPAppController.m
@@ -117,6 +117,7 @@
*/
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem
{
+
if ([menuItem action] == @selector(openCurrentConnectionInNewWindow:))
{
[menuItem setTitle:NSLocalizedString(@"Open in New Window", @"menu item open in new window")];
@@ -852,19 +853,31 @@
- (IBAction)reloadBundles:(id)sender
{
+
+ BOOL foundInstalledBundles = NO;
+
+ [bundleItems removeAllObjects];
+ [bundleUsedScopes removeAllObjects];
+ [bundleCategories removeAllObjects];
+ [bundleKeyEquivalents removeAllObjects];
+
+ // Get main menu "Bundles"'s submenu
+ NSMenu *menu = [[[NSApp mainMenu] itemWithTag:SPMainMenuBundles] submenu];
+
+ // Clean menu
+ [menu removeAllItems];
+
NSString *bundlePath = [[NSFileManager defaultManager] applicationSupportDirectoryForSubDirectory:SPBundleSupportFolder createIfNotExists:NO error:nil];
if(bundlePath) {
NSError *error = nil;
NSArray *foundBundles = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:bundlePath error:&error];
if (foundBundles && [foundBundles count]) {
- [bundleItems removeAllObjects];
- [bundleUsedScopes removeAllObjects];
- [bundleCategories removeAllObjects];
- [bundleKeyEquivalents removeAllObjects];
for(NSString* bundle in foundBundles) {
if(![[[bundle pathExtension] lowercaseString] isEqualToString:[SPUserBundleFileExtension lowercaseString]]) continue;
+ foundInstalledBundles = YES;
+
NSError *readError = nil;
NSString *convError = nil;
NSPropertyListFormat format;
@@ -892,7 +905,7 @@
[bundleKeyEquivalents setObject:[NSMutableDictionary dictionary] forKey:scope];
}
- if([cmdData objectForKey:SPBundleFileCategoryKey] && ![bundleCategories containsObject:[cmdData objectForKey:SPBundleFileCategoryKey]])
+ if([cmdData objectForKey:SPBundleFileCategoryKey] && ![[bundleCategories objectForKey:scope] containsObject:[cmdData objectForKey:SPBundleFileCategoryKey]])
[[bundleCategories objectForKey:scope] addObject:[cmdData objectForKey:SPBundleFileCategoryKey]];
}
@@ -937,9 +950,87 @@
[[bundleItems objectForKey:scope] sortUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]];
[[bundleCategories objectForKey:scope] sortUsingSelector:@selector(compare:)];
}
+ }
+ }
+
+ // Rebuild Bundles main menu item
+
+ NSMenuItem *anItem;
+ anItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Bundle Editor", @"bundle editor menu item label") action:@selector(openBundleEditor:) keyEquivalent:@"b"];
+ [anItem setKeyEquivalentModifierMask:(NSCommandKeyMask|NSAlternateKeyMask|NSControlKeyMask)];
+ [menu addItem:anItem];
+ [anItem release];
+ anItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Reload Bundles", @"reload bundles menu item label") action:@selector(reloadBundles:) keyEquivalent:@""];
+ [menu addItem:anItem];
+ [anItem release];
+
+ if(!foundInstalledBundles) return;
+
+ // Add installed Bundles
+ [menu addItem:[NSMenuItem separatorItem]];
+
+ NSArray *scopes = [NSArray arrayWithObjects:SPBundleScopeInputField, SPBundleScopeQueryEditor, nil];
+ NSArray *scopeTitles = [NSArray arrayWithObjects:NSLocalizedString(@"Input Fields", @"input fields menu item label"),
+ NSLocalizedString(@"Query Editor", @"query editor menu item label"), nil];
+ NSArray *scopeSelector = [NSArray arrayWithObjects:@"executeBundleItemForInputField:",
+ @"executeBundleItemForEditor:", nil];
+
+ NSInteger k = 0;
+ for(NSString* scope in scopes) {
+
+ NSArray *bundleCategories = [[NSApp delegate] bundleCategoriesForScope:scope];
+ NSArray *bundleItems = [[NSApp delegate] bundleItemsForScope:scope];
+
+ if(![bundleItems count]) continue;
+
+ NSMenu *bundleMenu = [[[NSMenu alloc] init] autorelease];
+ NSMenuItem *bundleSubMenuItem = [[NSMenuItem alloc] initWithTitle:[scopeTitles objectAtIndex:k] action:nil keyEquivalent:@""];
+ [bundleSubMenuItem setTag:10000000];
+
+ [menu addItem:bundleSubMenuItem];
+ [menu setSubmenu:bundleMenu forItem:bundleSubMenuItem];
+
+ NSMutableArray *categorySubMenus = [NSMutableArray array];
+ NSMutableArray *categoryMenus = [NSMutableArray array];
+ if([bundleCategories count]) {
+ for(NSString* title in bundleCategories) {
+ [categorySubMenus addObject:[[[NSMenuItem alloc] initWithTitle:title action:nil keyEquivalent:@""] autorelease]];
+ [categoryMenus addObject:[[[NSMenu alloc] init] autorelease]];
+ [bundleMenu addItem:[categorySubMenus lastObject]];
+ [bundleMenu setSubmenu:[categoryMenus lastObject] forItem:[categorySubMenus lastObject]];
+ }
+ }
+
+ NSInteger i = 0;
+ for(NSDictionary *item in bundleItems) {
+
+ NSString *keyEq;
+ if([item objectForKey:SPBundleFileKeyEquivalentKey])
+ keyEq = [[item objectForKey:SPBundleFileKeyEquivalentKey] objectAtIndex:0];
+ else
+ keyEq = @"";
+ NSMenuItem *mItem = [[[NSMenuItem alloc] initWithTitle:[item objectForKey:SPBundleInternLabelKey] action:NSSelectorFromString([scopeSelector objectAtIndex:k]) keyEquivalent:keyEq] autorelease];
+
+ if([keyEq length])
+ [mItem setKeyEquivalentModifierMask:[[[item objectForKey:SPBundleFileKeyEquivalentKey] objectAtIndex:1] intValue]];
+
+ if([item objectForKey:SPBundleFileTooltipKey])
+ [mItem setToolTip:[item objectForKey:SPBundleFileTooltipKey]];
+
+ [mItem setTag:1000000 + i++];
+
+ if([item objectForKey:SPBundleFileCategoryKey]) {
+ [[categoryMenus objectAtIndex:[bundleCategories indexOfObject:[item objectForKey:SPBundleFileCategoryKey]]] addItem:mItem];
+ } else {
+ [bundleMenu addItem:mItem];
+ }
}
+
+ [bundleSubMenuItem release];
+ k++;
}
+
}
#pragma mark -
diff --git a/Source/SPConstants.h b/Source/SPConstants.h
index 897c0c26..64003bad 100644
--- a/Source/SPConstants.h
+++ b/Source/SPConstants.h
@@ -151,8 +151,9 @@ typedef enum
SPMainMenuView = 3,
SPMainMenuDatabase = 4,
SPMainMenuTable = 5,
- SPMainMenuWindow = 6,
- SPMainMenuHelp = 7
+ SPMainMenuBundles = 6,
+ SPMainMenuWindow = 7,
+ SPMainMenuHelp = 8
} SPMainMenuTags;
// Encoding constants
diff --git a/Source/SPTextView.m b/Source/SPTextView.m
index 21ab5260..f83b2549 100644
--- a/Source/SPTextView.m
+++ b/Source/SPTextView.m
@@ -2991,7 +2991,17 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
* Disable the search in the MySQL help function when getRangeForCurrentWord returns zero length.
*/
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem
-{
+{
+
+ if([menuItem action] == @selector(executeBundleItemForEditor:))
+ {
+ return YES;
+ }
+ if([menuItem action] == @selector(executeBundleItemForInputField:))
+ {
+ return NO;
+ }
+
// Enable or disable the search in the MySQL help menu item depending on whether there is a
// selection and whether it is a reasonable length.
if ([menuItem action] == @selector(showMySQLHelpForCurrentWord:)) {
diff --git a/Source/SPTextViewAdditions.m b/Source/SPTextViewAdditions.m
index 381f8f0a..24a5236f 100644
--- a/Source/SPTextViewAdditions.m
+++ b/Source/SPTextViewAdditions.m
@@ -715,17 +715,19 @@
NSInteger i = 0;
for(NSDictionary *item in bundleItems) {
- NSString *keyEq = @"";
- // if([item objectForKey:SPBundleFileKeyEquivalentKey])
- // keyEq = [[item objectForKey:SPBundleFileKeyEquivalentKey] objectAtIndex:0];
- // else
- // keyEq = @"";
+ NSString *keyEq;
+ if([item objectForKey:SPBundleFileKeyEquivalentKey])
+ keyEq = [[item objectForKey:SPBundleFileKeyEquivalentKey] objectAtIndex:0];
+ else
+ keyEq = @"";
NSMenuItem *mItem = [[[NSMenuItem alloc] initWithTitle:[item objectForKey:SPBundleInternLabelKey] action:@selector(executeBundleItemForInputField:) keyEquivalent:keyEq] autorelease];
if([keyEq length])
[mItem setKeyEquivalentModifierMask:[[[item objectForKey:SPBundleFileKeyEquivalentKey] objectAtIndex:1] intValue]];
+ [mItem setTarget:[[NSApp mainWindow] firstResponder]];
+
if([item objectForKey:SPBundleFileTooltipKey])
[mItem setToolTip:[item objectForKey:SPBundleFileTooltipKey]];
@@ -744,6 +746,21 @@
}
+- (BOOL)validateMenuItem:(NSMenuItem *)menuItem
+{
+
+ if([menuItem action] == @selector(executeBundleItemForEditor:))
+ {
+ return NO;
+ }
+ if([menuItem action] == @selector(executeBundleItemForInputField:))
+ {
+ return YES;
+ }
+
+ return YES;
+
+}
#pragma mark -
#pragma mark multi-touch trackpad support