Browse Source

Add type column to query results outline view

master
Shadowfacts 5 months ago
parent
commit
954b0bc8a6
Signed by: Shadowfacts <me@shadowfacts.net> GPG Key ID: 94A5AB95422746E5

+ 64
- 0
MongoView/Node.swift View File

@@ -143,4 +143,68 @@ extension Node {
143 143
             return "(max key)"
144 144
         }
145 145
     }
146
+    
147
+    var typeString: String {
148
+        switch value {
149
+        case .double(_):
150
+            return "Double"
151
+        case .string(_):
152
+            return "String"
153
+        case .document(_):
154
+            return "Document"
155
+        case .array(_):
156
+            return "Array"
157
+        case let .binary(value):
158
+            switch Binary.Subtype(rawValue: value.subtype) {
159
+            case nil:
160
+                return "Unknown binary data"
161
+            case .generic:
162
+                return "Generic binary data"
163
+            case .function:
164
+                return "Function binary data"
165
+            case .binaryDeprecated:
166
+                return "Binary data"
167
+            case .uuidDeprecated:
168
+                fallthrough
169
+            case .uuid:
170
+                return "UUID"
171
+            case .md5:
172
+                return "MD5 hash"
173
+            case .userDefined:
174
+                return "User defined binary data"
175
+            }
176
+        case .undefined:
177
+            return "Undefined"
178
+        case .objectId(_):
179
+            return "ObjectId"
180
+        case .bool(_):
181
+            return "Bool"
182
+        case .datetime(_):
183
+            return "DateTime"
184
+        case .null:
185
+            return "Null"
186
+        case .regex(_):
187
+            return "RegEx"
188
+        case .dbPointer(_):
189
+            return "DBRef"
190
+        case .symbol(_):
191
+            return "Symbol"
192
+        case .code(_):
193
+            return "Code"
194
+        case .codeWithScope(_):
195
+            return "Code with scope"
196
+        case .int32(_):
197
+            return "Int32"
198
+        case .timestamp(_):
199
+            return "Timestamp"
200
+        case .int64(_):
201
+            return "Int64"
202
+        case .decimal128(_):
203
+            return "Decimal128"
204
+        case .minKey:
205
+            return "MinKey"
206
+        case .maxKey:
207
+            return "MaxKey"
208
+        }
209
+    }
146 210
 }

+ 7
- 0
MongoView/View Controllers/QueryViewController.swift View File

@@ -154,6 +154,11 @@ extension QueryViewController: NSOutlineViewDelegate {
154 154
             cell.textField!.stringValue = node.valueString
155 155
             cell.textField!.isEditable = false
156 156
             return cell
157
+        } else if tableColumn.identifier == .valueTypeColumn {
158
+            let cell = outlineView.makeView(withIdentifier: .valueTypeCell, owner: nil) as! NSTableCellView
159
+            cell.textField!.stringValue = node.typeString
160
+            cell.textField!.isEditable = false
161
+            return cell
157 162
         } else {
158 163
             return nil
159 164
         }
@@ -166,4 +171,6 @@ extension NSUserInterfaceItemIdentifier {
166 171
     static let fieldValueColumn = NSUserInterfaceItemIdentifier(rawValue: "FieldValueCol")
167 172
     static let fieldNameCell = NSUserInterfaceItemIdentifier(rawValue: "FieldNameCell")
168 173
     static let fieldValueCell = NSUserInterfaceItemIdentifier(rawValue: "FieldValueCell")
174
+    static let valueTypeColumn = NSUserInterfaceItemIdentifier(rawValue: "ValueTypeCol")
175
+    static let valueTypeCell = NSUserInterfaceItemIdentifier(rawValue: "ValueTypeCell")
169 176
 }

+ 40
- 7
MongoView/View Controllers/QueryViewController.xib View File

@@ -44,7 +44,7 @@
44 44
                                         <color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
45 45
                                         <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
46 46
                                         <size key="minSize" width="726" height="86"/>
47
-                                        <size key="maxSize" width="726" height="10000000"/>
47
+                                        <size key="maxSize" width="741" height="10000000"/>
48 48
                                         <color key="insertionPointColor" name="textColor" catalog="System" colorSpace="catalog"/>
49 49
                                         <allowedInputSourceLocales>
50 50
                                             <string>eu</string>
@@ -1004,7 +1004,7 @@
1004 1004
                                         <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
1005 1005
                                         <color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
1006 1006
                                         <tableColumns>
1007
-                                            <tableColumn identifier="FieldNameCol" width="362" minWidth="40" maxWidth="1000" id="emg-oX-7XY">
1007
+                                            <tableColumn identifier="FieldNameCol" width="339" minWidth="40" maxWidth="1000" id="emg-oX-7XY">
1008 1008
                                                 <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Field Name">
1009 1009
                                                     <font key="font" metaFont="controlContent" size="11"/>
1010 1010
                                                     <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
@@ -1018,11 +1018,11 @@
1018 1018
                                                 <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
1019 1019
                                                 <prototypeCellViews>
1020 1020
                                                     <tableCellView identifier="FieldNameCell" id="8dc-a6-0k5">
1021
-                                                        <rect key="frame" x="1" y="1" width="362" height="17"/>
1021
+                                                        <rect key="frame" x="1" y="1" width="339" height="17"/>
1022 1022
                                                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
1023 1023
                                                         <subviews>
1024 1024
                                                             <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="qEd-h6-M2A">
1025
-                                                                <rect key="frame" x="0.0" y="0.0" width="362" height="17"/>
1025
+                                                                <rect key="frame" x="0.0" y="0.0" width="339" height="17"/>
1026 1026
                                                                 <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
1027 1027
                                                                 <textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="8JQ-A4-jXh">
1028 1028
                                                                     <font key="font" metaFont="system"/>
@@ -1037,7 +1037,7 @@
1037 1037
                                                     </tableCellView>
1038 1038
                                                 </prototypeCellViews>
1039 1039
                                             </tableColumn>
1040
-                                            <tableColumn identifier="FieldValueCol" width="371" minWidth="40" maxWidth="1000" id="ggz-sp-EaO">
1040
+                                            <tableColumn identifier="FieldValueCol" width="297" minWidth="40" maxWidth="1000" id="ggz-sp-EaO">
1041 1041
                                                 <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Field Value">
1042 1042
                                                     <font key="font" metaFont="controlContent" size="11"/>
1043 1043
                                                     <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
@@ -1051,11 +1051,11 @@
1051 1051
                                                 <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
1052 1052
                                                 <prototypeCellViews>
1053 1053
                                                     <tableCellView identifier="FieldValueCell" id="E6Z-9f-0gg">
1054
-                                                        <rect key="frame" x="366" y="1" width="371" height="17"/>
1054
+                                                        <rect key="frame" x="343" y="1" width="297" height="17"/>
1055 1055
                                                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
1056 1056
                                                         <subviews>
1057 1057
                                                             <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Px2-mb-c5m">
1058
-                                                                <rect key="frame" x="0.0" y="0.0" width="371" height="17"/>
1058
+                                                                <rect key="frame" x="0.0" y="0.0" width="297" height="17"/>
1059 1059
                                                                 <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
1060 1060
                                                                 <textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="rED-77-VFk">
1061 1061
                                                                     <font key="font" metaFont="system"/>
@@ -1070,6 +1070,39 @@
1070 1070
                                                     </tableCellView>
1071 1071
                                                 </prototypeCellViews>
1072 1072
                                             </tableColumn>
1073
+                                            <tableColumn identifier="ValueTypeCol" width="94" minWidth="10" maxWidth="3.4028234663852886e+38" id="Tow-Y6-pc7">
1074
+                                                <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Value Type">
1075
+                                                    <font key="font" metaFont="controlContent" size="11"/>
1076
+                                                    <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
1077
+                                                    <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
1078
+                                                </tableHeaderCell>
1079
+                                                <textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" alignment="left" title="Text Cell" id="rKq-mL-SIz">
1080
+                                                    <font key="font" metaFont="system"/>
1081
+                                                    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
1082
+                                                    <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
1083
+                                                </textFieldCell>
1084
+                                                <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
1085
+                                                <prototypeCellViews>
1086
+                                                    <tableCellView identifier="ValueTypeCell" id="tUj-Jd-Rj1">
1087
+                                                        <rect key="frame" x="643" y="1" width="94" height="17"/>
1088
+                                                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
1089
+                                                        <subviews>
1090
+                                                            <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="mBU-Qs-G4S">
1091
+                                                                <rect key="frame" x="0.0" y="0.0" width="94" height="17"/>
1092
+                                                                <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
1093
+                                                                <textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="tmE-QF-vUZ">
1094
+                                                                    <font key="font" metaFont="system"/>
1095
+                                                                    <color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
1096
+                                                                    <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
1097
+                                                                </textFieldCell>
1098
+                                                            </textField>
1099
+                                                        </subviews>
1100
+                                                        <connections>
1101
+                                                            <outlet property="textField" destination="mBU-Qs-G4S" id="XuA-aG-cGx"/>
1102
+                                                        </connections>
1103
+                                                    </tableCellView>
1104
+                                                </prototypeCellViews>
1105
+                                            </tableColumn>
1073 1106
                                         </tableColumns>
1074 1107
                                     </outlineView>
1075 1108
                                 </subviews>

Loading…
Cancel
Save