|
1 |
| -import * as React from 'react'; |
2 |
| -import { injectable, inject, postConstruct } from 'inversify'; |
3 |
| -import URI from '@theia/core/lib/common/uri'; |
4 |
| -import { MessageService } from '@theia/core/lib/common/message-service'; |
5 |
| -import { CommandContribution, CommandRegistry } from '@theia/core/lib/common/command'; |
6 |
| -import { TabBarToolbarContribution, TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar'; |
7 |
| -import { BoardsService, BoardsServiceClient, CoreService, SketchesService, ToolOutputServiceClient, Port } from '../common/protocol'; |
8 |
| -import { ArduinoCommands } from './arduino-commands'; |
9 |
| -import { BoardsServiceClientImpl } from './boards/boards-service-client-impl'; |
10 |
| -import { SelectionService, MenuContribution, MenuModelRegistry, MAIN_MENU_BAR } from '@theia/core'; |
11 |
| -import { ArduinoToolbar } from './toolbar/arduino-toolbar'; |
12 |
| -import { EditorManager, EditorMainMenu } from '@theia/editor/lib/browser'; |
| 1 | +import { MAIN_MENU_BAR, MenuContribution, MenuModelRegistry, SelectionService } from '@theia/core'; |
13 | 2 | import {
|
14 |
| - ContextMenuRenderer, StatusBar, StatusBarAlignment, FrontendApplicationContribution, |
15 |
| - FrontendApplication, KeybindingContribution, KeybindingRegistry, OpenerService |
| 3 | + ContextMenuRenderer, |
| 4 | + FrontendApplication, FrontendApplicationContribution, |
| 5 | + OpenerService, StatusBar, StatusBarAlignment |
16 | 6 | } from '@theia/core/lib/browser';
|
| 7 | +import { ColorContribution } from '@theia/core/lib/browser/color-application-contribution'; |
| 8 | +import { ColorRegistry } from '@theia/core/lib/browser/color-registry'; |
| 9 | +import { CommonMenus } from '@theia/core/lib/browser/common-frontend-contribution'; |
| 10 | +import { TabBarToolbarContribution, TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar'; |
| 11 | +import { CommandContribution, CommandRegistry } from '@theia/core/lib/common/command'; |
| 12 | +import { MessageService } from '@theia/core/lib/common/message-service'; |
| 13 | +import URI from '@theia/core/lib/common/uri'; |
| 14 | +import { EditorMainMenu, EditorManager } from '@theia/editor/lib/browser'; |
17 | 15 | import { FileDialogService } from '@theia/filesystem/lib/browser/file-dialog';
|
18 | 16 | import { FileSystem } from '@theia/filesystem/lib/common';
|
19 |
| -import { CommonMenus } from '@theia/core/lib/browser/common-frontend-contribution'; |
| 17 | +import { ProblemContribution } from '@theia/markers/lib/browser/problem/problem-contribution'; |
20 | 18 | import { MonacoMenus } from '@theia/monaco/lib/browser/monaco-menu';
|
21 |
| -import { TerminalMenus } from '@theia/terminal/lib/browser/terminal-frontend-contribution'; |
22 |
| -import { BoardsConfigDialog } from './boards/boards-config-dialog'; |
23 |
| -import { BoardsToolBarItem } from './boards/boards-toolbar-item'; |
24 |
| -import { BoardsConfig } from './boards/boards-config'; |
25 |
| -import { MonitorConnection } from './monitor/monitor-connection'; |
26 |
| -import { MonitorViewContribution } from './monitor/monitor-view-contribution'; |
27 |
| -import { WorkspaceService } from './theia/workspace/workspace-service'; |
28 | 19 | import { FileNavigatorContribution } from '@theia/navigator/lib/browser/navigator-contribution';
|
29 |
| -import { OutputContribution } from '@theia/output/lib/browser/output-contribution'; |
30 | 20 | import { OutlineViewContribution } from '@theia/outline-view/lib/browser/outline-view-contribution';
|
31 |
| -import { ProblemContribution } from '@theia/markers/lib/browser/problem/problem-contribution'; |
| 21 | +import { OutputContribution } from '@theia/output/lib/browser/output-contribution'; |
32 | 22 | import { ScmContribution } from '@theia/scm/lib/browser/scm-contribution';
|
33 | 23 | import { SearchInWorkspaceFrontendContribution } from '@theia/search-in-workspace/lib/browser/search-in-workspace-frontend-contribution';
|
34 |
| -import { EditorMode } from './editor-mode'; |
35 |
| -import { ColorContribution } from '@theia/core/lib/browser/color-application-contribution'; |
36 |
| -import { ColorRegistry } from '@theia/core/lib/browser/color-registry'; |
| 24 | +import { TerminalMenus } from '@theia/terminal/lib/browser/terminal-frontend-contribution'; |
| 25 | +import { inject, injectable, postConstruct } from 'inversify'; |
| 26 | +import * as React from 'react'; |
| 27 | +import { MainMenuManager } from '../common/main-menu-manager'; |
| 28 | +import { BoardsService, BoardsServiceClient, CoreService, Port, SketchesService, ToolOutputServiceClient } from '../common/protocol'; |
37 | 29 | import { ArduinoDaemon } from '../common/protocol/arduino-daemon';
|
38 | 30 | import { ConfigService } from '../common/protocol/config-service';
|
39 |
| -import { BoardsDataStore } from './boards/boards-data-store'; |
40 |
| -import { MainMenuManager } from '../common/main-menu-manager'; |
41 | 31 | import { FileSystemExt } from '../common/protocol/filesystem-ext';
|
| 32 | +import { ArduinoCommands } from './arduino-commands'; |
| 33 | +import { BoardsConfig } from './boards/boards-config'; |
| 34 | +import { BoardsConfigDialog } from './boards/boards-config-dialog'; |
| 35 | +import { BoardsDataStore } from './boards/boards-data-store'; |
| 36 | +import { BoardsServiceClientImpl } from './boards/boards-service-client-impl'; |
| 37 | +import { BoardsToolBarItem } from './boards/boards-toolbar-item'; |
| 38 | +import { EditorMode } from './editor-mode'; |
42 | 39 | import { ArduinoMenus } from './menu/arduino-menus';
|
| 40 | +import { MonitorConnection } from './monitor/monitor-connection'; |
| 41 | +import { MonitorViewContribution } from './monitor/monitor-view-contribution'; |
| 42 | +import { WorkspaceService } from './theia/workspace/workspace-service'; |
| 43 | +import { ArduinoToolbar } from './toolbar/arduino-toolbar'; |
43 | 44 |
|
44 | 45 | @injectable()
|
45 | 46 | export class ArduinoFrontendContribution implements FrontendApplicationContribution,
|
46 |
| - TabBarToolbarContribution, CommandContribution, MenuContribution, KeybindingContribution, ColorContribution { |
| 47 | + TabBarToolbarContribution, CommandContribution, MenuContribution, ColorContribution { |
47 | 48 |
|
48 | 49 | @inject(MessageService)
|
49 | 50 | protected readonly messageService: MessageService;
|
@@ -255,17 +256,25 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut
|
255 | 256 | });
|
256 | 257 | }
|
257 | 258 |
|
258 |
| - registerKeybindings(keybindings: KeybindingRegistry): void { |
259 |
| - keybindings.unregisterKeybinding('ctrlcmd+n'); // Unregister the keybinding for `New File`, will be used by `New Sketch`. (eclipse-theia/theia#8170) |
260 |
| - } |
261 |
| - |
262 | 259 | protected async openSketchFiles(uri: string): Promise<void> {
|
263 |
| - const uris = await this.sketchService.getSketchFiles(uri); |
264 |
| - for (const uri of uris) { |
265 |
| - await this.editorManager.open(new URI(uri)); |
| 260 | + try { |
| 261 | + const sketch = await this.sketchService.loadSketch(uri); |
| 262 | + const { mainFileUri, otherSketchFileUris, additionalFileUris } = sketch; |
| 263 | + for (const uri of [mainFileUri, ...otherSketchFileUris, ...additionalFileUris]) { |
| 264 | + await this.ensureOpened(uri); |
| 265 | + } |
| 266 | + await this.ensureOpened(mainFileUri, true); |
| 267 | + } catch (e) { |
| 268 | + console.error(e); |
| 269 | + const message = e instanceof Error ? e.message : JSON.stringify(e); |
| 270 | + this.messageService.error(message); |
266 | 271 | }
|
267 |
| - if (uris.length) { |
268 |
| - await this.editorManager.open(new URI(uris[0])); // Make sure the sketch file has the focus. |
| 272 | + } |
| 273 | + |
| 274 | + protected async ensureOpened(uri: string, forceOpen: boolean = false): Promise<any> { |
| 275 | + const widget = this.editorManager.all.find(widget => widget.editor.uri.toString() === uri); |
| 276 | + if (!widget || forceOpen) { |
| 277 | + return this.editorManager.open(new URI(uri)); |
269 | 278 | }
|
270 | 279 | }
|
271 | 280 |
|
@@ -313,6 +322,24 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut
|
313 | 322 | hc: 'activityBar.inactiveForeground'
|
314 | 323 | },
|
315 | 324 | description: 'Background color of the toolbar items when hovering over them. Such as Upload, Verify, etc.'
|
| 325 | + }, |
| 326 | + { |
| 327 | + id: 'arduino.output.foreground', |
| 328 | + defaults: { |
| 329 | + dark: 'editor.foreground', |
| 330 | + light: 'editor.foreground', |
| 331 | + hc: 'editor.foreground' |
| 332 | + }, |
| 333 | + description: 'Color of the text in the Output view.' |
| 334 | + }, |
| 335 | + { |
| 336 | + id: 'arduino.output.background', |
| 337 | + defaults: { |
| 338 | + dark: 'editor.background', |
| 339 | + light: 'editor.background', |
| 340 | + hc: 'editor.background' |
| 341 | + }, |
| 342 | + description: 'Background color of the Output view.' |
316 | 343 | }
|
317 | 344 | );
|
318 | 345 | }
|
|
0 commit comments