diff options
-rw-r--r-- | Interfaces/English.lproj/DBView.xib | 113 | ||||
-rw-r--r-- | Source/CustomQuery.h | 13 | ||||
-rw-r--r-- | Source/CustomQuery.m | 282 | ||||
-rw-r--r-- | Source/TableContent.m | 17 |
4 files changed, 308 insertions, 117 deletions
diff --git a/Interfaces/English.lproj/DBView.xib b/Interfaces/English.lproj/DBView.xib index cc66fb2b..b8da8f5b 100644 --- a/Interfaces/English.lproj/DBView.xib +++ b/Interfaces/English.lproj/DBView.xib @@ -3,7 +3,7 @@ <data> <int key="IBDocument.SystemTarget">1050</int> <string key="IBDocument.SystemVersion">10B504</string> - <string key="IBDocument.InterfaceBuilderVersion">740</string> + <string key="IBDocument.InterfaceBuilderVersion">732</string> <string key="IBDocument.AppKitVersion">1038.2</string> <string key="IBDocument.HIToolboxVersion">437.00</string> <object class="NSMutableDictionary" key="IBDocument.PluginVersions"> @@ -16,20 +16,20 @@ </object> <object class="NSMutableArray" key="dict.values"> <bool key="EncodedWithXMLCoder">YES</bool> - <string>740</string> - <string>740</string> + <string>732</string> + <string>732</string> <string>1.2.1</string> </object> </object> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> - <integer value="1304"/> + <integer value="663"/> </object> <object class="NSArray" key="IBDocument.PluginDependencies"> <bool key="EncodedWithXMLCoder">YES</bool> <string>com.brandonwalkin.BWToolkit</string> - <string>com.apple.WebKitIBPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.WebKitIBPlugin</string> </object> <object class="NSMutableDictionary" key="IBDocument.Metadata"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -59,7 +59,7 @@ <string key="NSWindowTitle">Connecting...</string> <string key="NSWindowClass">NSWindow</string> <string key="NSViewClass">View</string> - <string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string> + <string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string> <string key="NSWindowContentMinSize">{780, 480}</string> <object class="NSView" key="NSWindowView" id="579726586"> <reference key="NSNextResponder"/> @@ -237,7 +237,7 @@ <string key="NSColorName">controlColor</string> <object class="NSColor" key="NSColor" id="1001122760"> <int key="NSColorSpace">3</int> - <bytes key="NSWhite">MC42NjY2NjY2ODY1AA</bytes> + <bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes> </object> </object> <reference key="NSTextColor" ref="454249633"/> @@ -871,7 +871,7 @@ <object class="NSTabViewItem" id="831053945"> <string key="NSIdentifier">source</string> <object class="NSView" key="NSView" id="461236772"> - <reference key="NSNextResponder" ref="714795046"/> + <nil key="NSNextResponder"/> <int key="NSvFlags">256</int> <object class="NSMutableArray" key="NSSubviews"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -1009,7 +1009,7 @@ <object class="NSComboTableView" key="NSTableView" id="567127181"> <reference key="NSNextResponder"/> <int key="NSvFlags">274</int> - <string key="NSFrameSize">{13, 504}</string> + <string key="NSFrameSize">{13, 558}</string> <reference key="NSSuperview"/> <reference key="NSWindow"/> <bool key="NSEnabled">YES</bool> @@ -2132,7 +2132,6 @@ </object> </object> <string key="NSFrame">{{10, 7}, {700, 544}}</string> - <reference key="NSSuperview" ref="714795046"/> </object> <string key="NSLabel">Structure</string> <reference key="NSColor" ref="62854682"/> @@ -2927,7 +2926,7 @@ <object class="NSTabViewItem" id="105987292"> <string key="NSIdentifier">customQuery</string> <object class="NSView" key="NSView" id="746504912"> - <nil key="NSNextResponder"/> + <reference key="NSNextResponder" ref="714795046"/> <int key="NSvFlags">256</int> <object class="NSMutableArray" key="NSSubviews"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -2954,6 +2953,29 @@ <object class="NSTextView" id="1055190999"> <reference key="NSNextResponder" ref="1072692119"/> <int key="NSvFlags">6418</int> + <object class="NSMutableSet" key="NSDragTypes"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="set.sortedObjects"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>Apple HTML pasteboard type</string> + <string>Apple PDF pasteboard type</string> + <string>Apple PICT pasteboard type</string> + <string>Apple PNG pasteboard type</string> + <string>Apple URL pasteboard type</string> + <string>CorePasteboardFlavorType 0x6D6F6F76</string> + <string>NSColor pasteboard type</string> + <string>NSFilenamesPboardType</string> + <string>NSStringPboardType</string> + <string>NeXT Encapsulated PostScript v1.2 pasteboard type</string> + <string>NeXT RTFD pasteboard type</string> + <string>NeXT Rich Text Format v1.0 pasteboard type</string> + <string>NeXT TIFF v4.0 pasteboard type</string> + <string>NeXT font pasteboard type</string> + <string>NeXT ruler pasteboard type</string> + <string>WebURLsWithTitlesPboardType</string> + <string>public.url</string> + </object> + </object> <string key="NSFrameSize">{688, 14}</string> <reference key="NSSuperview" ref="1072692119"/> <object class="NSTextContainer" key="NSTextContainer" id="326170846"> @@ -3630,7 +3652,7 @@ </object> <bool key="NSNoAutoenable">YES</bool> </object> - <int key="NSSelectedIndex">18</int> + <int key="NSSelectedIndex">1</int> <bool key="NSPullDown">YES</bool> <int key="NSPreferredEdge">1</int> <bool key="NSUsesItemFromMenu">YES</bool> @@ -3776,6 +3798,7 @@ </object> </object> <string key="NSFrame">{{10, 7}, {700, 544}}</string> + <reference key="NSSuperview" ref="714795046"/> </object> <string key="NSLabel">Custom Query</string> <reference key="NSColor" ref="62854682"/> @@ -4820,14 +4843,14 @@ <reference key="NSTabView" ref="714795046"/> </object> </object> - <reference key="NSSelectedTabViewItem" ref="831053945"/> + <reference key="NSSelectedTabViewItem" ref="105987292"/> <reference key="NSFont" ref="26"/> <int key="NSTvFlags">134217731</int> <bool key="NSAllowTruncatedLabels">YES</bool> <bool key="NSDrawsBackground">YES</bool> <object class="NSMutableArray" key="NSSubviews"> <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="461236772"/> + <reference ref="746504912"/> </object> </object> </object> @@ -4847,7 +4870,7 @@ </object> <string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string> <string key="NSMinSize">{780, 502}</string> - <string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string> + <string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string> <string key="NSFrameAutosaveName"/> </object> <object class="NSWindowTemplate" id="554105051"> @@ -6018,7 +6041,7 @@ <object class="NSMutableString" key="NSViewClass"> <characters key="NS.bytes">View</characters> </object> - <string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string> + <string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string> <string key="NSWindowContentMinSize">{213, 107}</string> <object class="NSView" key="NSWindowView" id="329225443"> <nil key="NSNextResponder"/> @@ -6297,7 +6320,7 @@ </object> <string key="NSScreenRect">{{0, 0}, {1440, 878}}</string> <string key="NSMinSize">{213, 129}</string> - <string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string> + <string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string> </object> <object class="NSWindowTemplate" id="734744289"> <int key="NSWindowStyleMask">1</int> @@ -6309,7 +6332,7 @@ <object class="NSMutableString" key="NSViewClass"> <characters key="NS.bytes">View</characters> </object> - <string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string> + <string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string> <string key="NSWindowContentMinSize">{213, 107}</string> <object class="NSView" key="NSWindowView" id="234287744"> <nil key="NSNextResponder"/> @@ -6465,7 +6488,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> </object> <string key="NSScreenRect">{{0, 0}, {1440, 878}}</string> <string key="NSMinSize">{213, 129}</string> - <string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string> + <string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string> </object> <object class="NSWindowTemplate" id="787219800"> <int key="NSWindowStyleMask">1</int> @@ -6475,7 +6498,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <string key="NSWindowTitle">New Relation</string> <string key="NSWindowClass">NSPanel</string> <nil key="NSViewClass"/> - <string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string> + <string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string> <object class="NSView" key="NSWindowView" id="842408319"> <nil key="NSNextResponder"/> <int key="NSvFlags">256</int> @@ -7076,7 +7099,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <string key="NSFrameSize">{302, 307}</string> </object> <string key="NSScreenRect">{{0, 0}, {1440, 878}}</string> - <string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string> + <string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string> </object> <object class="NSWindowTemplate" id="1066802919"> <int key="NSWindowStyleMask">3</int> @@ -7088,7 +7111,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <object class="NSMutableString" key="NSViewClass"> <characters key="NS.bytes">View</characters> </object> - <string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string> + <string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string> <string key="NSWindowContentMinSize">{213, 50}</string> <object class="NSView" key="NSWindowView" id="525490268"> <nil key="NSNextResponder"/> @@ -7208,7 +7231,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> </object> <string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string> <string key="NSMinSize">{213, 72}</string> - <string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string> + <string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string> </object> <object class="NSWindowTemplate" id="553728448"> <int key="NSWindowStyleMask">9</int> @@ -7220,7 +7243,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <object class="NSMutableString" key="NSViewClass"> <characters key="NS.bytes">View</characters> </object> - <string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string> + <string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string> <string key="NSWindowContentMinSize">{213, 107}</string> <object class="NSView" key="NSWindowView" id="1052076676"> <nil key="NSNextResponder"/> @@ -7355,7 +7378,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> </object> <string key="NSScreenRect">{{0, 0}, {1440, 878}}</string> <string key="NSMinSize">{213, 129}</string> - <string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string> + <string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string> </object> <object class="NSWindowTemplate" id="202784209"> <int key="NSWindowStyleMask">15</int> @@ -7367,7 +7390,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <object class="NSMutableString" key="NSViewClass"> <characters key="NS.bytes">View</characters> </object> - <string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string> + <string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string> <string key="NSWindowContentMinSize">{350, 200}</string> <object class="NSView" key="NSWindowView" id="226131408"> <nil key="NSNextResponder"/> @@ -7671,7 +7694,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> </object> <string key="NSScreenRect">{{0, 0}, {1440, 878}}</string> <string key="NSMinSize">{350, 222}</string> - <string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string> + <string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string> </object> <object class="NSWindowTemplate" id="828950706"> <int key="NSWindowStyleMask">15</int> @@ -7683,7 +7706,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <object class="NSMutableString" key="NSViewClass"> <characters key="NS.bytes">View</characters> </object> - <string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string> + <string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string> <string key="NSWindowContentMinSize">{350, 200}</string> <object class="NSView" key="NSWindowView" id="749598685"> <nil key="NSNextResponder"/> @@ -7885,7 +7908,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> </object> <string key="NSScreenRect">{{0, 0}, {1680, 1028}}</string> <string key="NSMinSize">{350, 222}</string> - <string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string> + <string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string> </object> <object class="NSWindowTemplate" id="466147946"> <int key="NSWindowStyleMask">9</int> @@ -7897,7 +7920,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <object class="NSMutableString" key="NSViewClass"> <characters key="NS.bytes">View</characters> </object> - <string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string> + <string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string> <string key="NSWindowContentMinSize">{213, 107}</string> <object class="NSView" key="NSWindowView" id="860968037"> <nil key="NSNextResponder"/> @@ -8046,7 +8069,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> </object> <string key="NSScreenRect">{{0, 0}, {1440, 878}}</string> <string key="NSMinSize">{213, 129}</string> - <string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string> + <string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string> </object> <object class="NSWindowTemplate" id="78186995"> <int key="NSWindowStyleMask">31</int> @@ -8056,7 +8079,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <string key="NSWindowTitle">MySQL Help</string> <string key="NSWindowClass">NSPanel</string> <nil key="NSViewClass"/> - <string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string> + <string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string> <string key="NSWindowContentMinSize">{351, 120}</string> <object class="NSView" key="NSWindowView" id="539508428"> <nil key="NSNextResponder"/> @@ -8450,7 +8473,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> </object> <string key="NSScreenRect">{{0, 0}, {1280, 1002}}</string> <string key="NSMinSize">{351, 136}</string> - <string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string> + <string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string> <string key="NSFrameAutosaveName">MYSQL_HELP_WINDOW</string> </object> <object class="NSWindowTemplate" id="176945499"> @@ -8463,7 +8486,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <object class="NSMutableString" key="NSViewClass"> <characters key="NS.bytes">View</characters> </object> - <string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string> + <string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string> <string key="NSWindowContentMinSize">{350, 250}</string> <object class="NSView" key="NSWindowView" id="1024486775"> <nil key="NSNextResponder"/> @@ -8854,7 +8877,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> </object> <string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string> <string key="NSMinSize">{350, 272}</string> - <string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string> + <string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string> </object> <object class="NSWindowTemplate" id="434046103"> <int key="NSWindowStyleMask">9</int> @@ -8987,7 +9010,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <string key="NSWindowTitle">Secure Text Input Sheet</string> <string key="NSWindowClass">NSPanel</string> <nil key="NSViewClass"/> - <string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string> + <string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string> <object class="NSView" key="NSWindowView" id="978976687"> <nil key="NSNextResponder"/> <int key="NSvFlags">256</int> @@ -9091,7 +9114,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <string key="NSFrameSize">{338, 138}</string> </object> <string key="NSScreenRect">{{0, 0}, {1280, 778}}</string> - <string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string> + <string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string> </object> <object class="NSCustomView" id="139279766"> <nil key="NSNextResponder"/> @@ -10957,7 +10980,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <string key="NSColorName">disabledControlTextColor</string> <object class="NSColor" key="NSColor"> <int key="NSColorSpace">3</int> - <bytes key="NSWhite">MC4zMzMzMzMzNDMzAA</bytes> + <bytes key="NSWhite">MC4zMzMzMzMzMzMzAA</bytes> </object> </object> </object> @@ -15180,6 +15203,14 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> </object> <int key="connectionID">6628</int> </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">runAllMenuItem</string> + <reference key="source" ref="601471102"/> + <reference key="destination" ref="216778737"/> + </object> + <int key="connectionID">6629</int> + </object> </object> <object class="IBMutableOrderedSet" key="objectRecords"> <object class="NSArray" key="orderedObjects"> @@ -23816,7 +23847,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{350, 236}, {259, 349}}</string> + <string>{{247, 228}, {256, 357}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> @@ -24767,7 +24798,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> </object> </object> <nil key="sourceID"/> - <int key="maxID">6628</int> + <int key="maxID">6629</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> @@ -24913,6 +24944,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <string>queryHistorySearchFieldView</string> <string>queryHistorySearchMenuItem</string> <string>runAllButton</string> + <string>runAllMenuItem</string> <string>runSelectionButton</string> <string>runSelectionMenuItem</string> <string>saveQueryFavoriteButton</string> @@ -24959,6 +24991,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <string>id</string> <string>NSMenuItem</string> <string>id</string> + <string>NSMenuItem</string> <string>id</string> <string>NSMenuItem</string> <string>NSButton</string> diff --git a/Source/CustomQuery.h b/Source/CustomQuery.h index a9d4f670..374cfc0d 100644 --- a/Source/CustomQuery.h +++ b/Source/CustomQuery.h @@ -82,6 +82,7 @@ IBOutlet id multipleLineEditingButton; IBOutlet NSMenuItem *runSelectionMenuItem; + IBOutlet NSMenuItem *runAllMenuItem; IBOutlet NSMenuItem *clearHistoryMenuItem; IBOutlet NSMenuItem *shiftLeftMenuItem; IBOutlet NSMenuItem *shiftRightMenuItem; @@ -109,8 +110,11 @@ NSString *usedQuery; NSRange currentQueryRange; NSArray *currentQueryRanges; + NSRange oldThreadedQueryRange; BOOL hasBackgroundAttribute; + BOOL selectionButtonCanBeEnabled; NSString *mySQLversion; + NSTableColumn *sortColumn; int queryStartPosition; @@ -119,6 +123,7 @@ NSString *helpHTMLTemplate; NSMutableArray *fullResult; + NSInteger fullResultCount; NSArray *cqColumnDefinition; NSString *lastExecutedQuery; @@ -135,6 +140,7 @@ // IBAction methods - (IBAction)runAllQueries:(id)sender; +- (void) runAllQueriesCallback; - (IBAction)runSelectedQueries:(id)sender; - (IBAction)chooseQueryFavorite:(id)sender; - (IBAction)chooseQueryHistory:(id)sender; @@ -153,7 +159,8 @@ - (IBAction)filterQueryHistory:(id)sender; // Query actions -- (void)performQueries:(NSArray *)queries; +- (void)performQueries:(NSArray *)queries withCallback:(SEL)customQueryCallbackMethod; +- (void)performQueriesTask:(NSDictionary *)taskArguments; - (NSString *)queryAtPosition:(long)position lookBehind:(BOOL *)doLookBehind; - (NSRange)queryRangeAtPosition:(long)position lookBehind:(BOOL *)doLookBehind; - (NSRange)queryTextRangeForQuery:(int)anIndex startPosition:(long)position; @@ -170,6 +177,10 @@ - (NSWindow *)helpWebViewWindow; - (void)setMySQLversion:(NSString *)theVersion; +// Task interaction +- (void) startDocumentTaskForTab:(NSNotification *)aNotification; +- (void) endDocumentTaskForTab:(NSNotification *)aNotification; + // Other - (void)setConnection:(MCPConnection *)theConnection; - (void)doPerformQueryService:(NSString *)query; diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m index 3fffaa7a..b1e49f68 100644 --- a/Source/CustomQuery.m +++ b/Source/CustomQuery.m @@ -64,23 +64,27 @@ queries = [queryParser splitSqlStringByCharacter:';']; [queryParser release]; - NSRange curRange = [textView selectedRange]; + oldThreadedQueryRange = [textView selectedRange]; // Unselect a selection if given to avoid interferring with error highlighting - [textView setSelectedRange:NSMakeRange(curRange.location, 0)]; + [textView setSelectedRange:NSMakeRange(oldThreadedQueryRange.location, 0)]; // Reset queryStartPosition queryStartPosition = 0; tableReloadAfterEditing = NO; - [self performQueries:queries]; + [self performQueries:queries withCallback:@selector(runAllQueriesCallback)]; +} + +- (void) runAllQueriesCallback +{ // If no error was selected reconstruct a given selection if([textView selectedRange].length == 0) - [textView setSelectedRange:curRange]; + [textView setSelectedRange:oldThreadedQueryRange]; // Invoke textStorageDidProcessEditing: for syntax highlighting and auto-uppercase NSRange oldRange = [textView selectedRange]; - [textView setSelectedRange:NSMakeRange(oldRange.location,0)]; + [textView setSelectedRange:NSMakeRange(oldThreadedQueryRange.location,0)]; [textView insertText:@""]; [textView setSelectedRange:oldRange]; } @@ -123,7 +127,7 @@ tableReloadAfterEditing = NO; - [self performQueries:queries]; + [self performQueries:queries withCallback:NULL]; } /** @@ -330,12 +334,34 @@ * Performs the mysql-query given by the user * sets the tableView columns corresponding to the mysql-result */ -- (void)performQueries:(NSArray *)queries; -{ +- (void)performQueries:(NSArray *)queries withCallback:(SEL)customQueryCallbackMethod; +{ + NSString *taskString; + if ([queries count] > 1) { + taskString = [NSString stringWithFormat:NSLocalizedString(@"Running query %i of %i...", @"Running multiple queries string"), 1, [queries count]]; + } else { + taskString = NSLocalizedString(@"Running query...", @"Running single query string"); + } + [tableDocumentInstance startTaskWithDescription:taskString]; + [errorText setStringValue:taskString]; + [affectedRowsText setStringValue:@""]; + + NSValue *encodedCallbackMethod = nil; + if (customQueryCallbackMethod) + encodedCallbackMethod = [NSValue valueWithBytes:&customQueryCallbackMethod objCType:@encode(SEL)]; + NSDictionary *taskArguments = [NSDictionary dictionaryWithObjectsAndKeys:queries, @"queries", encodedCallbackMethod, @"callback", nil]; + [NSThread detachNewThreadSelector:@selector(performQueriesTask:) toTarget:self withObject:taskArguments]; +} + +- (void)performQueriesTask:(NSDictionary *)taskArguments +{ + NSAutoreleasePool *queryRunningPool = [[NSAutoreleasePool alloc] init]; + NSArray *queries = [taskArguments objectForKey:@"queries"]; NSArray *theColumns; NSTableColumn *theCol; MCPStreamingResult *streamingResult = nil; NSMutableString *errors = [NSMutableString string]; + SEL callbackMethod = NULL; int i, totalQueriesRun = 0, totalAffectedRows = 0; double executionTime = 0; @@ -376,6 +402,12 @@ // Perform the supplied queries in series for ( i = 0 ; i < queryCount ; i++ ) { + if (i > 0) { + NSString *taskString = [NSString stringWithFormat:NSLocalizedString(@"Running query %i of %i...", @"Running multiple queries string"), i+1, queryCount]; + [tableDocumentInstance setTaskDescription:taskString]; + [errorText setStringValue:taskString]; + } + NSString *query = [NSArrayObjectAtIndex(queries, i) stringByTrimmingCharactersInSet:whitespaceAndNewlineSet]; // Don't run blank queries, or queries which only contain whitespace. @@ -392,10 +424,59 @@ // If this is the last query, retrieve and store the result; otherwise, // discard the result without fully loading. - if (totalQueriesRun == queryCount) + if (totalQueriesRun == queryCount) { + + // get column definitions for the result array + if (cqColumnDefinition) [cqColumnDefinition release]; + cqColumnDefinition = [[streamingResult fetchResultFieldsStructure] retain]; + + // Add columns corresponding to the query result + theColumns = [streamingResult fetchFieldNames]; + + if(!tableReloadAfterEditing) { + for ( i = 0 ; i < [streamingResult numOfFields] ; i++) { + NSDictionary *columnDefinition = NSArrayObjectAtIndex(cqColumnDefinition,i); + theCol = [[NSTableColumn alloc] initWithIdentifier:[columnDefinition objectForKey:@"datacolumnindex"]]; + [theCol setResizingMask:NSTableColumnUserResizingMask]; + [theCol setEditable:YES]; + SPTextAndLinkCell *dataCell = [[[SPTextAndLinkCell alloc] initTextCell:@""] autorelease]; + [dataCell setEditable:YES]; + [dataCell setFormatter:[[SPDataCellFormatter new] autorelease]]; + if ( [prefs boolForKey:SPUseMonospacedFonts] ) { + [dataCell setFont:[NSFont fontWithName:@"Monaco" size:10]]; + } else { + [dataCell setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + } + [dataCell setLineBreakMode:NSLineBreakByTruncatingTail]; + [theCol setDataCell:dataCell]; + [[theCol headerCell] setStringValue:NSArrayObjectAtIndex(theColumns, i)]; + + // Set the width of this column to saved value if exists and maps to a real column + if ([columnDefinition objectForKey:@"org_name"] && [[columnDefinition objectForKey:@"org_name"] length]) { + NSNumber *colWidth = [[[[prefs objectForKey:SPTableColumnWidths] objectForKey:[NSString stringWithFormat:@"%@@%@", [columnDefinition objectForKey:@"db"], [tableDocumentInstance host]]] objectForKey:[columnDefinition objectForKey:@"org_table"]] objectForKey:[columnDefinition objectForKey:@"org_name"]]; + if ( colWidth ) { + [theCol setWidth:[colWidth floatValue]]; + } + } + + [customQueryView addTableColumn:theCol]; + [theCol release]; + } + + [customQueryView sizeLastColumnToFit]; + + //tries to fix problem with last row (otherwise to small) + //sets last column to width of the first if smaller than 30 + //problem not fixed for resizing window + if ( [[customQueryView tableColumnWithIdentifier:[NSNumber numberWithInt:[theColumns count]-1]] width] < 30 ) + [[customQueryView tableColumnWithIdentifier:[NSNumber numberWithInt:[theColumns count]-1]] + setWidth:[[customQueryView tableColumnWithIdentifier:[NSNumber numberWithInt:0]] width]]; + } + [self processResultIntoDataStorage:streamingResult]; - else + } else { [streamingResult cancelResultLoad]; + } // Record any affected rows if ( [mySQLConnection affectedRows] != -1 ) @@ -587,7 +668,7 @@ [tableDocumentInstance setQueryMode:SP_QUERYMODE_INTERFACE]; // If no results were returned, redraw the empty table and post notifications before returning. - if ( ![fullResult count] ) { + if ( !fullResultCount ) { [customQueryView reloadData]; [streamingResult release]; @@ -599,12 +680,19 @@ description:[NSString stringWithFormat:NSLocalizedString(@"%@",@"description for query finished growl notification"), [errorText stringValue]] window:tableWindow notificationName:@"Query Finished"]; + + // Set up the callback if present + if ([taskArguments objectForKey:@"callback"]) { + [[taskArguments objectForKey:@"callback"] getValue:&callbackMethod]; + [self performSelectorOnMainThread:callbackMethod withObject:nil waitUntilDone:NO]; + } + + [tableDocumentInstance endTask]; + [queryRunningPool release]; + return; } - // get column definitions for the result array - cqColumnDefinition = [[streamingResult fetchResultFieldsStructure] retain]; - // Find result table name for copying as SQL INSERT. // If more than one table name is found set resultTableName to nil. // resultTableName will be set to the original table name (not defined via AS) provided by mysql return @@ -619,48 +707,7 @@ } } - // Add columns corresponding to the query result - theColumns = [streamingResult fetchFieldNames]; - - if(!tableReloadAfterEditing) { - for ( i = 0 ; i < [streamingResult numOfFields] ; i++) { - NSDictionary *columnDefinition = NSArrayObjectAtIndex(cqColumnDefinition,i); - theCol = [[NSTableColumn alloc] initWithIdentifier:[columnDefinition objectForKey:@"datacolumnindex"]]; - [theCol setResizingMask:NSTableColumnUserResizingMask]; - [theCol setEditable:YES]; - SPTextAndLinkCell *dataCell = [[[SPTextAndLinkCell alloc] initTextCell:@""] autorelease]; - [dataCell setEditable:YES]; - [dataCell setFormatter:[[SPDataCellFormatter new] autorelease]]; - if ( [prefs boolForKey:SPUseMonospacedFonts] ) { - [dataCell setFont:[NSFont fontWithName:@"Monaco" size:10]]; - } else { - [dataCell setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; - } - [dataCell setLineBreakMode:NSLineBreakByTruncatingTail]; - [theCol setDataCell:dataCell]; - [[theCol headerCell] setStringValue:NSArrayObjectAtIndex(theColumns, i)]; - - // Set the width of this column to saved value if exists and maps to a real column - if ([columnDefinition objectForKey:@"org_name"] && [[columnDefinition objectForKey:@"org_name"] length]) { - NSNumber *colWidth = [[[[prefs objectForKey:SPTableColumnWidths] objectForKey:[NSString stringWithFormat:@"%@@%@", [columnDefinition objectForKey:@"db"], [tableDocumentInstance host]]] objectForKey:[columnDefinition objectForKey:@"org_table"]] objectForKey:[columnDefinition objectForKey:@"org_name"]]; - if ( colWidth ) { - [theCol setWidth:[colWidth floatValue]]; - } - } - - [customQueryView addTableColumn:theCol]; - [theCol release]; - } - - [customQueryView sizeLastColumnToFit]; - //tries to fix problem with last row (otherwise to small) - //sets last column to width of the first if smaller than 30 - //problem not fixed for resizing window - if ( [[customQueryView tableColumnWithIdentifier:[NSNumber numberWithInt:[theColumns count]-1]] width] < 30 ) - [[customQueryView tableColumnWithIdentifier:[NSNumber numberWithInt:[theColumns count]-1]] - setWidth:[[customQueryView tableColumnWithIdentifier:[NSNumber numberWithInt:0]] width]]; - - } else { + if(tableReloadAfterEditing) { // scroll to last edited row after refreshing data // TODO: should be improved [customQueryView scrollRowToVisible:[customQueryView selectedRow]]; @@ -679,6 +726,15 @@ description:[NSString stringWithFormat:NSLocalizedString(@"%@",@"description for query finished growl notification"), [errorText stringValue]] window:tableWindow notificationName:@"Query Finished"]; + + // Set up the callback if present + if ([taskArguments objectForKey:@"callback"]) { + [[taskArguments objectForKey:@"callback"] getValue:&callbackMethod]; + [self performSelectorOnMainThread:callbackMethod withObject:nil waitUntilDone:NO]; + } + + [tableDocumentInstance endTask]; + [queryRunningPool release]; } /* @@ -688,9 +744,13 @@ { NSArray *tempRow; long rowsProcessed = 0; + NSUInteger nextTableDisplayBoundary = 50; NSAutoreleasePool *dataLoadingPool; + BOOL tableViewRedrawn = NO; // Remove all items from the table + fullResultCount = 0; + [customQueryView performSelectorOnMainThread:@selector(noteNumberOfRowsChanged) withObject:nil waitUntilDone:YES]; [fullResult removeAllObjects]; // Set up an autorelease pool for row processing @@ -700,16 +760,30 @@ while (tempRow = [theResult fetchNextRowAsArray]) { NSMutableArrayAddObject(fullResult, [NSMutableArray arrayWithArray:tempRow]); + fullResultCount++; // Update the count of rows processed rowsProcessed++; + // Update the table view with new results every now and then + if (rowsProcessed > nextTableDisplayBoundary) { + [customQueryView performSelectorOnMainThread:@selector(noteNumberOfRowsChanged) withObject:nil waitUntilDone:NO]; + if (!tableViewRedrawn) { + [customQueryView performSelectorOnMainThread:@selector(displayIfNeeded) withObject:nil waitUntilDone:NO]; + tableViewRedrawn = YES; + } + nextTableDisplayBoundary *= 2; + } + // Drain and reset the autorelease pool every ~1024 rows if (!(rowsProcessed % 1024)) { [dataLoadingPool drain]; dataLoadingPool = [[NSAutoreleasePool alloc] init]; } } + + [customQueryView performSelectorOnMainThread:@selector(noteNumberOfRowsChanged) withObject:nil waitUntilDone:NO]; + [customQueryView setNeedsDisplay:YES]; // Clean up the autorelease pool [dataLoadingPool drain]; @@ -1202,7 +1276,7 @@ if ( nil == fullResult ) { return 0; } else { - return [fullResult count]; + return fullResultCount; } } else { return 0; @@ -1214,8 +1288,8 @@ */ - (void)tableView:(CMCopyTable *)aTableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn*)aTableColumn row:(int)row { - if ( aTableView == customQueryView ) { + if (row > fullResultCount) return; // For NULL cell's display the user's NULL value placeholder in grey to easily distinguish it from other values if ([cell respondsToSelector:@selector(setTextColor:)]) { @@ -1233,6 +1307,7 @@ { if ( aTableView == customQueryView ) { + if (rowIndex > fullResultCount) return nil; id theValue = NSArrayObjectAtIndex(NSArrayObjectAtIndex(fullResult, rowIndex), [[aTableColumn identifier] intValue]); @@ -1339,7 +1414,7 @@ // On success reload table data by executing the last query tableReloadAfterEditing = YES; - [self performQueries:[NSArray arrayWithObject:lastExecutedQuery]]; + [self performQueries:[NSArray arrayWithObject:lastExecutedQuery] withCallback:NULL]; } else { NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, @@ -1439,17 +1514,25 @@ tableReloadAfterEditing = YES; queryIsTableSorter = YES; - [self performQueries:[NSArray arrayWithObject:queryString]]; + sortColumn = tableColumn; + [self performQueries:[NSArray arrayWithObject:queryString] withCallback:@selector(tableSortCallback)]; +} + +- (void) tableSortCallback +{ queryIsTableSorter = NO; - if(![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) return; + if(![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) { + sortColumn = nil; + return; + } //sets highlight and indicatorImage - [customQueryView setHighlightedTableColumn:tableColumn]; + [customQueryView setHighlightedTableColumn:sortColumn]; if ( isDesc ) - [customQueryView setIndicatorImage:[NSImage imageNamed:@"NSDescendingSortIndicator"] inTableColumn:tableColumn]; + [customQueryView setIndicatorImage:[NSImage imageNamed:@"NSDescendingSortIndicator"] inTableColumn:sortColumn]; else - [customQueryView setIndicatorImage:[NSImage imageNamed:@"NSAscendingSortIndicator"] inTableColumn:tableColumn]; + [customQueryView setIndicatorImage:[NSImage imageNamed:@"NSAscendingSortIndicator"] inTableColumn:sortColumn]; } @@ -1804,6 +1887,7 @@ // If no text is selected, disable the button and action menu. if ( caretPosition == NSNotFound ) { + selectionButtonCanBeEnabled = NO; [runSelectionButton setEnabled:NO]; [runSelectionMenuItem setEnabled:NO]; return; @@ -1821,9 +1905,13 @@ [runSelectionButton setTitle:NSLocalizedString(@"Run Previous", @"Title of button to run query just before text caret in custom query view")]; [runSelectionMenuItem setTitle:NSLocalizedString(@"Run Previous Query", @"Title of action menu item to run query just before text caret in custom query view")]; } - [runSelectionButton setEnabled:YES]; - [runSelectionMenuItem setEnabled:YES]; + selectionButtonCanBeEnabled = YES; + if (![tableDocumentInstance isWorking]) { + [runSelectionButton setEnabled:YES]; + [runSelectionMenuItem setEnabled:YES]; + } } else { + selectionButtonCanBeEnabled = NO; [runSelectionButton setEnabled:NO]; [runSelectionMenuItem setEnabled:NO]; } @@ -1831,11 +1919,14 @@ // For selection ranges, enable the button. } else { + selectionButtonCanBeEnabled = YES; [runSelectionButton setTitle:NSLocalizedString(@"Run Selection", @"Title of button to run selected text in custom query view")]; - [runSelectionButton setEnabled:YES]; [runSelectionMenuItem setTitle:NSLocalizedString(@"Run Selected Text", @"Title of action menu item to run selected text in custom query view")]; - [runSelectionMenuItem setEnabled:YES]; [commentLineOrSelectionMenuItem setTitle:NSLocalizedString(@"Comment Selection", @"Title of action menu item to comment selection")]; + if (![tableDocumentInstance isWorking]) { + [runSelectionButton setEnabled:YES]; + [runSelectionMenuItem setEnabled:YES]; + } } } @@ -2439,6 +2530,44 @@ } #pragma mark - +#pragma mark Task interaction + +/** + * Disable all content interactive elements during an ongoing task. + */ +- (void) startDocumentTaskForTab:(NSNotification *)aNotification +{ + + // Only disable elements if the current tab is the content view + if (![[aNotification object] isEqualToString:@"SwitchToRunQueryToolbarItemIdentifier"]) return; + + [customQueryView setEnabled:NO]; + [runSelectionButton setEnabled:NO]; + [runSelectionMenuItem setEnabled:NO]; + [runAllButton setEnabled:NO]; + [runAllMenuItem setEnabled:NO]; +} + +/** + * Enable all content interactive elements after an ongoing task. + */ +- (void) endDocumentTaskForTab:(NSNotification *)aNotification +{ + + // Only enable elements if the current tab is the content view + if (![[aNotification object] isEqualToString:@"SwitchToRunQueryToolbarItemIdentifier"]) return; + + if (selectionButtonCanBeEnabled) { + [runSelectionButton setEnabled:YES]; + [runSelectionMenuItem setEnabled:YES]; + } + [runAllButton setEnabled:YES]; + [runAllMenuItem setEnabled:YES]; + [customQueryView setEnabled:YES]; + [customQueryView displayIfNeeded]; +} + +#pragma mark - #pragma mark Other /** @@ -2552,6 +2681,9 @@ sortField = nil; isDesc = NO; + sortColumn = nil; + selectionButtonCanBeEnabled = NO; + cqColumnDefinition = nil; // init helpHTMLTemplate NSError *error; @@ -2572,6 +2704,7 @@ [[helpWebView backForwardList] setCapacity:20]; // init tableView's data source + fullResultCount = 0; fullResult = [[NSMutableArray alloc] init]; prefs = [NSUserDefaults standardUserDefaults]; @@ -2610,16 +2743,29 @@ // Set the structure and index view's vertical gridlines if required [customQueryView setGridStyleMask:([prefs boolForKey:SPDisplayTableViewVerticalGridlines]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; + + // Add observers for document task activity + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(startDocumentTaskForTab:) + name:SPDocumentTaskStartNotification + object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(endDocumentTaskForTab:) + name:SPDocumentTaskEndNotification + object:nil]; } - (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; + [usedQuery release]; [fullResult release]; [favoritesManager release]; if (helpHTMLTemplate) [helpHTMLTemplate release]; if (mySQLversion) [mySQLversion release]; if (sortField) [sortField release]; + if (cqColumnDefinition) [cqColumnDefinition release]; [super dealloc]; } diff --git a/Source/TableContent.m b/Source/TableContent.m index d038dfef..4286723a 100644 --- a/Source/TableContent.m +++ b/Source/TableContent.m @@ -1418,15 +1418,16 @@ } else if (rowsProcessed == targetRowCount) { [tableDocumentInstance performSelectorOnMainThread:@selector(setTaskProgressToIndeterminate) withObject:nil waitUntilDone:NO]; } - - if (rowsProcessed > nextTableDisplayBoundary) { - [tableContentView performSelectorOnMainThread:@selector(noteNumberOfRowsChanged) withObject:nil waitUntilDone:NO]; - if (!tableViewRedrawn) { - [tableContentView performSelectorOnMainThread:@selector(displayIfNeeded) withObject:nil waitUntilDone:NO]; - tableViewRedrawn = YES; - } - nextTableDisplayBoundary *= 2; + } + + // Update the table view with new results every now and then + if (rowsProcessed > nextTableDisplayBoundary) { + [tableContentView performSelectorOnMainThread:@selector(noteNumberOfRowsChanged) withObject:nil waitUntilDone:NO]; + if (!tableViewRedrawn) { + [tableContentView performSelectorOnMainThread:@selector(displayIfNeeded) withObject:nil waitUntilDone:NO]; + tableViewRedrawn = YES; } + nextTableDisplayBoundary *= 2; } // Drain and reset the autorelease pool every ~1024 rows |