Search in sources :

Example 16 with Disposable

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

the class ExternalResourceManagerExImpl method addTestResource.

@TestOnly
public static void addTestResource(final String url, final String location, Disposable parentDisposable) {
    final ExternalResourceManagerExImpl instance = (ExternalResourceManagerExImpl) getInstance();
    ApplicationManager.getApplication().runWriteAction(() -> instance.addResource(url, location));
    Disposer.register(parentDisposable, new Disposable() {

        @Override
        public void dispose() {
            ApplicationManager.getApplication().runWriteAction(() -> instance.removeResource(url));
        }
    });
}
Also used : Disposable(com.intellij.openapi.Disposable) TestOnly(org.jetbrains.annotations.TestOnly)

Example 17 with Disposable

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

the class ExternalResourceManagerExImpl method registerResourceTemporarily.

@TestOnly
public static void registerResourceTemporarily(final String url, final String location, Disposable disposable) {
    ApplicationManager.getApplication().runWriteAction(() -> getInstance().addResource(url, location));
    Disposer.register(disposable, new Disposable() {

        @Override
        public void dispose() {
            ApplicationManager.getApplication().runWriteAction(() -> getInstance().removeResource(url));
        }
    });
}
Also used : Disposable(com.intellij.openapi.Disposable) TestOnly(org.jetbrains.annotations.TestOnly)

Example 18 with Disposable

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

the class ValueHint method createInspectTree.

public static InspectDebuggerTree createInspectTree(final NodeDescriptorImpl descriptor, Project project) {
    final InspectDebuggerTree tree = new InspectDebuggerTree(project);
    final AnAction setValueAction = ActionManager.getInstance().getAction(DebuggerActions.SET_VALUE);
    setValueAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0)), tree);
    Disposer.register(tree, new Disposable() {

        @Override
        public void dispose() {
            setValueAction.unregisterCustomShortcutSet(tree);
        }
    });
    tree.setInspectDescriptor(descriptor);
    DebuggerContextImpl context = DebuggerManagerEx.getInstanceEx(project).getContext();
    tree.rebuild(context);
    return tree;
}
Also used : Disposable(com.intellij.openapi.Disposable) CustomShortcutSet(com.intellij.openapi.actionSystem.CustomShortcutSet) InspectDebuggerTree(com.intellij.debugger.ui.impl.InspectDebuggerTree) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 19 with Disposable

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

the class DebuggerAction method installEditAction.

public static Disposable installEditAction(final JTree tree, String actionName) {
    final DoubleClickListener listener = new DoubleClickListener() {

        @Override
        protected boolean onDoubleClick(MouseEvent e) {
            if (tree.getPathForLocation(e.getX(), e.getY()) == null)
                return false;
            DataContext dataContext = DataManager.getInstance().getDataContext(tree);
            GotoFrameSourceAction.doAction(dataContext);
            return true;
        }
    };
    listener.installOn(tree);
    Disposable disposable = () -> listener.uninstall(tree);
    DebuggerUIUtil.registerActionOnComponent(actionName, tree, disposable);
    return disposable;
}
Also used : Disposable(com.intellij.openapi.Disposable) DataContext(com.intellij.openapi.actionSystem.DataContext) MouseEvent(java.awt.event.MouseEvent) DoubleClickListener(com.intellij.ui.DoubleClickListener)

Example 20 with Disposable

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

the class CompilerCacheManager method flushCaches.

synchronized void flushCaches() {
    for (Disposable disposable : myCacheDisposables) {
        try {
            Disposer.dispose(disposable);
        } catch (Throwable e) {
            LOG.info(e);
        }
    }
    myCacheDisposables.clear();
    myGenericCachesMap.clear();
    myCompilerToCacheMap.clear();
}
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