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 1c12eba

Browse files
author
Akos Kitta
committed
feat: support updates in lib/boards widget
- can show badge with updates count, - better hover for libraries and platforms, - save/restore widget state (Closes #1398), - fixed `sentence` and `paragraph` order (Ref #1611) Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
1 parent 2aad0e3 commit 1c12eba

27 files changed

+1398
-336
lines changed

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

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ import {
99
FrontendApplicationContribution,
1010
FrontendApplication as TheiaFrontendApplication,
1111
} from '@theia/core/lib/browser/frontend-application';
12-
import { LibraryListWidget } from './library/library-list-widget';
12+
import {
13+
LibraryListWidget,
14+
LibraryListWidgetSearchOptions,
15+
} from './library/library-list-widget';
1316
import { ArduinoFrontendContribution } from './arduino-frontend-contribution';
1417
import {
1518
LibraryService,
@@ -25,7 +28,10 @@ import {
2528
} from '../common/protocol/sketches-service';
2629
import { SketchesServiceClientImpl } from './sketches-service-client-impl';
2730
import { CoreService, CoreServicePath } from '../common/protocol/core-service';
28-
import { BoardsListWidget } from './boards/boards-list-widget';
31+
import {
32+
BoardsListWidget,
33+
BoardsListWidgetSearchOptions,
34+
} from './boards/boards-list-widget';
2935
import { BoardsListWidgetFrontendContribution } from './boards/boards-widget-frontend-contribution';
3036
import { BoardsServiceProvider } from './boards/boards-service-provider';
3137
import { WorkspaceService as TheiaWorkspaceService } from '@theia/workspace/lib/browser/workspace-service';
@@ -73,7 +79,10 @@ import {
7379
} from '../common/protocol/config-service';
7480
import { MonitorWidget } from './serial/monitor/monitor-widget';
7581
import { MonitorViewContribution } from './serial/monitor/monitor-view-contribution';
76-
import { TabBarDecoratorService as TheiaTabBarDecoratorService } from '@theia/core/lib/browser/shell/tab-bar-decorator';
82+
import {
83+
TabBarDecorator,
84+
TabBarDecoratorService as TheiaTabBarDecoratorService,
85+
} from '@theia/core/lib/browser/shell/tab-bar-decorator';
7786
import { TabBarDecoratorService } from './theia/core/tab-bar-decorator';
7887
import { ProblemManager as TheiaProblemManager } from '@theia/markers/lib/browser';
7988
import { ProblemManager } from './theia/markers/problem-manager';
@@ -311,10 +320,10 @@ import { PreferencesEditorWidget } from './theia/preferences/preference-editor-w
311320
import { PreferencesWidget } from '@theia/preferences/lib/browser/views/preference-widget';
312321
import { createPreferencesWidgetContainer } from '@theia/preferences/lib/browser/views/preference-widget-bindings';
313322
import {
314-
BoardsFilterRenderer,
315-
LibraryFilterRenderer,
316-
}from'./widgets/component-list/filter-renderer';
317-
import{CheckForUpdates} from './contributions/check-for-updates';
323+
CheckForUpdates,
324+
BoardsUpdates,
325+
LibraryUpdates,
326+
} from './contributions/check-for-updates';
318327
import { OutputEditorFactory } from './theia/output/output-editor-factory';
319328
import { StartupTaskProvider } from '../electron-common/startup-task';
320329
import { DeleteSketch } from './contributions/delete-sketch';
@@ -353,6 +362,11 @@ import { CreateFeatures } from './create/create-features';
353362
import { Account } from './contributions/account';
354363
import { SidebarBottomMenuWidget } from './theia/core/sidebar-bottom-menu-widget';
355364
import { SidebarBottomMenuWidget as TheiaSidebarBottomMenuWidget } from '@theia/core/lib/browser/shell/sidebar-bottom-menu-widget';
365+
import {
366+
BoardsListWidgetTabBarDecorator,
367+
LibraryListWidgetTabBarDecorator,
368+
} from './widgets/component-list/list-widget-tabbar-decorator';
369+
import { HoverService } from './theia/core/hover-service';
356370

357371
export default new ContainerModule((bind, unbind, isBound, rebind) => {
358372
// Commands and toolbar items
@@ -368,8 +382,6 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
368382

369383
// Renderer for both the library and the core widgets.
370384
bind(ListItemRenderer).toSelf().inSingletonScope();
371-
bind(LibraryFilterRenderer).toSelf().inSingletonScope();
372-
bind(BoardsFilterRenderer).toSelf().inSingletonScope();
373385

374386
// Library service
375387
bind(LibraryService)
@@ -392,6 +404,11 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
392404
LibraryListWidgetFrontendContribution
393405
);
394406
bind(OpenHandler).toService(LibraryListWidgetFrontendContribution);
407+
bind(TabBarToolbarContribution).toService(
408+
LibraryListWidgetFrontendContribution
409+
);
410+
bind(CommandContribution).toService(LibraryListWidgetFrontendContribution);
411+
bind(LibraryListWidgetSearchOptions).toSelf().inSingletonScope();
395412

396413
// Sketch list service
397414
bind(SketchesService)
@@ -461,6 +478,11 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
461478
BoardsListWidgetFrontendContribution
462479
);
463480
bind(OpenHandler).toService(BoardsListWidgetFrontendContribution);
481+
bind(TabBarToolbarContribution).toService(
482+
BoardsListWidgetFrontendContribution
483+
);
484+
bind(CommandContribution).toService(BoardsListWidgetFrontendContribution);
485+
bind(BoardsListWidgetSearchOptions).toSelf().inSingletonScope();
464486

465487
// Board select dialog
466488
bind(BoardsConfigDialogWidget).toSelf().inSingletonScope();
@@ -1026,4 +1048,20 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
10261048
rebind(TheiaSidebarBottomMenuWidget).toService(SidebarBottomMenuWidget);
10271049

10281050
bind(ArduinoComponentContextMenuRenderer).toSelf().inSingletonScope();
1051+
1052+
bind(HoverService).toSelf().inSingletonScope();
1053+
bind(LibraryUpdates).toSelf().inSingletonScope();
1054+
bind(FrontendApplicationContribution).toService(LibraryUpdates);
1055+
bind(LibraryListWidgetTabBarDecorator).toSelf().inSingletonScope();
1056+
bind(TabBarDecorator).toService(LibraryListWidgetTabBarDecorator);
1057+
bind(FrontendApplicationContribution).toService(
1058+
LibraryListWidgetTabBarDecorator
1059+
);
1060+
bind(BoardsUpdates).toSelf().inSingletonScope();
1061+
bind(FrontendApplicationContribution).toService(BoardsUpdates);
1062+
bind(BoardsListWidgetTabBarDecorator).toSelf().inSingletonScope();
1063+
bind(TabBarDecorator).toService(BoardsListWidgetTabBarDecorator);
1064+
bind(FrontendApplicationContribution).toService(
1065+
BoardsListWidgetTabBarDecorator
1066+
);
10291067
});

‎arduino-ide-extension/src/browser/boards/boards-list-widget.ts‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { nls } from '@theia/core/lib/common';
12
import {
23
inject,
34
injectable,
@@ -8,10 +9,18 @@ import {
89
BoardsPackage,
910
BoardsService,
1011
} from '../../common/protocol/boards-service';
11-
import { ListWidget } from '../widgets/component-list/list-widget';
1212
import { ListItemRenderer } from '../widgets/component-list/list-item-renderer';
13-
import { nls } from '@theia/core/lib/common';
14-
import { BoardsFilterRenderer } from '../widgets/component-list/filter-renderer';
13+
import {
14+
ListWidget,
15+
ListWidgetSearchOptions,
16+
} from '../widgets/component-list/list-widget';
17+
18+
@injectable()
19+
export class BoardsListWidgetSearchOptions extends ListWidgetSearchOptions<BoardSearch> {
20+
get defaultOptions(): Required<BoardSearch> {
21+
return { query: '', type: 'All' };
22+
}
23+
}
1524

1625
@injectable()
1726
export class BoardsListWidget extends ListWidget<BoardsPackage, BoardSearch> {
@@ -21,7 +30,8 @@ export class BoardsListWidget extends ListWidget<BoardsPackage, BoardSearch> {
2130
constructor(
2231
@inject(BoardsService) service: BoardsService,
2332
@inject(ListItemRenderer) itemRenderer: ListItemRenderer<BoardsPackage>,
24-
@inject(BoardsFilterRenderer) filterRenderer: BoardsFilterRenderer
33+
@inject(BoardsListWidgetSearchOptions)
34+
searchOptions: BoardsListWidgetSearchOptions
2535
) {
2636
super({
2737
id: BoardsListWidget.WIDGET_ID,
@@ -31,8 +41,7 @@ export class BoardsListWidget extends ListWidget<BoardsPackage, BoardSearch> {
3141
installable: service,
3242
itemLabel: (item: BoardsPackage) => item.name,
3343
itemRenderer,
34-
filterRenderer,
35-
defaultSearchOptions: { query: '', type: 'All' },
44+
searchOptions,
3645
});
3746
}
3847

‎arduino-ide-extension/src/browser/boards/boards-widget-frontend-contribution.ts‎

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
1-
import { injectable } from '@theia/core/shared/inversify';
1+
import { MenuPath } from '@theia/core';
2+
import { Command } from '@theia/core/lib/common/command';
3+
import { nls } from '@theia/core/lib/common/nls';
4+
import { inject, injectable } from '@theia/core/shared/inversify';
5+
import { Type as TypeLabel } from '../../common/nls';
26
import {
37
BoardSearch,
48
BoardsPackage,
59
} from '../../common/protocol/boards-service';
610
import { URI } from '../contributions/contribution';
11+
import { MenuActionTemplate, SubmenuTemplate } from '../menu/register-menu';
712
import { ListWidgetFrontendContribution } from '../widgets/component-list/list-widget-frontend-contribution';
8-
import { BoardsListWidget } from './boards-list-widget';
13+
import {
14+
BoardsListWidget,
15+
BoardsListWidgetSearchOptions,
16+
} from './boards-list-widget';
917

1018
@injectable()
1119
export class BoardsListWidgetFrontendContribution extends ListWidgetFrontendContribution<
1220
BoardsPackage,
1321
BoardSearch
1422
> {
23+
@inject(BoardsListWidgetSearchOptions)
24+
protected readonly searchOptions: BoardsListWidgetSearchOptions;
25+
1526
constructor() {
1627
super({
1728
widgetId: BoardsListWidget.WIDGET_ID,
@@ -37,4 +48,51 @@ export class BoardsListWidgetFrontendContribution extends ListWidgetFrontendCont
3748
protected parse(uri: URI): BoardSearch | undefined {
3849
return BoardSearch.UriParser.parse(uri);
3950
}
51+
52+
protected buildFilterMenuGroup(
53+
menuPath: MenuPath
54+
): Array<MenuActionTemplate | SubmenuTemplate> {
55+
const typeSubmenuPath = [...menuPath, TypeLabel];
56+
return [
57+
{
58+
submenuPath: typeSubmenuPath,
59+
menuLabel: `${TypeLabel}: "${
60+
BoardSearch.TypeLabels[this.searchOptions.options.type]
61+
}"`,
62+
options: { order: String(0) },
63+
},
64+
...this.buildMenuActions<BoardSearch.Type>(
65+
typeSubmenuPath,
66+
BoardSearch.TypeLiterals.slice(),
67+
(type) => this.searchOptions.options.type === type,
68+
(type) => this.searchOptions.update({ type }),
69+
(type) => BoardSearch.TypeLabels[type]
70+
),
71+
];
72+
}
73+
74+
protected get showViewFilterContextMenuCommand(): Command & {
75+
label: string;
76+
} {
77+
return BoardsListWidgetFrontendContribution.Commands
78+
.SHOW_BOARDS_LIST_WIDGET_FILTER_CONTEXT_MENU;
79+
}
80+
81+
protected get showInstalledCommandId(): string {
82+
return 'arduino-show-installed-boards';
83+
}
84+
85+
protected get showUpdatesCommandId(): string {
86+
return 'arduino-show-boards-updates';
87+
}
88+
}
89+
export namespace BoardsListWidgetFrontendContribution {
90+
export namespace Commands {
91+
export const SHOW_BOARDS_LIST_WIDGET_FILTER_CONTEXT_MENU: Command & {
92+
label: string;
93+
} = {
94+
id: 'arduino-boards-list-widget-show-filter-context-menu',
95+
label: nls.localize('arduino/boards/filterBoards', 'Filter Boards...'),
96+
};
97+
}
4098
}

0 commit comments

Comments
(0)

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