Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
Akos Kitta 2020-07-16 16:33:49 +02:00
parent d29141aff6
commit a0bbfe0b5c
5 changed files with 34 additions and 51 deletions

View File

@ -79,7 +79,7 @@
"grpc_tools_node_protoc_ts": "^4.1.0",
"mocha": "^7.0.0",
"moment": "^2.24.0",
"protoc": "1.0.4",
"protoc": "^1.0.4",
"shelljs": "^0.8.3",
"sinon": "^9.0.1",
"uuid": "^3.2.1",

View File

@ -77,8 +77,8 @@ import { BoardsDetailsMenuUpdater } from './boards/boards-details-menu-updater';
import { BoardsConfigStore } from './boards/boards-config-store';
import { ILogger } from '@theia/core';
import { FileSystemExt, FileSystemExtPath } from '../common/protocol/filesystem-ext';
import { WorkspaceFrontendContribution } from '@theia/workspace/lib/browser';
import { ArduinoWorkspaceFrontendContribution } from './customization/arduino-workspace-frontend-contribution';
import { WorkspaceFrontendContribution, FileMenuContribution } from '@theia/workspace/lib/browser';
import { ArduinoWorkspaceFrontendContribution, ArduinoFileMenuContribution } from './customization/arduino-workspace-frontend-contribution';
const ElementQueries = require('css-element-queries/src/ElementQueries');
@ -255,6 +255,7 @@ export default new ContainerModule((bind: interfaces.Bind, unbind: interfaces.Un
rebind(SearchInWorkspaceFrontendContribution).to(ArduinoSearchInWorkspaceContribution).inSingletonScope();
rebind(FrontendApplication).to(ArduinoFrontendApplication).inSingletonScope();
rebind(WorkspaceFrontendContribution).to(ArduinoWorkspaceFrontendContribution).inSingletonScope();
rebind(FileMenuContribution).to(ArduinoFileMenuContribution).inSingletonScope();
// Show a disconnected status bar, when the daemon is not available
bind(ArduinoApplicationConnectionStatusContribution).toSelf().inSingletonScope();

View File

@ -1,62 +1,38 @@
import { injectable } from 'inversify';
import { isOSX } from '@theia/core/lib/common/os';
import { environment } from '@theia/application-package/lib/environment';
import { CommonMenus } from '@theia/core/lib/browser';
import { CommandRegistry } from '@theia/core/lib/common/command';
import { MenuModelRegistry } from '@theia/core/lib/common/menu';
import { WorkspaceCommands } from '@theia/workspace/lib/browser/workspace-commands';
import { WorkspaceCommands, FileMenuContribution } from '@theia/workspace/lib/browser/workspace-commands';
import { WorkspaceFrontendContribution } from '@theia/workspace/lib/browser/workspace-frontend-contribution';
// TODO: https://github.com/eclipse-theia/theia/issues/8175
@injectable()
export class ArduinoWorkspaceFrontendContribution extends WorkspaceFrontendContribution {
registerCommands(registry: CommandRegistry): void {
super.registerCommands(registry);
registry.unregisterCommand(WorkspaceCommands.SAVE_AS);
registry.unregisterCommand(WorkspaceCommands.OPEN_FOLDER);
// TODO: instead of blacklisting commands to remove, it would be more robust to whitelist the ones we want to keep
const commands = new Set(registry.commands);
[
WorkspaceCommands.OPEN,
WorkspaceCommands.OPEN_FILE,
WorkspaceCommands.OPEN_FOLDER,
WorkspaceCommands.OPEN_WORKSPACE,
WorkspaceCommands.OPEN_RECENT_WORKSPACE,
WorkspaceCommands.SAVE_WORKSPACE_AS,
WorkspaceCommands.SAVE_AS
].filter(commands.has.bind(commands)).forEach(registry.unregisterCommand.bind(registry));
}
registerMenus(registry: MenuModelRegistry): void {
if (isOSX || !environment.electron.is()) {
registry.registerMenuAction(CommonMenus.FILE_OPEN, {
commandId: WorkspaceCommands.OPEN.id,
order: 'a00'
});
}
if (!isOSX && environment.electron.is()) {
registry.registerMenuAction(CommonMenus.FILE_OPEN, {
commandId: WorkspaceCommands.OPEN_FILE.id,
label: `${WorkspaceCommands.OPEN_FILE.dialogLabel}...`,
order: 'a01'
});
registry.registerMenuAction(CommonMenus.FILE_OPEN, {
commandId: WorkspaceCommands.OPEN_FOLDER.id,
label: `${WorkspaceCommands.OPEN_FOLDER.dialogLabel}...`,
order: 'a02'
});
}
registry.registerMenuAction(CommonMenus.FILE_OPEN, {
commandId: WorkspaceCommands.OPEN_WORKSPACE.id,
order: 'a10'
});
registry.registerMenuAction(CommonMenus.FILE_OPEN, {
commandId: WorkspaceCommands.OPEN_RECENT_WORKSPACE.id,
order: 'a20'
});
registry.registerMenuAction(CommonMenus.FILE_OPEN, {
commandId: WorkspaceCommands.SAVE_WORKSPACE_AS.id,
order: 'a30'
});
registry.registerMenuAction(CommonMenus.FILE_CLOSE, {
commandId: WorkspaceCommands.CLOSE.id
});
// `Save As`
// menus.registerMenuAction(CommonMenus.FILE_SAVE, {
// commandId: WorkspaceCommands.SAVE_AS.id,
// });
registerMenus(_: MenuModelRegistry): void {
// NOOP
}
}
@injectable()
export class ArduinoFileMenuContribution extends FileMenuContribution {
registerMenus(_: MenuModelRegistry): void {
// NOOP
}
}

View File

@ -0,0 +1,6 @@
import { CommonMenus } from '@theia/core/lib/browser/common-frontend-contribution';
export namespace ArduinoMenus {
export const FILE__SKETCH_GROUP = [...CommonMenus.FILE, '0_sketch'];
export const FILE__PRINT_GROUP = [...CommonMenus.FILE, '1_print'];
}

View File

@ -11922,7 +11922,7 @@ proto-list@~1.2.1:
resolved "https://registry.yarnpkg.com/proto-list/-/proto-list-1.2.4.tgz#212d5bfe1318306a420f6402b8e26ff39647a849"
integrity sha1-IS1b/hMYMGpCD2QCuOJv85ZHqEk=
protoc@^1.0.4:
protoc@1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/protoc/-/protoc-1.0.4.tgz#fd0ba07132c459df80c6135889bd5cc92f0afec2"
integrity sha512-2crtOP6xhacdWBW+lkhQJmzwg2cPmqSsh51FOHQmgTd8dKksO9sFzlhzteh6x+qPTfPU7h6smC1eg5d9bqGpTQ==