-
Notifications
You must be signed in to change notification settings - Fork 398
Expand file tree
/
Copy pathSettingsView.swift
More file actions
82 lines (70 loc) · 3.17 KB
/
SettingsView.swift
File metadata and controls
82 lines (70 loc) · 3.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//
// SettingsView.swift
// Postgres
//
// Created by Chris on 03/08/2016.
// Copyright © 2016 postgresapp. All rights reserved.
//
import Cocoa
class SettingsViewController: NSViewController {
@objc dynamic var server: Server?
@IBAction func showDataDirectory(_ sender: AnyObject?) {
guard let path = self.server?.varPath else { return }
if !NSWorkspace.shared.selectFile(path, inFileViewerRootedAtPath: "") {
let userInfo = [
NSLocalizedDescriptionKey: "Folder not found.",
NSLocalizedRecoverySuggestionErrorKey: "It will be created the first time you start the server."
]
let error = NSError(domain: "com.postgresapp.Postgres2.missing-folder", code: 0, userInfo: userInfo)
self.presentError(error, modalFor: self.view.window!, delegate: nil, didPresent: nil, contextInfo: nil)
}
}
@IBAction func showBinariesDirectory(_ sender: AnyObject?) {
guard let path = self.server?.binPath else { return }
if !NSWorkspace.shared.selectFile(path, inFileViewerRootedAtPath: "") {
let userInfo = [
NSLocalizedDescriptionKey: "Folder not found."
]
let error = NSError(domain: "com.postgresapp.Postgres2.missing-folder", code: 0, userInfo: userInfo)
self.presentError(error, modalFor: self.view.window!, delegate: nil, didPresent: nil, contextInfo: nil)
}
}
@IBAction func showConfigFile(_ sender: AnyObject?) {
guard let path = self.server?.configFilePath else { return }
if !NSWorkspace.shared.selectFile(path, inFileViewerRootedAtPath: "") {
let userInfo = [
NSLocalizedDescriptionKey: "File not found.",
NSLocalizedRecoverySuggestionErrorKey: "It will be created the first time you start the server."
]
let error = NSError(domain: "com.postgresapp.Postgres2.missing-file", code: 0, userInfo: userInfo)
self.presentError(error, modalFor: self.view.window!, delegate: nil, didPresent: nil, contextInfo: nil)
}
}
@IBAction func showHBAFile(_ sender: AnyObject?) {
guard let path = self.server?.hbaFilePath else { return }
if !NSWorkspace.shared.selectFile(path, inFileViewerRootedAtPath: "") {
let userInfo = [
NSLocalizedDescriptionKey: "File not found.",
NSLocalizedRecoverySuggestionErrorKey: "It will be created the first time you start the server."
]
let error = NSError(domain: "com.postgresapp.Postgres2.missing-file", code: 0, userInfo: userInfo)
self.presentError(error, modalFor: self.view.window!, delegate: nil, didPresent: nil, contextInfo: nil)
}
}
@IBAction func openLogFile(_ sender: AnyObject?) {
guard let path = self.server?.logFilePath else { return }
if !NSWorkspace.shared.openFile(path, withApplication: "Console") {
let userInfo = [
NSLocalizedDescriptionKey: "File not found.",
NSLocalizedRecoverySuggestionErrorKey: "It will be created the first time you start the server."
]
let error = NSError(domain: "com.postgresapp.Postgres2.missing-file", code: 0, userInfo: userInfo)
self.presentError(error, modalFor: self.view.window!, delegate: nil, didPresent: nil, contextInfo: nil)
}
}
override func prepare(for segue: NSStoryboardSegue, sender: Any?) {
if let target = segue.destinationController as? ChangePasswordViewController {
target.server = server
}
}
}