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);
}
});
}
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;
}
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)));
});
}
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);
}
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);
}
});
}
Aggregations