@@ -6,6 +6,10 @@ import {
6
6
} from '@theia/core/shared/inversify' ;
7
7
import URI from '@theia/core/lib/common/uri' ;
8
8
import { ILogger } from '@theia/core/lib/common/logger' ;
9
+ import {
10
+ Disposable ,
11
+ DisposableCollection ,
12
+ } from '@theia/core/lib/common/disposable' ;
9
13
import { Saveable } from '@theia/core/lib/browser/saveable' ;
10
14
import { FileService } from '@theia/filesystem/lib/browser/file-service' ;
11
15
import { MaybePromise } from '@theia/core/lib/common/types' ;
@@ -62,6 +66,7 @@ import { MessageType } from '@theia/core/lib/common/message-service-protocol';
62
66
import { WorkspaceService } from '../theia/workspace/workspace-service' ;
63
67
import { MainMenuManager } from '../../common/main-menu-manager' ;
64
68
import { ConfigServiceClient } from '../config/config-service-client' ;
69
+ import { ApplicationShell } from '@theia/core/lib/browser/shell/application-shell' ;
65
70
66
71
export {
67
72
Command ,
@@ -217,6 +222,9 @@ export abstract class CoreServiceContribution extends SketchContribution {
217
222
@inject ( NotificationManager )
218
223
private readonly notificationManager : NotificationManager ;
219
224
225
+ @inject ( ApplicationShell )
226
+ private readonly shell : ApplicationShell ;
227
+
220
228
/**
221
229
* This is the internal (Theia) ID of the notification that is currently visible.
222
230
* 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 {
279
287
keepOutput ?: boolean ;
280
288
task : ( progressId : string , coreService : CoreService ) => Promise < T > ;
281
289
} ) : Promise < T > {
290
+ const toDisposeOnComplete = new DisposableCollection (
291
+ this . maybeActivateMonitorWidget ( )
292
+ ) ;
282
293
const { progressText, keepOutput, task } = options ;
283
294
this . outputChannelManager
284
295
. getChannel ( 'Arduino' )
@@ -290,9 +301,24 @@ export abstract class CoreServiceContribution extends SketchContribution {
290
301
run : ( { progressId } ) => task ( progressId , this . coreService ) ,
291
302
keepOutput,
292
303
} ) ;
304
+ toDisposeOnComplete . dispose ( ) ;
293
305
return result ;
294
306
}
295
307
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
+
296
322
private notificationId ( message : string , ...actions : string [ ] ) : string {
297
323
return this . notificationManager [ 'getMessageId' ] ( {
298
324
text : message ,
0 commit comments