How to use @theia/workspace - 10 common examples

To help you get started, we’ve selected a few @theia/workspace examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github eclipse-theia / theia / packages / git / src / browser / git-commands.ts View on Github external
protected async doDiscard(repository: Repository, change: GitFileChange) {
        // Allow deletion, only iff the same file is not yet in the Git index.
        if (await this.git.lsFiles(repository, change.uri, { errorUnmatch: true })) {
            if (await this.confirm(change.uri)) {
                try {
                    await this.git.unstage(repository, change.uri, { treeish: 'HEAD', reset: 'working-tree' });
                } catch (error) {
                    this.gitErrorHandler.handleError(error);
                }
            }
        } else {
            await this.commandService.executeCommand(WorkspaceCommands.FILE_DELETE.id, new URI(change.uri));
        }
    }
github eclipse-theia / theia / packages / git / src / browser / git-widget.tsx View on Github external
protected async doDiscard(repository: Repository, change: GitFileChange) {
        // Allow deletion, only iff the same file is not yet in the Git index.
        if (await this.git.lsFiles(repository, change.uri, { errorUnmatch: true })) {
            if (await this.confirm(change.uri)) {
                try {
                    await this.git.unstage(repository, change.uri, { treeish: 'HEAD', reset: 'working-tree' });
                } catch (error) {
                    this.gitErrorHandler.handleError(error);
                }
            }
        } else {
            await this.commandService.executeCommand(WorkspaceCommands.FILE_DELETE.id, new URI(change.uri));
        }
        if (this.listContainer) {
            this.listContainer.focus();
        }
    }
github eclipse-theia / theia / packages / git / src / browser / git-scm-provider.ts View on Github external
const { repository } = this;
        const status = this.getStatus();
        if (!(status && status.changes.some(change => change.uri === uri))) {
            return;
        }
        // Allow deletion, only iff the same file is not yet in the Git index.
        if (await this.git.lsFiles(repository, uri, { errorUnmatch: true })) {
            if (await this.confirm(uri)) {
                try {
                    await this.git.unstage(repository, uri, { treeish: 'HEAD', reset: 'working-tree' });
                } catch (error) {
                    this.gitErrorHandler.handleError(error);
                }
            }
        } else {
            await this.commands.executeCommand(WorkspaceCommands.FILE_DELETE.id, new URI(uri));
        }
    }
github eclipse-theia / theia / packages / plugin-ext / src / main / node / paths / plugin-paths-service.ts View on Github external
protected async buildWorkspaceId(workspace: FileStat, roots: FileStat[]): Promise {
        const homeDir = await this.getUserHomeDir();
        const untitledWorkspace = getTemporaryWorkspaceFileUri(new URI(homeDir));

        if (untitledWorkspace.toString() === workspace.uri) {
            // if workspace is temporary
            // then let create a storage path for each set of workspace roots
            const rootsStr = roots.map(root => root.uri).sort().join(',');
            return crypto.createHash('md5').update(rootsStr).digest('hex');
        } else {
            const uri = new URI(workspace.uri);
            let displayName = uri.displayName;

            if ((!workspace || !workspace.isDirectory) && (displayName.endsWith(`.${THEIA_EXT}`) || displayName.endsWith(`.${VSCODE_EXT}`))) {
                displayName = displayName.slice(0, displayName.lastIndexOf('.'));
            }

            return crypto.createHash('md5').update(uri.toString()).digest('hex');
        }
github eclipse-theia / theia / packages / navigator / src / browser / navigator-menu.ts View on Github external
// registry.registerMenuAction([CONTEXT_MENU_PATH, CUT_MENU_GROUP], {
        //     commandId: Commands.FILE_CUT
        // });
        registry.registerMenuAction(NavigatorContextMenu.CLIPBOARD, {
            commandId: CommonCommands.COPY.id
        });
        registry.registerMenuAction(NavigatorContextMenu.CLIPBOARD, {
            commandId: CommonCommands.PASTE.id
        });

        registry.registerMenuAction(NavigatorContextMenu.MOVE, {
            commandId: WorkspaceCommands.FILE_RENAME.id
        });
        registry.registerMenuAction(NavigatorContextMenu.MOVE, {
            commandId: WorkspaceCommands.FILE_DELETE.id
        });

        registry.registerMenuAction(NavigatorContextMenu.NEW, {
            commandId: WorkspaceCommands.NEW_FILE.id
        });
        registry.registerMenuAction(NavigatorContextMenu.NEW, {
            commandId: WorkspaceCommands.NEW_FOLDER.id
        });
        registry.registerMenuAction(NavigatorContextMenu.DIFF, {
            commandId: WorkspaceCommands.FILE_COMPARE.id
        });
    }
}
github eclipse-theia / theia / packages / navigator / src / browser / navigator-menu.ts View on Github external
registerMenus(registry: MenuModelRegistry) {
        registry.registerMenuAction(NavigatorContextMenu.OPEN, {
            commandId: WorkspaceCommands.FILE_OPEN.id
        });
        registry.registerSubmenu(NavigatorContextMenu.OPEN_WITH, 'Open With');
        this.openerService.getOpeners().then(openers => {
            for (const opener of openers) {
                const openWithCommand = WorkspaceCommands.FILE_OPEN_WITH(opener);
                registry.registerMenuAction(NavigatorContextMenu.OPEN_WITH, {
                    commandId: openWithCommand.id
                });
            }
        });

        // registry.registerMenuAction([CONTEXT_MENU_PATH, CUT_MENU_GROUP], {
        //     commandId: Commands.FILE_CUT
        // });
        registry.registerMenuAction(NavigatorContextMenu.CLIPBOARD, {
            commandId: CommonCommands.COPY.id
github eclipse-theia / theia / packages / navigator / src / browser / navigator-contribution.ts View on Github external
registerKeybindings(registry: KeybindingRegistry): void {
        super.registerKeybindings(registry);
        registry.registerKeybinding({
            command: FileNavigatorCommands.REVEAL_IN_NAVIGATOR.id,
            keybinding: 'alt+r'
        });

        registry.registerKeybinding({
            command: WorkspaceCommands.FILE_DELETE.id,
            keybinding: 'del',
            context: NavigatorKeybindingContexts.navigatorActive
        });
        if (isOSX) {
            registry.registerKeybinding({
                command: WorkspaceCommands.FILE_DELETE.id,
                keybinding: 'cmd+backspace',
                context: NavigatorKeybindingContexts.navigatorActive
            });
        }

        registry.registerKeybinding({
            command: WorkspaceCommands.FILE_RENAME.id,
            keybinding: 'f2',
            context: NavigatorKeybindingContexts.navigatorActive
        });

        registry.registerKeybinding({
            command: FileNavigatorCommands.TOGGLE_HIDDEN_FILES.id,
            keybinding: 'ctrlcmd+i',
            context: NavigatorKeybindingContexts.navigatorActive
        });
github eclipse-theia / theia / packages / navigator / src / browser / navigator-contribution.ts View on Github external
registerKeybindings(registry: KeybindingRegistry): void {
        super.registerKeybindings(registry);
        registry.registerKeybinding({
            command: FileNavigatorCommands.REVEAL_IN_NAVIGATOR.id,
            keybinding: 'alt+r'
        });

        registry.registerKeybinding({
            command: WorkspaceCommands.FILE_DELETE.id,
            keybinding: 'del',
            context: NavigatorKeybindingContexts.navigatorActive
        });
        if (isOSX) {
            registry.registerKeybinding({
                command: WorkspaceCommands.FILE_DELETE.id,
                keybinding: 'cmd+backspace',
                context: NavigatorKeybindingContexts.navigatorActive
            });
        }

        registry.registerKeybinding({
            command: WorkspaceCommands.FILE_RENAME.id,
            keybinding: 'f2',
            context: NavigatorKeybindingContexts.navigatorActive
        });
github eclipse-theia / theia / packages / navigator / src / browser / navigator-widget.tsx View on Github external
protected doOpenFolder(): void {
        this.commandService.executeCommand(WorkspaceCommands.OPEN_FOLDER.id);
    }

@theia/workspace

Theia - Workspace Extension

EPL-2.0
Latest version published 4 days ago

Package Health Score

87 / 100
Full package analysis