mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-06-14 16:16:32 +00:00
Enabled New Folder
in classic mode.
- Made sure the `Explorer` is visible before raising the input dialog. - Removed unused module. Fixes arduino/arduino-pro-ide#84 Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
parent
840cde872c
commit
35ac73181b
@ -3,7 +3,7 @@ import { injectable, inject, postConstruct } from 'inversify';
|
|||||||
import URI from '@theia/core/lib/common/uri';
|
import URI from '@theia/core/lib/common/uri';
|
||||||
import { EditorWidget } from '@theia/editor/lib/browser/editor-widget';
|
import { EditorWidget } from '@theia/editor/lib/browser/editor-widget';
|
||||||
import { MessageService } from '@theia/core/lib/common/message-service';
|
import { MessageService } from '@theia/core/lib/common/message-service';
|
||||||
import { CommandContribution, CommandRegistry, Command } from '@theia/core/lib/common/command';
|
import { CommandContribution, CommandRegistry, Command, CommandHandler } from '@theia/core/lib/common/command';
|
||||||
import { TabBarToolbarContribution, TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
|
import { TabBarToolbarContribution, TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
|
||||||
import { BoardsService } from '../common/protocol/boards-service';
|
import { BoardsService } from '../common/protocol/boards-service';
|
||||||
import { ArduinoCommands } from './arduino-commands';
|
import { ArduinoCommands } from './arduino-commands';
|
||||||
@ -257,6 +257,42 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut
|
|||||||
}
|
}
|
||||||
|
|
||||||
registerCommands(registry: CommandRegistry): void {
|
registerCommands(registry: CommandRegistry): void {
|
||||||
|
// TODO: use proper API https://github.com/eclipse-theia/theia/pull/6599
|
||||||
|
const allHandlers: { [id: string]: CommandHandler[] } = (registry as any)._handlers;
|
||||||
|
// Make sure to reveal the `Explorer` before executing `New File` and `New Folder`.
|
||||||
|
for (const command of [WorkspaceCommands.NEW_FILE, WorkspaceCommands.NEW_FOLDER]) {
|
||||||
|
const { id } = command;
|
||||||
|
const handlers = allHandlers[id].slice();
|
||||||
|
registry.unregisterCommand(id);
|
||||||
|
registry.registerCommand(command);
|
||||||
|
for (const handler of handlers) {
|
||||||
|
const wrapper: CommandHandler = {
|
||||||
|
execute: (...args: any[]) => {
|
||||||
|
this.fileNavigatorContributions.openView({ reveal: true }).then(() => handler.execute(args));
|
||||||
|
},
|
||||||
|
isVisible: (...args: any[]) => {
|
||||||
|
return handler.isVisible!(args);
|
||||||
|
},
|
||||||
|
isEnabled: (args: any[]) => {
|
||||||
|
return handler.isEnabled!(args);
|
||||||
|
},
|
||||||
|
isToggled: (args: any[]) => {
|
||||||
|
return handler.isToggled!(args);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (!handler.isEnabled) {
|
||||||
|
delete wrapper.isEnabled;
|
||||||
|
}
|
||||||
|
if (!handler.isToggled) {
|
||||||
|
delete wrapper.isToggled;
|
||||||
|
}
|
||||||
|
if (!handler.isVisible) {
|
||||||
|
delete wrapper.isVisible;
|
||||||
|
}
|
||||||
|
registry.registerHandler(id, wrapper);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
registry.registerCommand(ArduinoCommands.VERIFY, {
|
registry.registerCommand(ArduinoCommands.VERIFY, {
|
||||||
isVisible: widget => ArduinoToolbar.is(widget) && widget.side === 'left',
|
isVisible: widget => ArduinoToolbar.is(widget) && widget.side === 'left',
|
||||||
isEnabled: widget => true,
|
isEnabled: widget => true,
|
||||||
@ -398,7 +434,6 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut
|
|||||||
CommonCommands.COLLAPSE_PANEL,
|
CommonCommands.COLLAPSE_PANEL,
|
||||||
CommonCommands.TOGGLE_MAXIMIZED,
|
CommonCommands.TOGGLE_MAXIMIZED,
|
||||||
FileNavigatorCommands.REVEAL_IN_NAVIGATOR
|
FileNavigatorCommands.REVEAL_IN_NAVIGATOR
|
||||||
|
|
||||||
]) {
|
]) {
|
||||||
registry.unregisterMenuAction(command);
|
registry.unregisterMenuAction(command);
|
||||||
}
|
}
|
||||||
@ -406,8 +441,6 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut
|
|||||||
registry.unregisterMenuAction(FileSystemCommands.UPLOAD);
|
registry.unregisterMenuAction(FileSystemCommands.UPLOAD);
|
||||||
registry.unregisterMenuAction(FileDownloadCommands.DOWNLOAD);
|
registry.unregisterMenuAction(FileDownloadCommands.DOWNLOAD);
|
||||||
|
|
||||||
registry.unregisterMenuAction(WorkspaceCommands.NEW_FOLDER);
|
|
||||||
|
|
||||||
registry.unregisterMenuAction(WorkspaceCommands.OPEN_FOLDER);
|
registry.unregisterMenuAction(WorkspaceCommands.OPEN_FOLDER);
|
||||||
registry.unregisterMenuAction(WorkspaceCommands.OPEN_WORKSPACE);
|
registry.unregisterMenuAction(WorkspaceCommands.OPEN_WORKSPACE);
|
||||||
registry.unregisterMenuAction(WorkspaceCommands.OPEN_RECENT_WORKSPACE);
|
registry.unregisterMenuAction(WorkspaceCommands.OPEN_RECENT_WORKSPACE);
|
||||||
@ -502,7 +535,7 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut
|
|||||||
if (destinationFile && !destinationFile.isDirectory) {
|
if (destinationFile && !destinationFile.isDirectory) {
|
||||||
const message = await this.validate(destinationFile);
|
const message = await this.validate(destinationFile);
|
||||||
if (!message) {
|
if (!message) {
|
||||||
await this.workspaceService.open(destinationFileUri);
|
this.workspaceService.open(destinationFileUri);
|
||||||
return destinationFileUri;
|
return destinationFileUri;
|
||||||
} else {
|
} else {
|
||||||
this.messageService.warn(message);
|
this.messageService.warn(message);
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
import { injectable } from 'inversify';
|
|
||||||
import { FileMenuContribution } from '@theia/workspace/lib/browser';
|
|
||||||
import { MenuModelRegistry } from '@theia/core';
|
|
||||||
|
|
||||||
@injectable()
|
|
||||||
export class ArduinoFileMenuContribution extends FileMenuContribution {
|
|
||||||
|
|
||||||
registerMenus(registry: MenuModelRegistry) {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user