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 cdcec92

Browse files
Akos Kittafstasi
Akos Kitta
authored andcommitted
[atl-1217] sketchbook explorer
Signed-off-by: Akos Kitta <kittaakos@typefox.io> Can render commands in the sketchbook tree. Signed-off-by: Akos Kitta <kittaakos@typefox.io> fixed children for generic folder. Signed-off-by: Akos Kitta <kittaakos@typefox.io> Externalized the extensions into a single file. Signed-off-by: Akos Kitta <kittaakos@typefox.io> [dev]: Fixed the tasks. Signed-off-by: Akos Kitta <kittaakos@typefox.io> [dev]: Parse configs without `jsonc`. Signed-off-by: Akos Kitta <kittaakos@typefox.io> [doc]: Removed obsolete documentation. Signed-off-by: Akos Kitta <kittaakos@typefox.io> Fixed the `name` and the `repository` link. Signed-off-by: Akos Kitta <kittaakos@typefox.io> [dev]: Use `rm -rf` for the clean-up. Signed-off-by: Akos Kitta <kittaakos@typefox.io> Wiped the unused Dockerfile. Signed-off-by: Akos Kitta <kittaakos@typefox.io> open sketches commands Use template methods for the sketchbook trees. Signed-off-by: Akos Kitta <kittaakos@typefox.io> Exported the sketchbook tree container API. Signed-off-by: Akos Kitta <kittaakos@typefox.io> Fixed the icons. Signed-off-by: Akos Kitta <kittaakos@typefox.io> Simplified the type-guard on `SketchDirNode`. No need to keep the full `sketch` object on the tree node. Signed-off-by: Akos Kitta <kittaakos@typefox.io> Initialize the model with the CLI config object. Signed-off-by: Akos Kitta <kittaakos@typefox.io> Added required dependencies. Signed-off-by: Akos Kitta <kittaakos@typefox.io> Added `open`. Signed-off-by: Akos Kitta <kittaakos@typefox.io> Fixed the scrollbar issue in sketchbook tree. Signed-off-by: Akos Kitta <kittaakos@typefox.io> Removed the CLI config dependency from the widget. Signed-off-by: Akos Kitta <kittaakos@typefox.io> Exposed the tree model to the command service. Signed-off-by: Akos Kitta <kittaakos@typefox.io> Pinned `deepmerge` to `2.0.1`. Signed-off-by: Akos Kitta <kittaakos@typefox.io> Fixed bug when executing the command for node. The even propagation has to be stopped to avoid tree expand/collapse if running the commands. Signed-off-by: Akos Kitta <kittaakos@typefox.io> [dev]: Reordered the launch configs. Signed-off-by: Akos Kitta <kittaakos@typefox.io> Sketchbook explorer
1 parent 05c0505 commit cdcec92

38 files changed

+1087
-110
lines changed

‎.vscode/launch.json‎

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,6 @@
11
{
2-
// Use IntelliSense to learn about possible attributes.
3-
// Hover to view descriptions of existing attributes.
4-
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
52
"version": "0.2.0",
63
"configurations": [
7-
{
8-
"type": "node",
9-
"request": "attach",
10-
"name": "Attach by Process ID",
11-
"processId": "${command:PickProcess}"
12-
},
13-
{
14-
"type": "node",
15-
"request": "launch",
16-
"name": "Electron Packager",
17-
"program": "${workspaceRoot}/electron/packager/index.js",
18-
"cwd": "${workspaceFolder}/electron/packager"
19-
},
204
{
215
"type": "node",
226
"request": "launch",
@@ -106,6 +90,19 @@
10690
"smartStep": true,
10791
"internalConsoleOptions": "openOnSessionStart",
10892
"outputCapture": "std"
93+
},
94+
{
95+
"type": "node",
96+
"request": "attach",
97+
"name": "Attach by Process ID",
98+
"processId": "${command:PickProcess}"
99+
},
100+
{
101+
"type": "node",
102+
"request": "launch",
103+
"name": "Electron Packager",
104+
"program": "${workspaceRoot}/electron/packager/index.js",
105+
"cwd": "${workspaceFolder}/electron/packager"
109106
}
110107
]
111108
}

‎.vscode/tasks.json‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
{
2-
// See https://go.microsoft.com/fwlink/?LinkId=733558
3-
// for the documentation about the tasks.json format
42
"version": "2.0.0",
53
"tasks": [
64
{
@@ -35,7 +33,7 @@
3533
"panel": "new",
3634
"clear": false
3735
}
38-
}
36+
},
3937
{
4038
"label": "Arduino IDE - Watch Browser App",
4139
"type": "shell",

‎Dockerfile‎

Lines changed: 0 additions & 19 deletions
This file was deleted.

‎arduino-ide-extension/package.json‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,18 @@
3333
"@theia/search-in-workspace": "next",
3434
"@theia/terminal": "next",
3535
"@theia/workspace": "next",
36+
"@types/atob": "^2.1.2",
37+
"@types/auth0-js": "^9.14.0",
38+
"@types/btoa": "^1.2.3",
3639
"@types/dateformat": "^3.0.1",
3740
"@types/deepmerge": "^2.2.0",
3841
"@types/glob": "^5.0.35",
3942
"@types/google-protobuf": "^3.7.2",
4043
"@types/js-yaml": "^3.12.2",
44+
"@types/keytar": "^4.4.0",
4145
"@types/lodash.debounce": "^4.0.6",
4246
"@types/ncp": "^2.0.4",
47+
"@types/node-fetch": "^2.5.7",
4348
"@types/ps-tree": "^1.1.0",
4449
"@types/react-select": "^3.0.0",
4550
"@types/react-tabs": "^2.3.2",
@@ -48,15 +53,24 @@
4853
"@types/which": "^1.3.1",
4954
"ajv": "^6.5.3",
5055
"async-mutex": "^0.3.0",
56+
"atob": "^2.1.2",
57+
"auth0-js": "^9.14.0",
58+
"btoa": "^1.2.1",
5159
"css-element-queries": "^1.2.0",
5260
"dateformat": "^3.0.3",
53-
"deepmerge": "^4.2.2",
61+
"deepmerge": "2.0.1",
5462
"fuzzy": "^0.1.3",
5563
"glob": "^7.1.6",
5664
"google-protobuf": "^3.11.4",
57-
"lodash.debounce": "^4.0.8",
65+
"hash.js": "^1.1.7",
66+
"is-valid-path": "^0.1.1",
5867
"js-yaml": "^3.13.1",
68+
"jwt-decode": "^3.1.2",
69+
"keytar": "7.2.0",
70+
"lodash.debounce": "^4.0.8",
5971
"ncp": "^2.0.0",
72+
"node-fetch": "^2.6.1",
73+
"open": "^8.0.6",
6074
"p-queue": "^5.0.0",
6175
"ps-tree": "^1.2.0",
6276
"react-disable": "^0.1.0",

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import { SketchesServiceClientImpl } from '../common/protocol/sketches-service-c
5050
import { SaveAsSketch } from './contributions/save-as-sketch';
5151
import { FileChangeType } from '@theia/filesystem/lib/browser';
5252
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state';
53+
import { SketchbookWidgetContribution } from './widgets/sketchbook/sketchbook-widget-contribution';
5354

5455
@injectable()
5556
export class ArduinoFrontendContribution implements FrontendApplicationContribution,
@@ -124,6 +125,9 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut
124125
@inject(SearchInWorkspaceFrontendContribution)
125126
protected readonly siwContribution: SearchInWorkspaceFrontendContribution;
126127

128+
@inject(SketchbookWidgetContribution)
129+
protected readonly sketchbookWidgetContribution: SketchbookWidgetContribution;
130+
127131
@inject(EditorMode)
128132
protected readonly editorMode: EditorMode;
129133

@@ -215,7 +219,8 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut
215219
this.outlineContribution,
216220
this.problemContribution,
217221
this.scmContribution,
218-
this.siwContribution] as Array<FrontendApplicationContribution>) {
222+
this.siwContribution,
223+
this.sketchbookWidgetContribution] as Array<FrontendApplicationContribution>) {
219224
if (viewContribution.initializeLayout) {
220225
viewContribution.initializeLayout(app);
221226
}

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ import { NotificationManager } from './theia/messages/notifications-manager';
163163
import { NotificationManager as TheiaNotificationManager } from '@theia/messages/lib/browser/notifications-manager';
164164
import { NotificationsRenderer as TheiaNotificationsRenderer } from '@theia/messages/lib/browser/notifications-renderer';
165165
import { NotificationsRenderer } from './theia/messages/notifications-renderer';
166+
import { SketchbookWidgetContribution } from './widgets/sketchbook/sketchbook-widget-contribution';
167+
import { SketchbookWidget } from './widgets/sketchbook/sketchbook-widget';
168+
import { SketchbookTreeWidget } from './widgets/sketchbook/sketchbook-tree-widget';
169+
import { createSketchbookTreeWidget } from './widgets/sketchbook/sketchbook-tree-container';
166170

167171
const ElementQueries = require('css-element-queries/src/ElementQueries');
168172

@@ -448,4 +452,14 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
448452
rebind(TheiaNotificationManager).toService(NotificationManager);
449453
bind(NotificationsRenderer).toSelf().inSingletonScope();
450454
rebind(TheiaNotificationsRenderer).toService(NotificationsRenderer);
455+
456+
// UI for the Sketchbook
457+
bind(SketchbookWidget).toSelf();
458+
bindViewContribution(bind, SketchbookWidgetContribution);
459+
bind(FrontendApplicationContribution).toService(SketchbookWidgetContribution);
460+
bind(WidgetFactory).toDynamicValue(({ container }) => ({
461+
id: 'arduino-sketchbook-widget',
462+
createWidget: () => container.get(SketchbookWidget)
463+
}));
464+
bind(SketchbookTreeWidget).toDynamicValue(({ container }) => createSketchbookTreeWidget(container));
451465
});

‎arduino-ide-extension/src/browser/arduino-preferences.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ export const ArduinoConfigSchema: PreferenceSchema = {
4343
'type': 'boolean',
4444
'description': 'True to enable automatic update checks. The IDE will check for updates automatically and periodically.',
4545
'default': true
46+
},
47+
'arduino.sketchbook.showAllFiles': {
48+
'type': 'boolean',
49+
'description': 'True to show all sketch files inside the sketch. It is false by default.',
50+
'default': false
4651
}
4752
}
4853
};
@@ -56,6 +61,7 @@ export interface ArduinoConfiguration {
5661
'arduino.window.autoScale': boolean;
5762
'arduino.window.zoomLevel': number;
5863
'arduino.ide.autoUpdate': boolean;
64+
'arduino.sketchbook.showAllFiles': boolean;
5965
}
6066

6167
export const ArduinoPreferences = Symbol('ArduinoPreferences');

‎arduino-ide-extension/src/browser/contributions/sketch-control.ts‎

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import { WorkspaceCommands } from '@theia/workspace/lib/browser';
55
import { ContextMenuRenderer } from '@theia/core/lib/browser/context-menu-renderer';
66
import { Disposable, DisposableCollection } from '@theia/core/lib/common/disposable';
77
import { URI, SketchContribution, Command, CommandRegistry, MenuModelRegistry, KeybindingRegistry, TabBarToolbarRegistry, open } from './contribution';
8-
import { ArduinoMenus } from '../menu/arduino-menus';
8+
import { ArduinoMenus, PlaceholderMenuNode } from '../menu/arduino-menus';
9+
import { EditorManager } from '@theia/editor/lib/browser/editor-manager';
10+
import { SketchesServiceClientImpl } from '../../common/protocol/sketches-service-client-impl';
911

1012
@injectable()
1113
export class SketchControl extends SketchContribution {
@@ -19,6 +21,12 @@ export class SketchControl extends SketchContribution {
1921
@inject(ContextMenuRenderer)
2022
protected readonly contextMenuRenderer: ContextMenuRenderer;
2123

24+
@inject(EditorManager)
25+
protected readonly editorManager: EditorManager;
26+
27+
@inject(SketchesServiceClientImpl)
28+
protected readonly sketchesServiceClient: SketchesServiceClientImpl;
29+
2230
protected readonly toDisposeBeforeCreateNewContextMenu = new DisposableCollection();
2331

2432
registerCommands(registry: CommandRegistry): void {
@@ -42,8 +50,45 @@ export class SketchControl extends SketchContribution {
4250

4351
const { mainFileUri, rootFolderFileUris } = await this.sketchService.loadSketch(sketch.uri);
4452
const uris = [mainFileUri, ...rootFolderFileUris];
53+
54+
const currentSketch = await this.sketchesServiceClient.currentSketch();
55+
56+
const parentsketchUri = this.editorManager.currentEditor?.getResourceUri()?.toString();
57+
const parentsketch = await this.sketchService.getSketchFolder(parentsketchUri || '');
58+
59+
// if the current file is in the current opened sketch, show extra menus
60+
if (currentSketch && parentsketch && parentsketch.uri === currentSketch.uri) {
61+
this.menuRegistry.registerMenuAction(ArduinoMenus.SKETCH_CONTROL__CONTEXT__MAIN_GROUP, {
62+
commandId: WorkspaceCommands.FILE_RENAME.id,
63+
label: 'Rename',
64+
order: '1'
65+
});
66+
this.toDisposeBeforeCreateNewContextMenu.push(Disposable.create(() => this.menuRegistry.unregisterMenuAction(WorkspaceCommands.FILE_RENAME)));
67+
68+
this.menuRegistry.registerMenuAction(ArduinoMenus.SKETCH_CONTROL__CONTEXT__MAIN_GROUP, {
69+
commandId: WorkspaceCommands.FILE_DELETE.id, // TODO: customize delete. Wipe sketch if deleting main file. Close window.
70+
label: 'Delete',
71+
order: '2'
72+
});
73+
this.toDisposeBeforeCreateNewContextMenu.push(Disposable.create(() => this.menuRegistry.unregisterMenuAction(WorkspaceCommands.FILE_DELETE)));
74+
} else {
75+
// otherwise show grayed out placeholders
76+
const renamePlaceholder = new PlaceholderMenuNode(ArduinoMenus.SKETCH_CONTROL__CONTEXT__MAIN_GROUP, 'Rename');
77+
this.menuRegistry.registerMenuNode(ArduinoMenus.SKETCH_CONTROL__CONTEXT__MAIN_GROUP, renamePlaceholder);
78+
this.toDisposeBeforeCreateNewContextMenu.push(Disposable.create(() => this.menuRegistry.unregisterMenuNode(renamePlaceholder.id)));
79+
80+
const deletePlaceholder = new PlaceholderMenuNode(ArduinoMenus.SKETCH_CONTROL__CONTEXT__MAIN_GROUP, 'Delete');
81+
this.menuRegistry.registerMenuNode(ArduinoMenus.SKETCH_CONTROL__CONTEXT__MAIN_GROUP, deletePlaceholder);
82+
this.toDisposeBeforeCreateNewContextMenu.push(Disposable.create(() => this.menuRegistry.unregisterMenuNode(deletePlaceholder.id)));
83+
}
84+
85+
4586
for (let i = 0; i < uris.length; i++) {
4687
const uri = new URI(uris[i]);
88+
89+
90+
91+
// focus on the opened sketch
4792
const command = { id: `arduino-focus-file--${uri.toString()}` };
4893
const handler = { execute: () => open(this.openerService, uri) };
4994
this.toDisposeBeforeCreateNewContextMenu.push(registry.registerCommand(command, handler));
@@ -72,16 +117,6 @@ export class SketchControl extends SketchContribution {
72117
label: 'New Tab',
73118
order: '0'
74119
});
75-
registry.registerMenuAction(ArduinoMenus.SKETCH_CONTROL__CONTEXT__MAIN_GROUP, {
76-
commandId: WorkspaceCommands.FILE_RENAME.id,
77-
label: 'Rename',
78-
order: '1'
79-
});
80-
registry.registerMenuAction(ArduinoMenus.SKETCH_CONTROL__CONTEXT__MAIN_GROUP, {
81-
commandId: WorkspaceCommands.FILE_DELETE.id, // TODO: customize delete. Wipe sketch if deleting main file. Close window.
82-
label: 'Delete',
83-
order: '2'
84-
});
85120

86121
registry.registerMenuAction(ArduinoMenus.SKETCH_CONTROL__CONTEXT__NAVIGATION_GROUP, {
87122
commandId: CommonCommands.PREVIOUS_TAB.id,

‎arduino-ide-extension/src/browser/data/arduino.color-theme.json‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@
8585
],
8686
"colors": {
8787
"list.highlightForeground": "#005c5f",
88-
"list.activeSelectionBackground": "#005c5f",
88+
"list.activeSelectionForeground": "#424242",
89+
"list.activeSelectionBackground": "#DAE3E3",
90+
"list.inactiveSelectionForeground": "#424242",
91+
"list.inactiveSelectionBackground": "#DAE3E3",
92+
"list.hoverBackground": "#ECF1F1",
8993
"progressBar.background": "#005c5f",
9094
"editor.background": "#ffffff",
9195
"editorCursor.foreground": "#434f54",

‎arduino-ide-extension/src/browser/settings.tsx‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export interface Settings extends Index {
3434
verboseOnUpload: boolean; // `arduino.upload.verbose`
3535
verifyAfterUpload: boolean; // `arduino.upload.verify`
3636
enableLsLogs: boolean; // `arduino.language.log`
37+
sketchbookShowAllFiles: boolean; // `arduino.sketchbook.showAllFiles`
3738

3839
sketchbookPath: string; // CLI
3940
additionalUrls: string[]; // CLI
@@ -94,7 +95,8 @@ export class SettingsService {
9495
verboseOnUpload,
9596
verifyAfterUpload,
9697
enableLsLogs,
97-
cliConfig
98+
sketchbookShowAllFiles,
99+
cliConfig,
98100
] = await Promise.all([
99101
this.preferenceService.get<number>('editor.fontSize', 12),
100102
this.preferenceService.get<string>('workbench.colorTheme', 'arduino-theme'),
@@ -112,6 +114,7 @@ export class SettingsService {
112114
this.preferenceService.get<boolean>('arduino.upload.verbose', true),
113115
this.preferenceService.get<boolean>('arduino.upload.verify', true),
114116
this.preferenceService.get<boolean>('arduino.language.log', true),
117+
this.preferenceService.get<boolean>('arduino.sketchbook.showAllFiles', false),
115118
this.configService.getConfiguration()
116119
]);
117120
const { additionalUrls, sketchDirUri, network } = cliConfig;
@@ -129,6 +132,7 @@ export class SettingsService {
129132
verboseOnUpload,
130133
verifyAfterUpload,
131134
enableLsLogs,
135+
sketchbookShowAllFiles,
132136
additionalUrls,
133137
sketchbookPath,
134138
network
@@ -194,7 +198,8 @@ export class SettingsService {
194198
enableLsLogs,
195199
sketchbookPath,
196200
additionalUrls,
197-
network
201+
network,
202+
sketchbookShowAllFiles
198203
} = this._settings;
199204
const [config, sketchDirUri] = await Promise.all([
200205
this.configService.getConfiguration(),
@@ -217,6 +222,7 @@ export class SettingsService {
217222
this.preferenceService.set('arduino.upload.verbose', verboseOnUpload, PreferenceScope.User),
218223
this.preferenceService.set('arduino.upload.verify', verifyAfterUpload, PreferenceScope.User),
219224
this.preferenceService.set('arduino.language.log', enableLsLogs, PreferenceScope.User),
225+
this.preferenceService.set('arduino.sketchbook.showAllFiles', sketchbookShowAllFiles, PreferenceScope.User),
220226
this.configService.setConfiguration(config)
221227
]);
222228
this.onDidChangeEmitter.fire(this._settings);
@@ -370,6 +376,13 @@ export class SettingsComponent extends React.Component<SettingsComponent.Props,
370376
onChange={this.autoSaveDidChange} />
371377
Auto save
372378
</label>
379+
<label className='flex-line'>
380+
<input
381+
type='checkbox'
382+
checked={this.state.sketchbookShowAllFiles === true}
383+
onChange={this.sketchbookShowAllFilesDidChange} />
384+
Sketchbook show files
385+
</label>
373386
<label className='flex-line'>
374387
<input
375388
type='checkbox'
@@ -564,6 +577,10 @@ export class SettingsComponent extends React.Component<SettingsComponent.Props,
564577
this.setState({ checkForUpdates: event.target.checked });
565578
};
566579

580+
protected sketchbookShowAllFilesDidChange = (event: React.ChangeEvent<HTMLInputElement>) => {
581+
this.setState({ sketchbookShowAllFiles: event.target.checked });
582+
};
583+
567584
protected autoSaveDidChange = (event: React.ChangeEvent<HTMLInputElement>) => {
568585
this.setState({ autoSave: event.target.checked ? 'on' : 'off' });
569586
};

0 commit comments

Comments
(0)

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