How to use the @theia/core/lib/common.Disposable.create 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 / debug / src / browser / view / debug-configuration-widget.tsx View on Github external
focus(): void {
        if (!this.doFocus()) {
            this.onRender.push(Disposable.create(() => this.doFocus()));
            this.update();
        }
    }
    protected doFocus(): boolean {
github eclipse-theia / theia / packages / filesystem / src / browser / file-tree / file-tree-widget.tsx View on Github external
protected handleDragOverEvent(node: TreeNode | undefined, event: React.DragEvent): void {
        event.preventDefault();
        event.stopPropagation();
        if (!this.toCancelNodeExpansion.disposed) {
            return;
        }
        const timer = setTimeout(() => {
            const containing = DirNode.getContainingDir(node);
            if (!!containing && !containing.expanded) {
                this.model.expandNode(containing);
            }
        }, 500);
        this.toCancelNodeExpansion.push(Disposable.create(() => clearTimeout(timer)));
    }
github eclipse-theia / theia / packages / git / src / common / git-watcher.ts View on Github external
async watchGitChanges(repository: Repository): Promise {
        const watcher = await this.server.watchGitChanges(repository);
        const toDispose = new DisposableCollection();
        toDispose.push(Disposable.create(() => this.server.unwatchGitChanges(watcher)));
        return toDispose;
    }
github eclipse-theia / theia / packages / debug / src / browser / debug-session.tsx View on Github external
constructor(
        readonly id: string,
        readonly options: DebugSessionOptions,
        protected readonly connection: DebugSessionConnection,
        protected readonly terminalServer: TerminalService,
        protected readonly editorManager: EditorManager,
        protected readonly breakpoints: BreakpointManager,
        protected readonly labelProvider: LabelProvider,
        protected readonly messages: MessageClient,
        protected readonly fileSystem: FileSystem) {
        this.connection.onRequest('runInTerminal', (request: DebugProtocol.RunInTerminalRequest) => this.runInTerminal(request));
        this.toDispose.pushAll([
            this.onDidChangeEmitter,
            this.onDidChangeBreakpointsEmitter,
            Disposable.create(() => {
                this.clearBreakpoints();
                this.doUpdateThreads([]);
            }),
            this.connection,
            this.on('initialized', () => this.configure()),
            this.on('breakpoint', ({ body }) => this.updateBreakpoint(body)),
            this.on('continued', ({ body: { allThreadsContinued, threadId } }) => {
                if (allThreadsContinued !== false) {
                    this.clearThreads();
                } else {
                    this.clearThread(threadId);
                }
            }),
            this.on('stopped', async ({ body }) => {
                await this.updateThreads(body);
                await this.updateFrames();
github eclipse-theia / theia / packages / preview / src / browser / preview-contribution.ts View on Github external
if (!previewWidget || !editorWidget || !uri) {
            return;
        }
        if (this.synchronizedUris.has(uri)) {
            return;
        }
        const syncDisposables = new DisposableCollection();
        previewWidget.disposed.connect(() => syncDisposables.dispose());
        editorWidget.disposed.connect(() => syncDisposables.dispose());

        const editor = editorWidget.editor;
        syncDisposables.push(editor.onCursorPositionChanged(debounce(position => this.revealSourceLineInPreview(previewWidget!, position)), 100));
        syncDisposables.push(this.synchronizeScrollToEditor(previewWidget, editor));

        this.synchronizedUris.add(uri);
        syncDisposables.push(Disposable.create(() => this.synchronizedUris.delete(uri)));
    }
github eclipse-theia / theia / packages / monaco / src / browser / monaco-editor.ts View on Github external
protected increaseZIndex(element: HTMLElement, z: string, toDisposeOnBlur: DisposableCollection) {
        const parent = element.parentElement;
        if (parent && !element.classList.contains('p-DockPanel')) {
            const oldIndex = element.style.zIndex;
            toDisposeOnBlur.push(Disposable.create(() =>
                element.style.zIndex = oldIndex
            ));
            element.style.zIndex = z;
            this.increaseZIndex(parent, z, toDisposeOnBlur);
        }
    }
github eclipse-theia / theia / packages / scm / src / browser / scm-contribution.ts View on Github external
protected setStatusBarEntry(id: string, entry: StatusBarEntry): void {
        this.statusBar.setElement(id, entry);
        this.statusBarDisposable.push(Disposable.create(() => this.statusBar.removeElement(id)));
    }
github eclipsesource / graphical-lsp / client / packages / theia-integration / src / browser / diagram / glsp-diagram-widget.ts View on Github external
protected scheduleAutoSave() {
        if (this.shouldAutoSave) {
            this.autoSaveJobs.dispose();
            const autoSaveJob = window.setTimeout(() => this.doAutoSave(), this.autoSaveDelay);
            const disposableAutoSaveJob = Disposable.create(() => window.clearTimeout(autoSaveJob));
            this.autoSaveJobs.push(disposableAutoSaveJob);
        }
    }