mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-13 06:16:33 +00:00
Open the sketch in a new window.
Signed-off-by: jbicker <jan.bicker@typefox.io>
This commit is contained in:
parent
92afa48c05
commit
4096afde96
@ -4,7 +4,6 @@ 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 } from '@theia/core/lib/common/command';
|
import { CommandContribution, CommandRegistry } from '@theia/core/lib/common/command';
|
||||||
import { DefaultFrontendApplicationContribution } from '@theia/core/lib/browser/frontend-application';
|
|
||||||
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';
|
||||||
@ -21,7 +20,7 @@ import { WorkspaceService } from '@theia/workspace/lib/browser/workspace-service
|
|||||||
import { SketchFactory } from './sketch-factory';
|
import { SketchFactory } from './sketch-factory';
|
||||||
import { ArduinoToolbar } from './toolbar/arduino-toolbar';
|
import { ArduinoToolbar } from './toolbar/arduino-toolbar';
|
||||||
import { EditorManager } from '@theia/editor/lib/browser';
|
import { EditorManager } from '@theia/editor/lib/browser';
|
||||||
import { ContextMenuRenderer, OpenerService, Widget } from '@theia/core/lib/browser';
|
import { ContextMenuRenderer, OpenerService, Widget, Endpoint } from '@theia/core/lib/browser';
|
||||||
import { OpenFileDialogProps, FileDialogService } from '@theia/filesystem/lib/browser/file-dialog';
|
import { OpenFileDialogProps, FileDialogService } from '@theia/filesystem/lib/browser/file-dialog';
|
||||||
import { FileSystem } from '@theia/filesystem/lib/common';
|
import { FileSystem } from '@theia/filesystem/lib/common';
|
||||||
import { ArduinoOpenSketchContextMenu } from './arduino-file-menu';
|
import { ArduinoOpenSketchContextMenu } from './arduino-file-menu';
|
||||||
@ -29,7 +28,7 @@ import { Sketch, SketchesService } from '../common/protocol/sketches-service';
|
|||||||
import { WindowService } from '@theia/core/lib/browser/window/window-service';
|
import { WindowService } from '@theia/core/lib/browser/window/window-service';
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class ArduinoFrontendContribution extends DefaultFrontendApplicationContribution implements TabBarToolbarContribution, CommandContribution {
|
export class ArduinoFrontendContribution implements TabBarToolbarContribution, CommandContribution {
|
||||||
|
|
||||||
@inject(MessageService)
|
@inject(MessageService)
|
||||||
protected readonly messageService: MessageService;
|
protected readonly messageService: MessageService;
|
||||||
@ -79,12 +78,11 @@ export class ArduinoFrontendContribution extends DefaultFrontendApplicationContr
|
|||||||
@inject(OpenerService)
|
@inject(OpenerService)
|
||||||
protected readonly openerService: OpenerService;
|
protected readonly openerService: OpenerService;
|
||||||
|
|
||||||
@inject(SketchesService)
|
|
||||||
protected readonly sketches: SketchesService;
|
|
||||||
|
|
||||||
@inject(WindowService)
|
@inject(WindowService)
|
||||||
protected readonly windowService: WindowService;
|
protected readonly windowService: WindowService;
|
||||||
|
|
||||||
|
@inject(SketchesService)
|
||||||
|
protected readonly sketches: SketchesService;
|
||||||
|
|
||||||
@postConstruct()
|
@postConstruct()
|
||||||
protected async init(): Promise<void> {
|
protected async init(): Promise<void> {
|
||||||
@ -189,16 +187,7 @@ export class ArduinoFrontendContribution extends DefaultFrontendApplicationContr
|
|||||||
registry.registerCommand(ArduinoCommands.OPEN_SKETCH, {
|
registry.registerCommand(ArduinoCommands.OPEN_SKETCH, {
|
||||||
isEnabled: () => true,
|
isEnabled: () => true,
|
||||||
execute: async (sketch: Sketch) => {
|
execute: async (sketch: Sketch) => {
|
||||||
// const url = new URL(window.location.href);
|
this.openSketchFilesInNewWindow(sketch.uri);
|
||||||
// if (this.workspaceService.workspace) {
|
|
||||||
// const wsUri = this.workspaceService.workspace.uri;
|
|
||||||
// const path = new URI(wsUri).path;
|
|
||||||
// url.hash = path + '?sketch=' + sketch.name
|
|
||||||
// }
|
|
||||||
// this.windowService.openNewWindow(url.toString());
|
|
||||||
|
|
||||||
this.openSketchFiles(sketch.uri);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
registry.registerCommand(ArduinoCommands.NEW_SKETCH, new WorkspaceRootUriAwareCommandHandler(this.workspaceService, this.selectionService, {
|
registry.registerCommand(ArduinoCommands.NEW_SKETCH, new WorkspaceRootUriAwareCommandHandler(this.workspaceService, this.selectionService, {
|
||||||
@ -221,7 +210,14 @@ export class ArduinoFrontendContribution extends DefaultFrontendApplicationContr
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async openSketchFiles(uri: string) {
|
protected async openSketchFilesInNewWindow(uri: string) {
|
||||||
|
const location = new URL(window.location.href);
|
||||||
|
let url = new Endpoint().getRestUrl().withQuery(uri).toString();
|
||||||
|
url += location.hash;
|
||||||
|
this.windowService.openNewWindow(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
async openSketchFiles(uri: string) {
|
||||||
const fileStat = await this.fileSystem.getFileStat(uri);
|
const fileStat = await this.fileSystem.getFileStat(uri);
|
||||||
if (fileStat) {
|
if (fileStat) {
|
||||||
const sketchFiles = await this.sketches.getSketchFiles(fileStat);
|
const sketchFiles = await this.sketches.getSketchFiles(fileStat);
|
||||||
@ -251,7 +247,7 @@ export class ArduinoFrontendContribution extends DefaultFrontendApplicationContr
|
|||||||
if (destinationFileUri) {
|
if (destinationFileUri) {
|
||||||
const destinationFile = await this.fileSystem.getFileStat(destinationFileUri.toString());
|
const destinationFile = await this.fileSystem.getFileStat(destinationFileUri.toString());
|
||||||
if (destinationFile && !destinationFile.isDirectory) {
|
if (destinationFile && !destinationFile.isDirectory) {
|
||||||
await this.openSketchFiles(destinationFileUri.toString());
|
await this.openSketchFilesInNewWindow(destinationFileUri.toString());
|
||||||
return destinationFileUri;
|
return destinationFileUri;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import { CommandContribution } from '@theia/core/lib/common/command';
|
|||||||
import { bindViewContribution } from '@theia/core/lib/browser/shell/view-contribution';
|
import { bindViewContribution } from '@theia/core/lib/browser/shell/view-contribution';
|
||||||
import { TabBarToolbarContribution } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
|
import { TabBarToolbarContribution } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
|
||||||
import { WebSocketConnectionProvider } from '@theia/core/lib/browser/messaging/ws-connection-provider';
|
import { WebSocketConnectionProvider } from '@theia/core/lib/browser/messaging/ws-connection-provider';
|
||||||
import { FrontendApplicationContribution } from '@theia/core/lib/browser/frontend-application'
|
import { FrontendApplicationContribution, FrontendApplication } from '@theia/core/lib/browser/frontend-application'
|
||||||
import { LanguageGrammarDefinitionContribution } from '@theia/monaco/lib/browser/textmate';
|
import { LanguageGrammarDefinitionContribution } from '@theia/monaco/lib/browser/textmate';
|
||||||
import { LibraryListWidget } from './library/library-list-widget';
|
import { LibraryListWidget } from './library/library-list-widget';
|
||||||
import { ArduinoFrontendContribution } from './arduino-frontend-contribution';
|
import { ArduinoFrontendContribution } from './arduino-frontend-contribution';
|
||||||
@ -45,12 +45,14 @@ import { MonacoStatusBarContribution } from '@theia/monaco/lib/browser/monaco-st
|
|||||||
import { SilentMonacoStatusBarContribution } from './customization/silent-monaco-status-bar-contribution';
|
import { SilentMonacoStatusBarContribution } from './customization/silent-monaco-status-bar-contribution';
|
||||||
import { ApplicationShell } from '@theia/core/lib/browser';
|
import { ApplicationShell } from '@theia/core/lib/browser';
|
||||||
import { CustomApplicationShell } from './customization/custom-application-shell';
|
import { CustomApplicationShell } from './customization/custom-application-shell';
|
||||||
|
import { CustomFrontendApplication } from './customization/custom-frontend-application';
|
||||||
|
|
||||||
export default new ContainerModule((bind: interfaces.Bind, unbind: interfaces.Unbind, isBound: interfaces.IsBound, rebind: interfaces.Rebind) => {
|
export default new ContainerModule((bind: interfaces.Bind, unbind: interfaces.Unbind, isBound: interfaces.IsBound, rebind: interfaces.Rebind) => {
|
||||||
// Commands and toolbar items
|
// Commands and toolbar items
|
||||||
bind(ArduinoFrontendContribution).toSelf().inSingletonScope();
|
bind(ArduinoFrontendContribution).toSelf().inSingletonScope();
|
||||||
bind(CommandContribution).toService(ArduinoFrontendContribution);
|
bind(CommandContribution).toService(ArduinoFrontendContribution);
|
||||||
bind(TabBarToolbarContribution).toService(ArduinoFrontendContribution);
|
bind(TabBarToolbarContribution).toService(ArduinoFrontendContribution);
|
||||||
|
bind(FrontendApplicationContribution).toService(ArduinoFrontendContribution);
|
||||||
bind(MenuContribution).to(ArduinoFileMenuContribution).inSingletonScope();
|
bind(MenuContribution).to(ArduinoFileMenuContribution).inSingletonScope();
|
||||||
|
|
||||||
bind(ArduinoToolbarContribution).toSelf().inSingletonScope();
|
bind(ArduinoToolbarContribution).toSelf().inSingletonScope();
|
||||||
@ -126,7 +128,6 @@ export default new ContainerModule((bind: interfaces.Bind, unbind: interfaces.Un
|
|||||||
bind(OutlineViewContribution).to(SilentOutlineViewContribution).inSingletonScope();
|
bind(OutlineViewContribution).to(SilentOutlineViewContribution).inSingletonScope();
|
||||||
unbind(ProblemContribution);
|
unbind(ProblemContribution);
|
||||||
bind(ProblemContribution).to(SilentProblemContribution).inSingletonScope();
|
bind(ProblemContribution).to(SilentProblemContribution).inSingletonScope();
|
||||||
|
|
||||||
unbind(FileNavigatorContribution);
|
unbind(FileNavigatorContribution);
|
||||||
bind(FileNavigatorContribution).to(SilentNavigatorContribution).inSingletonScope();
|
bind(FileNavigatorContribution).to(SilentNavigatorContribution).inSingletonScope();
|
||||||
unbind(OutputToolbarContribution);
|
unbind(OutputToolbarContribution);
|
||||||
@ -137,4 +138,6 @@ export default new ContainerModule((bind: interfaces.Bind, unbind: interfaces.Un
|
|||||||
bind(MonacoStatusBarContribution).to(SilentMonacoStatusBarContribution).inSingletonScope();
|
bind(MonacoStatusBarContribution).to(SilentMonacoStatusBarContribution).inSingletonScope();
|
||||||
unbind(ApplicationShell);
|
unbind(ApplicationShell);
|
||||||
bind(ApplicationShell).to(CustomApplicationShell).inSingletonScope();
|
bind(ApplicationShell).to(CustomApplicationShell).inSingletonScope();
|
||||||
|
unbind(FrontendApplication);
|
||||||
|
bind(FrontendApplication).to(CustomFrontendApplication).inSingletonScope();
|
||||||
});
|
});
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
import { injectable, inject } from "inversify";
|
||||||
|
import { FrontendApplication } from "@theia/core/lib/browser";
|
||||||
|
import { ArduinoFrontendContribution } from "../arduino-frontend-contribution";
|
||||||
|
import URI from "@theia/core/lib/common/uri";
|
||||||
|
|
||||||
|
@injectable()
|
||||||
|
export class CustomFrontendApplication extends FrontendApplication {
|
||||||
|
|
||||||
|
@inject(ArduinoFrontendContribution)
|
||||||
|
protected readonly frontendContribution: ArduinoFrontendContribution;
|
||||||
|
|
||||||
|
protected async initializeLayout(): Promise<void> {
|
||||||
|
const location = new URI(window.location.href);
|
||||||
|
this.frontendContribution.openSketchFiles(decodeURIComponent(location.query));
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user