No disconnect/reconnect when DNDing the widget.

- Updated to next Theia,
 - Added elecron launch config,
 - Yet another syling for the input + selects,
 - Close monitor connection on widget close not detach.

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
Akos Kitta 2019-12-06 10:09:30 +01:00
parent 6154d1e8d5
commit 2f33038695
7 changed files with 925 additions and 501 deletions

42
.vscode/launch.json vendored
View File

@ -7,14 +7,39 @@
{ {
"type": "node", "type": "node",
"request": "launch", "request": "launch",
"name": "Launch Electron Packager", "name": "App (Electron)",
"program": "${workspaceRoot}/electron/packager/index.js", "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
"cwd": "${workspaceFolder}/electron/packager" "windows": {
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
},
"program": "${workspaceRoot}/electron-app/src-gen/frontend/electron-main.js",
"protocol": "inspector",
"args": [
"--log-level=debug",
"--hostname=localhost",
"--no-cluster",
"--remote-debugging-port=9222",
"--no-app-auto-install",
"--debug-cli=true"
],
"env": {
"NODE_ENV": "development"
},
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/electron-app/src-gen/backend/*.js",
"${workspaceRoot}/electron-app/src-gen/frontend/*.js",
"${workspaceRoot}/electron-app/lib/**/*.js",
"${workspaceRoot}/arduino-ide-extension/*/lib/**/*.js"
],
"smartStep": true,
"internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std"
}, },
{ {
"type": "node", "type": "node",
"request": "launch", "request": "launch",
"name": "Launch Backend", "name": "App (Browser)",
"program": "${workspaceRoot}/browser-app/src-gen/backend/main.js", "program": "${workspaceRoot}/browser-app/src-gen/backend/main.js",
"args": [ "args": [
"--hostname=0.0.0.0", "--hostname=0.0.0.0",
@ -38,7 +63,7 @@
{ {
"type": "node", "type": "node",
"request": "launch", "request": "launch",
"name": "Launch Backend (Debug CLI daemon)", "name": "App (Browser - Debug CLI daemon)",
"program": "${workspaceRoot}/browser-app/src-gen/backend/main.js", "program": "${workspaceRoot}/browser-app/src-gen/backend/main.js",
"args": [ "args": [
"--hostname=0.0.0.0", "--hostname=0.0.0.0",
@ -59,6 +84,13 @@
"smartStep": true, "smartStep": true,
"internalConsoleOptions": "openOnSessionStart", "internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std" "outputCapture": "std"
},
{
"type": "node",
"request": "launch",
"name": "Packager",
"program": "${workspaceRoot}/electron/packager/index.js",
"cwd": "${workspaceFolder}/electron/packager"
} }
] ]
} }

View File

@ -78,7 +78,7 @@ export class MonitorModel implements FrontendApplicationContribution {
this.storeState().then(() => this.onChangeEmitter.fire({ property: 'lineEnding', value: this._lineEnding })); this.storeState().then(() => this.onChangeEmitter.fire({ property: 'lineEnding', value: this._lineEnding }));
} }
protected restoreState(state: MonitorModel.State) { protected restoreState(state: MonitorModel.State): void {
this._autoscroll = state.autoscroll; this._autoscroll = state.autoscroll;
this._timestamp = state.timestamp; this._timestamp = state.timestamp;
this._baudRate = state.baudRate; this._baudRate = state.baudRate;
@ -86,7 +86,7 @@ export class MonitorModel implements FrontendApplicationContribution {
} }
protected async storeState(): Promise<void> { protected async storeState(): Promise<void> {
this.localStorageService.setData(MonitorModel.STORAGE_ID, { return this.localStorageService.setData(MonitorModel.STORAGE_ID, {
autoscroll: this._autoscroll, autoscroll: this._autoscroll,
timestamp: this._timestamp, timestamp: this._timestamp,
baudRate: this._baudRate, baudRate: this._baudRate,

View File

@ -41,6 +41,7 @@ export class MonitorWidget extends ReactWidget {
this.id = MonitorWidget.ID; this.id = MonitorWidget.ID;
this.title.label = 'Serial Monitor'; this.title.label = 'Serial Monitor';
this.title.iconClass = 'arduino-serial-monitor-tab-icon'; this.title.iconClass = 'arduino-serial-monitor-tab-icon';
this.title.closable = true;
this.scrollOptions = undefined; this.scrollOptions = undefined;
this.toDispose.push(this.clearOutputEmitter); this.toDispose.push(this.clearOutputEmitter);
} }
@ -56,14 +57,21 @@ export class MonitorWidget extends ReactWidget {
this.update(); this.update();
} }
dispose(): void {
super.dispose();
}
protected onAfterAttach(msg: Message): void { protected onAfterAttach(msg: Message): void {
super.onAfterAttach(msg); super.onAfterAttach(msg);
this.monitorConnection.autoConnect = true; this.monitorConnection.autoConnect = true;
} }
protected onBeforeDetach(msg: Message): void { onCloseRequest(msg: Message): void {
super.onBeforeDetach(msg);
this.monitorConnection.autoConnect = false; this.monitorConnection.autoConnect = false;
if (this.monitorConnection.connected) {
this.monitorConnection.disconnect();
}
super.onCloseRequest(msg);
} }
protected onResize(msg: Widget.ResizeMessage): void { protected onResize(msg: Widget.ResizeMessage): void {

View File

@ -21,7 +21,7 @@
.serial-monitor .head .send { .serial-monitor .head .send {
display: flex; display: flex;
flex: 1; flex: 1;
margin-right: 5px; margin-right: 2px;
} }
.serial-monitor .head .send > input { .serial-monitor .head .send > input {
@ -42,7 +42,7 @@
} }
.serial-monitor .head .config .select { .serial-monitor .head .config .select {
margin-left: 5px; margin-left: 3px;
} }
.serial-monitor .body { .serial-monitor .body {

View File

@ -1,6 +1,7 @@
import * as PQueue from 'p-queue'; import * as PQueue from 'p-queue';
import { injectable, inject, postConstruct, named } from 'inversify'; import { injectable, inject, postConstruct, named } from 'inversify';
import { ILogger } from '@theia/core/lib/common/logger'; import { ILogger } from '@theia/core/lib/common/logger';
import { Deferred } from '@theia/core/lib/common/promise-util';
import { BoardsService, AttachedSerialBoard, BoardPackage, Board, AttachedNetworkBoard, BoardsServiceClient, Port } from '../common/protocol/boards-service'; import { BoardsService, AttachedSerialBoard, BoardPackage, Board, AttachedNetworkBoard, BoardsServiceClient, Port } from '../common/protocol/boards-service';
import { import {
PlatformSearchReq, PlatformSearchReq,
@ -43,6 +44,7 @@ export class BoardsServiceImpl implements BoardsService {
*/ */
protected attachedBoards: { boards: Board[] } = { boards: [] }; protected attachedBoards: { boards: Board[] } = { boards: [] };
protected availablePorts: { ports: Port[] } = { ports: [] }; protected availablePorts: { ports: Port[] } = { ports: [] };
protected started = new Deferred<void>();
protected client: BoardsServiceClient | undefined; protected client: BoardsServiceClient | undefined;
protected readonly queue = new PQueue({ autoStart: true, concurrency: 1 }); protected readonly queue = new PQueue({ autoStart: true, concurrency: 1 });
@ -74,6 +76,7 @@ export class BoardsServiceImpl implements BoardsService {
if (!this.discoveryInitialized) { if (!this.discoveryInitialized) {
update([], sortedBoards, [], sortedPorts, 'Initialized attached boards and available ports.'); update([], sortedBoards, [], sortedPorts, 'Initialized attached boards and available ports.');
this.discoveryInitialized = true; this.discoveryInitialized = true;
this.started.resolve();
} else { } else {
Promise.all([ Promise.all([
this.getAttachedBoards(), this.getAttachedBoards(),
@ -120,10 +123,12 @@ export class BoardsServiceImpl implements BoardsService {
} }
async getAttachedBoards(): Promise<{ boards: Board[] }> { async getAttachedBoards(): Promise<{ boards: Board[] }> {
await this.started.promise;
return this.attachedBoards; return this.attachedBoards;
} }
async getAvailablePorts(): Promise<{ ports: Port[] }> { async getAvailablePorts(): Promise<{ ports: Port[] }> {
await this.started.promise;
return this.availablePorts; return this.availablePorts;
} }

View File

@ -71,7 +71,7 @@ export class MonitorServiceImpl implements MonitorService {
duplex.on('error', ((error: Error) => { duplex.on('error', ((error: Error) => {
const monitorError = ErrorWithCode.toMonitorError(error, config); const monitorError = ErrorWithCode.toMonitorError(error, config);
this.disconnect().then(() => { this.disconnect(monitorError).then(() => {
if (this.client) { if (this.client) {
this.client.notifyError(monitorError); this.client.notifyError(monitorError);
} }
@ -112,7 +112,10 @@ export class MonitorServiceImpl implements MonitorService {
}); });
} }
async disconnect(): Promise<Status> { async disconnect(reason?: MonitorError): Promise<Status> {
if (!this.connection && reason && reason.code === MonitorError.ErrorCodes.CLIENT_CANCEL) {
return Status.OK;
}
this.logger.info(`>>> Disposing monitor connection...`); this.logger.info(`>>> Disposing monitor connection...`);
if (!this.connection) { if (!this.connection) {
this.logger.warn(`<<< Not connected. Nothing to dispose.`); this.logger.warn(`<<< Not connected. Nothing to dispose.`);

1352
yarn.lock

File diff suppressed because it is too large Load Diff