Implemented the Widget

Re-introduced bottom panel tabs

Signed-off-by: jbicker <jan.bicker@typefox.io>
This commit is contained in:
jbicker
2019-07-26 09:57:42 +02:00
parent 206b65f138
commit 76d0f5a464
14 changed files with 894 additions and 18 deletions

View File

@@ -0,0 +1,60 @@
import { injectable, inject } from "inversify";
import { MonitorService, ConnectionConfig } from "../../common/protocol/monitor-service";
import { Emitter, Event } from "@theia/core";
@injectable()
export class MonitorConnection {
@inject(MonitorService)
protected readonly monitorService: MonitorService;
protected _connectionId: string | undefined;
protected _connectionConfig: ConnectionConfig;
protected readonly onConnectionChangedEmitter = new Emitter<string | undefined>();
readonly onConnectionChanged: Event<string | undefined> = this.onConnectionChangedEmitter.event;
get connectionId(): string | undefined {
return this._connectionId;
}
set connectionId(cid: string | undefined) {
this._connectionId = cid;
}
get connectionConfig(): ConnectionConfig {
return this._connectionConfig;
}
async connect(config: ConnectionConfig): Promise<string | undefined> {
if (this._connectionId) {
await this.disconnect();
}
const { connectionId } = await this.monitorService.connect(config);
this._connectionId = connectionId;
this._connectionConfig = config;
this.onConnectionChangedEmitter.fire(this._connectionId);
return connectionId;
}
async disconnect(): Promise<boolean> {
let result = true;
const connections = await this.monitorService.getConnectionIds();
if (this._connectionId && connections.findIndex(id => id === this._connectionId) >= 0) {
console.log('>>> Disposing existing monitor connection before establishing a new one...');
result = await this.monitorService.disconnect(this._connectionId);
if (!result) {
// TODO: better!!!
console.error(`Could not close connection: ${this._connectionId}. Check the backend logs.`);
} else {
console.log(`<<< Disposed ${this._connectionId} connection.`);
this._connectionId = undefined;
}
this.onConnectionChangedEmitter.fire(this._connectionId);
}
return result;
}
}