Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1aa9e08

Browse files
author
Akos Kitta
committed
moved selected board tracker to its module.
Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
1 parent 46c394d commit 1aa9e08

File tree

3 files changed

+57
-36
lines changed

3 files changed

+57
-36
lines changed

‎arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx‎

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ import {
2525
LocalStorageService,
2626
OnWillStopAction,
2727
SaveableWidget,
28-
StatusBar,
29-
StatusBarAlignment,
3028
} from '@theia/core/lib/browser';
3129
import { ColorContribution } from '@theia/core/lib/browser/color-application-contribution';
3230
import { ColorRegistry } from '@theia/core/lib/browser/color-registry';
@@ -57,7 +55,6 @@ import {
5755
} from '../common/protocol/sketches-service-client-impl';
5856
import { ArduinoCommands } from './arduino-commands';
5957
import { ArduinoPreferences } from './arduino-preferences';
60-
import { BoardsConfig } from './boards/boards-config';
6158
import { BoardsConfigDialog } from './boards/boards-config-dialog';
6259
import { BoardsServiceProvider } from './boards/boards-service-provider';
6360
import { BoardsToolBarItem } from './boards/boards-toolbar-item';
@@ -104,9 +101,6 @@ export class ArduinoFrontendContribution
104101
@inject(CommandRegistry)
105102
private readonly commandRegistry: CommandRegistry;
106103

107-
@inject(StatusBar)
108-
private readonly statusBar: StatusBar;
109-
110104
@inject(ArduinoPreferences)
111105
private readonly arduinoPreferences: ArduinoPreferences;
112106

@@ -162,36 +156,6 @@ export class ArduinoFrontendContribution
162156
)
163157
);
164158
}
165-
const updateStatusBar = ({
166-
selectedBoard,
167-
selectedPort,
168-
}: BoardsConfig.Config) => {
169-
this.statusBar.setElement('arduino-selected-board', {
170-
alignment: StatusBarAlignment.RIGHT,
171-
text: selectedBoard
172-
? `$(microchip) ${selectedBoard.name}`
173-
: `$(close) ${nls.localize(
174-
'arduino/common/noBoardSelected',
175-
'No board selected'
176-
)}`,
177-
className: 'arduino-selected-board',
178-
});
179-
if (selectedBoard) {
180-
this.statusBar.setElement('arduino-selected-port', {
181-
alignment: StatusBarAlignment.RIGHT,
182-
text: selectedPort
183-
? nls.localize(
184-
'arduino/common/selectedOn',
185-
'on {0}',
186-
selectedPort.address
187-
)
188-
: nls.localize('arduino/common/notConnected', '[not connected]'),
189-
className: 'arduino-selected-port',
190-
});
191-
}
192-
};
193-
this.boardsServiceClientImpl.onBoardsConfigChanged(updateStatusBar);
194-
updateStatusBar(this.boardsServiceClientImpl.boardsConfig);
195159
this.appStateService.reachedState('ready').then(async () => {
196160
const sketch = await this.sketchServiceClient.currentSketch();
197161
if (
@@ -282,6 +246,7 @@ export class ArduinoFrontendContribution
282246
webContents.setZoomLevel(zoomLevel);
283247
});
284248

249+
// Removes the _Settings_ (cog) icon from the left sidebar
285250
app.shell.leftPanelHandler.removeBottomMenu('settings-menu');
286251

287252
this.fileSystemFrontendContribution.onDidChangeEditorFile(

‎arduino-ide-extension/src/browser/arduino-ide-frontend-module.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ import { Daemon } from './contributions/daemon';
306306
import { Notifications } from './contributions/notifications';
307307
import { OpenSketchFiles } from './contributions/open-sketch-files';
308308
import { InoLanguage } from './contributions/ino-language';
309+
import { SelectedBoard } from './contributions/selected-board';
309310

310311
MonacoThemingService.register({
311312
id: 'arduino-theme',
@@ -700,6 +701,7 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
700701
Contribution.configure(bind, Notifications);
701702
Contribution.configure(bind, OpenSketchFiles);
702703
Contribution.configure(bind, InoLanguage);
704+
Contribution.configure(bind, SelectedBoard);
703705

704706
// Disabled the quick-pick customization from Theia when multiple formatters are available.
705707
// Use the default VS Code behavior, and pick the first one. In the IDE2, clang-format has `exclusive` selectors.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import {
2+
StatusBar,
3+
StatusBarAlignment,
4+
} from '@theia/core/lib/browser/status-bar/status-bar';
5+
import { nls } from '@theia/core/lib/common/nls';
6+
import { inject, injectable } from '@theia/core/shared/inversify';
7+
import { BoardsConfig } from '../boards/boards-config';
8+
import { BoardsServiceProvider } from '../boards/boards-service-provider';
9+
import { Contribution } from './contribution';
10+
11+
@injectable()
12+
export class SelectedBoard extends Contribution {
13+
@inject(StatusBar)
14+
private readonly statusBar: StatusBar;
15+
16+
@inject(BoardsServiceProvider)
17+
private readonly boardsServiceProvider: BoardsServiceProvider;
18+
19+
override onStart(): void {
20+
this.boardsServiceProvider.onBoardsConfigChanged((config) =>
21+
this.update(config)
22+
);
23+
}
24+
25+
override onReady(): void {
26+
this.update(this.boardsServiceProvider.boardsConfig);
27+
}
28+
29+
private update({ selectedBoard, selectedPort }: BoardsConfig.Config): void {
30+
this.statusBar.setElement('arduino-selected-board', {
31+
alignment: StatusBarAlignment.RIGHT,
32+
text: selectedBoard
33+
? `$(microchip) ${selectedBoard.name}`
34+
: `$(close) ${nls.localize(
35+
'arduino/common/noBoardSelected',
36+
'No board selected'
37+
)}`,
38+
className: 'arduino-selected-board',
39+
});
40+
if (selectedBoard) {
41+
this.statusBar.setElement('arduino-selected-port', {
42+
alignment: StatusBarAlignment.RIGHT,
43+
text: selectedPort
44+
? nls.localize(
45+
'arduino/common/selectedOn',
46+
'on {0}',
47+
selectedPort.address
48+
)
49+
: nls.localize('arduino/common/notConnected', '[not connected]'),
50+
className: 'arduino-selected-port',
51+
});
52+
}
53+
}
54+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /