-
Notifications
You must be signed in to change notification settings - Fork 226
Expand file tree
/
Copy pathdb-module.ts
More file actions
55 lines (42 loc) · 1.61 KB
/
db-module.ts
File metadata and controls
55 lines (42 loc) · 1.61 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
import { window } from "vscode";
import { App } from "../common/app";
import { extLogger } from "../common";
import { DisposableObject } from "../pure/disposable-object";
import { DbConfigStore } from "./config/db-config-store";
import { DbManager } from "./db-manager";
import { DbPanel } from "./ui/db-panel";
import { DbSelectionDecorationProvider } from "./ui/db-selection-decoration-provider";
import { DatabasePanelCommands } from "../common/commands";
export class DbModule extends DisposableObject {
public readonly dbManager: DbManager;
private readonly dbConfigStore: DbConfigStore;
private dbPanel: DbPanel | undefined;
private constructor(app: App) {
super();
this.dbConfigStore = new DbConfigStore(app);
this.dbManager = new DbManager(app, this.dbConfigStore);
}
public static async initialize(app: App): Promise<DbModule> {
const dbModule = new DbModule(app);
app.subscriptions.push(dbModule);
await dbModule.initialize(app);
return dbModule;
}
public getCommands(): DatabasePanelCommands {
if (!this.dbPanel) {
throw new Error("Database panel not initialized");
}
return {
...this.dbPanel.getCommands(),
};
}
private async initialize(app: App): Promise<void> {
void extLogger.log("Initializing database module");
await this.dbConfigStore.initialize();
this.dbPanel = new DbPanel(this.dbManager, app.credentials);
this.push(this.dbPanel);
this.push(this.dbConfigStore);
const dbSelectionDecorationProvider = new DbSelectionDecorationProvider();
window.registerFileDecorationProvider(dbSelectionDecorationProvider);
}
}