How to use the @theia/filesystem/lib/browser.DirNode.createRoot function in @theia/filesystem

To help you get started, we’ve selected a few @theia/filesystem 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 / plugin-ext / src / main / browser / dialogs-main.ts View on Github external
async $showSaveDialog(options: SaveDialogOptionsMain): Promise {
        const rootStat = await this.getRootUri(options.defaultUri ? options.defaultUri : undefined);

        // Fail if root not fount
        if (!rootStat) {
            throw new Error('Unable to find the rootStat');
        }

        // Take the info for root node
        const rootNode = DirNode.createRoot(rootStat);

        try {
            // Create save file dialog props
            const dialogProps = {
                title: 'Save',
                saveLabel: options.saveLabel,
                filters: options.filters
            } as SaveFileDialogProps;

            // Show save file dialog
            const dialog = this.saveFileDialogFactory(dialogProps);
            dialog.model.navigateTo(rootNode);
            const result = await dialog.open();

            // Return the result
            if (result) {
github eclipse-theia / theia / packages / plugin-ext / src / main / browser / dialogs-main.ts View on Github external
async $showOpenDialog(options: OpenDialogOptionsMain): Promise {
        const rootStat = await this.getRootUri(options.defaultUri ? options.defaultUri : undefined);

        // Fail if root not fount
        if (!rootStat) {
            throw new Error('Unable to find the rootStat');
        }

        // Take the info for root node
        const rootNode = DirNode.createRoot(rootStat);

        try {
            // Determine proper title for the dialog
            const canSelectFiles = typeof options.canSelectFiles === 'boolean' ? options.canSelectFiles : true;
            const canSelectFolders = typeof options.canSelectFolders === 'boolean' ? options.canSelectFolders : true;

            let title;
            if (canSelectFiles && canSelectFolders) {
                title = 'Open';
            } else {
                if (canSelectFiles) {
                    title = 'Open File';
                } else {
                    title = 'Open Folder';
                }
github eclipse-theia / theia / packages / plugin-dev / src / browser / hosted-plugin-manager-client.ts View on Github external
async selectPluginPath(): Promise {
        const workspaceFolder = (await this.workspaceService.roots)[0] || await this.fileSystem.getCurrentUserHome();
        if (!workspaceFolder) {
            throw new Error('Unable to find the root');
        }

        const rootNode = DirNode.createRoot(workspaceFolder);

        const dialog = this.openFileDialogFactory({
            title: HostedPluginCommands.SELECT_PATH.label!,
            openLabel: 'Select',
            canSelectFiles: false,
            canSelectFolders: true,
            canSelectMany: false
        });
        dialog.model.navigateTo(rootNode);
        const result = await dialog.open();

        if (UriSelection.is(result)) {
            if (await this.hostedPluginServer.isPluginValid(result.uri.toString())) {
                this.pluginLocation = result.uri;
                this.messageService.info('Plugin folder is set to: ' + this.labelProvider.getLongName(result.uri));
            } else {