@@ -4,7 +4,6 @@ import URI from '@theia/core/lib/common/uri';
4
4
import { EditorWidget } from '@theia/editor/lib/browser/editor-widget' ;
5
5
import { MessageService } from '@theia/core/lib/common/message-service' ;
6
6
import { CommandContribution , CommandRegistry } from '@theia/core/lib/common/command' ;
7
- import { DefaultFrontendApplicationContribution } from '@theia/core/lib/browser/frontend-application' ;
8
7
import { TabBarToolbarContribution , TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar' ;
9
8
import { BoardsService } from '../common/protocol/boards-service' ;
10
9
import { ArduinoCommands } from './arduino-commands' ;
@@ -21,15 +20,15 @@ import { WorkspaceService } from '@theia/workspace/lib/browser/workspace-service
21
20
import { SketchFactory } from './sketch-factory' ;
22
21
import { ArduinoToolbar } from './toolbar/arduino-toolbar' ;
23
22
import { EditorManager } from '@theia/editor/lib/browser' ;
24
- import { ContextMenuRenderer , OpenerService , Widget } from '@theia/core/lib/browser' ;
23
+ import { ContextMenuRenderer , OpenerService , Widget , Endpoint } from '@theia/core/lib/browser' ;
25
24
import { OpenFileDialogProps , FileDialogService } from '@theia/filesystem/lib/browser/file-dialog' ;
26
25
import { FileSystem } from '@theia/filesystem/lib/common' ;
27
26
import { ArduinoOpenSketchContextMenu } from './arduino-file-menu' ;
28
27
import { Sketch , SketchesService } from '../common/protocol/sketches-service' ;
29
28
import { WindowService } from '@theia/core/lib/browser/window/window-service' ;
30
29
31
30
@injectable ( )
32
- export class ArduinoFrontendContribution extends DefaultFrontendApplicationContribution implements TabBarToolbarContribution , CommandContribution {
31
+ export class ArduinoFrontendContribution implements TabBarToolbarContribution , CommandContribution {
33
32
34
33
@inject ( MessageService )
35
34
protected readonly messageService : MessageService ;
@@ -79,12 +78,11 @@ export class ArduinoFrontendContribution extends DefaultFrontendApplicationContr
79
78
@inject ( OpenerService )
80
79
protected readonly openerService : OpenerService ;
81
80
82
- @inject ( SketchesService )
83
- protected readonly sketches : SketchesService ;
84
-
85
81
@inject ( WindowService )
86
82
protected readonly windowService : WindowService ;
87
83
84
+ @inject ( SketchesService )
85
+ protected readonly sketches : SketchesService ;
88
86
89
87
@postConstruct ( )
90
88
protected async init ( ) : Promise < void > {
@@ -189,16 +187,7 @@ export class ArduinoFrontendContribution extends DefaultFrontendApplicationContr
189
187
registry . registerCommand ( ArduinoCommands . OPEN_SKETCH , {
190
188
isEnabled : ( ) => true ,
191
189
execute : async ( sketch : Sketch ) => {
192
- // const url = new URL(window.location.href);
193
- // if (this.workspaceService.workspace) {
194
- // const wsUri = this.workspaceService.workspace.uri;
195
- // const path = new URI(wsUri).path;
196
- // url.hash = path + '?sketch=' + sketch.name
197
- // }
198
- // this.windowService.openNewWindow(url.toString());
199
-
200
- this . openSketchFiles ( sketch . uri ) ;
201
-
190
+ this . openSketchFilesInNewWindow ( sketch . uri ) ;
202
191
}
203
192
} )
204
193
registry . registerCommand ( ArduinoCommands . NEW_SKETCH , new WorkspaceRootUriAwareCommandHandler ( this . workspaceService , this . selectionService , {
@@ -221,7 +210,14 @@ export class ArduinoFrontendContribution extends DefaultFrontendApplicationContr
221
210
} )
222
211
}
223
212
224
- protected async openSketchFiles ( uri : string ) {
213
+ protected async openSketchFilesInNewWindow ( uri : string ) {
214
+ const location = new URL ( window . location . href ) ;
215
+ let url = new Endpoint ( ) . getRestUrl ( ) . withQuery ( uri ) . toString ( ) ;
216
+ url += location . hash ;
217
+ this . windowService . openNewWindow ( url ) ;
218
+ }
219
+
220
+ async openSketchFiles ( uri : string ) {
225
221
const fileStat = await this . fileSystem . getFileStat ( uri ) ;
226
222
if ( fileStat ) {
227
223
const sketchFiles = await this . sketches . getSketchFiles ( fileStat ) ;
@@ -251,7 +247,7 @@ export class ArduinoFrontendContribution extends DefaultFrontendApplicationContr
251
247
if ( destinationFileUri ) {
252
248
const destinationFile = await this . fileSystem . getFileStat ( destinationFileUri . toString ( ) ) ;
253
249
if ( destinationFile && ! destinationFile . isDirectory ) {
254
- await this . openSketchFiles ( destinationFileUri . toString ( ) ) ;
250
+ await this . openSketchFilesInNewWindow ( destinationFileUri . toString ( ) ) ;
255
251
return destinationFileUri ;
256
252
}
257
253
}
0 commit comments