mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-29 14:16:39 +00:00
Updated MonitorWidget to use new monitor proxy
This commit is contained in:
parent
7889f40834
commit
ce2f1c227a
@ -152,7 +152,7 @@ import {
|
||||
OutputChannelRegistryMainImpl as TheiaOutputChannelRegistryMainImpl,
|
||||
OutputChannelRegistryMainImpl,
|
||||
} from './theia/plugin-ext/output-channel-registry-main';
|
||||
import { ExecutableService, ExecutableServicePath } from '../common/protocol';
|
||||
import { ExecutableService, ExecutableServicePath, MonitorManagerProxy, MonitorManagerProxyClient, MonitorManagerProxyPath } from '../common/protocol';
|
||||
import { MonacoTextModelService as TheiaMonacoTextModelService } from '@theia/monaco/lib/browser/monaco-text-model-service';
|
||||
import { MonacoTextModelService } from './theia/monaco/monaco-text-model-service';
|
||||
import { ResponseServiceImpl } from './response-service-impl';
|
||||
@ -267,7 +267,7 @@ import {
|
||||
IDEUpdaterDialogWidget,
|
||||
} from './dialogs/ide-updater/ide-updater-dialog';
|
||||
import { ElectronIpcConnectionProvider } from '@theia/core/lib/electron-browser/messaging/electron-ipc-connection-provider';
|
||||
import { MonitorManagerProxyClient } from '../common/monitor-manager-proxy';
|
||||
import { MonitorModel } from './monitor-model';
|
||||
import { MonitorManagerProxyClientImpl } from './monitor-manager-proxy-client-impl';
|
||||
|
||||
const ElementQueries = require('css-element-queries/src/ElementQueries');
|
||||
@ -402,13 +402,23 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
||||
|
||||
// Serial monitor
|
||||
bind(MonitorWidget).toSelf();
|
||||
bind(MonitorModel).toSelf().inSingletonScope();
|
||||
bindViewContribution(bind, MonitorViewContribution);
|
||||
bind(TabBarToolbarContribution).toService(MonitorViewContribution);
|
||||
bind(WidgetFactory).toDynamicValue((context) => ({
|
||||
id: MonitorWidget.ID,
|
||||
createWidget: () => context.container.get(MonitorWidget),
|
||||
createWidget: () => {
|
||||
return new MonitorWidget(
|
||||
context.container.get<MonitorModel>(MonitorModel),
|
||||
context.container.get<MonitorManagerProxyClient>(MonitorManagerProxyClient),
|
||||
context.container.get<BoardsServiceProvider>(BoardsServiceProvider),
|
||||
);
|
||||
}
|
||||
}));
|
||||
|
||||
bind(MonitorManagerProxy).toDynamicValue((context) =>
|
||||
WebSocketConnectionProvider.createProxy(context.container, MonitorManagerProxyPath)
|
||||
).inSingletonScope();
|
||||
|
||||
// Monitor manager proxy client to receive and delegate pluggable monitors
|
||||
// notifications from the backend
|
||||
|
@ -28,15 +28,6 @@ export class MonitorWidget extends ReactWidget {
|
||||
);
|
||||
static readonly ID = 'serial-monitor';
|
||||
|
||||
@inject(MonitorModel)
|
||||
protected readonly monitorModel: MonitorModel;
|
||||
|
||||
@inject(MonitorManagerProxyClient)
|
||||
protected readonly monitorManagerProxy: MonitorManagerProxyClient;
|
||||
|
||||
@inject(BoardsServiceProvider)
|
||||
protected readonly boardsServiceProvider: BoardsServiceProvider;
|
||||
|
||||
protected widgetHeight: number;
|
||||
|
||||
/**
|
||||
@ -50,7 +41,16 @@ export class MonitorWidget extends ReactWidget {
|
||||
protected closing = false;
|
||||
protected readonly clearOutputEmitter = new Emitter<void>();
|
||||
|
||||
constructor() {
|
||||
constructor(
|
||||
@inject(MonitorModel)
|
||||
protected readonly monitorModel: MonitorModel,
|
||||
|
||||
@inject(MonitorManagerProxyClient)
|
||||
protected readonly monitorManagerProxy: MonitorManagerProxyClient,
|
||||
|
||||
@inject(BoardsServiceProvider)
|
||||
protected readonly boardsServiceProvider: BoardsServiceProvider
|
||||
) {
|
||||
super();
|
||||
this.id = MonitorWidget.ID;
|
||||
this.title.label = MonitorWidget.LABEL;
|
||||
@ -62,6 +62,13 @@ export class MonitorWidget extends ReactWidget {
|
||||
Disposable.create(() => this.monitorManagerProxy.disconnect())
|
||||
);
|
||||
|
||||
// Start monitor right away if there is already a board/port combination selected
|
||||
const { selectedBoard, selectedPort } =
|
||||
this.boardsServiceProvider.boardsConfig;
|
||||
if (selectedBoard && selectedBoard.fqbn && selectedPort) {
|
||||
this.monitorManagerProxy.startMonitor(selectedBoard, selectedPort);
|
||||
}
|
||||
|
||||
this.toDispose.push(
|
||||
this.boardsServiceProvider.onBoardsConfigChanged(
|
||||
async ({ selectedBoard, selectedPort }) => {
|
||||
@ -70,6 +77,7 @@ export class MonitorWidget extends ReactWidget {
|
||||
selectedBoard,
|
||||
selectedPort
|
||||
);
|
||||
this.update();
|
||||
}
|
||||
}
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user