How to use the @theia/core/lib/common/disposable.DisposableCollection function in @theia/core

To help you get started, we’ve selected a few @theia/core 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 / monaco / src / browser / monaco-theming-service.ts View on Github external
register(theme: MonacoTheme, pending: { [uri: string]: Promise } = {}): Disposable {
        const toDispose = new DisposableCollection(Disposable.create(() => { /* mark as not disposed */ }));
        this.doRegister(theme, pending, toDispose);
        return toDispose;
    }
github eclipse-theia / theia / packages / plugin-ext / src / main / browser / view / plugin-view-registry.ts View on Github external
for (const viewId of this.containerViews.get(viewContainerId) || []) {
            const identifier = this.toPluginViewWidgetIdentifier(viewId);
            const widget = await this.widgetManager.getOrCreateWidget(PLUGIN_VIEW_FACTORY_ID, identifier);
            if (containerWidget.getTrackableWidgets().indexOf(widget) === -1) {
                containerWidget.addWidget(widget, {
                    initiallyCollapsed: !!containerWidget.getParts().length
                });
            }
            const part = containerWidget.getPartFor(widget);
            if (part) {
                const tryFireOnDidExpandView = () => {
                    if (!part.collapsed && part.isVisible) {
                        toFire.dispose();
                    }
                };
                const toFire = new DisposableCollection(
                    Disposable.create(() => this.onDidExpandViewEmitter.fire(viewId)),
                    part.onCollapsed(tryFireOnDidExpandView),
                    part.onVisibilityChanged(tryFireOnDidExpandView)
                );
                tryFireOnDidExpandView();
            }
        }
    }
github eclipse-theia / theia / packages / plugin-ext / src / main / browser / connection-main.ts View on Github external
protected async doCreateConnection(id: string): Promise {
        const reader = new PluginMessageReader();
        const writer = new PluginMessageWriter(id, this.proxy);
        const connection = new PluginConnection(
            reader,
            writer,
            () => {
                this.connections.delete(id);
                if (!toClose.disposed) {
                    this.proxy.$deleteConnection(id);
                }
            });
        const toClose = new DisposableCollection(Disposable.create(() => reader.fireClose()));
        this.toDispose.push(toClose);
        return connection;
    }
}
github eclipse-theia / theia / packages / plugin-ext / src / main / browser / quick-open-main.ts View on Github external
async $showInputBox(inputBox: TransferInputBox, validateInput: boolean): Promise {
        if (validateInput) {
            inputBox.validateInput = val => this.proxy.$validateInput(val);
        }

        const toDispose = new DisposableCollection();
        const quickInput = this.quickInput.open({
            busy: inputBox.busy,
            enabled: inputBox.enabled,
            ignoreFocusOut: inputBox.ignoreFocusOut,
            password: inputBox.password,
            step: inputBox.step,
            title: inputBox.title,
            totalSteps: inputBox.totalSteps,
            buttons: inputBox.buttons.map((btn, i) => this.convertQuickInputButton(btn, i, toDispose)),
            validationMessage: inputBox.validationMessage,
            placeHolder: inputBox.placeholder,
            value: inputBox.value,
            prompt: inputBox.prompt,
            validateInput: inputBox.validateInput
        });
github eclipse-theia / theia / packages / debug / src / browser / editor / debug-hover-widget.ts View on Github external
return;
        }
        if (this.options && this.options.selection.equalsRange(options.selection)) {
            return;
        }
        if (!this.isAttached) {
            Widget.attach(this, this.contentNode);
        }
        super.show();
        this.options = options;
        const expression = this.expressionProvider.get(this.editor.getControl().getModel()!, options.selection);
        if (!expression) {
            this.hide();
            return;
        }
        const toFocus = new DisposableCollection();
        if (this.options.focus === true) {
            toFocus.push(this.model.onNodeRefreshed(() => {
                toFocus.dispose();
                this.activate();
            }));
        }
        if (!await this.hoverSource.evaluate(expression)) {
            toFocus.dispose();
            this.hide();
            return;
        }
        this.editor.getControl().layoutContentWidget(this);
    }
    protected isEditorFrame(): boolean {
github eclipse-theia / theia / packages / plugin-ext / src / main / browser / text-editors-main.ts View on Github external
private onTextEditorAdd(editor: TextEditorMain): void {
        const id = editor.getId();
        const toDispose = new DisposableCollection(
            editor.onPropertiesChangedEvent(e => {
                this.proxy.$acceptEditorPropertiesChanged(id, e);
            }),
            Disposable.create(() => this.editorsToDispose.delete(id))
        );
        this.editorsToDispose.set(id, toDispose);
        this.toDispose.push(toDispose);
    }
github eclipse-theia / theia / packages / plugin-ext / src / main / browser / quick-open-main.ts View on Github external
async $showCustomQuickPick(options: TransferQuickPick): Promise {
        const toDispose = new DisposableCollection();
        const items = this.convertPickOpenItemToQuickOpenItem(options.items);
        const quickPick = this.quickPick.show(items, {
            buttons: options.buttons.map((btn, i) => this.convertQuickInputButton(btn, i, toDispose)),
            placeholder: options.placeholder,
            fuzzyMatchDescription: options.matchOnDescription,
            fuzzyMatchLabel: true,
            step: options.step,
            title: options.title,
            totalSteps: options.totalSteps,
            ignoreFocusOut: options.ignoreFocusOut,
            value: options.value,
            runIfSingle: false,
        });

        toDispose.push(this.quickPick.onDidAccept(() => this.proxy.$acceptOnDidAccept(options.quickInputIndex)));
        toDispose.push(this.quickPick.onDidChangeActiveItems(changedItems => this.proxy.$acceptDidChangeActive(options.quickInputIndex, changedItems)));
github eclipse-theia / theia / packages / plugin-ext / src / main / browser / plugin-contribution-handler.ts View on Github external
protected registerCommands(contribution: PluginContribution): Disposable {
        if (!contribution.commands) {
            return Disposable.NULL;
        }
        const toDispose = new DisposableCollection();
        for (const { iconUrl, command, category, title } of contribution.commands) {
            const reference = iconUrl && this.style.toIconClass(iconUrl);
            let iconClass;
            if (reference) {
                toDispose.push(reference);
                iconClass = reference.object.iconClass;
            }
            toDispose.push(this.registerCommand({ id: command, category, label: title, iconClass }));
        }
        return toDispose;
    }
github eclipse-theia / theia / packages / monaco / src / browser / monaco-semantic-highlighting-service.ts View on Github external
async decorate(languageId: string, uri: URI, ranges: SemanticHighlightingRange[]): Promise {
        const editor = await this.editor(uri);
        if (!editor) {
            return;
        }

        const key = uri.toString();
        if (!this.toDisposeOnEditorClose.has(key)) {
            this.toDisposeOnEditorClose.set(key, new DisposableCollection(
                editor.onDispose(() => this.deleteDecorations(key, editor))
            ));
        }

        const newDecorations = ranges.map(range => this.toDecoration(languageId, range));
        const oldDecorations = this.oldDecorations(key, editor, ranges);
        const newState = editor.deltaDecorations({
            newDecorations,
            oldDecorations
        });

        const decorationIds = this.decorationIds(key);
        newState.forEach(id => decorationIds.add(id));
        this.decorations.set(key, decorationIds);
    }