Added refresh attached boards command

This commit is contained in:
Christian Weichel 2019-05-09 20:03:38 +02:00
parent 97135bd08e
commit 7da8851fad
3 changed files with 27 additions and 7 deletions

View File

@ -18,4 +18,9 @@ export namespace ArduinoCommands {
category: 'File'
}
export const REFRESH_BOARDS: Command = {
id: "arduino-refresh-attached-boards",
label: "Refresh attached boards"
}
}

View File

@ -12,7 +12,6 @@ import { ConnectedBoards } from './components/connected-boards';
import { CoreService } from '../common/protocol/core-service';
import { WorkspaceServiceExt } from './workspace-service-ext';
import { ToolOutputServiceClient } from '../common/protocol/tool-output-service';
import { ConfirmDialog } from '@theia/core/lib/browser';
import { QuickPickService } from '@theia/core/lib/common/quick-pick-service';
import { BoardsListWidgetFrontendContribution } from './boards/boards-widget-frontend-contribution';
import { BoardsNotificationService } from './boards-notification-service';
@ -101,9 +100,14 @@ export class ArduinoFrontendContribution extends DefaultFrontendApplicationContr
}
const uri = this.toUri(widget);
if (uri) {
const result = await this.coreService.compile({ uri: uri.toString() });
console.log('compile result', result);
if (!uri) {
return;
}
try {
await this.coreService.compile({ uri: uri.toString() });
} catch (e) {
await this.messageService.error(e.toString());
}
}
});
@ -123,19 +127,28 @@ export class ArduinoFrontendContribution extends DefaultFrontendApplicationContr
try {
await this.coreService.upload({ uri: uri.toString() });
} catch (e) {
new ConfirmDialog({ title: "Error during upload", msg: e.toString(), ok: "Ok" }).open();
await this.messageService.error(e.toString());
}
}
});
registry.registerCommand(ArduinoCommands.NEW_SKETCH, new WorkspaceRootUriAwareCommandHandler(this.workspaceService, this.selectionService, {
execute: async uri => {
try {
// hack: sometimes we don't get the workspace root, but the currently active file: correct for that
if (uri.path.ext !== "") {
uri = uri.withPath(uri.path.dir.dir);
}
await this.sketchFactory.createNewSketch(uri);
} catch (e) {
new ConfirmDialog({ title: "Cannot create new sketch", msg: e.toString(), ok: "Ok" }).open();
await this.messageService.error(e.toString());
}
}
}))
}));
registry.registerCommand(ArduinoCommands.REFRESH_BOARDS, {
isEnabled: () => true,
execute: () => this.boardsNotificationService.notifyBoardsInstalled()
})
}
private async onNoBoardsInstalled() {

View File

@ -40,10 +40,12 @@ export class SketchFactory {
this.fileSystem.createFolder(sketchDir.toString());
this.fileSystem.createFile(sketchFile.toString(), { content: `
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
` });