mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-11-14 12:49:28 +00:00
Force default workspace on startup.
Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
committed by
Christian Weichel
parent
bb9435b125
commit
aa770607de
@@ -1,3 +1,4 @@
|
||||
import '../../src/browser/style/index.css';
|
||||
import { ContainerModule, interfaces } from 'inversify';
|
||||
import { WidgetFactory } from '@theia/core/lib/browser/widget-manager';
|
||||
import { CommandContribution } from '@theia/core/lib/common/command';
|
||||
@@ -18,11 +19,11 @@ import { BoardsListWidgetFrontendContribution } from './boards/boards-widget-fro
|
||||
import { WorkspaceServiceExt, WorkspaceServiceExtPath } from './workspace-service-ext';
|
||||
import { WorkspaceServiceExtImpl } from './workspace-service-ext-impl';
|
||||
import { ToolOutputServiceClient } from '../common/protocol/tool-output-service';
|
||||
|
||||
import '../../src/browser/style/index.css';
|
||||
import { ToolOutputService } from '../common/protocol/tool-output-service';
|
||||
import { ToolOutputServiceClientImpl } from './tool-output/client-service-impl';
|
||||
import { BoardsNotificationService } from './boards-notification-service';
|
||||
import { WorkspaceService } from '@theia/workspace/lib/browser/workspace-service';
|
||||
import { AWorkspaceService } from './arduino-workspace-service';
|
||||
|
||||
export default new ContainerModule((bind: interfaces.Bind, unbind: interfaces.Unbind, isBound: interfaces.IsBound, rebind: interfaces.Rebind) => {
|
||||
// Commands and toolbar items
|
||||
@@ -83,4 +84,6 @@ export default new ContainerModule((bind: interfaces.Bind, unbind: interfaces.Un
|
||||
container.get(BoardsService);
|
||||
return workspaceServiceExt;
|
||||
});
|
||||
|
||||
rebind(WorkspaceService).to(AWorkspaceService).inSingletonScope();
|
||||
});
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import { WorkspaceService } from "@theia/workspace/lib/browser/workspace-service";
|
||||
import { injectable, inject } from "inversify";
|
||||
import { WorkspaceServer } from "@theia/workspace/lib/common";
|
||||
import { FileSystem } from "@theia/filesystem/lib/common";
|
||||
import URI from "@theia/core/lib/common/uri";
|
||||
|
||||
/**
|
||||
* This is workaround to have custom frontend binding for the default workspace, although we
|
||||
* already have a custom binding for the backend.
|
||||
*/
|
||||
@injectable()
|
||||
export class AWorkspaceService extends WorkspaceService {
|
||||
|
||||
@inject(WorkspaceServer)
|
||||
protected readonly workspaceServer: WorkspaceServer;
|
||||
|
||||
@inject(FileSystem)
|
||||
protected readonly fileSystem: FileSystem;
|
||||
|
||||
protected async getDefaultWorkspacePath(): Promise<string | undefined> {
|
||||
const result = await super.getDefaultWorkspacePath();
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
const userHome = await this.fileSystem.getCurrentUserHome();
|
||||
if (userHome) {
|
||||
// The backend has created this location if it was missing.
|
||||
return new URI(userHome.uri).resolve('Arduino-PoC').resolve('workspace').toString();
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user