From fa2b337d82047f8ec3474dc67b125f34f7a49bfc Mon Sep 17 00:00:00 2001 From: Bibiko Date: Mon, 27 Sep 2010 09:25:46 +0000 Subject: =?UTF-8?q?=E2=80=A2=C2=A0initial=20sketch=20approach=20to=20allow?= =?UTF-8?q?=20to=20write=20complex=20WHERE=20clauses=20by=20using=20a=20ta?= =?UTF-8?q?ble=20approach=20-=20not=20yet=20activated?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Interfaces/English.lproj/DBView.xib | 1442 ++++++++++++++++++++++++++++++++--- Source/SPTableContent.h | 18 +- Source/SPTableContent.m | 571 +++++++++----- 3 files changed, 1705 insertions(+), 326 deletions(-) diff --git a/Interfaces/English.lproj/DBView.xib b/Interfaces/English.lproj/DBView.xib index c05d72c9..d4219db2 100644 --- a/Interfaces/English.lproj/DBView.xib +++ b/Interfaces/English.lproj/DBView.xib @@ -23,15 +23,14 @@ YES - - + YES com.brandonwalkin.BWToolkit - com.apple.InterfaceBuilder.CocoaPlugin com.apple.WebKitIBPlugin + com.apple.InterfaceBuilder.CocoaPlugin YES @@ -229,7 +228,7 @@ controlColor 3 - MC42NjY2NjY2NjY3AA + MC42NjY2NjY2ODY1AA @@ -274,7 +273,6 @@ {{1, 1}, {218, 38}} - 6 @@ -306,7 +304,6 @@ {{-1, -13}, {220, 40}} - 2 @@ -404,7 +401,6 @@ {214, 354} - 4 @@ -432,7 +428,6 @@ {214, 354} - 528 @@ -568,7 +563,6 @@ {214, 145} - 6 @@ -596,7 +590,6 @@ {214, 145} - 512 @@ -2405,7 +2398,6 @@ {{1, 17}, {694, 450}} - 2 @@ -2439,7 +2431,6 @@ {{1, 0}, {694, 17}} - 4 @@ -2448,7 +2439,6 @@ {{6, 33}, {696, 468}} - 562 @@ -3064,6 +3054,30 @@ 75 + + + 265 + {{734, 507}, {160, 16}} + + YES + + 67239424 + 134479872 + ShowFilterTable_Dummy_Button + + LucidaGrande + 9 + 3614 + + + -2038284033 + 268435585 + + f + 200 + 25 + + {{10, 7}, {706, 544}} @@ -6787,7 +6801,7 @@ View - {1.79769e+308, 1.79769e+308} + {3.40282e+38, 3.40282e+38} {213, 107} @@ -6943,7 +6957,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 {{0, 0}, {1440, 878}} {213, 129} - {1.79769e+308, 1.79769e+308} + {3.40282e+38, 3.40282e+38} 7 @@ -6953,7 +6967,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 Reset Auto Increment NSWindow - {1.79769e+308, 1.79769e+308} + {3.40282e+38, 3.40282e+38} {255, 95} @@ -7116,7 +7130,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 {{0, 0}, {1280, 1002}} {255, 117} - {1.79769e+308, 1.79769e+308} + {3.40282e+38, 3.40282e+38} 1 @@ -7126,7 +7140,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 New Relation NSPanel - {1.79769e+308, 1.79769e+308} + {3.40282e+38, 3.40282e+38} 256 @@ -7727,7 +7741,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 {302, 307} {{0, 0}, {1440, 878}} - {1.79769e+308, 1.79769e+308} + {3.40282e+38, 3.40282e+38} 9 @@ -7737,7 +7751,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 New Trigger NSPanel - {1.79769e+308, 1.79769e+308} + {3.40282e+38, 3.40282e+38} {360, 348} @@ -8144,7 +8158,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 {{0, 0}, {1680, 1028}} {360, 370} - {1.79769e+308, 1.79769e+308} + {3.40282e+38, 3.40282e+38} 3 @@ -8156,7 +8170,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 View - {1.79769e+308, 1.79769e+308} + {3.40282e+38, 3.40282e+38} {213, 50} @@ -8276,7 +8290,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 {{0, 0}, {1920, 1178}} {213, 72} - {1.79769e+308, 1.79769e+308} + {3.40282e+38, 3.40282e+38} 9 @@ -8288,7 +8302,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 View - {1.79769e+308, 1.79769e+308} + {3.40282e+38, 3.40282e+38} {213, 107} @@ -8423,7 +8437,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 {{0, 0}, {1440, 878}} {213, 129} - {1.79769e+308, 1.79769e+308} + {3.40282e+38, 3.40282e+38} 15 @@ -8435,10 +8449,10 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 View - {1.79769e+308, 1.79769e+308} + {3.40282e+38, 3.40282e+38} {350, 200} - + 256 YES @@ -8596,7 +8610,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 {{1, 1}, {411, 264}} - @@ -8626,7 +8639,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 {{-1, 42}, {413, 266}} - 514 @@ -8655,11 +8667,10 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 {411, 341} - {{0, 0}, {1680, 1028}} {350, 222} - {1.79769e+308, 1.79769e+308} + {3.40282e+38, 3.40282e+38} SPCreateSyntaxSheet @@ -8672,7 +8683,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 View - {1.79769e+308, 1.79769e+308} + {3.40282e+38, 3.40282e+38} {213, 107} @@ -8842,7 +8853,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 {{0, 0}, {1440, 878}} {213, 129} - {1.79769e+308, 1.79769e+308} + {3.40282e+38, 3.40282e+38} 31 @@ -8852,7 +8863,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 MySQL Help NSPanel - {1.79769e+308, 1.79769e+308} + {3.40282e+38, 3.40282e+38} {351, 120} @@ -9250,9 +9261,508 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 {{0, 0}, {1280, 1002}} {351, 136} - {1.79769e+308, 1.79769e+308} + {3.40282e+38, 3.40282e+38} MYSQL_HELP_WINDOW + + 8347 + 2 + {{131, 159}, {480, 270}} + 1685585920 + Filter + NSPanel + + {3.40282e+38, 3.40282e+38} + {240, 170} + + + 256 + + YES + + + 4364 + + YES + + + 2304 + + YES + + + 4352 + {478, 215} + + + YES + + + -2147483392 + {{-26, 0}, {16, 17}} + + + YES + + 3 + 2 + + 4 + MSAwLjE0MDAwMDAwMDYAA + + + 20 + -692060160 + + + 4 + 15 + 0 + YES + 0 + + + {478, 215} + + + + + + 4 + + + + -2147483392 + {{-100, -100}, {15, 120}} + + + 2 + + _doScroller: + 0.99253731966018677 + + + + -2147483392 + {{-100, -100}, {225, 15}} + + + 1 + + _doScroller: + 0.57142859697341919 + + + {{1, 55}, {478, 215}} + + + + 560 + + + + QSAAAEEgAABBsAAAQbAAAA + + + + 289 + {{380, 10}, {81, 28}} + + + YES + + 67239424 + 134348800 + Filter + + + -2038284033 + 268435585 + + f + 200 + 25 + + + + + 289 + {{293, 10}, {81, 28}} + + + YES + + 67239424 + 134348800 + Clear + + + -2038284033 + 268435585 + +  + 200 + 25 + + + + + 274 + + YES + + + 272 + + YES + + + 274 + + YES + + + 2304 + + YES + + + 274 + {478, 87} + + + YES + + + 256 + {478, 17} + + + + + + + -2147483392 + {{224, 0}, {16, 17}} + + + + + YES + + 242 + 40 + 1000 + + 75628096 + 2048 + + + + 3 + MC4zMzMzMzI5ODU2AA + + + + + 337772096 + 133120 + Text Cell + + + + + + 3 + YES + YES + + + + 3 + 2 + + 4 + MQA + + + 14 + -624918528 + + + 1 + 15 + 0 + YES + 1 + 1 + + + {{1, 17}, {478, 87}} + + + + + + 4 + MQA + + 4 + + + + -2147483392 + {{224, 17}, {15, 102}} + + + + _doScroller: + 0.98275864124298096 + + + + -2147483392 + {{1, 119}, {223, 15}} + + + 1 + + _doScroller: + 0.99382716417312622 + + + + 2304 + + YES + + + {{1, 0}, {478, 17}} + + + + + + 4 + + + + {480, 105} + + + + 562 + + + + + + QSAAAEEgAABBgAAAQYAAAA + + + {480, 106} + + + NSView + + + + 272 + + YES + + + 274 + + YES + + + 2304 + + YES + + + 2322 + + YES + + YES + Apple HTML pasteboard type + Apple PDF pasteboard type + Apple PICT pasteboard type + Apple PNG pasteboard type + Apple URL pasteboard type + CorePasteboardFlavorType 0x6D6F6F76 + NSColor pasteboard type + NSFilenamesPboardType + NSStringPboardType + NeXT Encapsulated PostScript v1.2 pasteboard type + NeXT RTFD pasteboard type + NeXT Rich Text Format v1.0 pasteboard type + NeXT TIFF v4.0 pasteboard type + NeXT font pasteboard type + NeXT ruler pasteboard type + WebURLsWithTitlesPboardType + public.url + + + {478, 14} + + + + + + + + + + + + YES + + + 134 + + + + 478 + 1 + + + 12263 + 0 + + + + YES + + YES + NSBackgroundColor + NSColor + + + YES + + + + + + + YES + + YES + NSColor + NSCursor + NSUnderline + + + YES + + + {8, -8} + 13 + + + + + + + 6 + {478, 1e+07} + {197, 4} + + + + {{1, 1}, {478, 106}} + + + + + + + 4 + + + + -2147483392 + {{464, 1}, {15, 91}} + + + + _doScroller: + 1 + 0.85256409645080566 + + + + -2147483392 + {{1, 92}, {463, 15}} + + + 1 + + _doScroller: + 1 + 0.94565218687057495 + + + {480, 108} + + + + 562 + + + + + + {{0, 107}, {480, 108}} + + + NSView + + + {{0, 55}, {480, 215}} + + + 2 + + NO + + YES + + + YES + + + + YES + + + YES + + + + + + + + + + + 0 + NO + + + {480, 270} + + + + {{0, 0}, {1280, 778}} + {240, 189} + {3.40282e+38, 3.40282e+38} + SPTableFilterPanel + 9 2 @@ -9384,7 +9894,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 Secure Text Input Sheet NSPanel - {1.79769e+308, 1.79769e+308} + {3.40282e+38, 3.40282e+38} 256 @@ -9488,7 +9998,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 {338, 150} {{0, 0}, {1280, 778}} - {1.79769e+308, 1.79769e+308} + {3.40282e+38, 3.40282e+38} @@ -9671,7 +10181,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 disabledControlTextColor 3 - MC4zMzMzMzMzMzMzAA + MC4zMzMzMzMzNDMzAA @@ -9975,6 +10485,79 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 {217, 20} NSView + + + 4364 + + YES + + + 268 + {{20, 1}, {176, 19}} + + YES + + 343014976 + 272794624 + + + Filter + + YES + 1 + + + + 130560 + 0 + search + + _searchFieldSearch: + + 138690815 + 0 + + 400 + 75 + + + 130560 + 0 + clear + + YES + + YES + + YES + AXDescription + NSAccessibilityEncodedAttributesValueType + + + YES + cancel + + + + + + _searchFieldCancel: + + 138690815 + 0 + + 400 + 75 + + SPQueryHistorySearchField + 10 + CAAAAA + + + + {217, 20} + NSView + YES @@ -10350,79 +10933,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 - - - 4364 - - YES - - - 268 - {{20, 1}, {176, 19}} - - YES - - 343014976 - 272794624 - - - Filter - - YES - 1 - - - - 130560 - 0 - search - - _searchFieldSearch: - - 138690815 - 0 - - 400 - 75 - - - 130560 - 0 - clear - - YES - - YES - - YES - AXDescription - NSAccessibilityEncodedAttributesValueType - - - YES - cancel - - - - - - _searchFieldCancel: - - 138690815 - 0 - - 400 - 75 - - SPQueryHistorySearchField - 10 - CAAAAA - - - - {217, 20} - NSView - @@ -14764,6 +15274,70 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 7501 + + + tableFilterClear: + + + + 7526 + + + + tableFilterExecute: + + + + 7527 + + + + filterTableWindow + + + + 7528 + + + + filterTableWhereClause + + + + 7529 + + + + dataSource + + + + 7530 + + + + delegate + + + + 7531 + + + + filterTableView + + + + 7532 + + + + showTableFilter: + + + + 7535 + @@ -17897,6 +18471,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 + @@ -20791,6 +21366,200 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 + + 7502 + + + YES + + + + Filter Table Window + + + 7503 + + + YES + + + + + + + + + 7504 + + + YES + + + + + + + 7505 + + + YES + + + + + + 7506 + + + YES + + + + + + 7507 + + + YES + + + + + + + + 7508 + + + + + 7509 + + + + + 7510 + + + + + 7511 + + + + + 7512 + + + + + 7513 + + + YES + + + + + + 7514 + + + YES + + + + + + 7515 + + + YES + + + + + + + + + 7516 + + + + + 7517 + + + + + 7518 + + + YES + + + + + + 7519 + + + + + 7520 + + + YES + + + + + + 7521 + + + + + 7522 + + + YES + + + + + + + + 7523 + + + + + 7524 + + + + + 7525 + + + + + 7533 + + + YES + + + + + + 7534 + + + @@ -22004,6 +22773,39 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 7494.IBPluginDependency 7499.IBPluginDependency 7500.IBPluginDependency + 7502.IBEditorWindowLastContentRect + 7502.IBPluginDependency + 7502.IBWindowTemplateEditedContentRect + 7502.NSWindowTemplate.visibleAtLaunch + 7502.windowTemplate.hasMinSize + 7502.windowTemplate.minSize + 7503.IBPluginDependency + 7504.IBPluginDependency + 7505.IBPluginDependency + 7506.IBPluginDependency + 7507.IBPluginDependency + 7508.IBPluginDependency + 7509.IBPluginDependency + 7510.IBPluginDependency + 7511.IBPluginDependency + 7512.IBPluginDependency + 7513.IBPluginDependency + 7514.IBPluginDependency + 7515.IBPluginDependency + 7516.IBPluginDependency + 7517.IBPluginDependency + 7518.CustomClassName + 7518.IBPluginDependency + 7519.IBPluginDependency + 7520.IBPluginDependency + 7521.IBPluginDependency + 7522.IBPluginDependency + 7523.CustomClassName + 7523.IBPluginDependency + 7524.IBPluginDependency + 7525.IBPluginDependency + 7533.IBPluginDependency + 7534.IBPluginDependency 858.IBPluginDependency 858.ImportedFromIB2 959.IBEditorWindowLastContentRect @@ -23651,6 +24453,39 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + {{153, 361}, {480, 270}} + com.apple.InterfaceBuilder.CocoaPlugin + {{153, 361}, {480, 270}} + + + {240, 170} + com.apple.InterfaceBuilder.CocoaPlugin + com.brandonwalkin.BWToolkit + com.brandonwalkin.BWToolkit + com.brandonwalkin.BWToolkit + com.brandonwalkin.BWToolkit + com.brandonwalkin.BWToolkit + com.brandonwalkin.BWToolkit + com.brandonwalkin.BWToolkit + com.brandonwalkin.BWToolkit + com.brandonwalkin.BWToolkit + com.brandonwalkin.BWToolkit + com.brandonwalkin.BWToolkit + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + SPCopyTable + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + SPTextView + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin {{265, 489}, {405, 267}} @@ -23689,7 +24524,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 - 7501 + 7535 @@ -28990,6 +29825,389 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 + + YES + + SPTableContent + NSObject + + YES + + YES + addRow: + copyRow: + filterTable: + navigatePaginationFromButton: + reloadTable: + removeRow: + setCompareTypes: + showTableFilter: + tableFilterClear: + tableFilterExecute: + toggleFilterField: + togglePagination: + + + YES + id + id + id + id + id + id + id + id + id + id + id + id + + + + YES + + YES + addRow: + copyRow: + filterTable: + navigatePaginationFromButton: + reloadTable: + removeRow: + setCompareTypes: + showTableFilter: + tableFilterClear: + tableFilterExecute: + toggleFilterField: + togglePagination: + + + YES + + addRow: + id + + + copyRow: + id + + + filterTable: + id + + + navigatePaginationFromButton: + id + + + reloadTable: + id + + + removeRow: + id + + + setCompareTypes: + id + + + showTableFilter: + id + + + tableFilterClear: + id + + + tableFilterExecute: + id + + + toggleFilterField: + id + + + togglePagination: + id + + + + + YES + + YES + addButton + argumentField + betweenTextField + compareField + contentFilterManager + contentViewPane + copyButton + countText + fieldField + filterButton + filterTableClearButton + filterTableFilterButton + filterTableView + filterTableWhereClause + filterTableWindow + firstBetweenField + limitRowsButton + limitRowsField + limitRowsStepper + multipleLineEditingButton + paginationButton + paginationNextButton + paginationPageField + paginationPageStepper + paginationPreviousButton + paginationView + reloadButton + removeButton + secondBetweenField + spHistoryControllerInstance + tableContentView + tableDataInstance + tableDocumentInstance + tableInfoInstance + tableSourceInstance + tablesListInstance + + + YES + id + id + id + id + id + NSView + id + id + NSPopUpButton + id + NSButton + NSButton + SPCopyTable + SPTextView + NSPanel + id + id + id + id + id + NSButton + NSButton + NSTextField + NSStepper + NSButton + NSView + id + id + id + SPHistoryController + SPCopyTable + id + id + SPTableInfo + id + id + + + + YES + + YES + addButton + argumentField + betweenTextField + compareField + contentFilterManager + contentViewPane + copyButton + countText + fieldField + filterButton + filterTableClearButton + filterTableFilterButton + filterTableView + filterTableWhereClause + filterTableWindow + firstBetweenField + limitRowsButton + limitRowsField + limitRowsStepper + multipleLineEditingButton + paginationButton + paginationNextButton + paginationPageField + paginationPageStepper + paginationPreviousButton + paginationView + reloadButton + removeButton + secondBetweenField + spHistoryControllerInstance + tableContentView + tableDataInstance + tableDocumentInstance + tableInfoInstance + tableSourceInstance + tablesListInstance + + + YES + + addButton + id + + + argumentField + id + + + betweenTextField + id + + + compareField + id + + + contentFilterManager + id + + + contentViewPane + NSView + + + copyButton + id + + + countText + id + + + fieldField + NSPopUpButton + + + filterButton + id + + + filterTableClearButton + NSButton + + + filterTableFilterButton + NSButton + + + filterTableView + SPCopyTable + + + filterTableWhereClause + SPTextView + + + filterTableWindow + NSPanel + + + firstBetweenField + id + + + limitRowsButton + id + + + limitRowsField + id + + + limitRowsStepper + id + + + multipleLineEditingButton + id + + + paginationButton + NSButton + + + paginationNextButton + NSButton + + + paginationPageField + NSTextField + + + paginationPageStepper + NSStepper + + + paginationPreviousButton + NSButton + + + paginationView + NSView + + + reloadButton + id + + + removeButton + id + + + secondBetweenField + id + + + spHistoryControllerInstance + SPHistoryController + + + tableContentView + SPCopyTable + + + tableDataInstance + id + + + tableDocumentInstance + id + + + tableInfoInstance + SPTableInfo + + + tableSourceInstance + id + + + tablesListInstance + id + + + + + IBDocumentRelativeSource + ../../Source/SPTableContent.h + + + YES diff --git a/Source/SPTableContent.h b/Source/SPTableContent.h index f88d6fe9..13ca3d92 100644 --- a/Source/SPTableContent.h +++ b/Source/SPTableContent.h @@ -28,7 +28,7 @@ #import #import -@class SPCopyTable, SPTextAndLinkCell, SPHistoryController, SPTableInfo, SPDataStorage; +@class SPCopyTable, SPTextAndLinkCell, SPHistoryController, SPTableInfo, SPDataStorage, SPTextView; @interface SPTableContent : NSObject { @@ -65,7 +65,13 @@ IBOutlet NSView *paginationView; IBOutlet NSTextField *paginationPageField; IBOutlet NSStepper *paginationPageStepper; - + + IBOutlet SPCopyTable *filterTableView; + IBOutlet NSPanel *filterTableWindow; + IBOutlet NSButton *filterTableFilterButton; + IBOutlet NSButton *filterTableClearButton; + IBOutlet SPTextView *filterTableWhereClause; + MCPConnection *mySQLConnection; BOOL _mainNibLoaded; @@ -76,6 +82,7 @@ NSString *selectedTable, *usedQuery; SPDataStorage *tableValues; NSMutableArray *dataColumns, *keys, *oldRow; + NSMutableDictionary *filterTableData; NSUInteger tableRowsCount, previousTableRowsCount; NSString *compareType; NSNumber *sortCol; @@ -143,6 +150,11 @@ - (IBAction)copyRow:(id)sender; - (IBAction)removeRow:(id)sender; +// Filter Table +- (IBAction)tableFilterExecute:(id)sender; +- (IBAction)tableFilterClear:(id)sender; +- (IBAction)showTableFilter:(id)sender; + // Getter methods - (NSArray *)currentResult; - (NSArray *)currentDataResult; @@ -191,4 +203,6 @@ - (NSArray*)fieldEditStatusForRow:(NSInteger)rowIndex andColumn:(NSInteger)columnIndex; +- (void)updateFilterTableClause; + @end diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m index 59a9e8c4..b7bcd0f9 100644 --- a/Source/SPTableContent.m +++ b/Source/SPTableContent.m @@ -68,8 +68,9 @@ tableValues = [[SPDataStorage alloc] init]; tableRowsCount = 0; previousTableRowsCount = 0; - dataColumns = [[NSMutableArray alloc] init]; - oldRow = [[NSMutableArray alloc] init]; + dataColumns = [[NSMutableArray alloc] init]; + oldRow = [[NSMutableArray alloc] init]; + filterTableData = [[NSMutableDictionary alloc] initWithCapacity:1]; selectedTable = nil; sortCol = nil; @@ -265,7 +266,7 @@ NSNumber *colWidth, *sortColumnNumberToRestore = nil; NSArray *columnNames; NSDictionary *columnDefinition; - NSTableColumn *theCol; + NSTableColumn *theCol, *filterCol; BOOL enableInteraction = ![[tableDocumentInstance selectedToolbarItemIdentifier] isEqualToString:SPMainToolbarTableContent] || ![tableDocumentInstance isWorking]; if (!tableDetails) { @@ -368,6 +369,10 @@ while ([[tableContentView tableColumns] count]) { [tableContentView removeTableColumn:NSArrayObjectAtIndex([tableContentView tableColumns], 0)]; } + while ([[filterTableView tableColumns] count]) { + [filterTableView removeTableColumn:NSArrayObjectAtIndex([filterTableView tableColumns], 0)]; + } + [filterTableData removeAllObjects]; // Retrieve the field names and types for this table from the data cache. This is used when requesting all data as part // of the fieldListForQuery method, and also to decide whether or not to preserve the current filter/sort settings. @@ -398,7 +403,7 @@ NSFont *tableFont = [NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPGlobalResultTableFont]]; [tableContentView setRowHeight:2.0f+NSSizeToCGSize([[NSString stringWithString:@"{ǞṶḹÜ∑zgyf"] sizeWithAttributes:[NSDictionary dictionaryWithObject:tableFont forKey:NSFontAttributeName]]).height]; - // Add the new columns to the table + // Add the new columns to the table and filterTable for ( i = 0 ; i < [dataColumns count] ; i++ ) { columnDefinition = NSArrayObjectAtIndex(dataColumns, i); @@ -407,6 +412,22 @@ [[theCol headerCell] setStringValue:[columnDefinition objectForKey:@"name"]]; [theCol setEditable:YES]; + // Set up column for filterTable + filterCol = [[NSTableColumn alloc] initWithIdentifier:[columnDefinition objectForKey:@"datacolumnindex"]]; + [[filterCol headerCell] setStringValue:[columnDefinition objectForKey:@"name"]]; + [filterCol setEditable:YES]; + SPTextAndLinkCell *filterDataCell = [[[SPTextAndLinkCell alloc] initTextCell:@""] autorelease]; + [filterDataCell setEditable:YES]; + [filterCol setDataCell:filterDataCell]; + [filterTableView addTableColumn:filterCol]; + [filterCol release]; + + [filterTableData setObject:[NSMutableDictionary dictionaryWithObjectsAndKeys: + [columnDefinition objectForKey:@"name"], @"name", + [columnDefinition objectForKey:@"typegrouping"], @"typegrouping", + [NSMutableArray arrayWithObjects:@"", @"", @"", @"", @"", @"", @"", @"", @"", @"", nil], @"filter", + nil] forKey:[columnDefinition objectForKey:@"datacolumnindex"]]; + // Set up the data cell depending on the column type id dataCell; if ([[columnDefinition objectForKey:@"typegrouping"] isEqualToString:@"enum"]) { @@ -466,6 +487,9 @@ [theCol release]; } + [filterTableView setDelegate:self]; + [filterTableView setDataSource:self]; + // If the table has been reloaded and the previously selected sort column is still present, reselect it. if (sortColumnNumberToRestore) { theCol = [tableContentView tableColumnWithIdentifier:sortColumnNumberToRestore]; @@ -542,6 +566,7 @@ if (!previousTableRowsCount) { [self clearTableValues]; } + [filterTableView reloadData]; } @@ -2772,6 +2797,31 @@ [error objectAtIndex:1]); } +#pragma mark - +#pragma mark Filter Table + +- (IBAction)tableFilterExecute:(id)sender +{ + +} + +- (IBAction)tableFilterClear:(id)sender +{ + + for(NSNumber *col in [filterTableData allKeys]) + [[filterTableData objectForKey:col] setObject:[NSMutableArray arrayWithObjects:@"", @"", @"", @"", @"", @"", @"", @"", @"", @"", nil] forKey:@"filter"]; + + [filterTableView reloadData]; + [filterTableView selectRowIndexes:[NSIndexSet indexSetWithIndex:0] byExtendingSelection:NO]; + [filterTableWhereClause setString:@""]; + +} + +- (IBAction)showTableFilter:(id)sender +{ + [filterTableWindow makeKeyAndOrderFront:nil]; +} + #pragma mark - #pragma mark Retrieving and setting table state @@ -3069,82 +3119,100 @@ - (NSString *)tableView:(NSTableView *)aTableView toolTipForCell:(SPTextAndLinkCell *)aCell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)row mouseLocation:(NSPoint)mouseLocation { - if([[aCell stringValue] length] < 2 || [tableDocumentInstance isWorking]) return nil; + if(aTableView == filterTableView) { + return nil; + } + else if(aTableView == tableContentView) { - NSImage *image; + if([[aCell stringValue] length] < 2 || [tableDocumentInstance isWorking]) return nil; - NSPoint pos = [NSEvent mouseLocation]; - pos.y -= 20; + NSImage *image; - // Try to get the original data. If not possible return nil. - // @try clause is used due to the multifarious cases of - // possible exceptions (eg for reloading tables etc.) - id theValue; - @try{ - theValue = [tableValues cellDataAtRow:row column:[[aTableColumn identifier] integerValue]]; - } - @catch(id ae) { - return nil; - } + NSPoint pos = [NSEvent mouseLocation]; + pos.y -= 20; - // Get the original data for trying to display the blob data as an image - if ([theValue isKindOfClass:[NSData class]]) { - image = [[[NSImage alloc] initWithData:theValue] autorelease]; - if(image) { - [SPTooltip showWithObject:image atLocation:pos ofType:@"image"]; + // Try to get the original data. If not possible return nil. + // @try clause is used due to the multifarious cases of + // possible exceptions (eg for reloading tables etc.) + id theValue; + @try{ + theValue = [tableValues cellDataAtRow:row column:[[aTableColumn identifier] integerValue]]; + } + @catch(id ae) { return nil; } - } - // Show the cell string value as tooltip (including line breaks and tabs) - // by using the cell's font - [SPTooltip showWithObject:[aCell stringValue] - atLocation:pos - ofType:@"text" - displayOptions:[NSDictionary dictionaryWithObjectsAndKeys: - [[aCell font] familyName], @"fontname", - [NSString stringWithFormat:@"%f",[[aCell font] pointSize]], @"fontsize", - nil]]; + // Get the original data for trying to display the blob data as an image + if ([theValue isKindOfClass:[NSData class]]) { + image = [[[NSImage alloc] initWithData:theValue] autorelease]; + if(image) { + [SPTooltip showWithObject:image atLocation:pos ofType:@"image"]; + return nil; + } + } + + // Show the cell string value as tooltip (including line breaks and tabs) + // by using the cell's font + [SPTooltip showWithObject:[aCell stringValue] + atLocation:pos + ofType:@"text" + displayOptions:[NSDictionary dictionaryWithObjectsAndKeys: + [[aCell font] familyName], @"fontname", + [NSString stringWithFormat:@"%f",[[aCell font] pointSize]], @"fontsize", + nil]]; - return nil; + return nil; + } } -- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView +- (NSInteger)numberOfRowsInTableView:(SPCopyTable *)aTableView { - return tableRowsCount; + if(aTableView == filterTableView) { + return [[[filterTableData objectForKey:[NSNumber numberWithInteger:0]] objectForKey:@"filter"] count]; + } + else if(aTableView == tableContentView) { + return tableRowsCount; + } } - (id)tableView:(SPCopyTable *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex { - NSUInteger columnIndex = [[aTableColumn identifier] integerValue]; - id theValue = nil; - - // While the table is being loaded, additional validation is required - data - // locks must be used to avoid crashes, and indexes higher than the available - // rows or columns may be requested. Return "..." to indicate loading in these - // cases. - if (isWorking) { - pthread_mutex_lock(&tableValuesLock); - if (rowIndex < tableRowsCount && columnIndex < [tableValues columnCount]) { - theValue = [[SPDataStorageObjectAtRowAndColumn(tableValues, rowIndex, columnIndex) copy] autorelease]; - } - pthread_mutex_unlock(&tableValuesLock); - if (!theValue) return @"..."; - } else { - theValue = SPDataStorageObjectAtRowAndColumn(tableValues, rowIndex, columnIndex); + if(aTableView == filterTableView) { + return NSArrayObjectAtIndex([[filterTableData objectForKey:[aTableColumn identifier]] objectForKey:@"filter"], rowIndex); } + else if(aTableView == tableContentView) { + + NSUInteger columnIndex = [[aTableColumn identifier] integerValue]; + id theValue = nil; + + // While the table is being loaded, additional validation is required - data + // locks must be used to avoid crashes, and indexes higher than the available + // rows or columns may be requested. Return "..." to indicate loading in these + // cases. + if (isWorking) { + pthread_mutex_lock(&tableValuesLock); + if (rowIndex < tableRowsCount && columnIndex < [tableValues columnCount]) { + theValue = [[SPDataStorageObjectAtRowAndColumn(tableValues, rowIndex, columnIndex) copy] autorelease]; + } + pthread_mutex_unlock(&tableValuesLock); + + if (!theValue) return @"..."; + } else { + theValue = SPDataStorageObjectAtRowAndColumn(tableValues, rowIndex, columnIndex); + } - if ([theValue isNSNull]) - return [prefs objectForKey:SPNullValue]; + if ([theValue isNSNull]) + return [prefs objectForKey:SPNullValue]; - if ([theValue isKindOfClass:[NSData class]]) - return [theValue shortStringRepresentationUsingEncoding:[mySQLConnection stringEncoding]]; + if ([theValue isKindOfClass:[NSData class]]) + return [theValue shortStringRepresentationUsingEncoding:[mySQLConnection stringEncoding]]; - if ([theValue isSPNotLoaded]) - return NSLocalizedString(@"(not loaded)", @"value shown for hidden blob and text fields"); + if ([theValue isSPNotLoaded]) + return NSLocalizedString(@"(not loaded)", @"value shown for hidden blob and text fields"); - return theValue; + return theValue; + } } /** @@ -3152,199 +3220,212 @@ */ - (void)tableView:(SPCopyTable *)aTableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn*)aTableColumn row:(NSInteger)rowIndex { - if (![cell respondsToSelector:@selector(setTextColor:)]) return; - NSUInteger columnIndex = [[aTableColumn identifier] integerValue]; - id theValue = nil; + if(aTableView == filterTableView) { + return; + } + else if(aTableView == tableContentView) { - // While the table is being loaded, additional validation is required - data - // locks must be used to avoid crashes, and indexes higher than the available - // rows or columns may be requested. Use gray to indicate loading in these cases. - if (isWorking) { - pthread_mutex_lock(&tableValuesLock); - if (rowIndex < tableRowsCount && columnIndex < [tableValues columnCount]) { + if (![cell respondsToSelector:@selector(setTextColor:)]) return; + + NSUInteger columnIndex = [[aTableColumn identifier] integerValue]; + id theValue = nil; + + // While the table is being loaded, additional validation is required - data + // locks must be used to avoid crashes, and indexes higher than the available + // rows or columns may be requested. Use gray to indicate loading in these cases. + if (isWorking) { + pthread_mutex_lock(&tableValuesLock); + if (rowIndex < tableRowsCount && columnIndex < [tableValues columnCount]) { + theValue = SPDataStorageObjectAtRowAndColumn(tableValues, rowIndex, columnIndex); + } + pthread_mutex_unlock(&tableValuesLock); + + if (!theValue) { + [cell setTextColor:[NSColor lightGrayColor]]; + return; + } + } else { theValue = SPDataStorageObjectAtRowAndColumn(tableValues, rowIndex, columnIndex); } - pthread_mutex_unlock(&tableValuesLock); - if (!theValue) { - [cell setTextColor:[NSColor lightGrayColor]]; + // If user wants to edit 'cell' set text color to black and return to avoid + // writing in gray if value was NULL + if ([aTableView editedColumn] != -1 + && [aTableView editedRow] == rowIndex + && [[NSArrayObjectAtIndex([aTableView tableColumns], [aTableView editedColumn]) identifier] integerValue] == columnIndex) { + [cell setTextColor:[NSColor blackColor]]; return; } - } else { - theValue = SPDataStorageObjectAtRowAndColumn(tableValues, rowIndex, columnIndex); - } - - // If user wants to edit 'cell' set text color to black and return to avoid - // writing in gray if value was NULL - if ([aTableView editedColumn] != -1 - && [aTableView editedRow] == rowIndex - && [[NSArrayObjectAtIndex([aTableView tableColumns], [aTableView editedColumn]) identifier] integerValue] == columnIndex) { - [cell setTextColor:[NSColor blackColor]]; - return; - } - // For null cells and not loaded cells, display the contents in gray. - if ([theValue isNSNull] || [theValue isSPNotLoaded]) { - [cell setTextColor:[NSColor lightGrayColor]]; + // For null cells and not loaded cells, display the contents in gray. + if ([theValue isNSNull] || [theValue isSPNotLoaded]) { + [cell setTextColor:[NSColor lightGrayColor]]; - // Otherwise, set the color to black - required as NSTableView reuses NSCells. - } else { - [cell setTextColor:[NSColor blackColor]]; + // Otherwise, set the color to black - required as NSTableView reuses NSCells. + } else { + [cell setTextColor:[NSColor blackColor]]; + } } } - (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex { + if(aTableView == filterTableView) { + [[[filterTableData objectForKey:[aTableColumn identifier]] objectForKey:@"filter"] replaceObjectAtIndex:rowIndex withObject:(NSString*)anObject]; + [self updateFilterTableClause]; + return; + } + else if(aTableView == tableContentView) { + // If table data come from a view + if([tablesListInstance tableType] == SPTableTypeView) { - // If table data come from a view - if([tablesListInstance tableType] == SPTableTypeView) { - - // Field editing - // if (fieldIDQueryString == nil) return; - NSDictionary *columnDefinition; + // Field editing + // if (fieldIDQueryString == nil) return; + NSDictionary *columnDefinition; - // Retrieve the column defintion - for(id c in cqColumnDefinition) { - if([[c objectForKey:@"datacolumnindex"] isEqualToNumber:[aTableColumn identifier]]) { - columnDefinition = [NSDictionary dictionaryWithDictionary:c]; - break; + // Retrieve the column defintion + for(id c in cqColumnDefinition) { + if([[c objectForKey:@"datacolumnindex"] isEqualToNumber:[aTableColumn identifier]]) { + columnDefinition = [NSDictionary dictionaryWithDictionary:c]; + break; + } } - } - // Resolve the original table name for current column if AS was used - NSString *tableForColumn = [columnDefinition objectForKey:@"org_table"]; + // Resolve the original table name for current column if AS was used + NSString *tableForColumn = [columnDefinition objectForKey:@"org_table"]; - if(!tableForColumn || ![tableForColumn length]) { - NSPoint pos = [NSEvent mouseLocation]; - pos.y -= 20; - [SPTooltip showWithObject:NSLocalizedString(@"Field is not editable. Field has no or multiple table or database origin(s).",@"field is not editable due to no table/database") - atLocation:pos - ofType:@"text"]; - NSBeep(); - return; - } + if(!tableForColumn || ![tableForColumn length]) { + NSPoint pos = [NSEvent mouseLocation]; + pos.y -= 20; + [SPTooltip showWithObject:NSLocalizedString(@"Field is not editable. Field has no or multiple table or database origin(s).",@"field is not editable due to no table/database") + atLocation:pos + ofType:@"text"]; + NSBeep(); + return; + } - // Resolve the original column name if AS was used - NSString *columnName = [columnDefinition objectForKey:@"org_name"]; + // Resolve the original column name if AS was used + NSString *columnName = [columnDefinition objectForKey:@"org_name"]; - [tableDocumentInstance startTaskWithDescription:NSLocalizedString(@"Updating field data...", @"updating field task description")]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryWillBePerformed" object:tableDocumentInstance]; + [tableDocumentInstance startTaskWithDescription:NSLocalizedString(@"Updating field data...", @"updating field task description")]; + [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryWillBePerformed" object:tableDocumentInstance]; - [self storeCurrentDetailsForRestoration]; + [self storeCurrentDetailsForRestoration]; - // Check if the IDstring identifies the current field bijectively and get the WHERE clause - NSArray *editStatus = [self fieldEditStatusForRow:rowIndex andColumn:[aTableColumn identifier]]; - NSString *fieldIDQueryStr = [editStatus objectAtIndex:1]; - NSInteger numberOfPossibleUpdateRows = [[editStatus objectAtIndex:0] integerValue]; + // Check if the IDstring identifies the current field bijectively and get the WHERE clause + NSArray *editStatus = [self fieldEditStatusForRow:rowIndex andColumn:[aTableColumn identifier]]; + NSString *fieldIDQueryStr = [editStatus objectAtIndex:1]; + NSInteger numberOfPossibleUpdateRows = [[editStatus objectAtIndex:0] integerValue]; - if(numberOfPossibleUpdateRows == 1) { + if(numberOfPossibleUpdateRows == 1) { - NSString *newObject = nil; - if ( [anObject isKindOfClass:[NSCalendarDate class]] ) { - newObject = [NSString stringWithFormat:@"'%@'", [mySQLConnection prepareString:[anObject description]]]; - } else if ( [anObject isKindOfClass:[NSNumber class]] ) { - newObject = [anObject stringValue]; - } else if ( [anObject isKindOfClass:[NSData class]] ) { - newObject = [NSString stringWithFormat:@"X'%@'", [mySQLConnection prepareBinaryData:anObject]]; - } else { - if ( [[anObject description] isEqualToString:@"CURRENT_TIMESTAMP"] ) { - newObject = @"CURRENT_TIMESTAMP"; - } else if([anObject isEqualToString:[prefs stringForKey:SPNullValue]]) { - newObject = @"NULL"; - } else if ([[columnDefinition objectForKey:@"typegrouping"] isEqualToString:@"bit"]) { - newObject = [NSString stringWithFormat:@"b'%@'", ((![[anObject description] length] || [[anObject description] isEqualToString:@"0"]) ? @"0" : [anObject description])]; - } else if ([[columnDefinition objectForKey:@"typegrouping"] isEqualToString:@"date"] - && [[anObject description] isEqualToString:@"NOW()"]) { - newObject = @"NOW()"; - } else { + NSString *newObject = nil; + if ( [anObject isKindOfClass:[NSCalendarDate class]] ) { newObject = [NSString stringWithFormat:@"'%@'", [mySQLConnection prepareString:[anObject description]]]; + } else if ( [anObject isKindOfClass:[NSNumber class]] ) { + newObject = [anObject stringValue]; + } else if ( [anObject isKindOfClass:[NSData class]] ) { + newObject = [NSString stringWithFormat:@"X'%@'", [mySQLConnection prepareBinaryData:anObject]]; + } else { + if ( [[anObject description] isEqualToString:@"CURRENT_TIMESTAMP"] ) { + newObject = @"CURRENT_TIMESTAMP"; + } else if([anObject isEqualToString:[prefs stringForKey:SPNullValue]]) { + newObject = @"NULL"; + } else if ([[columnDefinition objectForKey:@"typegrouping"] isEqualToString:@"bit"]) { + newObject = [NSString stringWithFormat:@"b'%@'", ((![[anObject description] length] || [[anObject description] isEqualToString:@"0"]) ? @"0" : [anObject description])]; + } else if ([[columnDefinition objectForKey:@"typegrouping"] isEqualToString:@"date"] + && [[anObject description] isEqualToString:@"NOW()"]) { + newObject = @"NOW()"; + } else { + newObject = [NSString stringWithFormat:@"'%@'", [mySQLConnection prepareString:[anObject description]]]; + } } - } - [mySQLConnection queryString: - [NSString stringWithFormat:@"UPDATE %@.%@ SET %@.%@.%@ = %@ %@ LIMIT 1", - [[columnDefinition objectForKey:@"db"] backtickQuotedString], [tableForColumn backtickQuotedString], - [[columnDefinition objectForKey:@"db"] backtickQuotedString], [tableForColumn backtickQuotedString], [columnName backtickQuotedString], newObject, fieldIDQueryStr]]; + [mySQLConnection queryString: + [NSString stringWithFormat:@"UPDATE %@.%@ SET %@.%@.%@ = %@ %@ LIMIT 1", + [[columnDefinition objectForKey:@"db"] backtickQuotedString], [tableForColumn backtickQuotedString], + [[columnDefinition objectForKey:@"db"] backtickQuotedString], [tableForColumn backtickQuotedString], [columnName backtickQuotedString], newObject, fieldIDQueryStr]]; - // Check for errors while UPDATE - if ([mySQLConnection queryErrored]) { - SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), NSLocalizedString(@"Cancel", @"cancel button"), nil, [tableDocumentInstance parentWindow], self, nil, nil, - [NSString stringWithFormat:NSLocalizedString(@"Couldn't write field.\nMySQL said: %@", @"message of panel when error while updating field to db"), [mySQLConnection getLastErrorMessage]]); + // Check for errors while UPDATE + if ([mySQLConnection queryErrored]) { + SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), NSLocalizedString(@"Cancel", @"cancel button"), nil, [tableDocumentInstance parentWindow], self, nil, nil, + [NSString stringWithFormat:NSLocalizedString(@"Couldn't write field.\nMySQL said: %@", @"message of panel when error while updating field to db"), [mySQLConnection getLastErrorMessage]]); - [tableDocumentInstance endTask]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:tableDocumentInstance]; - return; - } + [tableDocumentInstance endTask]; + [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:tableDocumentInstance]; + return; + } - // This shouldn't happen – for safety reasons - if ( ![mySQLConnection affectedRows] ) { - if ( [prefs boolForKey:SPShowNoAffectedRowsError] ) { - SPBeginAlertSheet(NSLocalizedString(@"Warning", @"warning"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [tableDocumentInstance parentWindow], self, nil, nil, - NSLocalizedString(@"The row was not written to the MySQL database. You probably haven't changed anything.\nReload the table to be sure that the row exists and use a primary key for your table.\n(This error can be turned off in the preferences.)", @"message of panel when no rows have been affected after writing to the db")); - } else { - NSBeep(); + // This shouldn't happen – for safety reasons + if ( ![mySQLConnection affectedRows] ) { + if ( [prefs boolForKey:SPShowNoAffectedRowsError] ) { + SPBeginAlertSheet(NSLocalizedString(@"Warning", @"warning"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [tableDocumentInstance parentWindow], self, nil, nil, + NSLocalizedString(@"The row was not written to the MySQL database. You probably haven't changed anything.\nReload the table to be sure that the row exists and use a primary key for your table.\n(This error can be turned off in the preferences.)", @"message of panel when no rows have been affected after writing to the db")); + } else { + NSBeep(); + } + [tableDocumentInstance endTask]; + [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:tableDocumentInstance]; + return; } - [tableDocumentInstance endTask]; + + } else { + SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [tableDocumentInstance parentWindow], self, nil, nil, + [NSString stringWithFormat:NSLocalizedString(@"Updating field content failed. Couldn't identify field origin unambiguously (%ld match%@). It's very likely that while editing this field the table `%@` was changed by an other user.", @"message of panel when error while updating field to db after enabling it"), + (long)numberOfPossibleUpdateRows, (numberOfPossibleUpdateRows>1)?@"es":@"", tableForColumn]); + [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:tableDocumentInstance]; + [tableDocumentInstance endTask]; return; + } - } else { - SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [tableDocumentInstance parentWindow], self, nil, nil, - [NSString stringWithFormat:NSLocalizedString(@"Updating field content failed. Couldn't identify field origin unambiguously (%ld match%@). It's very likely that while editing this field the table `%@` was changed by an other user.", @"message of panel when error while updating field to db after enabling it"), - (long)numberOfPossibleUpdateRows, (numberOfPossibleUpdateRows>1)?@"es":@"", tableForColumn]); + // Reload table after each editing due to complex declarations + if(isFirstChangeInView) { + // Set up the table details for the new table, and trigger an interface update + // if the view was modified for the very first time + NSDictionary *tableDetails = [NSDictionary dictionaryWithObjectsAndKeys: + tableForColumn, @"name", + [tableDataInstance columns], @"columns", + [tableDataInstance columnNames], @"columnNames", + [tableDataInstance getConstraints], @"constraints", + nil]; + [self performSelectorOnMainThread:@selector(setTableDetails:) withObject:tableDetails waitUntilDone:YES]; + isFirstChangeInView = NO; + } [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:tableDocumentInstance]; [tableDocumentInstance endTask]; - return; - } + [self loadTableValues]; + return; - // Reload table after each editing due to complex declarations - if(isFirstChangeInView) { - // Set up the table details for the new table, and trigger an interface update - // if the view was modified for the very first time - NSDictionary *tableDetails = [NSDictionary dictionaryWithObjectsAndKeys: - tableForColumn, @"name", - [tableDataInstance columns], @"columns", - [tableDataInstance columnNames], @"columnNames", - [tableDataInstance getConstraints], @"constraints", - nil]; - [self performSelectorOnMainThread:@selector(setTableDetails:) withObject:tableDetails waitUntilDone:YES]; - isFirstChangeInView = NO; } - [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:tableDocumentInstance]; - [tableDocumentInstance endTask]; - - [self loadTableValues]; - - return; - - } - // Catch editing events in the row and if the row isn't currently being edited, - // start an edit. This allows edits including enum changes to save correctly. - if ( !isEditingRow ) { - [oldRow setArray:[tableValues rowContentsAtIndex:rowIndex]]; - isEditingRow = YES; - currentlyEditingRow = rowIndex; - } + // Catch editing events in the row and if the row isn't currently being edited, + // start an edit. This allows edits including enum changes to save correctly. + if ( !isEditingRow ) { + [oldRow setArray:[tableValues rowContentsAtIndex:rowIndex]]; + isEditingRow = YES; + currentlyEditingRow = rowIndex; + } - NSDictionary *column = NSArrayObjectAtIndex(dataColumns, [[aTableColumn identifier] integerValue]); + NSDictionary *column = NSArrayObjectAtIndex(dataColumns, [[aTableColumn identifier] integerValue]); - if (anObject) { + if (anObject) { - // Restore NULLs if necessary - if ([anObject isEqualToString:[prefs objectForKey:SPNullValue]] && [[column objectForKey:@"null"] boolValue]) - anObject = [NSNull null]; + // Restore NULLs if necessary + if ([anObject isEqualToString:[prefs objectForKey:SPNullValue]] && [[column objectForKey:@"null"] boolValue]) + anObject = [NSNull null]; - [tableValues replaceObjectInRow:rowIndex column:[[aTableColumn identifier] integerValue] withObject:anObject]; - } else { - [tableValues replaceObjectInRow:rowIndex column:[[aTableColumn identifier] integerValue] withObject:@""]; + [tableValues replaceObjectInRow:rowIndex column:[[aTableColumn identifier] integerValue] withObject:anObject]; + } else { + [tableValues replaceObjectInRow:rowIndex column:[[aTableColumn identifier] integerValue] withObject:@""]; + } } } @@ -3359,7 +3440,7 @@ - (void)tableView:(NSTableView*)tableView didClickTableColumn:(NSTableColumn *)tableColumn { - if ( [selectedTable isEqualToString:@""] || !selectedTable ) + if ( [selectedTable isEqualToString:@""] || !selectedTable || tableView != tableContentView ) return; // Prevent sorting while the table is still loading @@ -3373,6 +3454,7 @@ [self sortTableTaskWithColumn:tableColumn]; } } + - (void)sortTableTaskWithColumn:(NSTableColumn *)tableColumn { NSAutoreleasePool *sortPool = [[NSAutoreleasePool alloc] init]; @@ -3434,14 +3516,14 @@ - (void)tableViewSelectionDidChange:(NSNotification *)aNotification { - isFirstChangeInView = YES; + // Check our notification object is our table content view + if ([aNotification object] != tableContentView) return; - [addButton setEnabled:([tablesListInstance tableType] == SPTableTypeTable)]; + isFirstChangeInView = YES; - // Check our notification object is our table content view - if ([aNotification object] != tableContentView) return; + [addButton setEnabled:([tablesListInstance tableType] == SPTableTypeTable)]; // If we are editing a row, attempt to save that row - if saving failed, reselect the edit row. if (isEditingRow && [tableContentView selectedRow] != currentlyEditingRow && ![self saveRowOnDeselect]) return; @@ -3467,11 +3549,15 @@ [self updateCountText]; } -- (void)tableViewColumnDidResize:(NSNotification *)aNotification /** saves the new column size in the preferences */ +- (void)tableViewColumnDidResize:(NSNotification *)aNotification { + + // Check our notification object is our table content view + if ([aNotification object] != tableContentView) return; + // sometimes the column has no identifier. I can't figure out what is causing it, so we just skip over this item if (![[[aNotification userInfo] objectForKey:@"NSTableColumn"] identifier]) return; @@ -3666,7 +3752,14 @@ */ - (BOOL)tableView:(NSTableView *)aTableView shouldSelectRow:(NSInteger)rowIndex { - return tableRowsSelectable; + + if(aTableView == filterTableView) + return YES; + else if(aTableView == tableContentView) + return tableRowsSelectable; + else + return YES; + } /** @@ -3674,6 +3767,7 @@ */ - (CGFloat)tableView:(NSTableView *)tableView sizeToFitWidthOfColumn:(NSInteger)columnIndex { + NSTableColumn *theColumn = [[tableView tableColumns] objectAtIndex:columnIndex]; NSDictionary *columnDefinition = [dataColumns objectAtIndex:[[theColumn identifier] integerValue]]; @@ -3779,6 +3873,12 @@ #pragma mark - #pragma mark Other methods +- (void)controlTextDidChange:(NSNotification *)notification +{ + if ([notification object] == filterTableView) { + [self updateFilterTableClause]; + } +} /** * If user selected a table cell which is a blob field and tried to edit it * cancel the fieldEditor, display the field editor sheet instead for editing @@ -3787,6 +3887,8 @@ - (BOOL)control:(NSControl *)control textShouldBeginEditing:(NSText *)fieldEditor { + if(control != tableContentView) return YES; + NSUInteger row, column; BOOL shouldBeginEditing = YES; @@ -3859,18 +3961,19 @@ { // Check firstly if SPCopyTable can handle command - if([tableContentView control:control textView:textView doCommandBySelector:(SEL)command]) + if([control control:control textView:textView doCommandBySelector:(SEL)command]) return YES; // Trap the escape key if ( [[control window] methodForSelector:command] == [[control window] methodForSelector:@selector(cancelOperation:)] ) { - NSUInteger row = [tableContentView editedRow]; + NSUInteger row = [control editedRow]; // Abort editing [control abortEditing]; - [self cancelRowEditing]; + if(control == tableContentView) + [self cancelRowEditing]; return TRUE; } @@ -3916,6 +4019,49 @@ return YES; } +/** + * Update WHERE clause in Filter Table Window - TODO not yet finished - initial approach only by HansJB + */ +- (void)updateFilterTableClause +{ + NSMutableString *clause = [NSMutableString string]; + NSInteger numberOfRows = [self numberOfRowsInTableView:filterTableView]; + NSInteger numberOfCols = [[filterTableView tableColumns] count]; + NSInteger numberOfValues = 0; + NSRange opRange; + for(NSInteger i=0; i"] || + [op isEqualToString:@"<"] || + [op isEqualToString:@"="]) { + [clause appendFormat:@"%@ %@ %@", [[filterCellData objectForKey:@"name"] backtickQuotedString], op, pattern]; + } + + } else { + [clause appendFormat:@"%@ LIKE '%%%@%%'", [[filterCellData objectForKey:@"name"] backtickQuotedString], filterCell]; + } + numberOfValues++; + } + } + if(numberOfValues) + [clause appendString:@"\nOR\n"]; + } + [filterTableWhereClause setString:[clause substringToIndex:([clause length]-4)]]; + [filterTableWhereClause insertText:@""]; + [filterTableWhereClause didChangeText]; + [filterTableWhereClause scrollRangeToVisible:NSMakeRange(0, 0)]; +} + /** * Makes the content filter field have focus by making it the first responder. */ @@ -3956,6 +4102,7 @@ pthread_mutex_destroy(&tableValuesLock); [dataColumns release]; [oldRow release]; + [filterTableData release]; if (selectedTable) [selectedTable release]; if (contentFilters) [contentFilters release]; if (numberOfDefaultFilters) [numberOfDefaultFilters release]; -- cgit v1.2.3