Split DatabaseViewController into multiple VCs
This commit is contained in:
parent
edb01fa6e2
commit
54f8236332
|
@ -17,6 +17,12 @@
|
||||||
D626BF83243BD2EE0075117B /* EditDocumentWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = D626BF81243BD2EE0075117B /* EditDocumentWindowController.xib */; };
|
D626BF83243BD2EE0075117B /* EditDocumentWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = D626BF81243BD2EE0075117B /* EditDocumentWindowController.xib */; };
|
||||||
D626BF86243BE19A0075117B /* EditDocumentViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D626BF84243BE19A0075117B /* EditDocumentViewController.swift */; };
|
D626BF86243BE19A0075117B /* EditDocumentViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D626BF84243BE19A0075117B /* EditDocumentViewController.swift */; };
|
||||||
D626BF87243BE19A0075117B /* EditDocumentViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = D626BF85243BE19A0075117B /* EditDocumentViewController.xib */; };
|
D626BF87243BE19A0075117B /* EditDocumentViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = D626BF85243BE19A0075117B /* EditDocumentViewController.xib */; };
|
||||||
|
D627CE7E24E38F3B00C39FE5 /* MainSplitViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D627CE7C24E38F3A00C39FE5 /* MainSplitViewController.swift */; };
|
||||||
|
D627CE8224E38FBE00C39FE5 /* DatabaseCollectionListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D627CE8024E38FBE00C39FE5 /* DatabaseCollectionListViewController.swift */; };
|
||||||
|
D627CE8324E38FBE00C39FE5 /* DatabaseCollectionListViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = D627CE8124E38FBE00C39FE5 /* DatabaseCollectionListViewController.xib */; };
|
||||||
|
D627CE8824E399F100C39FE5 /* DetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D627CE8624E399F100C39FE5 /* DetailViewController.swift */; };
|
||||||
|
D627CE8924E399F100C39FE5 /* DetailViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = D627CE8724E399F100C39FE5 /* DetailViewController.xib */; };
|
||||||
|
D627CE8B24E438EE00C39FE5 /* DatabaseCollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = D627CE8A24E438EE00C39FE5 /* DatabaseCollection.swift */; };
|
||||||
D63CDEBE23C837DC0012D658 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D63CDEBD23C837DC0012D658 /* AppDelegate.swift */; };
|
D63CDEBE23C837DC0012D658 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D63CDEBD23C837DC0012D658 /* AppDelegate.swift */; };
|
||||||
D63CDEC023C837DD0012D658 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D63CDEBF23C837DD0012D658 /* Assets.xcassets */; };
|
D63CDEC023C837DD0012D658 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D63CDEBF23C837DD0012D658 /* Assets.xcassets */; };
|
||||||
D63CDEC323C837DD0012D658 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = D63CDEC123C837DD0012D658 /* MainMenu.xib */; };
|
D63CDEC323C837DD0012D658 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = D63CDEC123C837DD0012D658 /* MainMenu.xib */; };
|
||||||
|
@ -44,8 +50,6 @@
|
||||||
D63CDF3D23C838470012D658 /* DatabaseWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = D63CDF3B23C838470012D658 /* DatabaseWindowController.xib */; };
|
D63CDF3D23C838470012D658 /* DatabaseWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = D63CDF3B23C838470012D658 /* DatabaseWindowController.xib */; };
|
||||||
D63CDF4023C839010012D658 /* QueryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D63CDF3E23C839010012D658 /* QueryViewController.swift */; };
|
D63CDF4023C839010012D658 /* QueryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D63CDF3E23C839010012D658 /* QueryViewController.swift */; };
|
||||||
D63CDF4123C839010012D658 /* QueryViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = D63CDF3F23C839010012D658 /* QueryViewController.xib */; };
|
D63CDF4123C839010012D658 /* QueryViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = D63CDF3F23C839010012D658 /* QueryViewController.xib */; };
|
||||||
D63CDF4423C970C50012D658 /* DatabaseViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D63CDF4223C970C50012D658 /* DatabaseViewController.swift */; };
|
|
||||||
D63CDF4523C970C50012D658 /* DatabaseViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = D63CDF4323C970C50012D658 /* DatabaseViewController.xib */; };
|
|
||||||
D6A7D096243541A400B46857 /* WindowStatusView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6A7D095243541A400B46857 /* WindowStatusView.swift */; };
|
D6A7D096243541A400B46857 /* WindowStatusView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6A7D095243541A400B46857 /* WindowStatusView.swift */; };
|
||||||
D6A7D09A243546B500B46857 /* WindowStatusView.xib in Resources */ = {isa = PBXBuildFile; fileRef = D6A7D099243546B500B46857 /* WindowStatusView.xib */; };
|
D6A7D09A243546B500B46857 /* WindowStatusView.xib in Resources */ = {isa = PBXBuildFile; fileRef = D6A7D099243546B500B46857 /* WindowStatusView.xib */; };
|
||||||
D6A7D0A42435885B00B46857 /* JavaScriptHighlighter.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6A7D0A32435885B00B46857 /* JavaScriptHighlighter.swift */; };
|
D6A7D0A42435885B00B46857 /* JavaScriptHighlighter.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6A7D0A32435885B00B46857 /* JavaScriptHighlighter.swift */; };
|
||||||
|
@ -97,6 +101,12 @@
|
||||||
D626BF81243BD2EE0075117B /* EditDocumentWindowController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = EditDocumentWindowController.xib; sourceTree = "<group>"; };
|
D626BF81243BD2EE0075117B /* EditDocumentWindowController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = EditDocumentWindowController.xib; sourceTree = "<group>"; };
|
||||||
D626BF84243BE19A0075117B /* EditDocumentViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditDocumentViewController.swift; sourceTree = "<group>"; };
|
D626BF84243BE19A0075117B /* EditDocumentViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditDocumentViewController.swift; sourceTree = "<group>"; };
|
||||||
D626BF85243BE19A0075117B /* EditDocumentViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = EditDocumentViewController.xib; sourceTree = "<group>"; };
|
D626BF85243BE19A0075117B /* EditDocumentViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = EditDocumentViewController.xib; sourceTree = "<group>"; };
|
||||||
|
D627CE7C24E38F3A00C39FE5 /* MainSplitViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainSplitViewController.swift; sourceTree = "<group>"; };
|
||||||
|
D627CE8024E38FBE00C39FE5 /* DatabaseCollectionListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DatabaseCollectionListViewController.swift; sourceTree = "<group>"; };
|
||||||
|
D627CE8124E38FBE00C39FE5 /* DatabaseCollectionListViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = DatabaseCollectionListViewController.xib; sourceTree = "<group>"; };
|
||||||
|
D627CE8624E399F100C39FE5 /* DetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailViewController.swift; sourceTree = "<group>"; };
|
||||||
|
D627CE8724E399F100C39FE5 /* DetailViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = DetailViewController.xib; sourceTree = "<group>"; };
|
||||||
|
D627CE8A24E438EE00C39FE5 /* DatabaseCollection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DatabaseCollection.swift; sourceTree = "<group>"; };
|
||||||
D63CDEBA23C837DC0012D658 /* MongoView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MongoView.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
D63CDEBA23C837DC0012D658 /* MongoView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MongoView.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
D63CDEBD23C837DC0012D658 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
D63CDEBD23C837DC0012D658 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||||
D63CDEBF23C837DD0012D658 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
D63CDEBF23C837DD0012D658 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||||
|
@ -118,8 +128,6 @@
|
||||||
D63CDF3B23C838470012D658 /* DatabaseWindowController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = DatabaseWindowController.xib; sourceTree = "<group>"; };
|
D63CDF3B23C838470012D658 /* DatabaseWindowController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = DatabaseWindowController.xib; sourceTree = "<group>"; };
|
||||||
D63CDF3E23C839010012D658 /* QueryViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QueryViewController.swift; sourceTree = "<group>"; };
|
D63CDF3E23C839010012D658 /* QueryViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QueryViewController.swift; sourceTree = "<group>"; };
|
||||||
D63CDF3F23C839010012D658 /* QueryViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = QueryViewController.xib; sourceTree = "<group>"; };
|
D63CDF3F23C839010012D658 /* QueryViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = QueryViewController.xib; sourceTree = "<group>"; };
|
||||||
D63CDF4223C970C50012D658 /* DatabaseViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DatabaseViewController.swift; sourceTree = "<group>"; };
|
|
||||||
D63CDF4323C970C50012D658 /* DatabaseViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = DatabaseViewController.xib; sourceTree = "<group>"; };
|
|
||||||
D6A7D095243541A400B46857 /* WindowStatusView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WindowStatusView.swift; sourceTree = "<group>"; };
|
D6A7D095243541A400B46857 /* WindowStatusView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WindowStatusView.swift; sourceTree = "<group>"; };
|
||||||
D6A7D099243546B500B46857 /* WindowStatusView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = WindowStatusView.xib; sourceTree = "<group>"; };
|
D6A7D099243546B500B46857 /* WindowStatusView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = WindowStatusView.xib; sourceTree = "<group>"; };
|
||||||
D6A7D0A32435885B00B46857 /* JavaScriptHighlighter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JavaScriptHighlighter.swift; sourceTree = "<group>"; };
|
D6A7D0A32435885B00B46857 /* JavaScriptHighlighter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JavaScriptHighlighter.swift; sourceTree = "<group>"; };
|
||||||
|
@ -174,8 +182,11 @@
|
||||||
children = (
|
children = (
|
||||||
D60C863D23CA2E2100C9DB8E /* ServerConnectViewController.swift */,
|
D60C863D23CA2E2100C9DB8E /* ServerConnectViewController.swift */,
|
||||||
D60C863E23CA2E2100C9DB8E /* ServerConnectViewController.xib */,
|
D60C863E23CA2E2100C9DB8E /* ServerConnectViewController.xib */,
|
||||||
D63CDF4223C970C50012D658 /* DatabaseViewController.swift */,
|
D627CE7C24E38F3A00C39FE5 /* MainSplitViewController.swift */,
|
||||||
D63CDF4323C970C50012D658 /* DatabaseViewController.xib */,
|
D627CE8024E38FBE00C39FE5 /* DatabaseCollectionListViewController.swift */,
|
||||||
|
D627CE8124E38FBE00C39FE5 /* DatabaseCollectionListViewController.xib */,
|
||||||
|
D627CE8624E399F100C39FE5 /* DetailViewController.swift */,
|
||||||
|
D627CE8724E399F100C39FE5 /* DetailViewController.xib */,
|
||||||
D63CDF3E23C839010012D658 /* QueryViewController.swift */,
|
D63CDF3E23C839010012D658 /* QueryViewController.swift */,
|
||||||
D63CDF3F23C839010012D658 /* QueryViewController.xib */,
|
D63CDF3F23C839010012D658 /* QueryViewController.xib */,
|
||||||
D626BF84243BE19A0075117B /* EditDocumentViewController.swift */,
|
D626BF84243BE19A0075117B /* EditDocumentViewController.swift */,
|
||||||
|
@ -220,6 +231,7 @@
|
||||||
D63CDF3423C838190012D658 /* MongoController.swift */,
|
D63CDF3423C838190012D658 /* MongoController.swift */,
|
||||||
D6ABB01324B4DE7600F79DA8 /* StatusManager.swift */,
|
D6ABB01324B4DE7600F79DA8 /* StatusManager.swift */,
|
||||||
D63CDF3323C838190012D658 /* Node.swift */,
|
D63CDF3323C838190012D658 /* Node.swift */,
|
||||||
|
D627CE8A24E438EE00C39FE5 /* DatabaseCollection.swift */,
|
||||||
D6D4665223CB730C00F13B1B /* MongoEvaluator.swift */,
|
D6D4665223CB730C00F13B1B /* MongoEvaluator.swift */,
|
||||||
D624090E243903E90020E09F /* ExtendedJSON.swift */,
|
D624090E243903E90020E09F /* ExtendedJSON.swift */,
|
||||||
D6A7D0A22435880700B46857 /* Synax Highlighting */,
|
D6A7D0A22435880700B46857 /* Synax Highlighting */,
|
||||||
|
@ -350,9 +362,10 @@
|
||||||
D63CDEC023C837DD0012D658 /* Assets.xcassets in Resources */,
|
D63CDEC023C837DD0012D658 /* Assets.xcassets in Resources */,
|
||||||
D60C863A23CA2DD100C9DB8E /* ServerConnectWindowController.xib in Resources */,
|
D60C863A23CA2DD100C9DB8E /* ServerConnectWindowController.xib in Resources */,
|
||||||
D626BF87243BE19A0075117B /* EditDocumentViewController.xib in Resources */,
|
D626BF87243BE19A0075117B /* EditDocumentViewController.xib in Resources */,
|
||||||
D63CDF4523C970C50012D658 /* DatabaseViewController.xib in Resources */,
|
|
||||||
D6A7D09A243546B500B46857 /* WindowStatusView.xib in Resources */,
|
D6A7D09A243546B500B46857 /* WindowStatusView.xib in Resources */,
|
||||||
D63CDF3D23C838470012D658 /* DatabaseWindowController.xib in Resources */,
|
D63CDF3D23C838470012D658 /* DatabaseWindowController.xib in Resources */,
|
||||||
|
D627CE8924E399F100C39FE5 /* DetailViewController.xib in Resources */,
|
||||||
|
D627CE8324E38FBE00C39FE5 /* DatabaseCollectionListViewController.xib in Resources */,
|
||||||
D63CDEC323C837DD0012D658 /* MainMenu.xib in Resources */,
|
D63CDEC323C837DD0012D658 /* MainMenu.xib in Resources */,
|
||||||
D626BF83243BD2EE0075117B /* EditDocumentWindowController.xib in Resources */,
|
D626BF83243BD2EE0075117B /* EditDocumentWindowController.xib in Resources */,
|
||||||
D63CDF4123C839010012D658 /* QueryViewController.xib in Resources */,
|
D63CDF4123C839010012D658 /* QueryViewController.xib in Resources */,
|
||||||
|
@ -366,6 +379,7 @@
|
||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
D627CE8B24E438EE00C39FE5 /* DatabaseCollection.swift in Sources */,
|
||||||
D63CDEBE23C837DC0012D658 /* AppDelegate.swift in Sources */,
|
D63CDEBE23C837DC0012D658 /* AppDelegate.swift in Sources */,
|
||||||
D6D4665323CB730C00F13B1B /* MongoEvaluator.swift in Sources */,
|
D6D4665323CB730C00F13B1B /* MongoEvaluator.swift in Sources */,
|
||||||
D624090F243903E90020E09F /* ExtendedJSON.swift in Sources */,
|
D624090F243903E90020E09F /* ExtendedJSON.swift in Sources */,
|
||||||
|
@ -373,13 +387,15 @@
|
||||||
D60C863923CA2DD100C9DB8E /* ServerConnectWindowController.swift in Sources */,
|
D60C863923CA2DD100C9DB8E /* ServerConnectWindowController.swift in Sources */,
|
||||||
D63CDF3723C8381A0012D658 /* Node.swift in Sources */,
|
D63CDF3723C8381A0012D658 /* Node.swift in Sources */,
|
||||||
D626BF86243BE19A0075117B /* EditDocumentViewController.swift in Sources */,
|
D626BF86243BE19A0075117B /* EditDocumentViewController.swift in Sources */,
|
||||||
|
D627CE8224E38FBE00C39FE5 /* DatabaseCollectionListViewController.swift in Sources */,
|
||||||
D60C863F23CA2E2100C9DB8E /* ServerConnectViewController.swift in Sources */,
|
D60C863F23CA2E2100C9DB8E /* ServerConnectViewController.swift in Sources */,
|
||||||
D63CDF4423C970C50012D658 /* DatabaseViewController.swift in Sources */,
|
D627CE8824E399F100C39FE5 /* DetailViewController.swift in Sources */,
|
||||||
D63CDF3C23C838470012D658 /* DatabaseWindowController.swift in Sources */,
|
D63CDF3C23C838470012D658 /* DatabaseWindowController.swift in Sources */,
|
||||||
D6A7D096243541A400B46857 /* WindowStatusView.swift in Sources */,
|
D6A7D096243541A400B46857 /* WindowStatusView.swift in Sources */,
|
||||||
D626BF82243BD2EE0075117B /* EditDocumentWindowController.swift in Sources */,
|
D626BF82243BD2EE0075117B /* EditDocumentWindowController.swift in Sources */,
|
||||||
D6A7D0A42435885B00B46857 /* JavaScriptHighlighter.swift in Sources */,
|
D6A7D0A42435885B00B46857 /* JavaScriptHighlighter.swift in Sources */,
|
||||||
D6ABB01424B4DE7600F79DA8 /* StatusManager.swift in Sources */,
|
D6ABB01424B4DE7600F79DA8 /* StatusManager.swift in Sources */,
|
||||||
|
D627CE7E24E38F3B00C39FE5 /* MainSplitViewController.swift in Sources */,
|
||||||
D62408C12438CF550020E09F /* JavaScriptEditorView.swift in Sources */,
|
D62408C12438CF550020E09F /* JavaScriptEditorView.swift in Sources */,
|
||||||
D63CDF4023C839010012D658 /* QueryViewController.swift in Sources */,
|
D63CDF4023C839010012D658 /* QueryViewController.swift in Sources */,
|
||||||
);
|
);
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
//
|
||||||
|
// DatabaseCollection.swift
|
||||||
|
// MongoView
|
||||||
|
//
|
||||||
|
// Created by Shadowfacts on 8/12/20.
|
||||||
|
// Copyright © 2020 Shadowfacts. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
struct DatabaseCollections {
|
||||||
|
let database: String
|
||||||
|
let collections: [String]
|
||||||
|
}
|
||||||
|
|
||||||
|
struct DatabaseCollection: CustomStringConvertible {
|
||||||
|
let database: String
|
||||||
|
let name: String
|
||||||
|
|
||||||
|
var description: String {
|
||||||
|
return "\(database).\(name)"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,127 @@
|
||||||
|
//
|
||||||
|
// DatabaseCollectionListViewController.swift
|
||||||
|
// MongoView
|
||||||
|
//
|
||||||
|
// Created by Shadowfacts on 8/11/20.
|
||||||
|
// Copyright © 2020 Shadowfacts. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Cocoa
|
||||||
|
import NIO
|
||||||
|
import Combine
|
||||||
|
|
||||||
|
class DatabaseCollectionListViewController: NSViewController {
|
||||||
|
|
||||||
|
@IBOutlet weak var outlineView: NSOutlineView!
|
||||||
|
|
||||||
|
let mongoController: MongoController
|
||||||
|
|
||||||
|
let selectedCollection = PassthroughSubject<DatabaseCollection, Never>()
|
||||||
|
|
||||||
|
private var databaseCollections: [DatabaseCollections] = []
|
||||||
|
|
||||||
|
init(mongoController: MongoController) {
|
||||||
|
self.mongoController = mongoController
|
||||||
|
|
||||||
|
super.init(nibName: "DatabaseCollectionListViewController", bundle: .main)
|
||||||
|
}
|
||||||
|
|
||||||
|
required init?(coder: NSCoder) {
|
||||||
|
fatalError("init(coder:) has not been implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override func viewDidLoad() {
|
||||||
|
super.viewDidLoad()
|
||||||
|
|
||||||
|
mongoController.client.listDatabaseNames().flatMap { (databaseNames) -> EventLoopFuture<[DatabaseCollections]> in
|
||||||
|
let futures = databaseNames.map { (name: String) -> EventLoopFuture<DatabaseCollections> in
|
||||||
|
let db = self.mongoController.client.db(name)
|
||||||
|
return db.listCollectionNames().map { (collectionNames: [String]) -> DatabaseCollections in
|
||||||
|
let sortedNames = collectionNames.sorted()
|
||||||
|
return DatabaseCollections(database: name, collections: sortedNames)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return EventLoopFuture.whenAllSucceed(futures, on: futures.first!.eventLoop)
|
||||||
|
}.whenComplete { [weak self] (res) in
|
||||||
|
guard let self = self else { return }
|
||||||
|
|
||||||
|
switch res {
|
||||||
|
case let .success(databaseCollections):
|
||||||
|
let sortedCollections = databaseCollections.sorted(by: { $0.database < $1.database })
|
||||||
|
self.databaseCollections = sortedCollections
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
self.outlineView.reloadData()
|
||||||
|
}
|
||||||
|
case let .failure(error):
|
||||||
|
fatalError("error getting database names: \(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
outlineView.dataSource = self
|
||||||
|
outlineView.delegate = self
|
||||||
|
}
|
||||||
|
|
||||||
|
@IBAction func outlineCellDoubleClicked(_ sender: Any) {
|
||||||
|
let item = outlineView.item(atRow: outlineView.clickedRow)!
|
||||||
|
|
||||||
|
if item is DatabaseCollections {
|
||||||
|
if outlineView.isItemExpanded(item) {
|
||||||
|
outlineView.collapseItem(item)
|
||||||
|
} else {
|
||||||
|
outlineView.expandItem(item)
|
||||||
|
}
|
||||||
|
} else if let collection = item as? DatabaseCollection {
|
||||||
|
selectedCollection.send(collection)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension DatabaseCollectionListViewController: NSOutlineViewDataSource {
|
||||||
|
func outlineView(_ outlineView: NSOutlineView, numberOfChildrenOfItem item: Any?) -> Int {
|
||||||
|
if item == nil {
|
||||||
|
return databaseCollections.count
|
||||||
|
} else if let database = item as? DatabaseCollections {
|
||||||
|
return database.collections.count
|
||||||
|
} else {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func outlineView(_ outlineView: NSOutlineView, isItemExpandable item: Any) -> Bool {
|
||||||
|
return item is DatabaseCollections
|
||||||
|
}
|
||||||
|
|
||||||
|
func outlineView(_ outlineView: NSOutlineView, child index: Int, ofItem item: Any?) -> Any {
|
||||||
|
if item == nil {
|
||||||
|
return databaseCollections[index]
|
||||||
|
} else if let databaseCollections = item as? DatabaseCollections {
|
||||||
|
let collection = databaseCollections.collections[index]
|
||||||
|
return DatabaseCollection(database: databaseCollections.database, name: collection)
|
||||||
|
} else {
|
||||||
|
fatalError()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension DatabaseCollectionListViewController: NSOutlineViewDelegate {
|
||||||
|
func outlineView(_ outlineView: NSOutlineView, viewFor tableColumn: NSTableColumn?, item: Any) -> NSView? {
|
||||||
|
if let database = item as? DatabaseCollections {
|
||||||
|
let cell = outlineView.makeView(withIdentifier: .databaseNameCell, owner: nil) as! NSTableCellView
|
||||||
|
cell.textField!.stringValue = database.database
|
||||||
|
cell.textField!.isEditable = false
|
||||||
|
return cell
|
||||||
|
} else if let collection = item as? DatabaseCollection {
|
||||||
|
let cell = outlineView.makeView(withIdentifier: .collectionNameCell, owner: nil) as! NSTableCellView
|
||||||
|
cell.textField!.stringValue = collection.name
|
||||||
|
cell.textField!.isEditable = false
|
||||||
|
return cell
|
||||||
|
} else {
|
||||||
|
fatalError()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension NSUserInterfaceItemIdentifier {
|
||||||
|
static let databaseNameCell = NSUserInterfaceItemIdentifier(rawValue: "DatabaseNameCell")
|
||||||
|
static let collectionNameCell = NSUserInterfaceItemIdentifier(rawValue: "CollectionNameCell")
|
||||||
|
}
|
|
@ -0,0 +1,108 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="16097" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||||
|
<dependencies>
|
||||||
|
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="16097"/>
|
||||||
|
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||||
|
</dependencies>
|
||||||
|
<objects>
|
||||||
|
<customObject id="-2" userLabel="File's Owner" customClass="DatabaseCollectionListViewController" customModule="MongoView" customModuleProvider="target">
|
||||||
|
<connections>
|
||||||
|
<outlet property="outlineView" destination="PYy-rp-1sY" id="Ag4-pd-TtB"/>
|
||||||
|
<outlet property="view" destination="CSW-JG-jb6" id="wPe-4V-JEk"/>
|
||||||
|
</connections>
|
||||||
|
</customObject>
|
||||||
|
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||||
|
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||||
|
<scrollView autohidesScrollers="YES" horizontalLineScroll="26" horizontalPageScroll="10" verticalLineScroll="26" verticalPageScroll="10" usesPredominantAxisScrolling="NO" id="CSW-JG-jb6">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="150" height="400"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
|
<clipView key="contentView" drawsBackground="NO" id="uX8-zh-NZd">
|
||||||
|
<rect key="frame" x="1" y="1" width="148" height="398"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
|
<subviews>
|
||||||
|
<outlineView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" selectionHighlightStyle="sourceList" multipleSelection="NO" autosaveColumns="NO" rowHeight="24" rowSizeStyle="automatic" viewBased="YES" indentationPerLevel="16" outlineTableColumn="nUE-Qx-Fdi" id="PYy-rp-1sY">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="148" height="398"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
|
<size key="intercellSpacing" width="3" height="2"/>
|
||||||
|
<color key="backgroundColor" name="_sourceListBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||||
|
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
|
||||||
|
<tableColumns>
|
||||||
|
<tableColumn width="145" minWidth="16" maxWidth="1000" id="nUE-Qx-Fdi">
|
||||||
|
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border">
|
||||||
|
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
|
||||||
|
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
|
||||||
|
</tableHeaderCell>
|
||||||
|
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" title="Text Cell" id="qEZ-z5-ScP">
|
||||||
|
<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="DatabaseNameCell" id="qxw-S5-5TO">
|
||||||
|
<rect key="frame" x="1" y="1" width="145" height="17"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
|
<subviews>
|
||||||
|
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Rdr-4s-WEp">
|
||||||
|
<rect key="frame" x="0.0" y="1" width="145" height="14"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||||
|
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="HEADER CELL" id="m7l-6x-d1Y">
|
||||||
|
<font key="font" metaFont="smallSystemBold"/>
|
||||||
|
<color key="textColor" name="headerColor" catalog="System" colorSpace="catalog"/>
|
||||||
|
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||||
|
</textFieldCell>
|
||||||
|
</textField>
|
||||||
|
</subviews>
|
||||||
|
<connections>
|
||||||
|
<outlet property="textField" destination="Rdr-4s-WEp" id="uxa-OG-78l"/>
|
||||||
|
</connections>
|
||||||
|
</tableCellView>
|
||||||
|
<tableCellView identifier="CollectionNameCell" id="Jfx-os-pKH">
|
||||||
|
<rect key="frame" x="1" y="20" width="145" height="17"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
|
<subviews>
|
||||||
|
<imageView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="3XC-L1-Mmo">
|
||||||
|
<rect key="frame" x="3" y="0.0" width="17" height="17"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
|
<imageCell key="cell" refusesFirstResponder="YES" imageScaling="proportionallyDown" image="NSActionTemplate" id="w8x-qJ-eUa"/>
|
||||||
|
</imageView>
|
||||||
|
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="22A-k5-6kG">
|
||||||
|
<rect key="frame" x="25" y="0.0" width="120" height="17"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||||
|
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="MvS-zU-uSK">
|
||||||
|
<font key="font" metaFont="system"/>
|
||||||
|
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||||
|
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||||
|
</textFieldCell>
|
||||||
|
</textField>
|
||||||
|
</subviews>
|
||||||
|
<connections>
|
||||||
|
<outlet property="imageView" destination="3XC-L1-Mmo" id="2te-tg-hnE"/>
|
||||||
|
<outlet property="textField" destination="22A-k5-6kG" id="opL-jf-aEN"/>
|
||||||
|
</connections>
|
||||||
|
</tableCellView>
|
||||||
|
</prototypeCellViews>
|
||||||
|
</tableColumn>
|
||||||
|
</tableColumns>
|
||||||
|
<connections>
|
||||||
|
<action trigger="doubleAction" selector="outlineCellDoubleClicked:" target="-2" id="tK6-yr-CRA"/>
|
||||||
|
</connections>
|
||||||
|
</outlineView>
|
||||||
|
</subviews>
|
||||||
|
<nil key="backgroundColor"/>
|
||||||
|
</clipView>
|
||||||
|
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="b0d-if-wLj">
|
||||||
|
<rect key="frame" x="1" y="119" width="238" height="15"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
</scroller>
|
||||||
|
<scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="vsz-HX-7re">
|
||||||
|
<rect key="frame" x="224" y="17" width="15" height="102"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
</scroller>
|
||||||
|
<point key="canvasLocation" x="-15" y="177"/>
|
||||||
|
</scrollView>
|
||||||
|
</objects>
|
||||||
|
<resources>
|
||||||
|
<image name="NSActionTemplate" width="14" height="14"/>
|
||||||
|
</resources>
|
||||||
|
</document>
|
|
@ -1,218 +0,0 @@
|
||||||
//
|
|
||||||
// DatabaseViewController.swift
|
|
||||||
// MongoView
|
|
||||||
//
|
|
||||||
// Created by Shadowfacts on 1/10/20.
|
|
||||||
// Copyright © 2020 Shadowfacts. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
import Cocoa
|
|
||||||
import MongoSwift
|
|
||||||
import NIO
|
|
||||||
|
|
||||||
struct DatabaseCollections {
|
|
||||||
let database: String
|
|
||||||
let collections: [String]
|
|
||||||
}
|
|
||||||
|
|
||||||
struct DatabaseCollection: CustomStringConvertible {
|
|
||||||
let database: String
|
|
||||||
let name: String
|
|
||||||
|
|
||||||
var description: String {
|
|
||||||
return "\(database).\(name)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class DatabaseViewController: NSViewController {
|
|
||||||
|
|
||||||
@IBOutlet weak var collectionsOutlineView: NSOutlineView!
|
|
||||||
@IBOutlet weak var detailContainerView: NSView!
|
|
||||||
|
|
||||||
let mongoController: MongoController
|
|
||||||
|
|
||||||
private var databaseCollections: [DatabaseCollections] = []
|
|
||||||
private var selectedCollection: DatabaseCollection?
|
|
||||||
|
|
||||||
private var placeholderLabel: NSTextField?
|
|
||||||
private var queryViewController: QueryViewController?
|
|
||||||
|
|
||||||
init(mongoController: MongoController) {
|
|
||||||
self.mongoController = mongoController
|
|
||||||
|
|
||||||
super.init(nibName: "DatabaseViewController", bundle: .main)
|
|
||||||
}
|
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
|
||||||
fatalError("init(coder:) has not been implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
override func viewDidLoad() {
|
|
||||||
super.viewDidLoad()
|
|
||||||
|
|
||||||
mongoController.client.listDatabaseNames().flatMap { (databaseNames) -> EventLoopFuture<[DatabaseCollections]> in
|
|
||||||
let futures = databaseNames.map { (name: String) -> EventLoopFuture<DatabaseCollections> in
|
|
||||||
let db = self.mongoController.client.db(name)
|
|
||||||
return db.listCollectionNames().map { (collectionNames: [String]) -> DatabaseCollections in
|
|
||||||
let sortedNames = collectionNames.sorted()
|
|
||||||
return DatabaseCollections(database: name, collections: sortedNames)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return EventLoopFuture.whenAllSucceed(futures, on: futures.first!.eventLoop)
|
|
||||||
}.whenComplete { [weak self] (res) in
|
|
||||||
guard let self = self else { return }
|
|
||||||
|
|
||||||
switch res {
|
|
||||||
case let .success(databaseCollections):
|
|
||||||
let sortedCollections = databaseCollections.sorted(by: { $0.database < $1.database })
|
|
||||||
self.databaseCollections = sortedCollections
|
|
||||||
DispatchQueue.main.async {
|
|
||||||
self.collectionsOutlineView.reloadData()
|
|
||||||
}
|
|
||||||
|
|
||||||
case let .failure(error):
|
|
||||||
fatalError("error getting database names: \(error)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
collectionsOutlineView.dataSource = self
|
|
||||||
collectionsOutlineView.delegate = self
|
|
||||||
|
|
||||||
collectionsOutlineView.target = self
|
|
||||||
collectionsOutlineView.doubleAction = #selector(cellDoubleClicked)
|
|
||||||
|
|
||||||
updateDetailView()
|
|
||||||
}
|
|
||||||
|
|
||||||
func showCollection(_ collection: DatabaseCollection) {
|
|
||||||
selectedCollection = collection
|
|
||||||
updateDetailView()
|
|
||||||
}
|
|
||||||
|
|
||||||
private func updateDetailView() {
|
|
||||||
if let collection = selectedCollection {
|
|
||||||
if let placeholderLabel = placeholderLabel {
|
|
||||||
placeholderLabel.removeFromSuperview()
|
|
||||||
}
|
|
||||||
if let oldQueryViewController = self.queryViewController {
|
|
||||||
oldQueryViewController.view.removeFromSuperview()
|
|
||||||
oldQueryViewController.removeFromParent()
|
|
||||||
}
|
|
||||||
|
|
||||||
let queryViewController = QueryViewController(mongoController: mongoController, collection: collection)
|
|
||||||
self.queryViewController = queryViewController
|
|
||||||
queryViewController.view.translatesAutoresizingMaskIntoConstraints = false
|
|
||||||
addChild(queryViewController)
|
|
||||||
detailContainerView.addSubview(queryViewController.view)
|
|
||||||
NSLayoutConstraint.activate([
|
|
||||||
queryViewController.view.leadingAnchor.constraint(equalTo: detailContainerView.leadingAnchor),
|
|
||||||
queryViewController.view.trailingAnchor.constraint(equalTo: detailContainerView.trailingAnchor),
|
|
||||||
queryViewController.view.topAnchor.constraint(equalTo: detailContainerView.topAnchor),
|
|
||||||
queryViewController.view.bottomAnchor.constraint(equalTo: detailContainerView.bottomAnchor)
|
|
||||||
])
|
|
||||||
|
|
||||||
self.title = queryViewController.title
|
|
||||||
} else {
|
|
||||||
if let queryViewController = queryViewController {
|
|
||||||
queryViewController.view.removeFromSuperview()
|
|
||||||
queryViewController.removeFromParent()
|
|
||||||
}
|
|
||||||
|
|
||||||
if self.placeholderLabel == nil {
|
|
||||||
let label = NSTextField(labelWithString: "Select a collection to begin")
|
|
||||||
self.placeholderLabel = label
|
|
||||||
label.translatesAutoresizingMaskIntoConstraints = false
|
|
||||||
detailContainerView.addSubview(label)
|
|
||||||
NSLayoutConstraint.activate([
|
|
||||||
label.centerXAnchor.constraint(equalTo: detailContainerView.centerXAnchor),
|
|
||||||
label.centerYAnchor.constraint(equalTo: detailContainerView.centerYAnchor)
|
|
||||||
])
|
|
||||||
|
|
||||||
self.title = "No Query"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@objc func cellDoubleClicked() {
|
|
||||||
let item = collectionsOutlineView.item(atRow: collectionsOutlineView.clickedRow)!
|
|
||||||
|
|
||||||
if item is DatabaseCollections {
|
|
||||||
if collectionsOutlineView.isItemExpanded(item) {
|
|
||||||
collectionsOutlineView.collapseItem(item)
|
|
||||||
} else {
|
|
||||||
collectionsOutlineView.expandItem(item)
|
|
||||||
}
|
|
||||||
} else if let collection = item as? DatabaseCollection {
|
|
||||||
// only open a new window/tab if our own query has changed from the default, otherwise replace our query controller
|
|
||||||
if let queryViewController = queryViewController, queryViewController.hasFilterChanged {
|
|
||||||
(NSApplication.shared.delegate as! AppDelegate).newWindow(mongoController: mongoController, collection: collection)
|
|
||||||
} else {
|
|
||||||
self.selectedCollection = collection
|
|
||||||
updateDetailView()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@IBAction func refresh(_ sender: Any) {
|
|
||||||
queryViewController?.refresh()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extension DatabaseViewController: NSMenuItemValidation {
|
|
||||||
func validateMenuItem(_ menuItem: NSMenuItem) -> Bool {
|
|
||||||
if menuItem.action == #selector(refresh(_:)) {
|
|
||||||
return queryViewController != nil
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extension DatabaseViewController: NSOutlineViewDataSource {
|
|
||||||
func outlineView(_ outlineView: NSOutlineView, numberOfChildrenOfItem item: Any?) -> Int {
|
|
||||||
if item == nil {
|
|
||||||
return databaseCollections.count
|
|
||||||
} else if let database = item as? DatabaseCollections {
|
|
||||||
return database.collections.count
|
|
||||||
} else {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func outlineView(_ outlineView: NSOutlineView, isItemExpandable item: Any) -> Bool {
|
|
||||||
return item is DatabaseCollections
|
|
||||||
}
|
|
||||||
|
|
||||||
func outlineView(_ outlineView: NSOutlineView, child index: Int, ofItem item: Any?) -> Any {
|
|
||||||
if item == nil {
|
|
||||||
return databaseCollections[index]
|
|
||||||
} else if let databaseCollections = item as? DatabaseCollections {
|
|
||||||
let collection = databaseCollections.collections[index]
|
|
||||||
return DatabaseCollection(database: databaseCollections.database, name: collection)
|
|
||||||
} else {
|
|
||||||
fatalError()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extension DatabaseViewController: NSOutlineViewDelegate {
|
|
||||||
func outlineView(_ outlineView: NSOutlineView, viewFor tableColumn: NSTableColumn?, item: Any) -> NSView? {
|
|
||||||
if let database = item as? DatabaseCollections {
|
|
||||||
let cell = outlineView.makeView(withIdentifier: .databaseNameCell, owner: nil) as! NSTableCellView
|
|
||||||
cell.textField!.stringValue = database.database
|
|
||||||
cell.textField!.isEditable = false
|
|
||||||
return cell
|
|
||||||
} else if let collection = item as? DatabaseCollection {
|
|
||||||
let cell = outlineView.makeView(withIdentifier: .collectionNameCell, owner: nil) as! NSTableCellView
|
|
||||||
cell.textField!.stringValue = collection.name
|
|
||||||
cell.textField!.isEditable = false
|
|
||||||
return cell
|
|
||||||
} else {
|
|
||||||
fatalError()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extension NSUserInterfaceItemIdentifier {
|
|
||||||
static let databaseNameCell = NSUserInterfaceItemIdentifier(rawValue: "DatabaseNameCell")
|
|
||||||
static let collectionNameCell = NSUserInterfaceItemIdentifier(rawValue: "CollectionNameCell")
|
|
||||||
}
|
|
|
@ -1,143 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="15702" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
|
||||||
<dependencies>
|
|
||||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="15702"/>
|
|
||||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
|
||||||
</dependencies>
|
|
||||||
<objects>
|
|
||||||
<customObject id="-2" userLabel="File's Owner" customClass="DatabaseViewController" customModule="MongoView" customModuleProvider="target">
|
|
||||||
<connections>
|
|
||||||
<outlet property="collectionsOutlineView" destination="V8b-zo-g9y" id="MHN-98-SLo"/>
|
|
||||||
<outlet property="detailContainerView" destination="XEU-4D-Mdl" id="TwG-BX-2Gv"/>
|
|
||||||
<outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
|
|
||||||
</connections>
|
|
||||||
</customObject>
|
|
||||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
|
||||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
|
||||||
<customView id="Hz6-mo-xeY">
|
|
||||||
<rect key="frame" x="0.0" y="0.0" width="963" height="618"/>
|
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
|
||||||
<subviews>
|
|
||||||
<splitView arrangesAllSubviews="NO" dividerStyle="thin" vertical="YES" translatesAutoresizingMaskIntoConstraints="NO" id="5Fg-Gm-qda">
|
|
||||||
<rect key="frame" x="0.0" y="0.0" width="963" height="618"/>
|
|
||||||
<subviews>
|
|
||||||
<customView id="oWj-Ph-gg6">
|
|
||||||
<rect key="frame" x="0.0" y="0.0" width="258" height="618"/>
|
|
||||||
<autoresizingMask key="autoresizingMask"/>
|
|
||||||
<subviews>
|
|
||||||
<scrollView autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="h6f-Xn-ruZ">
|
|
||||||
<rect key="frame" x="0.0" y="0.0" width="258" height="618"/>
|
|
||||||
<clipView key="contentView" drawsBackground="NO" id="x7X-dI-jkR">
|
|
||||||
<rect key="frame" x="1" y="1" width="256" height="616"/>
|
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
|
||||||
<subviews>
|
|
||||||
<outlineView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" selectionHighlightStyle="sourceList" multipleSelection="NO" autosaveColumns="NO" rowSizeStyle="automatic" viewBased="YES" indentationPerLevel="16" outlineTableColumn="jbA-H8-mVM" id="V8b-zo-g9y">
|
|
||||||
<rect key="frame" x="0.0" y="0.0" width="256" height="616"/>
|
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
|
||||||
<size key="intercellSpacing" width="3" height="2"/>
|
|
||||||
<color key="backgroundColor" name="_sourceListBackgroundColor" catalog="System" colorSpace="catalog"/>
|
|
||||||
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
|
|
||||||
<tableColumns>
|
|
||||||
<tableColumn width="253" minWidth="16" maxWidth="1000" id="jbA-H8-mVM">
|
|
||||||
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border">
|
|
||||||
<font key="font" metaFont="label" size="11"/>
|
|
||||||
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
|
|
||||||
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
|
|
||||||
</tableHeaderCell>
|
|
||||||
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" title="Text Cell" id="xnp-1R-i8D">
|
|
||||||
<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="DatabaseNameCell" id="rKw-cV-n1d">
|
|
||||||
<rect key="frame" x="1" y="1" width="253" height="17"/>
|
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
|
||||||
<subviews>
|
|
||||||
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="FFr-3D-mui">
|
|
||||||
<rect key="frame" x="0.0" y="1" width="253" height="14"/>
|
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
|
||||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="HEADER CELL" id="cEl-mJ-9oh">
|
|
||||||
<font key="font" metaFont="smallSystemBold"/>
|
|
||||||
<color key="textColor" name="headerColor" catalog="System" colorSpace="catalog"/>
|
|
||||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
|
||||||
</textFieldCell>
|
|
||||||
</textField>
|
|
||||||
</subviews>
|
|
||||||
<connections>
|
|
||||||
<outlet property="textField" destination="FFr-3D-mui" id="5i3-fV-eYZ"/>
|
|
||||||
</connections>
|
|
||||||
</tableCellView>
|
|
||||||
<tableCellView identifier="CollectionNameCell" id="hIt-06-qWa">
|
|
||||||
<rect key="frame" x="1" y="20" width="253" height="17"/>
|
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
|
||||||
<subviews>
|
|
||||||
<imageView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ccM-b1-d7j">
|
|
||||||
<rect key="frame" x="3" y="0.0" width="17" height="17"/>
|
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
|
||||||
<imageCell key="cell" refusesFirstResponder="YES" imageScaling="proportionallyDown" image="NSActionTemplate" id="kCZ-pa-Nqs"/>
|
|
||||||
</imageView>
|
|
||||||
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Lxc-CX-ZCN">
|
|
||||||
<rect key="frame" x="25" y="0.0" width="228" height="17"/>
|
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
|
||||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="5CJ-WG-qTe">
|
|
||||||
<font key="font" metaFont="system"/>
|
|
||||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
|
||||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
|
||||||
</textFieldCell>
|
|
||||||
</textField>
|
|
||||||
</subviews>
|
|
||||||
<connections>
|
|
||||||
<outlet property="imageView" destination="ccM-b1-d7j" id="otw-h0-Zyz"/>
|
|
||||||
<outlet property="textField" destination="Lxc-CX-ZCN" id="cW2-4u-Tl2"/>
|
|
||||||
</connections>
|
|
||||||
</tableCellView>
|
|
||||||
</prototypeCellViews>
|
|
||||||
</tableColumn>
|
|
||||||
</tableColumns>
|
|
||||||
</outlineView>
|
|
||||||
</subviews>
|
|
||||||
<nil key="backgroundColor"/>
|
|
||||||
</clipView>
|
|
||||||
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="all-QE-bCD">
|
|
||||||
<rect key="frame" x="1" y="119" width="238" height="15"/>
|
|
||||||
<autoresizingMask key="autoresizingMask"/>
|
|
||||||
</scroller>
|
|
||||||
<scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="x72-Cx-DrL">
|
|
||||||
<rect key="frame" x="224" y="17" width="15" height="102"/>
|
|
||||||
<autoresizingMask key="autoresizingMask"/>
|
|
||||||
</scroller>
|
|
||||||
</scrollView>
|
|
||||||
</subviews>
|
|
||||||
<constraints>
|
|
||||||
<constraint firstAttribute="trailing" secondItem="h6f-Xn-ruZ" secondAttribute="trailing" id="CYf-mb-0kx"/>
|
|
||||||
<constraint firstItem="h6f-Xn-ruZ" firstAttribute="top" secondItem="oWj-Ph-gg6" secondAttribute="top" id="OHe-aL-LhC"/>
|
|
||||||
<constraint firstItem="h6f-Xn-ruZ" firstAttribute="leading" secondItem="oWj-Ph-gg6" secondAttribute="leading" id="d9N-28-6qQ"/>
|
|
||||||
<constraint firstAttribute="bottom" secondItem="h6f-Xn-ruZ" secondAttribute="bottom" id="fmp-A8-teG"/>
|
|
||||||
</constraints>
|
|
||||||
</customView>
|
|
||||||
<customView fixedFrame="YES" id="XEU-4D-Mdl">
|
|
||||||
<rect key="frame" x="259" y="0.0" width="704" height="618"/>
|
|
||||||
<autoresizingMask key="autoresizingMask"/>
|
|
||||||
</customView>
|
|
||||||
</subviews>
|
|
||||||
<holdingPriorities>
|
|
||||||
<real value="250"/>
|
|
||||||
<real value="250"/>
|
|
||||||
</holdingPriorities>
|
|
||||||
</splitView>
|
|
||||||
</subviews>
|
|
||||||
<constraints>
|
|
||||||
<constraint firstItem="5Fg-Gm-qda" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" id="HRn-8t-EI3"/>
|
|
||||||
<constraint firstItem="5Fg-Gm-qda" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" id="Tco-te-GLJ"/>
|
|
||||||
<constraint firstAttribute="trailing" secondItem="5Fg-Gm-qda" secondAttribute="trailing" id="f5N-wp-15r"/>
|
|
||||||
<constraint firstAttribute="bottom" secondItem="5Fg-Gm-qda" secondAttribute="bottom" id="l7G-Jh-PBe"/>
|
|
||||||
</constraints>
|
|
||||||
<point key="canvasLocation" x="-8.5" y="361"/>
|
|
||||||
</customView>
|
|
||||||
</objects>
|
|
||||||
<resources>
|
|
||||||
<image name="NSActionTemplate" width="14" height="14"/>
|
|
||||||
</resources>
|
|
||||||
</document>
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
//
|
||||||
|
// DetailViewController.swift
|
||||||
|
// MongoView
|
||||||
|
//
|
||||||
|
// Created by Shadowfacts on 8/11/20.
|
||||||
|
// Copyright © 2020 Shadowfacts. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Cocoa
|
||||||
|
|
||||||
|
class DetailViewController: NSViewController {
|
||||||
|
|
||||||
|
override func viewDidLoad() {
|
||||||
|
super.viewDidLoad()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="16097" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||||
|
<dependencies>
|
||||||
|
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="16097"/>
|
||||||
|
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||||
|
</dependencies>
|
||||||
|
<objects>
|
||||||
|
<customObject id="-2" userLabel="File's Owner" customClass="DetailViewController" customModule="MongoView" customModuleProvider="target">
|
||||||
|
<connections>
|
||||||
|
<outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
|
||||||
|
</connections>
|
||||||
|
</customObject>
|
||||||
|
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||||
|
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||||
|
<customView id="Hz6-mo-xeY">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="480" height="272"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
|
<subviews>
|
||||||
|
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="PWc-n0-PoD">
|
||||||
|
<rect key="frame" x="156" y="128" width="169" height="16"/>
|
||||||
|
<textFieldCell key="cell" lineBreakMode="clipping" title="Select a collection to begin" id="8Vw-6z-chU">
|
||||||
|
<font key="font" usesAppearanceFont="YES"/>
|
||||||
|
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||||
|
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||||
|
</textFieldCell>
|
||||||
|
</textField>
|
||||||
|
</subviews>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstItem="PWc-n0-PoD" firstAttribute="centerX" secondItem="Hz6-mo-xeY" secondAttribute="centerX" id="0RT-Qd-Ehi"/>
|
||||||
|
<constraint firstItem="PWc-n0-PoD" firstAttribute="centerY" secondItem="Hz6-mo-xeY" secondAttribute="centerY" id="i20-B9-H29"/>
|
||||||
|
</constraints>
|
||||||
|
<point key="canvasLocation" x="140" y="154"/>
|
||||||
|
</customView>
|
||||||
|
</objects>
|
||||||
|
</document>
|
|
@ -0,0 +1,105 @@
|
||||||
|
//
|
||||||
|
// MainSplitViewController.swift
|
||||||
|
// MongoView
|
||||||
|
//
|
||||||
|
// Created by Shadowfacts on 8/11/20.
|
||||||
|
// Copyright © 2020 Shadowfacts. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Cocoa
|
||||||
|
import Combine
|
||||||
|
|
||||||
|
class MainSplitViewController: NSSplitViewController {
|
||||||
|
|
||||||
|
let mongoController: MongoController
|
||||||
|
let initialCollection: DatabaseCollection?
|
||||||
|
|
||||||
|
private var detailViewController = DetailViewController()
|
||||||
|
private var currentQueryViewController: QueryViewController? {
|
||||||
|
detailViewController.children.first as? QueryViewController
|
||||||
|
}
|
||||||
|
|
||||||
|
private var collectionSubscriber: Cancellable?
|
||||||
|
private var titleObservation: NSKeyValueObservation?
|
||||||
|
|
||||||
|
init(mongoController: MongoController, initialCollection: DatabaseCollection?) {
|
||||||
|
self.mongoController = mongoController
|
||||||
|
self.initialCollection = initialCollection
|
||||||
|
|
||||||
|
super.init(nibName: nil, bundle: nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
required init?(coder: NSCoder) {
|
||||||
|
fatalError("init(coder:) has not been implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override func viewDidLoad() {
|
||||||
|
super.viewDidLoad()
|
||||||
|
|
||||||
|
let listVC = DatabaseCollectionListViewController(mongoController: mongoController)
|
||||||
|
let sourceListItem = NSSplitViewItem(sidebarWithViewController: listVC)
|
||||||
|
let detailItem = NSSplitViewItem(viewController: detailViewController)
|
||||||
|
detailItem.maximumThickness = NSSplitViewItem.unspecifiedDimension
|
||||||
|
|
||||||
|
addSplitViewItem(sourceListItem)
|
||||||
|
addSplitViewItem(detailItem)
|
||||||
|
|
||||||
|
NSLayoutConstraint.activate([
|
||||||
|
sourceListItem.viewController.view.widthAnchor.constraint(greaterThanOrEqualToConstant: 200),
|
||||||
|
sourceListItem.viewController.view.widthAnchor.constraint(lessThanOrEqualToConstant: 500),
|
||||||
|
detailItem.viewController.view.widthAnchor.constraint(greaterThanOrEqualToConstant: 200),
|
||||||
|
])
|
||||||
|
|
||||||
|
collectionSubscriber = listVC.selectedCollection.sink(receiveValue: self.selectCollection)
|
||||||
|
|
||||||
|
if let initialCollection = initialCollection {
|
||||||
|
selectCollection(initialCollection)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func selectCollection(_ collection: DatabaseCollection) {
|
||||||
|
if currentQueryViewController?.hasFilterChanged ?? false {
|
||||||
|
(NSApp.delegate as! AppDelegate).newWindow(mongoController: mongoController, collection: collection)
|
||||||
|
} else {
|
||||||
|
let queryVC = QueryViewController(mongoController: mongoController, collection: collection)
|
||||||
|
setDetailChild(queryVC)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func setDetailChild(_ vc: NSViewController) {
|
||||||
|
if let child = detailViewController.children.first {
|
||||||
|
child.removeFromParent()
|
||||||
|
child.view.removeFromSuperview()
|
||||||
|
}
|
||||||
|
|
||||||
|
vc.view.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
|
||||||
|
detailViewController.addChild(vc)
|
||||||
|
detailViewController.view.addSubview(vc.view)
|
||||||
|
|
||||||
|
NSLayoutConstraint.activate([
|
||||||
|
detailViewController.view.leadingAnchor.constraint(equalTo: vc.view.leadingAnchor),
|
||||||
|
detailViewController.view.trailingAnchor.constraint(equalTo: vc.view.trailingAnchor),
|
||||||
|
detailViewController.view.topAnchor.constraint(equalTo: vc.view.topAnchor),
|
||||||
|
detailViewController.view.bottomAnchor.constraint(equalTo: vc.view.bottomAnchor),
|
||||||
|
])
|
||||||
|
|
||||||
|
titleObservation = vc.observe(\.title, options: .initial, changeHandler: { [unowned self] (_, _) in
|
||||||
|
self.title = vc.title
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
@IBAction func refresh(_ sender: Any) {
|
||||||
|
currentQueryViewController?.refresh()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
extension MainSplitViewController: NSMenuItemValidation {
|
||||||
|
func validateMenuItem(_ menuItem: NSMenuItem) -> Bool {
|
||||||
|
if menuItem.action == #selector(refresh(_:)) {
|
||||||
|
return currentQueryViewController != nil
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
|
@ -68,13 +68,6 @@ class QueryViewController: NSViewController {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override func viewDidAppear() {
|
|
||||||
super.viewDidAppear()
|
|
||||||
|
|
||||||
|
|
||||||
view.window!.makeFirstResponder(outlineView)
|
|
||||||
}
|
|
||||||
|
|
||||||
func refresh(reload: Bool = true) {
|
func refresh(reload: Bool = true) {
|
||||||
let filterText = filterTextView.string.trimmingCharacters(in: .whitespacesAndNewlines)
|
let filterText = filterTextView.string.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
let filter: Document
|
let filter: Document
|
||||||
|
|
|
@ -20,7 +20,7 @@ class DatabaseWindowController: NSWindowController {
|
||||||
var mongoController: MongoController!
|
var mongoController: MongoController!
|
||||||
var initialCollection: DatabaseCollection?
|
var initialCollection: DatabaseCollection?
|
||||||
|
|
||||||
private var databaseViewController: DatabaseViewController!
|
private var mainViewController: NSViewController!
|
||||||
|
|
||||||
private var statusChangeHandler: Cancellable?
|
private var statusChangeHandler: Cancellable?
|
||||||
private var connectionStatusChangeHandler: Cancellable?
|
private var connectionStatusChangeHandler: Cancellable?
|
||||||
|
@ -69,7 +69,7 @@ class DatabaseWindowController: NSWindowController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private func updateWindowTitle() {
|
private func updateWindowTitle() {
|
||||||
window?.title = databaseViewController?.title ?? "MongoView"
|
window?.title = mainViewController?.title ?? "MongoView"
|
||||||
}
|
}
|
||||||
|
|
||||||
private func updateStatusText(manager: StatusManager) {
|
private func updateStatusText(manager: StatusManager) {
|
||||||
|
@ -92,14 +92,10 @@ class DatabaseWindowController: NSWindowController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private func initializeUI() {
|
private func initializeUI() {
|
||||||
databaseViewController = DatabaseViewController(mongoController: mongoController)
|
mainViewController = MainSplitViewController(mongoController: mongoController, initialCollection: initialCollection)
|
||||||
// otherwise the VC size uses the size from the nib, potentially changing the window size
|
// otherwise the VC size uses the size from the nib, potentially changing the window size
|
||||||
databaseViewController.view.frame = CGRect(origin: .zero, size: window!.frame.size)
|
mainViewController.view.frame = CGRect(origin: .zero, size: window!.frame.size)
|
||||||
contentViewController = databaseViewController
|
contentViewController = mainViewController
|
||||||
|
|
||||||
if let initialCollection = initialCollection {
|
|
||||||
databaseViewController.showCollection(initialCollection)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -153,7 +149,7 @@ extension DatabaseWindowController: NSToolbarDelegate {
|
||||||
item.label = "Refresh"
|
item.label = "Refresh"
|
||||||
item.paletteLabel = "Refresh"
|
item.paletteLabel = "Refresh"
|
||||||
item.target = self
|
item.target = self
|
||||||
let button = NSButton(image: NSImage(named: NSImage.refreshTemplateName)!, target: nil, action: #selector(DatabaseViewController.refresh(_:)))
|
let button = NSButton(image: NSImage(named: NSImage.refreshTemplateName)!, target: nil, action: #selector(MainSplitViewController.refresh(_:)))
|
||||||
button.bezelStyle = .texturedRounded
|
button.bezelStyle = .texturedRounded
|
||||||
item.view = button
|
item.view = button
|
||||||
return item
|
return item
|
||||||
|
|
Loading…
Reference in New Issue