File tree 5 files changed +15
-7
lines changed
arduino-ide-extension/src
5 files changed +15
-7
lines changed Original file line number Diff line number Diff line change 1
1
import { injectable } from '@theia/core/shared/inversify' ;
2
2
import URI from '@theia/core/lib/common/uri' ;
3
- import { CommandService } from '@theia/core/lib/common/command' ;
4
3
import { ArduinoMenus } from '../menu/arduino-menus' ;
5
4
import {
6
5
SketchContribution ,
@@ -15,7 +14,7 @@ import { nls } from '@theia/core/lib/common/nls';
15
14
export class OpenSketchExternal extends SketchContribution {
16
15
override registerCommands ( registry : CommandRegistry ) : void {
17
16
registry . registerCommand ( OpenSketchExternal . Commands . OPEN_EXTERNAL , {
18
- execute : ( ) => this . openExternal ( registry ) ,
17
+ execute : ( ) => this . openExternal ( ) ,
19
18
} ) ;
20
19
}
21
20
@@ -34,14 +33,14 @@ export class OpenSketchExternal extends SketchContribution {
34
33
} ) ;
35
34
}
36
35
37
- protected async openExternal ( commandService : CommandService ) : Promise < void > {
36
+ protected async openExternal ( ) : Promise < void > {
38
37
const uri = await this . sketchServiceClient . currentSketchFile ( ) ;
39
38
if ( uri ) {
40
39
const exists = await this . fileService . exists ( new URI ( uri ) ) ;
41
40
if ( exists ) {
42
41
const fsPath = await this . fileService . fsPath ( new URI ( uri ) ) ;
43
42
if ( fsPath ) {
44
- commandService . executeCommand ( 'revealFileInOS' , fsPath ) ;
43
+ window . electronTheiaCore . showItemInFolder ( fsPath ) ;
45
44
}
46
45
}
47
46
}
Original file line number Diff line number Diff line change @@ -119,7 +119,7 @@ export class SketchbookWidgetContribution
119
119
if ( exists ) {
120
120
const fsPath = await this . fileService . fsPath ( new URI ( arg . node . uri ) ) ;
121
121
if ( fsPath ) {
122
- registry . executeCommand ( 'revealFileInOS' , fsPath ) ;
122
+ window . electronArduino . openPath ( fsPath ) ;
123
123
}
124
124
}
125
125
}
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import type { Sketch } from '../common/protocol/sketches-service';
8
8
import {
9
9
CHANNEL_APP_VERSION ,
10
10
CHANNEL_IS_FIRST_WINDOW ,
11
+ CHANNEL_OPEN_PATH ,
11
12
CHANNEL_PLOTTER_WINDOW_DID_CLOSE ,
12
13
CHANNEL_QUIT_APP ,
13
14
CHANNEL_SCHEDULE_DELETION ,
@@ -22,7 +23,7 @@ import {
22
23
OpenDialogOptions ,
23
24
SaveDialogOptions ,
24
25
} from '../electron-common/electron-arduino' ;
25
- import { hasStartupTasks , StartupTasks } from '../electron-common/startup-task' ;
26
+ import { StartupTasks , hasStartupTasks } from '../electron-common/startup-task' ;
26
27
27
28
const api : ElectronArduino = {
28
29
showMessageBox : ( options : MessageBoxOptions ) =>
@@ -66,6 +67,7 @@ const api: ElectronArduino = {
66
67
ipcRenderer . removeListener ( CHANNEL_PLOTTER_WINDOW_DID_CLOSE , listener )
67
68
) ;
68
69
} ,
70
+ openPath : ( fsPath : string ) => ipcRenderer . send ( CHANNEL_OPEN_PATH , fsPath ) ,
69
71
} ;
70
72
71
73
export function preload ( ) : void {
Original file line number Diff line number Diff line change @@ -50,6 +50,7 @@ export interface ElectronArduino {
50
50
setRepresentedFilename ( fsPath : string ) : void ;
51
51
showPlotterWindow ( params : { url : string ; forceReload ?: boolean } ) : void ;
52
52
registerPlotterWindowCloseHandler ( handler : ( ) => void ) : Disposable ;
53
+ openPath ( fsPath : string ) : void ;
53
54
}
54
55
55
56
declare global {
@@ -69,6 +70,7 @@ export const CHANNEL_SCHEDULE_DELETION = 'Arduino:ScheduleDeletion';
69
70
export const CHANNEL_SET_REPRESENTED_FILENAME =
70
71
'Arduino:SetRepresentedFilename' ;
71
72
export const CHANNEL_SHOW_PLOTTER_WINDOW = 'Arduino:ShowPlotterWindow' ;
73
+ export const CHANNEL_OPEN_PATH = 'Arduino:OpenPath' ;
72
74
// main to renderer
73
75
export const CHANNEL_SEND_STARTUP_TASKS = 'Arduino:SendStartupTasks' ;
74
76
export const CHANNEL_PLOTTER_WINDOW_DID_CLOSE = 'Arduino:PlotterWindowDidClose' ;
Original file line number Diff line number Diff line change @@ -3,19 +3,21 @@ import {
3
3
dialog ,
4
4
ipcMain ,
5
5
IpcMainEvent ,
6
+ shell ,
6
7
} from '@theia/core/electron-shared/electron' ;
7
8
import { Disposable } from '@theia/core/lib/common/disposable' ;
8
9
import { CHANNEL_REQUEST_RELOAD } from '@theia/core/lib/electron-common/electron-api' ;
9
10
import {
10
- ElectronMainApplication as TheiaElectronMainApplication ,
11
11
ElectronMainApplicationContribution ,
12
+ ElectronMainApplication as TheiaElectronMainApplication ,
12
13
} from '@theia/core/lib/electron-main/electron-main-application' ;
13
14
import { createDisposableListener } from '@theia/core/lib/electron-main/event-utils' ;
14
15
import { injectable } from '@theia/core/shared/inversify' ;
15
16
import { WebContents } from '@theia/electron/shared/electron' ;
16
17
import {
17
18
CHANNEL_APP_VERSION ,
18
19
CHANNEL_IS_FIRST_WINDOW ,
20
+ CHANNEL_OPEN_PATH ,
19
21
CHANNEL_QUIT_APP ,
20
22
CHANNEL_SEND_STARTUP_TASKS ,
21
23
CHANNEL_SET_REPRESENTED_FILENAME ,
@@ -94,6 +96,9 @@ export class ElectronArduino implements ElectronMainApplicationContribution {
94
96
window . setRepresentedFilename ( fsPath ) ;
95
97
}
96
98
} ) ;
99
+ ipcMain . on ( CHANNEL_OPEN_PATH , ( _ , fsPath : string ) => {
100
+ shell . openPath ( fsPath ) ;
101
+ } ) ;
97
102
}
98
103
}
99
104
You can’t perform that action at this time.
0 commit comments