Add type column to query results outline view

This commit is contained in:
Shadowfacts 2020-01-12 11:05:01 -05:00
parent 8104853f13
commit 954b0bc8a6
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
3 changed files with 111 additions and 7 deletions

View File

@ -143,4 +143,68 @@ extension Node {
return "(max key)"
}
}
var typeString: String {
switch value {
case .double(_):
return "Double"
case .string(_):
return "String"
case .document(_):
return "Document"
case .array(_):
return "Array"
case let .binary(value):
switch Binary.Subtype(rawValue: value.subtype) {
case nil:
return "Unknown binary data"
case .generic:
return "Generic binary data"
case .function:
return "Function binary data"
case .binaryDeprecated:
return "Binary data"
case .uuidDeprecated:
fallthrough
case .uuid:
return "UUID"
case .md5:
return "MD5 hash"
case .userDefined:
return "User defined binary data"
}
case .undefined:
return "Undefined"
case .objectId(_):
return "ObjectId"
case .bool(_):
return "Bool"
case .datetime(_):
return "DateTime"
case .null:
return "Null"
case .regex(_):
return "RegEx"
case .dbPointer(_):
return "DBRef"
case .symbol(_):
return "Symbol"
case .code(_):
return "Code"
case .codeWithScope(_):
return "Code with scope"
case .int32(_):
return "Int32"
case .timestamp(_):
return "Timestamp"
case .int64(_):
return "Int64"
case .decimal128(_):
return "Decimal128"
case .minKey:
return "MinKey"
case .maxKey:
return "MaxKey"
}
}
}

View File

@ -154,6 +154,11 @@ extension QueryViewController: NSOutlineViewDelegate {
cell.textField!.stringValue = node.valueString
cell.textField!.isEditable = false
return cell
} else if tableColumn.identifier == .valueTypeColumn {
let cell = outlineView.makeView(withIdentifier: .valueTypeCell, owner: nil) as! NSTableCellView
cell.textField!.stringValue = node.typeString
cell.textField!.isEditable = false
return cell
} else {
return nil
}
@ -166,4 +171,6 @@ extension NSUserInterfaceItemIdentifier {
static let fieldValueColumn = NSUserInterfaceItemIdentifier(rawValue: "FieldValueCol")
static let fieldNameCell = NSUserInterfaceItemIdentifier(rawValue: "FieldNameCell")
static let fieldValueCell = NSUserInterfaceItemIdentifier(rawValue: "FieldValueCell")
static let valueTypeColumn = NSUserInterfaceItemIdentifier(rawValue: "ValueTypeCol")
static let valueTypeCell = NSUserInterfaceItemIdentifier(rawValue: "ValueTypeCell")
}

View File

@ -44,7 +44,7 @@
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
<size key="minSize" width="726" height="86"/>
<size key="maxSize" width="726" height="10000000"/>
<size key="maxSize" width="741" height="10000000"/>
<color key="insertionPointColor" name="textColor" catalog="System" colorSpace="catalog"/>
<allowedInputSourceLocales>
<string>eu</string>
@ -1004,7 +1004,7 @@
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
<tableColumns>
<tableColumn identifier="FieldNameCol" width="362" minWidth="40" maxWidth="1000" id="emg-oX-7XY">
<tableColumn identifier="FieldNameCol" width="339" minWidth="40" maxWidth="1000" id="emg-oX-7XY">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Field Name">
<font key="font" metaFont="controlContent" size="11"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
@ -1018,11 +1018,11 @@
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<prototypeCellViews>
<tableCellView identifier="FieldNameCell" id="8dc-a6-0k5">
<rect key="frame" x="1" y="1" width="362" height="17"/>
<rect key="frame" x="1" y="1" width="339" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="qEd-h6-M2A">
<rect key="frame" x="0.0" y="0.0" width="362" height="17"/>
<rect key="frame" x="0.0" y="0.0" width="339" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="8JQ-A4-jXh">
<font key="font" metaFont="system"/>
@ -1037,7 +1037,7 @@
</tableCellView>
</prototypeCellViews>
</tableColumn>
<tableColumn identifier="FieldValueCol" width="371" minWidth="40" maxWidth="1000" id="ggz-sp-EaO">
<tableColumn identifier="FieldValueCol" width="297" minWidth="40" maxWidth="1000" id="ggz-sp-EaO">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Field Value">
<font key="font" metaFont="controlContent" size="11"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
@ -1051,11 +1051,11 @@
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<prototypeCellViews>
<tableCellView identifier="FieldValueCell" id="E6Z-9f-0gg">
<rect key="frame" x="366" y="1" width="371" height="17"/>
<rect key="frame" x="343" y="1" width="297" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Px2-mb-c5m">
<rect key="frame" x="0.0" y="0.0" width="371" height="17"/>
<rect key="frame" x="0.0" y="0.0" width="297" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="rED-77-VFk">
<font key="font" metaFont="system"/>
@ -1070,6 +1070,39 @@
</tableCellView>
</prototypeCellViews>
</tableColumn>
<tableColumn identifier="ValueTypeCol" width="94" minWidth="10" maxWidth="3.4028234663852886e+38" id="Tow-Y6-pc7">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Value Type">
<font key="font" metaFont="controlContent" size="11"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</tableHeaderCell>
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" alignment="left" title="Text Cell" id="rKq-mL-SIz">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<prototypeCellViews>
<tableCellView identifier="ValueTypeCell" id="tUj-Jd-Rj1">
<rect key="frame" x="643" y="1" width="94" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="mBU-Qs-G4S">
<rect key="frame" x="0.0" y="0.0" width="94" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="tmE-QF-vUZ">
<font key="font" metaFont="system"/>
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
<connections>
<outlet property="textField" destination="mBU-Qs-G4S" id="XuA-aG-cGx"/>
</connections>
</tableCellView>
</prototypeCellViews>
</tableColumn>
</tableColumns>
</outlineView>
</subviews>