diff options
-rw-r--r-- | Interfaces/English.lproj/DBView.xib | 223 | ||||
-rw-r--r-- | Resources/English.lproj/DBView.strings | bin | 100836 -> 99710 bytes | |||
-rw-r--r-- | Resources/English.lproj/FieldEditorSheet.strings | bin | 11500 -> 11502 bytes | |||
-rw-r--r-- | Resources/English.lproj/Localizable.strings | bin | 183032 -> 183004 bytes | |||
-rw-r--r-- | Resources/English.lproj/MainMenu.strings | bin | 41002 -> 42638 bytes | |||
-rw-r--r-- | Source/SPConnectionController.m | 2 | ||||
-rw-r--r-- | Source/SPDataImport.m | 6 | ||||
-rw-r--r-- | Source/SPDatabaseDocument.h | 18 | ||||
-rw-r--r-- | Source/SPDatabaseDocument.m | 157 | ||||
-rw-r--r-- | Source/SPDatabaseViewController.h | 53 | ||||
-rw-r--r-- | Source/SPDatabaseViewController.m | 485 | ||||
-rw-r--r-- | Source/SPExtendedTableInfo.m | 2 | ||||
-rw-r--r-- | Source/SPHistoryController.m | 2 | ||||
-rw-r--r-- | Source/SPIndexesController.m | 4 | ||||
-rw-r--r-- | Source/SPTableContent.m | 8 | ||||
-rw-r--r-- | Source/SPTableStructure.m | 14 | ||||
-rw-r--r-- | Source/SPTableStructureDelegate.m | 4 | ||||
-rw-r--r-- | Source/SPTablesList.h | 11 | ||||
-rw-r--r-- | Source/SPTablesList.m | 343 | ||||
-rw-r--r-- | Source/SPWindowController.m | 2 | ||||
-rw-r--r-- | sequel-pro.xcodeproj/project.pbxproj | 7 |
21 files changed, 739 insertions, 602 deletions
diff --git a/Interfaces/English.lproj/DBView.xib b/Interfaces/English.lproj/DBView.xib index 3a32ac16..e8ba4357 100644 --- a/Interfaces/English.lproj/DBView.xib +++ b/Interfaces/English.lproj/DBView.xib @@ -23,12 +23,13 @@ </object> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> + <integer value="676"/> </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"> <string key="NS.key.0">PluginDependencyRecalculationVersion</string> @@ -46,7 +47,7 @@ <string key="NSClassName">NSApplication</string> </object> <object class="NSCustomView" id="632807581"> - <nil key="NSNextResponder"/> + <reference key="NSNextResponder"/> <int key="NSvFlags">274</int> <object class="NSMutableArray" key="NSSubviews"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -221,7 +222,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"/> @@ -266,6 +267,7 @@ </object> <string key="NSFrame">{{1, 1}, {218, 38}}</string> <reference key="NSSuperview" ref="607475905"/> + <reference key="NSNextKeyView" ref="970881282"/> <reference key="NSDocView" ref="970881282"/> <object class="NSColor" key="NSBGColor" id="1024678221"> <int key="NSColorSpace">6</int> @@ -297,6 +299,7 @@ </object> <string key="NSFrame">{{-1, -13}, {220, 40}}</string> <reference key="NSSuperview" ref="801427893"/> + <reference key="NSNextKeyView" ref="494991824"/> <int key="NSsFlags">2</int> <reference key="NSVScroller" ref="196112633"/> <reference key="NSHScroller" ref="142487484"/> @@ -394,6 +397,7 @@ </object> <string key="NSFrameSize">{214, 354}</string> <reference key="NSSuperview" ref="233472824"/> + <reference key="NSNextKeyView" ref="251040077"/> <reference key="NSDocView" ref="251040077"/> <reference key="NSBGColor" ref="1024678221"/> <int key="NScvFlags">4</int> @@ -421,6 +425,7 @@ </object> <string key="NSFrameSize">{214, 354}</string> <reference key="NSSuperview" ref="1017775084"/> + <reference key="NSNextKeyView" ref="73685676"/> <int key="NSsFlags">528</int> <reference key="NSVScroller" ref="693168867"/> <reference key="NSHScroller" ref="656188692"/> @@ -556,6 +561,7 @@ </object> <string key="NSFrameSize">{214, 145}</string> <reference key="NSSuperview" ref="298226231"/> + <reference key="NSNextKeyView" ref="347093764"/> <reference key="NSDocView" ref="347093764"/> <reference key="NSBGColor" ref="1024678221"/> <int key="NScvFlags">6</int> @@ -583,6 +589,7 @@ </object> <string key="NSFrameSize">{214, 145}</string> <reference key="NSSuperview" ref="192579410"/> + <reference key="NSNextKeyView" ref="685057119"/> <int key="NSsFlags">512</int> <reference key="NSVScroller" ref="245346414"/> <reference key="NSHScroller" ref="353686052"/> @@ -1659,6 +1666,7 @@ </object> <string key="NSFrame">{{1, 17}, {694, 289}}</string> <reference key="NSSuperview" ref="22340145"/> + <reference key="NSNextKeyView" ref="715508012"/> <reference key="NSDocView" ref="715508012"/> <reference key="NSBGColor" ref="1024678221"/> <int key="NScvFlags">4</int> @@ -1692,6 +1700,7 @@ </object> <string key="NSFrame">{{1, 0}, {694, 17}}</string> <reference key="NSSuperview" ref="22340145"/> + <reference key="NSNextKeyView" ref="926883367"/> <reference key="NSDocView" ref="926883367"/> <reference key="NSBGColor" ref="1024678221"/> <int key="NScvFlags">4</int> @@ -1700,6 +1709,7 @@ </object> <string key="NSFrame">{{-1, 22}, {696, 307}}</string> <reference key="NSSuperview" ref="220777809"/> + <reference key="NSNextKeyView" ref="16936123"/> <int key="NSsFlags">562</int> <reference key="NSVScroller" ref="943144555"/> <reference key="NSHScroller" ref="456666876"/> @@ -2246,6 +2256,7 @@ </object> <string key="NSFrame">{{1, 17}, {694, 140}}</string> <reference key="NSSuperview" ref="376224367"/> + <reference key="NSNextKeyView" ref="584834515"/> <reference key="NSDocView" ref="584834515"/> <reference key="NSBGColor" ref="1024678221"/> <int key="NScvFlags">4</int> @@ -2278,6 +2289,7 @@ </object> <string key="NSFrame">{{1, 0}, {694, 17}}</string> <reference key="NSSuperview" ref="376224367"/> + <reference key="NSNextKeyView" ref="459548655"/> <reference key="NSDocView" ref="459548655"/> <reference key="NSBGColor" ref="1024678221"/> <int key="NScvFlags">4</int> @@ -2286,6 +2298,7 @@ </object> <string key="NSFrame">{{-1, 23}, {696, 158}}</string> <reference key="NSSuperview" ref="1063281455"/> + <reference key="NSNextKeyView" ref="794929378"/> <int key="NSsFlags">562</int> <reference key="NSVScroller" ref="1019209947"/> <reference key="NSHScroller" ref="328951385"/> @@ -6170,6 +6183,7 @@ </object> </object> <string key="NSFrameSize">{943, 549}</string> + <reference key="NSSuperview"/> <string key="NSClassName">NSView</string> </object> <object class="NSWindowTemplate" id="554105051"> @@ -6892,10 +6906,10 @@ <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"> - <reference key="NSNextResponder"/> + <nil key="NSNextResponder"/> <int key="NSvFlags">256</int> <object class="NSMutableArray" key="NSSubviews"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -6904,7 +6918,6 @@ <int key="NSvFlags">256</int> <string key="NSFrame">{{17, 74}, {272, 28}}</string> <reference key="NSSuperview" ref="234287744"/> - <reference key="NSWindow"/> <bool key="NSEnabled">YES</bool> <object class="NSTextFieldCell" key="NSCell" id="420541191"> <int key="NSCellFlags">67239424</int> @@ -6922,7 +6935,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <int key="NSvFlags">256</int> <string key="NSFrame">{{74, 45}, {162, 22}}</string> <reference key="NSSuperview" ref="234287744"/> - <reference key="NSWindow"/> <bool key="NSEnabled">YES</bool> <object class="NSPopUpButtonCell" key="NSCell" id="1007861376"> <int key="NSCellFlags">-2076049856</int> @@ -7004,7 +7016,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <int key="NSvFlags">256</int> <string key="NSFrame">{{154, 17}, {84, 28}}</string> <reference key="NSSuperview" ref="234287744"/> - <reference key="NSWindow"/> <int key="NSTag">1</int> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="827163428"> @@ -7028,7 +7039,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <int key="NSvFlags">256</int> <string key="NSFrame">{{72, 17}, {84, 28}}</string> <reference key="NSSuperview" ref="234287744"/> - <reference key="NSWindow"/> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="125727271"> <int key="NSCellFlags">67239424</int> @@ -7047,12 +7057,10 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> </object> </object> <string key="NSFrameSize">{306, 122}</string> - <reference key="NSSuperview"/> - <reference key="NSWindow"/> </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="423199625"> <int key="NSWindowStyleMask">7</int> @@ -7062,7 +7070,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <string key="NSWindowTitle">Reset Auto Increment</string> <string key="NSWindowClass">NSWindow</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">{255, 95}</string> <object class="NSView" key="NSWindowView" id="748618982"> <nil key="NSNextResponder"/> @@ -7225,7 +7233,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> </object> <string key="NSScreenRect">{{0, 0}, {1280, 1002}}</string> <string key="NSMinSize">{255, 117}</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> @@ -7235,7 +7243,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> @@ -7836,7 +7844,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="437271354"> <int key="NSWindowStyleMask">9</int> @@ -7846,7 +7854,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <string key="NSWindowTitle">New Trigger</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">{360, 348}</string> <object class="NSView" key="NSWindowView" id="729080358"> <nil key="NSNextResponder"/> @@ -8253,7 +8261,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> </object> <string key="NSScreenRect">{{0, 0}, {1680, 1028}}</string> <string key="NSMinSize">{360, 370}</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> @@ -8265,7 +8273,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"/> @@ -8385,7 +8393,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> @@ -8397,7 +8405,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"/> @@ -8532,7 +8540,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="828950706"> <int key="NSWindowStyleMask">15</int> @@ -8544,7 +8552,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"/> @@ -8767,7 +8775,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> <string key="NSFrameAutosaveName">SPCreateSyntaxSheet</string> </object> <object class="NSWindowTemplate" id="466147946"> @@ -8780,7 +8788,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"/> @@ -8950,7 +8958,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> @@ -8960,7 +8968,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"/> @@ -9358,7 +9366,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="633448481"> @@ -9369,7 +9377,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <string key="NSWindowTitle">Filter</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">{380, 170}</string> <object class="NSView" key="NSWindowView" id="257361103"> <nil key="NSNextResponder"/> @@ -10014,7 +10022,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> </object> <string key="NSScreenRect">{{0, 0}, {1280, 778}}</string> <string key="NSMinSize">{380, 192}</string> - <string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string> + <string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string> <string key="NSFrameAutosaveName">SPTableFilterPanel</string> </object> <object class="NSWindowTemplate" id="923391973"> @@ -10514,7 +10522,7 @@ bGQgTmFtZQkgID0gQAoJCQkJICBMRU5HVEgoYEBgKSA+IEA</bytes> <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> @@ -10618,7 +10626,7 @@ bGQgTmFtZQkgID0gQAoJCQkJICBMRU5HVEgoYEBgKSA+IEA</bytes> <string key="NSFrameSize">{338, 150}</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="884983195"> <nil key="NSNextResponder"/> @@ -10801,7 +10809,7 @@ bGQgTmFtZQkgID0gQAoJCQkJICBMRU5HVEgoYEBgKSA+IEA</bytes> <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> @@ -11790,22 +11798,6 @@ bGQgTmFtZQkgID0gQAoJCQkJICBMRU5HVEgoYEBgKSA+IEA</bytes> </object> <object class="IBConnectionRecord"> <object class="IBOutletConnection" key="connection"> - <string key="label">tabView</string> - <reference key="source" ref="438574515"/> - <reference key="destination" ref="714795046"/> - </object> - <int key="connectionID">600</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBOutletConnection" key="connection"> - <string key="label">delegate</string> - <reference key="source" ref="714795046"/> - <reference key="destination" ref="438574515"/> - </object> - <int key="connectionID">601</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBOutletConnection" key="connection"> <string key="label">tableDumpInstance</string> <reference key="source" ref="438574515"/> <reference key="destination" ref="225526897"/> @@ -16157,6 +16149,14 @@ bGQgTmFtZQkgID0gQAoJCQkJICBMRU5HVEgoYEBgKSA+IEA</bytes> </object> <int key="connectionID">7672</int> </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">delegate</string> + <reference key="source" ref="714795046"/> + <reference key="destination" ref="427689665"/> + </object> + <int key="connectionID">7673</int> + </object> </object> <object class="IBMutableOrderedSet" key="objectRecords"> <object class="NSArray" key="orderedObjects"> @@ -25803,7 +25803,7 @@ bGQgTmFtZQkgID0gQAoJCQkJICBMRU5HVEgoYEBgKSA+IEA</bytes> </object> </object> <nil key="sourceID"/> - <int key="maxID">7672</int> + <int key="maxID">7673</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> @@ -27087,12 +27087,6 @@ bGQgTmFtZQkgID0gQAoJCQkJICBMRU5HVEgoYEBgKSA+IEA</bytes> <string>toggleNavigator:</string> <string>updateWindowTitle:</string> <string>validateSaveConnectionAccessory:</string> - <string>viewContent:</string> - <string>viewQuery:</string> - <string>viewRelations:</string> - <string>viewStatus:</string> - <string>viewStructure:</string> - <string>viewTriggers:</string> </object> <object class="NSMutableArray" key="dict.values"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -27139,12 +27133,6 @@ bGQgTmFtZQkgID0gQAoJCQkJICBMRU5HVEgoYEBgKSA+IEA</bytes> <string>id</string> <string>id</string> <string>id</string> - <string>id</string> - <string>id</string> - <string>id</string> - <string>id</string> - <string>id</string> - <string>id</string> </object> </object> <object class="NSMutableDictionary" key="actionInfosByName"> @@ -27194,12 +27182,6 @@ bGQgTmFtZQkgID0gQAoJCQkJICBMRU5HVEgoYEBgKSA+IEA</bytes> <string>toggleNavigator:</string> <string>updateWindowTitle:</string> <string>validateSaveConnectionAccessory:</string> - <string>viewContent:</string> - <string>viewQuery:</string> - <string>viewRelations:</string> - <string>viewStatus:</string> - <string>viewStructure:</string> - <string>viewTriggers:</string> </object> <object class="NSMutableArray" key="dict.values"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -27375,30 +27357,6 @@ bGQgTmFtZQkgID0gQAoJCQkJICBMRU5HVEgoYEBgKSA+IEA</bytes> <string key="name">validateSaveConnectionAccessory:</string> <string key="candidateClassName">id</string> </object> - <object class="IBActionInfo"> - <string key="name">viewContent:</string> - <string key="candidateClassName">id</string> - </object> - <object class="IBActionInfo"> - <string key="name">viewQuery:</string> - <string key="candidateClassName">id</string> - </object> - <object class="IBActionInfo"> - <string key="name">viewRelations:</string> - <string key="candidateClassName">id</string> - </object> - <object class="IBActionInfo"> - <string key="name">viewStatus:</string> - <string key="candidateClassName">id</string> - </object> - <object class="IBActionInfo"> - <string key="name">viewStructure:</string> - <string key="candidateClassName">id</string> - </object> - <object class="IBActionInfo"> - <string key="name">viewTriggers:</string> - <string key="candidateClassName">id</string> - </object> </object> </object> <object class="NSMutableDictionary" key="outlets"> @@ -27902,6 +27860,73 @@ bGQgTmFtZQkgID0gQAoJCQkJICBMRU5HVEgoYEBgKSA+IEA</bytes> </object> <object class="IBPartialClassDescription"> <string key="className">SPDatabaseDocument</string> + <object class="NSMutableDictionary" key="actions"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>viewContent:</string> + <string>viewQuery:</string> + <string>viewRelations:</string> + <string>viewStatus:</string> + <string>viewStructure:</string> + <string>viewTriggers:</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + </object> + </object> + <object class="NSMutableDictionary" key="actionInfosByName"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>viewContent:</string> + <string>viewQuery:</string> + <string>viewRelations:</string> + <string>viewStatus:</string> + <string>viewStructure:</string> + <string>viewTriggers:</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBActionInfo"> + <string key="name">viewContent:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">viewQuery:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">viewRelations:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">viewStatus:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">viewStructure:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">viewTriggers:</string> + <string key="candidateClassName">id</string> + </object> + </object> + </object> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">Source/SPDatabaseViewController.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">SPDatabaseDocument</string> <object class="IBClassDescriptionSource" key="sourceIdentifier"> <string key="majorKey">IBProjectSource</string> <string key="minorKey">Source/SPPrintController.h</string> @@ -30254,7 +30279,6 @@ bGQgTmFtZQkgID0gQAoJCQkJICBMRU5HVEgoYEBgKSA+IEA</bytes> <object class="NSArray" key="dict.sortedKeys"> <bool key="EncodedWithXMLCoder">YES</bool> <string>addField:</string> - <string>closeKeySheet:</string> <string>closeSheet:</string> <string>copyField:</string> <string>reloadTable:</string> @@ -30275,7 +30299,6 @@ bGQgTmFtZQkgID0gQAoJCQkJICBMRU5HVEgoYEBgKSA+IEA</bytes> <string>id</string> <string>id</string> <string>id</string> - <string>id</string> </object> </object> <object class="NSMutableDictionary" key="actionInfosByName"> @@ -30283,7 +30306,6 @@ bGQgTmFtZQkgID0gQAoJCQkJICBMRU5HVEgoYEBgKSA+IEA</bytes> <object class="NSArray" key="dict.sortedKeys"> <bool key="EncodedWithXMLCoder">YES</bool> <string>addField:</string> - <string>closeKeySheet:</string> <string>closeSheet:</string> <string>copyField:</string> <string>reloadTable:</string> @@ -30300,10 +30322,6 @@ bGQgTmFtZQkgID0gQAoJCQkJICBMRU5HVEgoYEBgKSA+IEA</bytes> <string key="candidateClassName">id</string> </object> <object class="IBActionInfo"> - <string key="name">closeKeySheet:</string> - <string key="candidateClassName">id</string> - </object> - <object class="IBActionInfo"> <string key="name">closeSheet:</string> <string key="candidateClassName">id</string> </object> @@ -30889,7 +30907,6 @@ bGQgTmFtZQkgID0gQAoJCQkJICBMRU5HVEgoYEBgKSA+IEA</bytes> <string>showCreateSyntaxContextMenuItem</string> <string>showCreateSyntaxMenuItem</string> <string>spHistoryControllerInstance</string> - <string>tabView</string> <string>tableContentInstance</string> <string>tableDataInstance</string> <string>tableDocumentInstance</string> @@ -30941,7 +30958,6 @@ bGQgTmFtZQkgID0gQAoJCQkJICBMRU5HVEgoYEBgKSA+IEA</bytes> <string>id</string> <string>id</string> <string>id</string> - <string>id</string> <string>NSButton</string> <string>id</string> <string>NSSplitView</string> @@ -30986,7 +31002,6 @@ bGQgTmFtZQkgID0gQAoJCQkJICBMRU5HVEgoYEBgKSA+IEA</bytes> <string>showCreateSyntaxContextMenuItem</string> <string>showCreateSyntaxMenuItem</string> <string>spHistoryControllerInstance</string> - <string>tabView</string> <string>tableContentInstance</string> <string>tableDataInstance</string> <string>tableDocumentInstance</string> @@ -31103,10 +31118,6 @@ bGQgTmFtZQkgID0gQAoJCQkJICBMRU5HVEgoYEBgKSA+IEA</bytes> <string key="candidateClassName">SPHistoryController</string> </object> <object class="IBToOneOutletInfo"> - <string key="name">tabView</string> - <string key="candidateClassName">id</string> - </object> - <object class="IBToOneOutletInfo"> <string key="name">tableContentInstance</string> <string key="candidateClassName">id</string> </object> diff --git a/Resources/English.lproj/DBView.strings b/Resources/English.lproj/DBView.strings Binary files differindex 3573001b..440d66bb 100644 --- a/Resources/English.lproj/DBView.strings +++ b/Resources/English.lproj/DBView.strings diff --git a/Resources/English.lproj/FieldEditorSheet.strings b/Resources/English.lproj/FieldEditorSheet.strings Binary files differindex 84f66d66..f6f508dd 100644 --- a/Resources/English.lproj/FieldEditorSheet.strings +++ b/Resources/English.lproj/FieldEditorSheet.strings diff --git a/Resources/English.lproj/Localizable.strings b/Resources/English.lproj/Localizable.strings Binary files differindex ac4a1524..5a482a5d 100644 --- a/Resources/English.lproj/Localizable.strings +++ b/Resources/English.lproj/Localizable.strings diff --git a/Resources/English.lproj/MainMenu.strings b/Resources/English.lproj/MainMenu.strings Binary files differindex ff2e820a..e2be88de 100644 --- a/Resources/English.lproj/MainMenu.strings +++ b/Resources/English.lproj/MainMenu.strings diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m index 241a6e1d..1128b822 100644 --- a/Source/SPConnectionController.m +++ b/Source/SPConnectionController.m @@ -84,7 +84,7 @@ { if (self = [super init]) { tableDocument = theTableDocument; - databaseConnectionSuperview = [tableDocument parentView]; + databaseConnectionSuperview = [tableDocument databaseView]; databaseConnectionView = [tableDocument valueForKey:@"contentViewSplitter"]; connectionKeychainItemName = nil; connectionKeychainItemAccount = nil; diff --git a/Source/SPDataImport.m b/Source/SPDataImport.m index f7f3eb4c..dff20466 100644 --- a/Source/SPDataImport.m +++ b/Source/SPDataImport.m @@ -1120,11 +1120,7 @@ // If import was done into a new table or the table selected for import is also selected in the content view, // update the content view - on the main thread to avoid crashes. if ([tablesListInstance tableName] && [selectedTableTarget isEqualToString:[tablesListInstance tableName]]) { - if ([[tableDocumentInstance selectedToolbarItemIdentifier] isEqualToString:SPMainToolbarTableContent]) { - [tableContentInstance performSelectorOnMainThread:@selector(reloadTable:) withObject:nil waitUntilDone:YES]; - } else { - [tablesListInstance setContentRequiresReload:YES]; - } + [tableDocumentInstance setContentRequiresReload:YES]; } } diff --git a/Source/SPDatabaseDocument.h b/Source/SPDatabaseDocument.h index f01abe63..35681506 100644 --- a/Source/SPDatabaseDocument.h +++ b/Source/SPDatabaseDocument.h @@ -139,6 +139,16 @@ MCPConnection *mySQLConnection; + NSInteger currentTabIndex; + + NSString *selectedTableName; + NSInteger selectedTableType; + + BOOL structureLoaded; + BOOL contentLoaded; + BOOL statusLoaded; + BOOL triggersLoaded; + NSString *selectedDatabase; NSString *mySQLVersion; NSUserDefaults *prefs; @@ -292,11 +302,9 @@ - (IBAction)toggleNavigator:(id)sender; // Accessor methods -- (NSView *)parentView; - (NSString *)host; - (NSString *)name; - (NSString *)database; -- (NSString *)table; - (NSString *)port; - (NSString *)mySQLVersion; - (NSString *)user; @@ -315,12 +323,6 @@ - (IBAction)saveConnectionSheet:(id)sender; - (IBAction)import:(id)sender; - (IBAction)importFromClipboard:(id)sender; -- (IBAction)viewStructure:(id)sender; -- (IBAction)viewContent:(id)sender; -- (IBAction)viewQuery:(id)sender; -- (IBAction)viewStatus:(id)sender; -- (IBAction)viewRelations:(id)sender; -- (IBAction)viewTriggers:(id)sender; - (IBAction)addConnectionToFavorites:(id)sender; - (BOOL)isCustomQuerySelected; diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m index beb8ab5a..75a16e73 100644 --- a/Source/SPDatabaseDocument.m +++ b/Source/SPDatabaseDocument.m @@ -87,6 +87,15 @@ chooseDatabaseButton = nil; chooseDatabaseToolbarItem = nil; connectionController = nil; + + selectedTableName = nil; + selectedTableType = SPTableTypeNone; + + structureLoaded = NO; + contentLoaded = NO; + statusLoaded = NO; + triggersLoaded = NO; + selectedDatabase = nil; mySQLConnection = nil; mySQLVersion = nil; @@ -1218,12 +1227,12 @@ if (selectedDatabase) [selectedDatabase release], selectedDatabase = nil; selectedDatabase = [[NSString alloc] initWithString:dbName]; [chooseDatabaseButton selectItemWithTitle:selectedDatabase]; - [self updateWindowTitle:self]; + [[self onMainThread] updateWindowTitle:self]; } } else { if (selectedDatabase) [selectedDatabase release], selectedDatabase = nil; [chooseDatabaseButton selectItemAtIndex:0]; - [self updateWindowTitle:self]; + [[self onMainThread] updateWindowTitle:self]; } } @@ -1634,19 +1643,19 @@ // Update the selected menu item if (useLatin1Transport) { - [self updateEncodingMenuWithSelectedEncoding:[self encodingTagFromMySQLEncoding:[NSString stringWithFormat:@"%@-", mysqlEncoding]]]; + [[self onMainThread] updateEncodingMenuWithSelectedEncoding:[self encodingTagFromMySQLEncoding:[NSString stringWithFormat:@"%@-", mysqlEncoding]]]; } else { - [self updateEncodingMenuWithSelectedEncoding:[self encodingTagFromMySQLEncoding:mysqlEncoding]]; + [[self onMainThread] updateEncodingMenuWithSelectedEncoding:[self encodingTagFromMySQLEncoding:mysqlEncoding]]; } // Update the stored connection encoding to prevent switches [mySQLConnection storeEncodingForRestoration]; - // Reload stuff as appropriate + // Reload views as appropriate if (reloadViews) { - if ([tablesListInstance structureLoaded]) [tableSourceInstance reloadTable:self]; - if ([tablesListInstance contentLoaded]) [tableContentInstance reloadTable:self]; - if ([tablesListInstance statusLoaded]) [extendedTableInfoInstance reloadTable:self]; + [self setStructureRequiresReload:YES]; + [self setContentRequiresReload:YES]; + [self setStatusRequiresReload:YES]; } } @@ -2617,16 +2626,6 @@ #pragma mark - #pragma mark Accessor methods - -/** - * Returns the parent view, which in its turn contains the database view for this - * connection. - */ -- (NSView *)parentView -{ - return parentView; -} - /** * Returns the host */ @@ -2734,14 +2733,6 @@ } /** - * Returns the currently selected table (passing the request to SPTablesList) - */ -- (NSString *)table -{ - return [tablesListInstance tableName]; -} - -/** * Returns the MySQL version */ - (NSString *)mySQLVersion @@ -3711,113 +3702,6 @@ return YES; } -- (IBAction)viewStructure:(id)sender -{ - // Cancel the selection if currently editing a view and unable to save - if (![self couldCommitCurrentViewActions]) { - [mainToolbar setSelectedItemIdentifier:*SPViewModeToMainToolbarMap[[prefs integerForKey:SPLastViewMode]]]; - return; - } - - [tableTabView selectTabViewItemAtIndex:0]; - [mainToolbar setSelectedItemIdentifier:SPMainToolbarTableStructure]; - [spHistoryControllerInstance updateHistoryEntries]; - - [prefs setInteger:SPStructureViewMode forKey:SPLastViewMode]; -} - -- (IBAction)viewContent:(id)sender -{ - - // Cancel the selection if currently editing a view and unable to save - if (![self couldCommitCurrentViewActions]) { - [mainToolbar setSelectedItemIdentifier:*SPViewModeToMainToolbarMap[[prefs integerForKey:SPLastViewMode]]]; - return; - } - - [tableTabView selectTabViewItemAtIndex:1]; - [mainToolbar setSelectedItemIdentifier:SPMainToolbarTableContent]; - [spHistoryControllerInstance updateHistoryEntries]; - - [prefs setInteger:SPContentViewMode forKey:SPLastViewMode]; -} - -- (IBAction)viewQuery:(id)sender -{ - - // Cancel the selection if currently editing a view and unable to save - if (![self couldCommitCurrentViewActions]) { - [mainToolbar setSelectedItemIdentifier:*SPViewModeToMainToolbarMap[[prefs integerForKey:SPLastViewMode]]]; - return; - } - - [tableTabView selectTabViewItemAtIndex:2]; - [mainToolbar setSelectedItemIdentifier:SPMainToolbarCustomQuery]; - [spHistoryControllerInstance updateHistoryEntries]; - - // Set the focus on the text field - [parentWindow makeFirstResponder:customQueryTextView]; - - [prefs setInteger:SPQueryEditorViewMode forKey:SPLastViewMode]; -} - -- (IBAction)viewStatus:(id)sender -{ - - // Cancel the selection if currently editing a view and unable to save - if (![self couldCommitCurrentViewActions]) { - [mainToolbar setSelectedItemIdentifier:*SPViewModeToMainToolbarMap[[prefs integerForKey:SPLastViewMode]]]; - return; - } - - [tableTabView selectTabViewItemAtIndex:3]; - [mainToolbar setSelectedItemIdentifier:SPMainToolbarTableInfo]; - [spHistoryControllerInstance updateHistoryEntries]; - - // Refresh data - if([self table] && [[self table] length]) { - [tableDataInstance resetAllData]; - [extendedTableInfoInstance loadTable:[self table]]; - } - - [parentWindow makeFirstResponder:[extendedTableInfoInstance valueForKeyPath:@"tableCreateSyntaxTextView"]]; - - [prefs setInteger:SPTableInfoViewMode forKey:SPLastViewMode]; -} - -- (IBAction)viewRelations:(id)sender -{ - - // Cancel the selection if currently editing a view and unable to save - if (![self couldCommitCurrentViewActions]) { - [mainToolbar setSelectedItemIdentifier:*SPViewModeToMainToolbarMap[[prefs integerForKey:SPLastViewMode]]]; - return; - } - - [tableTabView selectTabViewItemAtIndex:4]; - [mainToolbar setSelectedItemIdentifier:SPMainToolbarTableRelations]; - [spHistoryControllerInstance updateHistoryEntries]; - - [prefs setInteger:SPRelationsViewMode forKey:SPLastViewMode]; -} - -- (IBAction)viewTriggers:(id)sender -{ - - // Cancel the selection if currently editing a view and unable to save - if (![self couldCommitCurrentViewActions]) { - [mainToolbar setSelectedItemIdentifier:*SPViewModeToMainToolbarMap[[prefs integerForKey:SPLastViewMode]]]; - return; - } - - [tableTabView selectTabViewItemAtIndex:5]; - [mainToolbar setSelectedItemIdentifier:SPMainToolbarTableTriggers]; - [spHistoryControllerInstance updateHistoryEntries]; - - [prefs setInteger:SPTriggersViewMode forKey:SPLastViewMode]; -} - - /** * Adds the current database connection details to the user's favorites if it doesn't already exist. */ @@ -4491,7 +4375,7 @@ - (void)connectionControllerConnectAttemptFailed:(id)controller { // Reset the window title - [self updateWindowTitle:self]; + [[self onMainThread] updateWindowTitle:self]; } #pragma mark - @@ -4721,6 +4605,7 @@ [printWebView release]; [taskProgressWindow close]; + if (selectedTableName) [selectedTableName release]; if (connectionController) [connectionController release]; if (processListController) [processListController release]; if (serverVariablesController) [serverVariablesController release]; @@ -4854,7 +4739,7 @@ [tablesListInstance setConnection:mySQLConnection]; [tableDumpInstance setConnection:mySQLConnection]; - [self updateWindowTitle:self]; + [[self onMainThread] updateWindowTitle:self]; } /** @@ -4893,7 +4778,7 @@ [tablesListInstance setConnection:mySQLConnection]; [tableDumpInstance setConnection:mySQLConnection]; - [self updateWindowTitle:self]; + [[self onMainThread] updateWindowTitle:self]; } /** diff --git a/Source/SPDatabaseViewController.h b/Source/SPDatabaseViewController.h new file mode 100644 index 00000000..14dd5e88 --- /dev/null +++ b/Source/SPDatabaseViewController.h @@ -0,0 +1,53 @@ +// +// $Id$ +// +// SPDatabaseViewController.h +// sequel-pro +// +// Created by Rowan Beentje on 31/10/2010. +// Copyright 2010 Arboreal. All rights reserved. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// More info at <http://code.google.com/p/sequel-pro/> + +#import "SPDatabaseDocument.h" + + +@interface SPDatabaseDocument (SPDatabaseViewController) + +// Getters +- (NSView *)parentView; +- (NSString *)table; +- (NSInteger)tableType; +- (BOOL)structureLoaded; +- (BOOL)contentLoaded; +- (BOOL)statusLoaded; + +// Tab view control +- (IBAction)viewStructure:(id)sender; +- (IBAction)viewContent:(id)sender; +- (IBAction)viewQuery:(id)sender; +- (IBAction)viewStatus:(id)sender; +- (IBAction)viewRelations:(id)sender; +- (IBAction)viewTriggers:(id)sender; +- (void)setStructureRequiresReload:(BOOL)reload; +- (void)setContentRequiresReload:(BOOL)reload; +- (void)setStatusRequiresReload:(BOOL)reload; + +// Table control +- (void)loadTable:(NSString *)aTable ofType:(NSInteger)aTableType; + +@end diff --git a/Source/SPDatabaseViewController.m b/Source/SPDatabaseViewController.m new file mode 100644 index 00000000..cb5b5bb2 --- /dev/null +++ b/Source/SPDatabaseViewController.m @@ -0,0 +1,485 @@ +// +// $Id$ +// +// SPDatabaseViewController.m +// sequel-pro +// +// Created by Rowan Beentje on 31/10/2010. +// Copyright 2010 Arboreal. All rights reserved. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// More info at <http://code.google.com/p/sequel-pro/> + +#import "SPDatabaseViewController.h" +#import "SPTableData.h" + +@interface SPDatabaseDocument (SPDatabaseViewControllerPrivateAPI) + +- (void)_loadTabTask:(NSTabViewItem *)tabViewItem; +- (void)_loadTableTask; + +@end + + +@implementation SPDatabaseDocument (SPDatabaseViewController) + +#pragma mark - +#pragma mark Getters + +/** + * Returns the master database view, containing the tables list and views for + * table setup and contents. + */ +- (NSView *)databaseView +{ + return parentView; +} + +/** + * Returns the name of the currently selected table/view/procedure/function. + */ +- (NSString *)table +{ + return selectedTableName; +} + +/** + * Returns the currently selected table type, or -1 if no table or multiple tables are selected + */ +- (NSInteger)tableType +{ + return selectedTableType; +} + +/** + * Returns YES if table source has already been loaded + */ +- (BOOL)structureLoaded +{ + return structureLoaded; +} + +/** + * Returns YES if table content has already been loaded + */ +- (BOOL)contentLoaded +{ + return contentLoaded; +} + +/** + * Returns YES if table status has already been loaded + */ +- (BOOL)statusLoaded +{ + return statusLoaded; +} + + +#pragma mark - +#pragma mark Tab view control and delegate methods + +- (IBAction)viewStructure:(id)sender +{ + // Cancel the selection if currently editing a view and unable to save + if (![self couldCommitCurrentViewActions]) { + [mainToolbar setSelectedItemIdentifier:*SPViewModeToMainToolbarMap[[prefs integerForKey:SPLastViewMode]]]; + return; + } + + [tableTabView selectTabViewItemAtIndex:0]; + [mainToolbar setSelectedItemIdentifier:SPMainToolbarTableStructure]; + [spHistoryControllerInstance updateHistoryEntries]; + + [prefs setInteger:SPStructureViewMode forKey:SPLastViewMode]; +} + +- (IBAction)viewContent:(id)sender +{ + + // Cancel the selection if currently editing a view and unable to save + if (![self couldCommitCurrentViewActions]) { + [mainToolbar setSelectedItemIdentifier:*SPViewModeToMainToolbarMap[[prefs integerForKey:SPLastViewMode]]]; + return; + } + + [tableTabView selectTabViewItemAtIndex:1]; + [mainToolbar setSelectedItemIdentifier:SPMainToolbarTableContent]; + [spHistoryControllerInstance updateHistoryEntries]; + + [prefs setInteger:SPContentViewMode forKey:SPLastViewMode]; +} + +- (IBAction)viewQuery:(id)sender +{ + + // Cancel the selection if currently editing a view and unable to save + if (![self couldCommitCurrentViewActions]) { + [mainToolbar setSelectedItemIdentifier:*SPViewModeToMainToolbarMap[[prefs integerForKey:SPLastViewMode]]]; + return; + } + + [tableTabView selectTabViewItemAtIndex:2]; + [mainToolbar setSelectedItemIdentifier:SPMainToolbarCustomQuery]; + [spHistoryControllerInstance updateHistoryEntries]; + + // Set the focus on the text field + [parentWindow makeFirstResponder:customQueryTextView]; + + [prefs setInteger:SPQueryEditorViewMode forKey:SPLastViewMode]; +} + +- (IBAction)viewStatus:(id)sender +{ + + // Cancel the selection if currently editing a view and unable to save + if (![self couldCommitCurrentViewActions]) { + [mainToolbar setSelectedItemIdentifier:*SPViewModeToMainToolbarMap[[prefs integerForKey:SPLastViewMode]]]; + return; + } + + [tableTabView selectTabViewItemAtIndex:3]; + [mainToolbar setSelectedItemIdentifier:SPMainToolbarTableInfo]; + [spHistoryControllerInstance updateHistoryEntries]; + + // Refresh data + if([self table] && [[self table] length]) { + [tableDataInstance resetAllData]; + [extendedTableInfoInstance loadTable:[self table]]; + } + + [parentWindow makeFirstResponder:[extendedTableInfoInstance valueForKeyPath:@"tableCreateSyntaxTextView"]]; + + [prefs setInteger:SPTableInfoViewMode forKey:SPLastViewMode]; +} + +- (IBAction)viewRelations:(id)sender +{ + + // Cancel the selection if currently editing a view and unable to save + if (![self couldCommitCurrentViewActions]) { + [mainToolbar setSelectedItemIdentifier:*SPViewModeToMainToolbarMap[[prefs integerForKey:SPLastViewMode]]]; + return; + } + + [tableTabView selectTabViewItemAtIndex:4]; + [mainToolbar setSelectedItemIdentifier:SPMainToolbarTableRelations]; + [spHistoryControllerInstance updateHistoryEntries]; + + [prefs setInteger:SPRelationsViewMode forKey:SPLastViewMode]; +} + +- (IBAction)viewTriggers:(id)sender +{ + + // Cancel the selection if currently editing a view and unable to save + if (![self couldCommitCurrentViewActions]) { + [mainToolbar setSelectedItemIdentifier:*SPViewModeToMainToolbarMap[[prefs integerForKey:SPLastViewMode]]]; + return; + } + + [tableTabView selectTabViewItemAtIndex:5]; + [mainToolbar setSelectedItemIdentifier:SPMainToolbarTableTriggers]; + [spHistoryControllerInstance updateHistoryEntries]; + + [prefs setInteger:SPTriggersViewMode forKey:SPLastViewMode]; +} + +/** + * Mark the structure tab for refresh when it's next switched to, + * or reload the view if it's currently active + */ +- (void)setStructureRequiresReload:(BOOL)reload +{ + if (reload && selectedTableName && [tableTabView indexOfTabViewItem:[tableTabView selectedTabViewItem]] == SPTableViewStructure) { + [tableSourceInstance loadTable:selectedTableName]; + } else { + structureLoaded = !reload; + } +} + +/** + * Mark the content tab for refresh when it's next switched to, + * or reload the view if it's currently active + */ +- (void)setContentRequiresReload:(BOOL)reload +{ + if (reload && selectedTableName && [tableTabView indexOfTabViewItem:[tableTabView selectedTabViewItem]] == SPTableViewContent) { + [tableContentInstance loadTable:selectedTableName]; + } else { + contentLoaded = !reload; + } +} + +/** + * Mark the extended tab info for refresh when it's next switched to, + * or reload the view if it's currently active + */ +- (void)setStatusRequiresReload:(BOOL)reload +{ + if (reload && selectedTableName && [tableTabView indexOfTabViewItem:[tableTabView selectedTabViewItem]] == SPTableViewStatus) { + [[extendedTableInfoInstance onMainThread] loadTable:selectedTableName]; + } else { + statusLoaded = !reload; + } +} + + +/** + * Triggers a task to update the newly selected tab view, ensuring + * the data is fully loaded and up-to-date. + */ +- (void)tabView:(NSTabView *)aTabView didSelectTabViewItem:(NSTabViewItem *)tabViewItem +{ + [self startTaskWithDescription:[NSString stringWithFormat:NSLocalizedString(@"Loading %@...", @"Loading table task string"), [self table]]]; + if ([NSThread isMainThread]) { + [NSThread detachNewThreadSelector:@selector(_loadTabTask:) toTarget:self withObject:tabViewItem]; + } else { + [self _loadTabTask:tabViewItem]; + } +} + +#pragma mark - +#pragma mark Table control + +/** + * Loads a specified table into the database view, and ensures it's selected in + * the tables list. Passing a table name of nil will deselect any currently selected + * table, but will leave multiple selections intact. + * If this method is supplied with the currently selected name, a reload rather than + * a load will be triggered. + */ +- (void)loadTable:(NSString *)aTable ofType:(NSInteger)aTableType +{ + + // Ensure a connection is still present + if (![mySQLConnection isConnected]) return; + + // If the supplied table name was nil, clear the views. + if (!aTable) { + + // Update the selected table name and type + if (selectedTableName) [selectedTableName release], selectedTableName = nil; + selectedTableType = SPTableTypeNone; + + // Clear the views + if ([[tablesListInstance selectedTableNames] count] == 1) { + [[tablesListInstance onMainThread] setSelection:nil]; + } + [tableSourceInstance loadTable:nil]; + [tableContentInstance loadTable:nil]; + [[extendedTableInfoInstance onMainThread] loadTable:nil]; + [[tableTriggersInstance onMainThread] loadTriggers]; + structureLoaded = NO; + contentLoaded = NO; + statusLoaded = NO; + triggersLoaded = NO; + + // Update the window title + [[self onMainThread] updateWindowTitle:self]; + + // Add a history entry + [spHistoryControllerInstance updateHistoryEntries]; + + // Notify listeners of the table change + [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:SPTableChangedNotification object:self]; + + return; + } + + BOOL isReloading = (selectedTableName && [selectedTableName isEqualToString:aTable]); + + // Store the new name + if (selectedTableName) [selectedTableName release]; + selectedTableName = [[NSString alloc] initWithString:aTable]; + selectedTableType = aTableType; + + // Start a task + if (isReloading) { + [self startTaskWithDescription:NSLocalizedString(@"Reloading...", @"Reloading table task string")]; + } else { + [self startTaskWithDescription:[NSString stringWithFormat:NSLocalizedString(@"Loading %@...", @"Loading table task string"), aTable]]; + } + + // Update the tables list interface - also updates menus to reflect the selected table type + [[tablesListInstance onMainThread] setSelection:[NSDictionary dictionaryWithObjectsAndKeys:aTable, @"name", [NSNumber numberWithInteger:aTableType], @"type", nil]]; + + // If on the main thread, fire up a thread to deal with view changes and data loading; + // if already on a background thread, make the changes on the existing thread. + if ([NSThread isMainThread]) { + [NSThread detachNewThreadSelector:@selector(_loadTableTask) toTarget:self withObject:nil]; + } else { + [self _loadTableTask]; + } +} + +@end + +#pragma mark - + +@implementation SPDatabaseDocument (SPDatabaseViewControllerPrivateAPI) + +/** + * In a threaded task, ensure that the supplied tab is loaded - + * usually as a result of switching to it. + */ +- (void)_loadTabTask:(NSTabViewItem *)tabViewItem +{ + NSAutoreleasePool *tabLoadPool = [[NSAutoreleasePool alloc] init]; + + // If anything other than a single table or view is selected, don't proceed. + if (![self table] + || ([tablesListInstance tableType] != SPTableTypeTable && [tablesListInstance tableType] != SPTableTypeView)) + { + [self endTask]; + [tabLoadPool drain]; + return; + } + + // Get the tab view index and ensure the associated view is loaded + NSInteger selectedTabViewIndex = [[tabViewItem tabView] indexOfTabViewItem:tabViewItem]; + + switch (selectedTabViewIndex) { + case SPTableViewStructure: + if (!structureLoaded) { + [tableSourceInstance loadTable:selectedTableName]; + structureLoaded = YES; + } + break; + case SPTableViewContent: + if (!contentLoaded) { + [tableContentInstance loadTable:selectedTableName]; + contentLoaded = YES; + } + break; + case SPTableViewStatus: + if (!statusLoaded) { + [[extendedTableInfoInstance onMainThread] loadTable:selectedTableName]; + statusLoaded = YES; + } + break; + case SPTableViewTriggers: + if (!triggersLoaded) { + [[tableTriggersInstance onMainThread] loadTriggers]; + triggersLoaded = YES; + } + break; + } + + [self endTask]; + [tabLoadPool drain]; +} + + +/** + * In a threaded task, load the currently selected table/view/proc/function. + */ +- (void)_loadTableTask +{ + NSAutoreleasePool *loadPool = [[NSAutoreleasePool alloc] init]; + NSString *tableEncoding = nil; + + // Update the window title + [[self onMainThread] updateWindowTitle:self]; + + // Reset table information caches + [tableDataInstance resetAllData]; + + // Ensure status and details are fetched using UTF8 + NSString *previousEncoding = [mySQLConnection encoding]; + BOOL changeEncoding = ![previousEncoding isEqualToString:@"utf8"]; + if (changeEncoding) { + [mySQLConnection storeEncodingForRestoration]; + [mySQLConnection setEncoding:@"utf8"]; + } + + // Cache status information on the working thread + [tableDataInstance updateStatusInformationForCurrentTable]; + + // Check the current encoding against the table encoding to see whether + // an encoding change and reset is required + if( selectedTableType == SPTableTypeView || selectedTableType == SPTableTypeTable) { + + // tableEncoding == nil indicates that there was an error while retrieving table data + tableEncoding = [tableDataInstance tableEncoding]; + + // If encoding is set to Autodetect, update the connection character set encoding + // based on the newly selected table's encoding - but only if it differs from the current encoding. + if ([[[NSUserDefaults standardUserDefaults] objectForKey:SPDefaultEncoding] intValue] == SPEncodingAutodetect) { + if (tableEncoding != nil && ![tableEncoding isEqualToString:previousEncoding]) { + [self setConnectionEncoding:tableEncoding reloadingViews:NO]; + changeEncoding = NO; + } + } + } + + if (changeEncoding) [mySQLConnection restoreStoredEncoding]; + + // Notify listeners of the table change now that the state is fully set up. + [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:SPTableChangedNotification object:self]; + + // Restore view states as appropriate + [spHistoryControllerInstance restoreViewStates]; + + // Reset all loaded views + structureLoaded = NO; + contentLoaded = NO; + statusLoaded = NO; + triggersLoaded = NO; + [tableSourceInstance loadTable:nil]; + [tableContentInstance loadTable:nil]; + [[extendedTableInfoInstance onMainThread] loadTable:nil]; + [[tableTriggersInstance onMainThread] loadTriggers]; + + // Load the currently selected view if looking at a table or view + if (tableEncoding && (selectedTableType == SPTableTypeView || selectedTableType == SPTableTypeTable)) + { + NSInteger selectedTabViewIndex = [tableTabView indexOfTabViewItem:[tableTabView selectedTabViewItem]]; + + switch (selectedTabViewIndex) { + case SPTableViewStructure: + [tableSourceInstance loadTable:selectedTableName]; + structureLoaded = YES; + break; + case SPTableViewContent: + [tableContentInstance loadTable:selectedTableName]; + contentLoaded = YES; + break; + case SPTableViewStatus: + [[extendedTableInfoInstance onMainThread] loadTable:selectedTableName]; + statusLoaded = YES; + break; + case SPTableViewTriggers: + [[tableTriggersInstance onMainThread] loadTriggers]; + triggersLoaded = YES; + break; + } + } + + // Update the "Show Create Syntax" window if it's already opened + // according to the selected table/view/proc/func + if([[[self onMainThread] getCreateTableSyntaxWindow] isVisible]) + [[self onMainThread] showCreateTableSyntax:self]; + + // Add a history entry + [spHistoryControllerInstance updateHistoryEntries]; + + // Empty the loading pool and exit the thread + [self endTask]; + [loadPool drain]; +} + +@end
\ No newline at end of file diff --git a/Source/SPExtendedTableInfo.m b/Source/SPExtendedTableInfo.m index bcf726c7..1f67b95d 100644 --- a/Source/SPExtendedTableInfo.m +++ b/Source/SPExtendedTableInfo.m @@ -102,7 +102,7 @@ if ([connection getLastErrorID] == 0) { // Reload the table's data - [tablesListInstance updateSelectionWithTaskString:NSLocalizedString(@"Reloading data...", @"Reloading data task description")]; + [tableDocumentInstance loadTable:selectedTable ofType:[tableDocumentInstance tableType]]; } else { [sender selectItemWithTitle:currentType]; diff --git a/Source/SPHistoryController.m b/Source/SPHistoryController.m index 3d7f00d0..3fb0e100 100644 --- a/Source/SPHistoryController.m +++ b/Source/SPHistoryController.m @@ -413,7 +413,7 @@ // If the same table was selected, mark the content as requiring a reload if ([historyEntry objectForKey:@"table"] && [[theDocument table] isEqualToString:[historyEntry objectForKey:@"table"]]) { - [tablesListInstance setContentRequiresReload:YES]; + [theDocument setContentRequiresReload:YES]; } // Update the database and table name if necessary diff --git a/Source/SPIndexesController.m b/Source/SPIndexesController.m index 09f1a3d8..a19480e6 100644 --- a/Source/SPIndexesController.m +++ b/Source/SPIndexesController.m @@ -716,7 +716,7 @@ static const NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; } else { [tableData resetAllData]; - [tablesList setStatusRequiresReload:YES]; + [dbDocument setStatusRequiresReload:YES]; [tableStructure loadTable:table]; } @@ -795,7 +795,7 @@ static const NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; } else { [tableData resetAllData]; - [tablesList setStatusRequiresReload:YES]; + [dbDocument setStatusRequiresReload:YES]; [tableStructure loadTable:table]; } diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m index fe9e37ec..3c44b980 100644 --- a/Source/SPTableContent.m +++ b/Source/SPTableContent.m @@ -2005,8 +2005,8 @@ NSUInteger i; // Load table if not already done - if ( ![tablesListInstance contentLoaded] ) { - [self loadTable:[tablesListInstance tableName]]; + if ( ![tableDocumentInstance contentLoaded] ) { + [self loadTable:[tableDocumentInstance table]]; } tableColumns = [tableContentView tableColumns]; @@ -2060,8 +2060,8 @@ NSUInteger i; // Load the table if not already loaded - if ( ![tablesListInstance contentLoaded] ) { - [self loadTable:[tablesListInstance tableName]]; + if ( ![tableDocumentInstance contentLoaded] ) { + [self loadTable:[tableDocumentInstance table]]; } tableColumns = [tableContentView tableColumns]; diff --git a/Source/SPTableStructure.m b/Source/SPTableStructure.m index 86b4a84a..79a0a0a2 100644 --- a/Source/SPTableStructure.m +++ b/Source/SPTableStructure.m @@ -352,7 +352,7 @@ - (IBAction)reloadTable:(id)sender { [tableDataInstance resetAllData]; - [tablesListInstance setStatusRequiresReload:YES]; + [tableDocumentInstance setStatusRequiresReload:YES]; // Query the structure of all databases in the background (mainly for completion) [NSThread detachNewThreadSelector:@selector(queryDbStructureWithUserInfo:) toTarget:mySQLConnection withObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", nil]]; @@ -1100,11 +1100,11 @@ currentlyEditingRow = -1; [tableDataInstance resetAllData]; - [tablesListInstance setStatusRequiresReload:YES]; + [tableDocumentInstance setStatusRequiresReload:YES]; [self loadTable:selectedTable]; // Mark the content table for refresh - [tablesListInstance setContentRequiresReload:YES]; + [tableDocumentInstance setContentRequiresReload:YES]; // Query the structure of all databases in the background [NSThread detachNewThreadSelector:@selector(queryDbStructureWithUserInfo:) toTarget:mySQLConnection withObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", selectedTable, @"affectedItem", [NSNumber numberWithInt:[tablesListInstance tableType]], @"affectedItemType", nil]]; @@ -1322,8 +1322,8 @@ id field; //load table if not already done - if ( ![tablesListInstance structureLoaded] ) { - [self loadTable:[tablesListInstance tableName]]; + if ( ![tableDocumentInstance structureLoaded] ) { + [self loadTable:[tableDocumentInstance table]]; } //get field names @@ -1525,11 +1525,11 @@ } else { [tableDataInstance resetAllData]; - [tablesListInstance setStatusRequiresReload:YES]; + [tableDocumentInstance setStatusRequiresReload:YES]; [self loadTable:selectedTable]; // Mark the content table cache for refresh - [tablesListInstance setContentRequiresReload:YES]; + [tableDocumentInstance setContentRequiresReload:YES]; } [tableDocumentInstance endTask]; diff --git a/Source/SPTableStructureDelegate.m b/Source/SPTableStructureDelegate.m index 84c0a80c..049e2507 100644 --- a/Source/SPTableStructureDelegate.m +++ b/Source/SPTableStructureDelegate.m @@ -338,11 +338,11 @@ } else { [tableDataInstance resetAllData]; - [tablesListInstance setStatusRequiresReload:YES]; + [tableDocumentInstance setStatusRequiresReload:YES]; [self loadTable:selectedTable]; // Mark the content table cache for refresh - [tablesListInstance setContentRequiresReload:YES]; + [tableDocumentInstance setContentRequiresReload:YES]; if ( originalRowIndex < destinationRowIndex ) { [tableSourceView selectRowIndexes:[NSIndexSet indexSetWithIndex:destinationRowIndex-1] byExtendingSelection:NO]; diff --git a/Source/SPTablesList.h b/Source/SPTablesList.h index f0b0bed4..1ae4eecd 100644 --- a/Source/SPTablesList.h +++ b/Source/SPTablesList.h @@ -56,7 +56,6 @@ IBOutlet id copyTableNameField; IBOutlet id copyTableMessageField; IBOutlet id copyTableContentSwitch; - IBOutlet id tabView; IBOutlet id tableSheet; IBOutlet id tableNameField; IBOutlet id tableEncodingButton; @@ -101,7 +100,7 @@ BOOL tableListIsSelectable; BOOL tableListContainsViews; - BOOL structureLoaded, contentLoaded, statusLoaded, triggersLoaded, alertSheetOpened; + BOOL alertSheetOpened; } // IBAction methods @@ -117,8 +116,6 @@ // Additional methods - (void)setConnection:(MCPConnection *)theConnection; - (void)doPerformQueryService:(NSString *)query; -- (void)updateSelectionWithTaskString:(NSString *)taskString; -- (void)updateSelectionTask; - (void)setSelection:(NSDictionary *)selectionDetails; - (void)selectTableAtIndex:(NSNumber *)row; - (void)makeTableListFilterHaveFocus; @@ -139,18 +136,12 @@ - (NSArray *)allDatabaseNames; - (NSArray *)allSystemDatabaseNames; - (NSString *)selectedDatabase; -- (BOOL)structureLoaded; -- (BOOL)contentLoaded; -- (BOOL)statusLoaded; // Setters - (void)setContentRequiresReload:(BOOL)reload; - (void)setStatusRequiresReload:(BOOL)reload; - (BOOL)selectItemWithName:(NSString *)theName; -// Tabview delegate methods -- (void)loadTabTask:(NSTabViewItem *)tabViewItem; - // Table list filter interaction - (void) showFilter; - (void) hideFilter; diff --git a/Source/SPTablesList.m b/Source/SPTablesList.m index 722c3242..fc7be0f8 100644 --- a/Source/SPTablesList.m +++ b/Source/SPTablesList.m @@ -620,15 +620,6 @@ } /** - * Selects customQuery tab and passes query to customQueryInstance - */ -- (void)doPerformQueryService:(NSString *)query -{ - [tabView selectTabViewItemAtIndex:2]; - [customQueryInstance doPerformQueryService:query]; -} - -/** * Performs interface validation for various controls. */ - (void)controlTextDidChange:(NSNotification *)notification @@ -665,135 +656,6 @@ } /** - * Updates the current table selection. Triggered most times tableViewSelectionDidChange: - * fires, and also as a result of certain table actions. - */ -- (void)updateSelectionWithTaskString:(NSString *)taskString -{ - if (![mySQLConnection isConnected] || [tablesListView selectedRow] < 0) { - return; - } - id selectedItem = [filteredTables objectAtIndex:[tablesListView selectedRow]]; - if(![selectedItem isKindOfClass:[NSString class]]) { - return; - } - - // If there is a multiple or blank selection, clear all views directly. - if ( [tablesListView numberOfSelectedRows] != 1 || ![(NSString *)selectedItem length] ) { - - // Update the selection variables and the interface - [self performSelectorOnMainThread:@selector(setSelection:) withObject:nil waitUntilDone:YES]; - - // Add a history entry - [spHistoryControllerInstance updateHistoryEntries]; - - // Notify listeners of the table change now that the state is fully set up - [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:SPTableChangedNotification object:tableDocumentInstance]; - - return; - } - - // Otherwise, set up a task - [tableDocumentInstance startTaskWithDescription:taskString]; - - // If on the main thread, fire up a thread to deal with view changes and data loading, else perform inline - if ([NSThread isMainThread]) { - [NSThread detachNewThreadSelector:@selector(updateSelectionTask) toTarget:self withObject:nil]; - } else { - [self updateSelectionTask]; - } -} - -- (void) updateSelectionTask -{ - NSAutoreleasePool *selectionChangePool = [[NSAutoreleasePool alloc] init]; - NSString *tableEncoding = nil; - NSString *previousEncoding = [mySQLConnection encoding]; - BOOL changeEncoding = ![previousEncoding isEqualToString:@"utf8"]; - if (changeEncoding) { - [mySQLConnection storeEncodingForRestoration]; - [mySQLConnection setEncoding:@"utf8"]; - } - - // Update selection variables and interface - NSDictionary *selectionDetails = [NSDictionary dictionaryWithObjectsAndKeys: - [filteredTables objectAtIndex:[tablesListView selectedRow]], @"name", - [filteredTableTypes objectAtIndex:[tablesListView selectedRow]], @"type", - nil]; - [self performSelectorOnMainThread:@selector(setSelection:) withObject:selectionDetails waitUntilDone:YES]; - - // Ensure status information is cached on the working thread - [tableDataInstance updateStatusInformationForCurrentTable]; - - // Check the encoding if appropriate to determine if an encoding change is required - if( selectedTableType == SPTableTypeView || selectedTableType == SPTableTypeTable) { - - // tableEncoding == nil indicates that there was an error while retrieving table data - tableEncoding = [tableDataInstance tableEncoding]; - - // If encoding is set to Autodetect, update the connection character set encoding - // based on the newly selected table's encoding - but only if it differs from the current encoding. - if ([[[NSUserDefaults standardUserDefaults] objectForKey:SPDefaultEncoding] intValue] == SPEncodingAutodetect) { - if (tableEncoding != nil && ![tableEncoding isEqualToString:previousEncoding]) { - [tableDocumentInstance setConnectionEncoding:tableEncoding reloadingViews:NO]; - changeEncoding = NO; - } - } - } - - if (changeEncoding) [mySQLConnection restoreStoredEncoding]; - - // Notify listeners of the table change now that the state is fully set up. - [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:SPTableChangedNotification object:tableDocumentInstance]; - - // Restore view states as appropriate - [spHistoryControllerInstance restoreViewStates]; - - structureLoaded = NO; - contentLoaded = NO; - statusLoaded = NO; - triggersLoaded = NO; - if( selectedTableType == SPTableTypeView || selectedTableType == SPTableTypeTable) { - if ( [tabView indexOfTabViewItem:[tabView selectedTabViewItem]] == SPTableViewStructure ) { - [tableSourceInstance loadTable:selectedTableName]; - structureLoaded = YES; - } else if ( [tabView indexOfTabViewItem:[tabView selectedTabViewItem]] == SPTableViewContent ) { - if(tableEncoding == nil) { - [tableContentInstance loadTable:nil]; - } else { - [tableContentInstance loadTable:selectedTableName]; - } - contentLoaded = YES; - } else if ( [tabView indexOfTabViewItem:[tabView selectedTabViewItem]] == SPTableViewStatus ) { - [[extendedTableInfoInstance onMainThread] loadTable:selectedTableName]; - statusLoaded = YES; - } else if ( [tabView indexOfTabViewItem:[tabView selectedTabViewItem]] == SPTableViewTriggers ) { - [[tableTriggersInstance onMainThread] loadTriggers]; - triggersLoaded = YES; - } - } else { - - // if we are not looking at a table or view, clear these - [tableSourceInstance loadTable:nil]; - [tableContentInstance loadTable:nil]; - [[extendedTableInfoInstance onMainThread] loadTable:nil]; - [[tableTriggersInstance onMainThread] loadTriggers]; - } - - // Update the "Show Create Syntax" window if it's already opened - // according to the selected table/view/proc/func - if([[tableDocumentInstance getCreateTableSyntaxWindow] isVisible]) - [tableDocumentInstance performSelectorOnMainThread:@selector(showCreateTableSyntax:) withObject:self waitUntilDone:YES]; - - // Add a history entry - [spHistoryControllerInstance updateHistoryEntries]; - - // Empty the loading pool and exit the thread - [tableDocumentInstance endTask]; - [selectionChangePool drain]; -} - -/** * Takes a dictionary of selection details, containing the selection name * and type, and updates stored variables and the table list interface to * match. @@ -815,18 +677,6 @@ selectedTableName = nil; } - selectedTableType = SPTableTypeNone; - - [tableSourceInstance loadTable:nil]; - [tableContentInstance loadTable:nil]; - [extendedTableInfoInstance loadTable:nil]; - [tableTriggersInstance loadTriggers]; - - structureLoaded = NO; - contentLoaded = NO; - statusLoaded = NO; - triggersLoaded = NO; - // Set gear menu items Remove/Duplicate table/view according to the table types // if at least one item is selected if ([indexes count]) { @@ -922,9 +772,6 @@ [[tableSubMenu itemAtIndex:9] setHidden:NO]; [[tableSubMenu itemAtIndex:10] setHidden:NO]; - // set window title - [tableDocumentInstance updateWindowTitle:self]; - return; } @@ -947,10 +794,7 @@ [tablesListView reloadData]; } - // Reset the table information caches - [tableDataInstance resetAllData]; - - // Show menu separatoes + // Show menu separators [separatorTableMenuItem setHidden:NO]; [separatorTableContextMenuItem setHidden:NO]; [separatorTableMenuItem2 setHidden:NO]; @@ -1094,9 +938,6 @@ [showCreateSyntaxContextMenuItem setHidden:NO]; [showCreateSyntaxContextMenuItem setTitle:NSLocalizedString(@"Show Create Function Syntax...", @"show create func syntax menu item")]; } - - // set window title - [tableDocumentInstance updateWindowTitle:self]; } #pragma mark - @@ -1259,48 +1100,10 @@ return tableTypes; } -/** - * Returns YES if table source has already been loaded - */ -- (BOOL)structureLoaded -{ - return structureLoaded; -} - -/** - * Returns YES if table content has already been loaded - */ -- (BOOL)contentLoaded -{ - return contentLoaded; -} - -/** - * Returns YES if table status has already been loaded - */ -- (BOOL)statusLoaded -{ - return statusLoaded; -} #pragma mark - #pragma mark Setter methods -/** - * Mark the content table for refresh when it's next switched to - */ -- (void)setContentRequiresReload:(BOOL)reload -{ - contentLoaded = !reload; -} - -/** - * Mark the exteded table info for refresh when it's next switched to - */ -- (void)setStatusRequiresReload:(BOOL)reload -{ - statusLoaded = !reload; -} /** * Select an item using the provided name; returns YES if the @@ -1343,7 +1146,7 @@ selectedTableName = [[NSString alloc] initWithString:[tables objectAtIndex:itemIndex]]; selectedTableType = [[tableTypes objectAtIndex:itemIndex] integerValue]; [self updateFilter:self]; - [self updateSelectionWithTaskString:[NSString stringWithFormat:NSLocalizedString(@"Loading %@...", @"Loading table task string"), theName]]; + [tableDocumentInstance loadTable:selectedTableName ofType:selectedTableType]; } } @@ -1428,31 +1231,10 @@ if (selectedTableName) [selectedTableName release]; selectedTableName = [[NSString alloc] initWithString:newTableName]; - // if the 'table' is a view or a table, reload the currently selected view + // if the 'table' is a view or a table, ensure data is reloaded if (selectedTableType == SPTableTypeTable || selectedTableType == SPTableTypeView) { - statusLoaded = NO; - structureLoaded = NO; - contentLoaded = NO; - triggersLoaded = NO; - switch ([tabView indexOfTabViewItem:[tabView selectedTabViewItem]]) { - case SPTableViewStructure: - [tableSourceInstance loadTable:newTableName]; - structureLoaded = YES; - break; - case SPTableViewContent: - [tableContentInstance loadTable:newTableName]; - contentLoaded = YES; - break; - case SPTableViewStatus: - [extendedTableInfoInstance loadTable:newTableName]; - statusLoaded = YES; - break; - case SPTableViewTriggers: - [tableTriggersInstance loadTriggers]; - triggersLoaded = YES; - break; - } + [tableDocumentInstance loadTable:selectedTableName ofType:selectedTableType]; } } @catch (NSException * myException) { @@ -1516,28 +1298,18 @@ */ - (void)tableViewSelectionDidChange:(NSNotification *)aNotification { + if ([tablesListView numberOfSelectedRows] != 1) { - if([tablesListView selectedRow] < 0) { - // Reset all - if (selectedTableName) [selectedTableName release]; - selectedTableName = nil; + // Ensure the state is cleared + if ([tableDocumentInstance table]) [tableDocumentInstance loadTable:nil ofType:SPTableTypeNone]; + if (selectedTableName) [selectedTableName release], selectedTableName = nil; selectedTableType = SPTableTypeNone; - [tableSourceInstance loadTable:nil]; - [tableContentInstance loadTable:nil]; - [extendedTableInfoInstance loadTable:nil]; - [tableTriggersInstance loadTriggers]; - structureLoaded = NO; - contentLoaded = NO; - statusLoaded = NO; - triggersLoaded = NO; - [self updateSelectionWithTaskString:NSLocalizedString(@"Reloading...", @"Reloading table task string")]; return; } - id selectedItem = [filteredTables objectAtIndex:[tablesListView selectedRow]]; + NSInteger selectedRowIndex = [tablesListView selectedRow]; - if(![selectedItem isKindOfClass:[NSString class]]) { - [self updateSelectionWithTaskString:NSLocalizedString(@"Reloading...", @"Reloading table task string")]; + if (![[filteredTables objectAtIndex:selectedRowIndex] isKindOfClass:[NSString class]]) { return; } @@ -1545,32 +1317,28 @@ if ([tableDocumentInstance isWorking]) tableListIsSelectable = NO; // Perform no action if the selected table hasn't actually changed - reselection etc - if ([tablesListView numberOfSelectedRows] == 1 - && [(NSString *)selectedItem length] - && [selectedTableName isEqualToString:(NSString *)selectedItem] - && selectedTableType == [[filteredTableTypes objectAtIndex:[tablesListView selectedRow]] integerValue]) - { + NSString *newName = [filteredTables objectAtIndex:selectedRowIndex]; + NSInteger newType = [[filteredTableTypes objectAtIndex:selectedRowIndex] integerValue]; + if ([selectedTableName isEqualToString:newName] && selectedTableType == newType) { return; } // Save existing scroll position and details [spHistoryControllerInstance updateHistoryEntries]; - NSString *tableName = @"data"; - if ([tablesListView numberOfSelectedRows] == 1 && [selectedItem isKindOfClass:[NSString class]] && [(NSString *)selectedItem length]) - tableName = [filteredTables objectAtIndex:[tablesListView selectedRow]]; - [self updateSelectionWithTaskString:[NSString stringWithFormat:NSLocalizedString(@"Loading %@...", @"Loading table task string"), tableName]]; + if (selectedTableName) [selectedTableName release], selectedTableName = nil; + selectedTableName = [[NSString alloc] initWithString:newName]; + selectedTableType = newType; + [tableDocumentInstance loadTable:selectedTableName ofType:selectedTableType]; - if([[SPNavigatorController sharedNavigatorController] syncMode] && [tablesListView numberOfSelectedRows] == 1) { + if([[SPNavigatorController sharedNavigatorController] syncMode]) { NSMutableString *schemaPath = [NSMutableString string]; [schemaPath setString:[tableDocumentInstance connectionID]]; if([tableDocumentInstance database] && [[tableDocumentInstance database] length]) { [schemaPath appendString:SPUniqueSchemaDelimiter]; [schemaPath appendString:[tableDocumentInstance database]]; - if(tableName && [tableName length]) { - [schemaPath appendString:SPUniqueSchemaDelimiter]; - [schemaPath appendString:tableName]; - } + [schemaPath appendString:SPUniqueSchemaDelimiter]; + [schemaPath appendString:selectedTableName]; } [[SPNavigatorController sharedNavigatorController] selectPath:schemaPath]; } @@ -1682,57 +1450,7 @@ } #pragma mark - -#pragma mark TabView delegate methods - -/** - * Loads structure or source if tab selected the first time, - * using a threaded load if currently on the main thread. - */ -- (void)tabView:(NSTabView *)aTabView didSelectTabViewItem:(NSTabViewItem *)tabViewItem -{ - [tableDocumentInstance startTaskWithDescription:[NSString stringWithFormat:NSLocalizedString(@"Loading %@...", @"Loading table task string"), selectedTableName]]; - if ([NSThread isMainThread]) { - [NSThread detachNewThreadSelector:@selector(loadTabTask:) toTarget:self withObject:tabViewItem]; - } else { - [self loadTabTask:tabViewItem]; - } -} -- (void)loadTabTask:(NSTabViewItem *)tabViewItem -{ - NSAutoreleasePool *tabLoadPool = [[NSAutoreleasePool alloc] init]; - - if ([tablesListView numberOfSelectedRows] == 1 - && ([self tableType] == SPTableTypeTable || [self tableType] == SPTableTypeView) ) - { - - if ( ([tabView indexOfTabViewItem:[tabView selectedTabViewItem]] == SPTableViewStructure) && !structureLoaded ) { - [tableSourceInstance loadTable:selectedTableName]; - structureLoaded = YES; - } - - if ( ([tabView indexOfTabViewItem:[tabView selectedTabViewItem]] == SPTableViewContent) && !contentLoaded ) { - [tableContentInstance loadTable:selectedTableName]; - contentLoaded = YES; - } - - if ( ([tabView indexOfTabViewItem:[tabView selectedTabViewItem]] == SPTableViewStatus) && !statusLoaded ) { - [[extendedTableInfoInstance onMainThread] loadTable:selectedTableName]; - statusLoaded = YES; - } - - if ( ([tabView indexOfTabViewItem:[tabView selectedTabViewItem]] == SPTableViewTriggers) && !triggersLoaded ) { - [[tableTriggersInstance onMainThread] loadTriggers]; - triggersLoaded = YES; - } - } - else { - [tableSourceInstance loadTable:nil]; - [tableContentInstance loadTable:nil]; - } - - [tableDocumentInstance endTask]; - [tabLoadPool drain]; -} +#pragma mark Interface validation /** * Menu item interface validation @@ -1949,10 +1667,6 @@ filteredTables = tables; tableTypes = [[NSMutableArray alloc] init]; filteredTableTypes = tableTypes; - structureLoaded = NO; - contentLoaded = NO; - statusLoaded = NO; - triggersLoaded = NO; isTableListFiltered = NO; tableListIsSelectable = YES; tableListContainsViews = NO; @@ -2159,11 +1873,7 @@ } // Ensure the the table's content view is updated to show that it has been truncated - if ([tabView indexOfTabViewItem:[tabView selectedTabViewItem]] == SPTableViewContent) { - [tableContentInstance reloadTable:self]; - } else { - [self setContentRequiresReload:YES]; - } + [tableDocumentInstance setContentRequiresReload:YES]; [tableDataInstance resetStatusData]; } @@ -2233,17 +1943,16 @@ [tableTypes insertObject:[NSNumber numberWithInteger:SPTableTypeTable] atIndex:addItemAtIndex]; } - // Set the selected table name and type, and then use updateFilter and updateSelection to update the filter list and selection. + // Set the selected table name and type, and then update the filter list and the + // selection. if (selectedTableName) [selectedTableName release]; - selectedTableName = [[NSString alloc] initWithString:tableName]; selectedTableType = SPTableTypeTable; [self updateFilter:self]; - [tablesListView scrollRowToVisible:[tablesListView selectedRow]]; - [self updateSelectionWithTaskString:[NSString stringWithFormat:NSLocalizedString(@"Loading %@...", @"Loading table task string"), selectedTableName]]; + [tableDocumentInstance loadTable:selectedTableName ofType:selectedTableType]; // Query the structure of all databases in the background (mainly for completion) [NSThread detachNewThreadSelector:@selector(queryDbStructureWithUserInfo:) toTarget:mySQLConnection withObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", nil]]; @@ -2439,7 +2148,7 @@ selectedTableType = tblType; [self updateFilter:self]; [tablesListView scrollRowToVisible:[tablesListView selectedRow]]; - [self updateSelectionWithTaskString:[NSString stringWithFormat:NSLocalizedString(@"Loading %@...", @"Loading table task string"), selectedTableName]]; + [tableDocumentInstance loadTable:selectedTableName ofType:selectedTableType]; // Query the structure of all databases in the background (mainly for completion) [NSThread detachNewThreadSelector:@selector(queryDbStructureWithUserInfo:) toTarget:mySQLConnection withObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", nil]]; diff --git a/Source/SPWindowController.m b/Source/SPWindowController.m index 22b7c13d..b22248fe 100644 --- a/Source/SPWindowController.m +++ b/Source/SPWindowController.m @@ -106,7 +106,7 @@ // Set up a new tab with the connection view as the identifier, add the view, and add it to the tab view NSTabViewItem *newItem = [[[NSTabViewItem alloc] initWithIdentifier:newTableDocument] autorelease]; - [newItem setView:[newTableDocument parentView]]; + [newItem setView:[newTableDocument databaseView]]; [tabView addTabViewItem:newItem]; [tabView selectTabViewItem:newItem]; [newTableDocument setParentTabViewItem:newItem]; diff --git a/sequel-pro.xcodeproj/project.pbxproj b/sequel-pro.xcodeproj/project.pbxproj index c61ac93c..def9b39d 100644 --- a/sequel-pro.xcodeproj/project.pbxproj +++ b/sequel-pro.xcodeproj/project.pbxproj @@ -231,6 +231,7 @@ 588B2CCA0FE5641E00EC5FC0 /* ssh-disconnected.png in Resources */ = {isa = PBXBuildFile; fileRef = 588B2CC70FE5641E00EC5FC0 /* ssh-disconnected.png */; }; 589235321020C1230011DE00 /* SPHistoryController.m in Sources */ = {isa = PBXBuildFile; fileRef = 589235301020C1230011DE00 /* SPHistoryController.m */; }; 589582151154F8F400EDCC28 /* SPMainThreadTrampoline.m in Sources */ = {isa = PBXBuildFile; fileRef = 589582141154F8F400EDCC28 /* SPMainThreadTrampoline.m */; }; + 5897FE4F127DE86D0047897C /* SPDatabaseViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5897FE4E127DE86D0047897C /* SPDatabaseViewController.m */; }; 589ED05B11E0ACD100C1DCEA /* DMLocalizedNib.m in Sources */ = {isa = PBXBuildFile; fileRef = 589ED05A11E0ACD100C1DCEA /* DMLocalizedNib.m */; }; 58A137CD123ED5E6000B1B75 /* titlebarlock.png in Resources */ = {isa = PBXBuildFile; fileRef = 58A137CC123ED5E6000B1B75 /* titlebarlock.png */; }; 58A8A72711A0149100B95749 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 58A8A72611A0149100B95749 /* MainWindow.xib */; }; @@ -866,6 +867,8 @@ 589235311020C1230011DE00 /* SPHistoryController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPHistoryController.h; sourceTree = "<group>"; }; 589582131154F8F400EDCC28 /* SPMainThreadTrampoline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPMainThreadTrampoline.h; sourceTree = "<group>"; }; 589582141154F8F400EDCC28 /* SPMainThreadTrampoline.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPMainThreadTrampoline.m; sourceTree = "<group>"; }; + 5897FE4D127DE86D0047897C /* SPDatabaseViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPDatabaseViewController.h; sourceTree = "<group>"; }; + 5897FE4E127DE86D0047897C /* SPDatabaseViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPDatabaseViewController.m; sourceTree = "<group>"; }; 589ED05A11E0ACD100C1DCEA /* DMLocalizedNib.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DMLocalizedNib.m; sourceTree = "<group>"; }; 58A137CC123ED5E6000B1B75 /* titlebarlock.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = titlebarlock.png; sourceTree = "<group>"; }; 58A8A72411A0148400B95749 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/MainWindow.xib; sourceTree = "<group>"; }; @@ -1356,6 +1359,8 @@ 29FA88221114619E00D1AF3D /* SPTableTriggers.m */, 17E6414E0EF01EF6001BC333 /* SPTableContent.h */, 17E6414F0EF01EF6001BC333 /* SPTableContent.m */, + 5897FE4D127DE86D0047897C /* SPDatabaseViewController.h */, + 5897FE4E127DE86D0047897C /* SPDatabaseViewController.m */, 17E641500EF01EF6001BC333 /* SPDatabaseDocument.h */, 17E641510EF01EF6001BC333 /* SPDatabaseDocument.m */, 17D38FC2127B0C9500672B13 /* Connection View */, @@ -2513,7 +2518,6 @@ isa = PBXProject; buildConfigurationList = C05733CB08A9546B00998B17 /* Build configuration list for PBXProject "sequel-pro" */; compatibilityVersion = "Xcode 3.1"; - developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( English, @@ -2956,6 +2960,7 @@ 175EC63512733B36009A7C0F /* SPExportControllerDelegate.m in Sources */, 17D38EBC12771A1C00672B13 /* SPTableStructureDelegate.m in Sources */, 17D38F701279E23A00672B13 /* SPTableFieldValidation.m in Sources */, + 5897FE4F127DE86D0047897C /* SPDatabaseViewController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; |