Search in sources :

Example 71 with Disposable

use of com.intellij.openapi.Disposable in project intellij-community by JetBrains.

the class ExtensibleQueryFactory method registerExecutor.

public void registerExecutor(final QueryExecutor<Result, Parameters> queryExecutor, Disposable parentDisposable) {
    registerExecutor(queryExecutor);
    Disposer.register(parentDisposable, new Disposable() {

        @Override
        public void dispose() {
            unregisterExecutor(queryExecutor);
        }
    });
}
Also used : Disposable(com.intellij.openapi.Disposable)

Example 72 with Disposable

use of com.intellij.openapi.Disposable in project intellij-community by JetBrains.

the class ApplicationManager method setApplication.

public static void setApplication(@NotNull Application instance, @NotNull Getter<FileTypeRegistry> fileTypeRegistryGetter, @NotNull Disposable parent) {
    final Application old = ourApplication;
    final Getter<FileTypeRegistry> oldFileTypeRegistry = FileTypeRegistry.ourInstanceGetter;
    Disposer.register(parent, new Disposable() {

        @Override
        public void dispose() {
            if (old != null) {
                // to prevent NPEs in threads still running
                setApplication(old);
                //noinspection AssignmentToStaticFieldFromInstanceMethod
                FileTypeRegistry.ourInstanceGetter = oldFileTypeRegistry;
            }
        }
    });
    setApplication(instance);
    FileTypeRegistry.ourInstanceGetter = fileTypeRegistryGetter;
}
Also used : Disposable(com.intellij.openapi.Disposable) FileTypeRegistry(com.intellij.openapi.fileTypes.FileTypeRegistry)

Example 73 with Disposable

use of com.intellij.openapi.Disposable in project intellij-community by JetBrains.

the class CustomPopupFullValueEvaluator method evaluate.

@Override
public void evaluate(@NotNull final XFullValueEvaluationCallback callback) {
    final T data = getData();
    DebuggerUIUtil.invokeLater(() -> {
        if (callback.isObsolete())
            return;
        final JComponent comp = createComponent(data);
        Project project = getEvaluationContext().getProject();
        JBPopup popup = DebuggerUIUtil.createValuePopup(project, comp, null);
        JFrame frame = WindowManager.getInstance().getFrame(project);
        Dimension frameSize = frame.getSize();
        Dimension size = new Dimension(frameSize.width / 2, frameSize.height / 2);
        popup.setSize(size);
        if (comp instanceof Disposable) {
            Disposer.register(popup, (Disposable) comp);
        }
        callback.evaluated("");
        popup.show(new RelativePoint(frame, new Point(size.width / 2, size.height / 2)));
    });
}
Also used : Disposable(com.intellij.openapi.Disposable) Project(com.intellij.openapi.project.Project) RelativePoint(com.intellij.ui.awt.RelativePoint) RelativePoint(com.intellij.ui.awt.RelativePoint) JBPopup(com.intellij.openapi.ui.popup.JBPopup)

Example 74 with Disposable

use of com.intellij.openapi.Disposable in project intellij-community by JetBrains.

the class JsonSchemaHighlightingTest method testImpl.

private void testImpl(@NotNull final String schema, @NotNull final String text) throws Exception {
    final PsiFile file = createFile(myModule, "config.json", text);
    final Annotator annotator = new JsonSchemaAnnotator();
    registerProvider(getProject(), schema);
    LanguageAnnotators.INSTANCE.addExplicitExtension(JsonLanguage.INSTANCE, annotator);
    Disposer.register(getTestRootDisposable(), new Disposable() {

        @Override
        public void dispose() {
            LanguageAnnotators.INSTANCE.removeExplicitExtension(JsonLanguage.INSTANCE, annotator);
            JsonSchemaTestServiceImpl.setProvider(null);
        }
    });
    configureByFile(file.getVirtualFile());
    doTest(file.getVirtualFile(), true, false);
}
Also used : Disposable(com.intellij.openapi.Disposable) JsonSchemaAnnotator(com.jetbrains.jsonSchema.ide.JsonSchemaAnnotator) Annotator(com.intellij.lang.annotation.Annotator) JsonSchemaAnnotator(com.jetbrains.jsonSchema.ide.JsonSchemaAnnotator) PsiFile(com.intellij.psi.PsiFile)

Example 75 with Disposable

use of com.intellij.openapi.Disposable in project intellij-community by JetBrains.

the class FileSystemTreeImpl method addListener.

public void addListener(final Listener listener, final Disposable parent) {
    myListeners.add(listener);
    Disposer.register(parent, new Disposable() {

        public void dispose() {
            myListeners.remove(listener);
        }
    });
}
Also used : Disposable(com.intellij.openapi.Disposable)

Aggregations

Disposable (com.intellij.openapi.Disposable)282 NotNull (org.jetbrains.annotations.NotNull)52 Test (org.junit.Test)25 Project (com.intellij.openapi.project.Project)18 TestOnly (org.jetbrains.annotations.TestOnly)17 ArrayList (java.util.ArrayList)13 VirtualFile (com.intellij.openapi.vfs.VirtualFile)11 RelativePoint (com.intellij.ui.awt.RelativePoint)11 Nullable (org.jetbrains.annotations.Nullable)10 Document (com.intellij.openapi.editor.Document)9 File (java.io.File)9 ProcessHandler (com.intellij.execution.process.ProcessHandler)6 Editor (com.intellij.openapi.editor.Editor)6 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)6 VirtualFilePointer (com.intellij.openapi.vfs.pointers.VirtualFilePointer)6 Content (com.intellij.ui.content.Content)6 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)5 Alarm (com.intellij.util.Alarm)5 ActionEvent (java.awt.event.ActionEvent)5 ListSelectionEvent (javax.swing.event.ListSelectionEvent)5