Search in sources :

Example 61 with Disposable

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);
        }
    });
}
Also used : Disposable(com.intellij.openapi.Disposable) Override(java.lang.Override) Override(java.lang.Override)

Example 62 with Disposable

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);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Disposable(com.intellij.openapi.Disposable) TreeBasedStructureViewBuilder(com.intellij.ide.structureView.TreeBasedStructureViewBuilder) StructureViewBuilder(com.intellij.ide.structureView.StructureViewBuilder) EditorFactory(com.intellij.openapi.editor.EditorFactory) TreeBasedStructureViewBuilder(com.intellij.ide.structureView.TreeBasedStructureViewBuilder) StructureViewModel(com.intellij.ide.structureView.StructureViewModel) PsiClass(com.intellij.psi.PsiClass) PsiPackage(com.intellij.psi.PsiPackage) Document(com.intellij.openapi.editor.Document) CommanderPanel(com.intellij.ide.commander.CommanderPanel) FileStructureDialog(com.intellij.ide.util.FileStructureDialog) Editor(com.intellij.openapi.editor.Editor)

Example 63 with Disposable

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);
        }
    });
}
Also used : Disposable(com.intellij.openapi.Disposable)

Example 64 with Disposable

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);
        }
    });
}
Also used : Disposable(com.intellij.openapi.Disposable)

Example 65 with Disposable

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;
        }
    });
}
Also used : Disposable(com.intellij.openapi.Disposable) TestOnly(org.jetbrains.annotations.TestOnly)

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