Skip to content

Commit 6e72be1

Browse files
Akos Kittakittaakos
Akos Kitta
authored andcommitted
feat: re-focus monitor widget after verify/upload
supported when the monitor widget was the current in the bottom panel, and the core command (upload/verify/etc./) was successful Signed-off-by: Akos Kitta <[email protected]>
1 parent e4beb03 commit 6e72be1

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

arduino-ide-extension/src/browser/contributions/contribution.ts

+26
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import {
66
} from '@theia/core/shared/inversify';
77
import URI from '@theia/core/lib/common/uri';
88
import { ILogger } from '@theia/core/lib/common/logger';
9+
import {
10+
Disposable,
11+
DisposableCollection,
12+
} from '@theia/core/lib/common/disposable';
913
import { Saveable } from '@theia/core/lib/browser/saveable';
1014
import { FileService } from '@theia/filesystem/lib/browser/file-service';
1115
import { MaybePromise } from '@theia/core/lib/common/types';
@@ -62,6 +66,7 @@ import { MessageType } from '@theia/core/lib/common/message-service-protocol';
6266
import { WorkspaceService } from '../theia/workspace/workspace-service';
6367
import { MainMenuManager } from '../../common/main-menu-manager';
6468
import { ConfigServiceClient } from '../config/config-service-client';
69+
import { ApplicationShell } from '@theia/core/lib/browser/shell/application-shell';
6570

6671
export {
6772
Command,
@@ -217,6 +222,9 @@ export abstract class CoreServiceContribution extends SketchContribution {
217222
@inject(NotificationManager)
218223
private readonly notificationManager: NotificationManager;
219224

225+
@inject(ApplicationShell)
226+
private readonly shell: ApplicationShell;
227+
220228
/**
221229
* This is the internal (Theia) ID of the notification that is currently visible.
222230
* It's stored here as a field to be able to close it before executing any new core command (such as verify, upload, etc.)
@@ -279,6 +287,9 @@ export abstract class CoreServiceContribution extends SketchContribution {
279287
keepOutput?: boolean;
280288
task: (progressId: string, coreService: CoreService) => Promise<T>;
281289
}): Promise<T> {
290+
const toDisposeOnComplete = new DisposableCollection(
291+
this.maybeActivateMonitorWidget()
292+
);
282293
const { progressText, keepOutput, task } = options;
283294
this.outputChannelManager
284295
.getChannel('Arduino')
@@ -290,9 +301,24 @@ export abstract class CoreServiceContribution extends SketchContribution {
290301
run: ({ progressId }) => task(progressId, this.coreService),
291302
keepOutput,
292303
});
304+
toDisposeOnComplete.dispose();
293305
return result;
294306
}
295307

308+
// TODO: cleanup!
309+
// this dependency does not belong here
310+
// support core command contribution handlers, the monitor-widget should implement it and register itself as a handler
311+
// the monitor widget should reveal itself after a successful core command execution
312+
private maybeActivateMonitorWidget(): Disposable {
313+
const currentWidget = this.shell.bottomPanel.currentTitle?.owner;
314+
if (currentWidget?.id === 'serial-monitor') {
315+
return Disposable.create(() =>
316+
this.shell.bottomPanel.activateWidget(currentWidget)
317+
);
318+
}
319+
return Disposable.NULL;
320+
}
321+
296322
private notificationId(message: string, ...actions: string[]): string {
297323
return this.notificationManager['getMessageId']({
298324
text: message,

0 commit comments

Comments
 (0)