Skip to content

Commit 3571032

Browse files
author
Akos Kitta
committed
Removed unused New, Save, and Open logic.
The icons were removed in arduino#1194. Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
1 parent d6691be commit 3571032

File tree

3 files changed

+11
-134
lines changed

3 files changed

+11
-134
lines changed

arduino-ide-extension/src/browser/contributions/new-sketch.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { nls } from '@theia/core/lib/common';
22
import { injectable } from '@theia/core/shared/inversify';
33
import { ArduinoMenus } from '../menu/arduino-menus';
4-
import { ArduinoToolbar } from '../toolbar/arduino-toolbar';
54
import {
65
SketchContribution,
76
URI,
@@ -17,11 +16,6 @@ export class NewSketch extends SketchContribution {
1716
registry.registerCommand(NewSketch.Commands.NEW_SKETCH, {
1817
execute: () => this.newSketch(),
1918
});
20-
registry.registerCommand(NewSketch.Commands.NEW_SKETCH__TOOLBAR, {
21-
isVisible: (widget) =>
22-
ArduinoToolbar.is(widget) && widget.side === 'left',
23-
execute: () => registry.executeCommand(NewSketch.Commands.NEW_SKETCH.id),
24-
});
2519
}
2620

2721
override registerMenus(registry: MenuModelRegistry): void {
@@ -54,8 +48,5 @@ export namespace NewSketch {
5448
export const NEW_SKETCH: Command = {
5549
id: 'arduino-new-sketch',
5650
};
57-
export const NEW_SKETCH__TOOLBAR: Command = {
58-
id: 'arduino-new-sketch--toolbar',
59-
};
6051
}
6152
}

arduino-ide-extension/src/browser/contributions/open-sketch.ts

Lines changed: 11 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,25 @@
1-
import { inject, injectable } from '@theia/core/shared/inversify';
21
import * as remote from '@theia/core/electron-shared/@electron/remote';
3-
import { Widget, ContextMenuRenderer } from '@theia/core/lib/browser';
4-
import {
5-
Disposable,
6-
DisposableCollection,
7-
} from '@theia/core/lib/common/disposable';
2+
import { nls } from '@theia/core/lib/common/nls';
3+
import { injectable } from '@theia/core/shared/inversify';
4+
import { SketchesError, SketchRef } from '../../common/protocol';
85
import { ArduinoMenus } from '../menu/arduino-menus';
9-
import { ArduinoToolbar } from '../toolbar/arduino-toolbar';
106
import {
11-
SketchContribution,
12-
Sketch,
13-
URI,
147
Command,
158
CommandRegistry,
16-
MenuModelRegistry,
179
KeybindingRegistry,
10+
MenuModelRegistry,
11+
Sketch,
12+
SketchContribution,
13+
URI,
1814
} from './contribution';
19-
import { ExamplesService } from '../../common/protocol/examples-service';
20-
import { BuiltInExamples } from './examples';
21-
import { Sketchbook } from './sketchbook';
22-
import {
23-
SketchContainer,
24-
SketchesError,
25-
SketchRef,
26-
} from '../../common/protocol';
27-
import { nls } from '@theia/core/lib/common/nls';
2815

29-
export type SketchLocation = string | URI | SketchRef | Sketch;
16+
export type SketchLocation = string | URI | SketchRef;
3017
export namespace SketchLocation {
3118
export function toUri(location: SketchLocation): URI {
3219
if (typeof location === 'string') {
3320
return new URI(location);
3421
} else if (SketchRef.is(location)) {
3522
return toUri(location.uri);
36-
} else if (Sketch.is(location)) {
37-
return toUri(location.uri);
3823
} else {
3924
return location;
4025
}
@@ -61,32 +46,12 @@ export namespace OpenSketchParams {
6146

6247
@injectable()
6348
export class OpenSketch extends SketchContribution {
64-
@inject(MenuModelRegistry)
65-
private readonly menuRegistry: MenuModelRegistry;
66-
67-
@inject(ContextMenuRenderer)
68-
private readonly contextMenuRenderer: ContextMenuRenderer;
69-
70-
@inject(BuiltInExamples)
71-
private readonly builtInExamples: BuiltInExamples;
72-
73-
@inject(ExamplesService)
74-
private readonly examplesService: ExamplesService;
75-
76-
@inject(Sketchbook)
77-
private readonly sketchbook: Sketchbook;
78-
79-
private readonly toDispose = new DisposableCollection();
80-
8149
override registerCommands(registry: CommandRegistry): void {
8250
registry.registerCommand(OpenSketch.Commands.OPEN_SKETCH, {
8351
execute: async (arg) => {
84-
let toOpen: string | URI | SketchRef | Sketch | undefined = undefined;
85-
if (!OpenSketchParams.is(arg)) {
86-
toOpen = await this.selectSketch();
87-
} else {
88-
toOpen = arg.toOpen;
89-
}
52+
const toOpen = !OpenSketchParams.is(arg)
53+
? await this.selectSketch()
54+
: arg.toOpen;
9055
if (toOpen) {
9156
return this.openSketch(
9257
toOpen,
@@ -95,72 +60,6 @@ export class OpenSketch extends SketchContribution {
9560
}
9661
},
9762
});
98-
registry.registerCommand(OpenSketch.Commands.OPEN_SKETCH__TOOLBAR, {
99-
isVisible: (widget) =>
100-
ArduinoToolbar.is(widget) && widget.side === 'left',
101-
execute: async (_: Widget, target: EventTarget) => {
102-
const container = await this.sketchService.getSketches({
103-
exclude: ['**/hardware/**'],
104-
});
105-
if (SketchContainer.isEmpty(container)) {
106-
this.selectSketch().then((sketch) => this.openSketch(sketch));
107-
} else {
108-
this.toDispose.dispose();
109-
if (!(target instanceof HTMLElement)) {
110-
return;
111-
}
112-
const { parentElement } = target;
113-
if (!parentElement) {
114-
return;
115-
}
116-
117-
this.menuRegistry.registerMenuAction(
118-
ArduinoMenus.OPEN_SKETCH__CONTEXT__OPEN_GROUP,
119-
{
120-
commandId: OpenSketch.Commands.OPEN_SKETCH.id,
121-
label: nls.localize(
122-
'vscode/workspaceActions/openFileFolder',
123-
'Open...'
124-
),
125-
}
126-
);
127-
this.toDispose.push(
128-
Disposable.create(() =>
129-
this.menuRegistry.unregisterMenuAction(
130-
OpenSketch.Commands.OPEN_SKETCH
131-
)
132-
)
133-
);
134-
this.sketchbook.registerRecursively(
135-
[...container.children, ...container.sketches],
136-
ArduinoMenus.OPEN_SKETCH__CONTEXT__RECENT_GROUP,
137-
this.toDispose
138-
);
139-
try {
140-
const containers = await this.examplesService.builtIns();
141-
for (const container of containers) {
142-
this.builtInExamples.registerRecursively(
143-
container,
144-
ArduinoMenus.OPEN_SKETCH__CONTEXT__EXAMPLES_GROUP,
145-
this.toDispose
146-
);
147-
}
148-
} catch (e) {
149-
console.error('Error when collecting built-in examples.', e);
150-
}
151-
const options = {
152-
menuPath: ArduinoMenus.OPEN_SKETCH__CONTEXT,
153-
anchor: {
154-
x: parentElement.getBoundingClientRect().left,
155-
y:
156-
parentElement.getBoundingClientRect().top +
157-
parentElement.offsetHeight,
158-
},
159-
};
160-
this.contextMenuRenderer.render(options);
161-
}
162-
},
163-
});
16463
}
16564

16665
override registerMenus(registry: MenuModelRegistry): void {
@@ -277,8 +176,5 @@ export namespace OpenSketch {
277176
export const OPEN_SKETCH: Command = {
278177
id: 'arduino-open-sketch',
279178
};
280-
export const OPEN_SKETCH__TOOLBAR: Command = {
281-
id: 'arduino-open-sketch--toolbar',
282-
};
283179
}
284180
}

arduino-ide-extension/src/browser/contributions/save-sketch.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { injectable } from '@theia/core/shared/inversify';
22
import { CommonCommands } from '@theia/core/lib/browser/common-frontend-contribution';
33
import { ArduinoMenus } from '../menu/arduino-menus';
4-
import { ArduinoToolbar } from '../toolbar/arduino-toolbar';
54
import { SaveAsSketch } from './save-as-sketch';
65
import {
76
SketchContribution,
@@ -19,12 +18,6 @@ export class SaveSketch extends SketchContribution {
1918
registry.registerCommand(SaveSketch.Commands.SAVE_SKETCH, {
2019
execute: () => this.saveSketch(),
2120
});
22-
registry.registerCommand(SaveSketch.Commands.SAVE_SKETCH__TOOLBAR, {
23-
isVisible: (widget) =>
24-
ArduinoToolbar.is(widget) && widget.side === 'left',
25-
execute: () =>
26-
registry.executeCommand(SaveSketch.Commands.SAVE_SKETCH.id),
27-
});
2821
}
2922

3023
override registerMenus(registry: MenuModelRegistry): void {
@@ -68,8 +61,5 @@ export namespace SaveSketch {
6861
export const SAVE_SKETCH: Command = {
6962
id: 'arduino-save-sketch',
7063
};
71-
export const SAVE_SKETCH__TOOLBAR: Command = {
72-
id: 'arduino-save-sketch--toolbar',
73-
};
7464
}
7565
}

0 commit comments

Comments
 (0)