1
+ import { ClipboardService } from '@theia/core/lib/browser/clipboard-service' ;
1
2
import {
2
- inject ,
3
- injectable ,
4
- interfaces ,
5
- postConstruct ,
6
- } from '@theia/core/shared/inversify' ;
7
- import URI from '@theia/core/lib/common/uri' ;
8
- import { ILogger } from '@theia/core/lib/common/logger' ;
9
- import {
10
- Disposable ,
11
- DisposableCollection ,
12
- } from '@theia/core/lib/common/disposable' ;
13
- import { Saveable } from '@theia/core/lib/browser/saveable' ;
14
- import { FileService } from '@theia/filesystem/lib/browser/file-service' ;
15
- import { MaybePromise } from '@theia/core/lib/common/types' ;
16
- import { LabelProvider } from '@theia/core/lib/browser/label-provider' ;
17
- import { EditorManager } from '@theia/editor/lib/browser/editor-manager' ;
18
- import { MessageService } from '@theia/core/lib/common/message-service' ;
19
- import { EnvVariablesServer } from '@theia/core/lib/common/env-variables' ;
20
- import { open , OpenerService } from '@theia/core/lib/browser/opener-service' ;
21
- import {
22
- MenuModelRegistry ,
23
- MenuContribution ,
24
- } from '@theia/core/lib/common/menu' ;
3
+ FrontendApplication ,
4
+ FrontendApplicationContribution ,
5
+ } from '@theia/core/lib/browser/frontend-application' ;
6
+ import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state' ;
25
7
import {
26
- KeybindingRegistry ,
27
8
KeybindingContribution ,
9
+ KeybindingRegistry ,
28
10
} from '@theia/core/lib/browser/keybinding' ;
11
+ import { LabelProvider } from '@theia/core/lib/browser/label-provider' ;
12
+ import { OpenerService , open } from '@theia/core/lib/browser/opener-service' ;
13
+ import { Saveable } from '@theia/core/lib/browser/saveable' ;
14
+ import { ApplicationShell } from '@theia/core/lib/browser/shell/application-shell' ;
29
15
import {
30
16
TabBarToolbarContribution ,
31
17
TabBarToolbarRegistry ,
32
18
} from '@theia/core/lib/browser/shell/tab-bar-toolbar' ;
33
- import {
34
- FrontendApplicationContribution ,
35
- FrontendApplication ,
36
- } from '@theia/core/lib/browser/frontend-application' ;
19
+ import { CancellationToken } from '@theia/core/lib/common/cancellation' ;
37
20
import {
38
21
Command ,
39
- CommandRegistry ,
40
22
CommandContribution ,
23
+ CommandRegistry ,
41
24
CommandService ,
42
25
} from '@theia/core/lib/common/command' ;
43
- import { SettingsService } from '../dialogs/settings/settings' ;
44
26
import {
45
- CurrentSketch ,
46
- SketchesServiceClientImpl ,
47
- } from '../sketches-service-client-impl' ;
27
+ Disposable ,
28
+ DisposableCollection ,
29
+ } from '@theia/core/lib/common/disposable' ;
30
+ import { EnvVariablesServer } from '@theia/core/lib/common/env-variables' ;
31
+ import { ILogger } from '@theia/core/lib/common/logger' ;
32
+ import {
33
+ MenuContribution ,
34
+ MenuModelRegistry ,
35
+ } from '@theia/core/lib/common/menu' ;
36
+ import { MessageService } from '@theia/core/lib/common/message-service' ;
37
+ import { MessageType } from '@theia/core/lib/common/message-service-protocol' ;
38
+ import { nls } from '@theia/core/lib/common/nls' ;
39
+ import { MaybePromise , isObject } from '@theia/core/lib/common/types' ;
40
+ import URI from '@theia/core/lib/common/uri' ;
41
+ import {
42
+ inject ,
43
+ injectable ,
44
+ interfaces ,
45
+ postConstruct ,
46
+ } from '@theia/core/shared/inversify' ;
47
+ import { EditorManager } from '@theia/editor/lib/browser/editor-manager' ;
48
+ import { FileService } from '@theia/filesystem/lib/browser/file-service' ;
49
+ import { NotificationManager } from '@theia/messages/lib/browser/notifications-manager' ;
50
+ import { OutputChannelSeverity } from '@theia/output/lib/browser/output-channel' ;
51
+ import { MainMenuManager } from '../../common/main-menu-manager' ;
52
+ import { userAbort } from '../../common/nls' ;
48
53
import {
49
- SketchesService ,
50
- FileSystemExt ,
51
- Sketch ,
52
- CoreService ,
53
54
CoreError ,
55
+ CoreService ,
56
+ FileSystemExt ,
54
57
ResponseServiceClient ,
58
+ Sketch ,
59
+ SketchesService ,
55
60
} from '../../common/protocol' ;
61
+ import {
62
+ ExecuteWithProgress ,
63
+ UserAbortApplicationError ,
64
+ } from '../../common/protocol/progressible' ;
56
65
import { ArduinoPreferences } from '../arduino-preferences' ;
57
- import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state' ;
58
- import { nls } from '@theia/core' ;
59
- import { OutputChannelManager } from '../theia/output/output-channel' ;
60
- import { ClipboardService } from '@theia/core/lib/browser/clipboard-service' ;
61
- import { ExecuteWithProgress } from '../../common/protocol/progressible' ;
62
- import { BoardsServiceProvider } from '../boards/boards-service-provider' ;
63
66
import { BoardsDataStore } from '../boards/boards-data-store' ;
64
- import { NotificationManager } from '@theia/messages/lib/browser/notifications-manager' ;
65
- import { MessageType } from '@theia/core/lib/common/message-service-protocol' ;
66
- import { WorkspaceService } from '../theia/workspace/workspace-service' ;
67
- import { MainMenuManager } from '../../common/main-menu-manager' ;
67
+ import { BoardsServiceProvider } from '../boards/boards-service-provider' ;
68
68
import { ConfigServiceClient } from '../config/config-service-client' ;
69
- import { ApplicationShell } from '@theia/core/lib/browser/shell/application-shell' ;
70
69
import { DialogService } from '../dialog-service' ;
70
+ import { SettingsService } from '../dialogs/settings/settings' ;
71
+ import {
72
+ CurrentSketch ,
73
+ SketchesServiceClientImpl ,
74
+ } from '../sketches-service-client-impl' ;
71
75
import { ApplicationConnectionStatusContribution } from '../theia/core/connection-status-service' ;
76
+ import { OutputChannelManager } from '../theia/output/output-channel' ;
77
+ import { WorkspaceService } from '../theia/workspace/workspace-service' ;
72
78
73
79
export {
74
80
Command ,
75
81
CommandRegistry ,
76
- MenuModelRegistry ,
77
82
KeybindingRegistry ,
83
+ MenuModelRegistry ,
84
+ Sketch ,
78
85
TabBarToolbarRegistry ,
79
86
URI ,
80
- Sketch ,
81
87
open ,
82
88
} ;
83
89
@@ -247,6 +253,12 @@ export abstract class CoreServiceContribution extends SketchContribution {
247
253
}
248
254
249
255
protected handleError ( error : unknown ) : void {
256
+ if ( isObject ( error ) && UserAbortApplicationError . is ( error ) ) {
257
+ this . outputChannelManager
258
+ . getChannel ( 'Arduino' )
259
+ . appendLine ( userAbort , OutputChannelSeverity . Warning ) ;
260
+ return ;
261
+ }
250
262
this . tryToastErrorMessage ( error ) ;
251
263
}
252
264
@@ -293,7 +305,13 @@ export abstract class CoreServiceContribution extends SketchContribution {
293
305
protected async doWithProgress < T > ( options : {
294
306
progressText : string ;
295
307
keepOutput ?: boolean ;
296
- task : ( progressId : string , coreService : CoreService ) => Promise < T > ;
308
+ task : (
309
+ progressId : string ,
310
+ coreService : CoreService ,
311
+ cancellationToken ?: CancellationToken
312
+ ) => Promise < T > ;
313
+ // false by default
314
+ cancelable ?: boolean ;
297
315
} ) : Promise < T > {
298
316
const toDisposeOnComplete = new DisposableCollection (
299
317
this . maybeActivateMonitorWidget ( )
@@ -306,8 +324,10 @@ export abstract class CoreServiceContribution extends SketchContribution {
306
324
messageService : this . messageService ,
307
325
responseService : this . responseService ,
308
326
progressText,
309
- run : ( { progressId } ) => task ( progressId , this . coreService ) ,
327
+ run : ( { progressId, cancellationToken } ) =>
328
+ task ( progressId , this . coreService , cancellationToken ) ,
310
329
keepOutput,
330
+ cancelable : options . cancelable ,
311
331
} ) ;
312
332
toDisposeOnComplete . dispose ( ) ;
313
333
return result ;
0 commit comments