use of com.intellij.openapi.Disposable in project intellij-community by JetBrains.
the class YYYYYYY method addPropertyChangeListener.
@Override
public void addPropertyChangeListener(@NotNull final PropertyChangeListener listener, @NotNull Disposable parentDisposable) {
addPropertyChangeListener(listener);
Disposer.register(parentDisposable, new Disposable() {
@Override
public void dispose() {
removePropertyChangeListener(listener);
}
});
}
use of com.intellij.openapi.Disposable in project intellij-community by JetBrains.
the class FileStructureDialogTest method testFileStructureForClass.
public void testFileStructureForClass() throws Exception {
final PsiPackage aPackage = JavaDirectoryService.getInstance().getPackage(getPackageDirectory());
assertNotNull(aPackage);
final PsiClass psiClass = aPackage.getClasses()[0];
final VirtualFile virtualFile = psiClass.getContainingFile().getVirtualFile();
assertNotNull(virtualFile);
final StructureViewBuilder structureViewBuilder = StructureViewBuilder.PROVIDER.getStructureViewBuilder(virtualFile.getFileType(), virtualFile, myProject);
assertNotNull(structureViewBuilder);
final StructureViewModel structureViewModel = ((TreeBasedStructureViewBuilder) structureViewBuilder).createStructureViewModel(null);
final EditorFactory factory = EditorFactory.getInstance();
assertNotNull(factory);
final Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
assertNotNull(document);
final Editor editor = factory.createEditor(document, myProject);
try {
final FileStructureDialog dialog = new FileStructureDialog(structureViewModel, editor, myProject, psiClass, new Disposable() {
@Override
public void dispose() {
structureViewModel.dispose();
}
}, true);
try {
final CommanderPanel panel = dialog.getPanel();
assertListsEqual((ListModel) panel.getModel(), "Inner1\n" + "Inner2\n" + "__method(): void\n" + "_myField1: int\n" + "_myField2: String\n");
} finally {
dialog.close(0);
}
} finally {
factory.releaseEditor(editor);
}
}
use of com.intellij.openapi.Disposable in project intellij-community by JetBrains.
the class MetaRegistry method addMetadataBinding.
/**
* @see com.intellij.psi.meta.MetaDataContributor
* @deprecated
*/
public static <T extends PsiMetaData> void addMetadataBinding(ElementFilter filter, Class<T> aMetadataClass, Disposable parentDisposable) {
final MyBinding binding = new MyBinding(filter, aMetadataClass);
addBinding(binding);
Disposer.register(parentDisposable, new Disposable() {
@Override
public void dispose() {
ourBindings.remove(binding);
}
});
}
use of com.intellij.openapi.Disposable in project intellij-community by JetBrains.
the class PomModelImpl method addModelListener.
@Override
public void addModelListener(@NotNull final PomModelListener listener, @NotNull Disposable parentDisposable) {
addModelListener(listener);
Disposer.register(parentDisposable, new Disposable() {
@Override
public void dispose() {
removeModelListener(listener);
}
});
}
use of com.intellij.openapi.Disposable in project intellij-community by JetBrains.
the class PsiDocumentManagerBase method disableBackgroundCommit.
@TestOnly
public void disableBackgroundCommit(@NotNull Disposable parentDisposable) {
assert myPerformBackgroundCommit;
myPerformBackgroundCommit = false;
Disposer.register(parentDisposable, new Disposable() {
@Override
public void dispose() {
myPerformBackgroundCommit = true;
}
});
}
Aggregations