1+ import { ClipboardService } from '@theia/core/lib/browser/clipboard-service' ;
12import {
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' ;
257import {
26- KeybindingRegistry ,
278 KeybindingContribution ,
9+ KeybindingRegistry ,
2810} 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' ;
2915import {
3016 TabBarToolbarContribution ,
3117 TabBarToolbarRegistry ,
3218} 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' ;
3720import {
3821 Command ,
39- CommandRegistry ,
4022 CommandContribution ,
23+ CommandRegistry ,
4124 CommandService ,
4225} from '@theia/core/lib/common/command' ;
43- import { SettingsService } from '../dialogs/settings/settings' ;
4426import {
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' ;
4853import {
49- SketchesService ,
50- FileSystemExt ,
51- Sketch ,
52- CoreService ,
5354 CoreError ,
55+ CoreService ,
56+ FileSystemExt ,
5457 ResponseServiceClient ,
58+ Sketch ,
59+ SketchesService ,
5560} from '../../common/protocol' ;
61+ import {
62+ ExecuteWithProgress ,
63+ UserAbortApplicationError ,
64+ } from '../../common/protocol/progressible' ;
5665import { 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' ;
6366import { 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' ;
6868import { ConfigServiceClient } from '../config/config-service-client' ;
69- import { ApplicationShell } from '@theia/core/lib/browser/shell/application-shell' ;
7069import { DialogService } from '../dialog-service' ;
70+ import { SettingsService } from '../dialogs/settings/settings' ;
71+ import {
72+ CurrentSketch ,
73+ SketchesServiceClientImpl ,
74+ } from '../sketches-service-client-impl' ;
7175import { ApplicationConnectionStatusContribution } from '../theia/core/connection-status-service' ;
76+ import { OutputChannelManager } from '../theia/output/output-channel' ;
77+ import { WorkspaceService } from '../theia/workspace/workspace-service' ;
7278
7379export {
7480 Command ,
7581 CommandRegistry ,
76- MenuModelRegistry ,
7782 KeybindingRegistry ,
83+ MenuModelRegistry ,
84+ Sketch ,
7885 TabBarToolbarRegistry ,
7986 URI ,
80- Sketch ,
8187 open ,
8288} ;
8389
@@ -247,6 +253,12 @@ export abstract class CoreServiceContribution extends SketchContribution {
247253 }
248254
249255 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+ }
250262 this . tryToastErrorMessage ( error ) ;
251263 }
252264
@@ -293,7 +305,13 @@ export abstract class CoreServiceContribution extends SketchContribution {
293305 protected async doWithProgress < T > ( options : {
294306 progressText : string ;
295307 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 ;
297315 } ) : Promise < T > {
298316 const toDisposeOnComplete = new DisposableCollection (
299317 this . maybeActivateMonitorWidget ( )
@@ -306,8 +324,10 @@ export abstract class CoreServiceContribution extends SketchContribution {
306324 messageService : this . messageService ,
307325 responseService : this . responseService ,
308326 progressText,
309- run : ( { progressId } ) => task ( progressId , this . coreService ) ,
327+ run : ( { progressId, cancellationToken } ) =>
328+ task ( progressId , this . coreService , cancellationToken ) ,
310329 keepOutput,
330+ cancelable : options . cancelable ,
311331 } ) ;
312332 toDisposeOnComplete . dispose ( ) ;
313333 return result ;
0 commit comments