com.intellij.util.DisposeAwareRunnable Java Examples

The following examples show how to use com.intellij.util.DisposeAwareRunnable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProjectUtils.java    From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 6 votes vote down vote up
/**
 * Runs a thread when initialized
 *
 * @param project
 * @param r
 */
public static void runWhenInitialized(final Project project, final Runnable r) {
    if (project.isDisposed()) return;

    if (isNoBackgroundMode()) {
        r.run();
        return;
    }

    if (!project.isInitialized()) {
        StartupManager.getInstance(project).registerPostStartupActivity(DisposeAwareRunnable.create(r, project));
        return;
    }

    runDumbAware(project, r);
}
 
Example #2
Source File: CrudUtils.java    From crud-intellij-plugin with Apache License 2.0 5 votes vote down vote up
public static void invokeAndWait(Project p, ModalityState state, Runnable r) {
    if (isNoBackgroundMode()) {
        r.run();
    } else {
        ApplicationManager.getApplication().invokeAndWait(DisposeAwareRunnable.create(r, p), state);
    }
}
 
Example #3
Source File: CrudUtils.java    From crud-intellij-plugin with Apache License 2.0 5 votes vote down vote up
public static void invokeLater(Project p, ModalityState state, Runnable r) {
    if (isNoBackgroundMode()) {
        r.run();
    } else {
        ApplicationManager.getApplication().invokeLater(DisposeAwareRunnable.create(r, p), state);
    }

}
 
Example #4
Source File: CrudUtils.java    From crud-intellij-plugin with Apache License 2.0 5 votes vote down vote up
public static void runWhenInitialized(final Project project, final Runnable r) {
    if (project.isDisposed()) {
        return;
    }
    if (isNoBackgroundMode()) {
        r.run();
        return;
    }
    if (!project.isInitialized()) {
        StartupManager.getInstance(project).registerPostStartupActivity(DisposeAwareRunnable.create(r, project));
        return;
    }
    runDumbAware(project, r);
}
 
Example #5
Source File: CrudUtils.java    From crud-intellij-plugin with Apache License 2.0 5 votes vote down vote up
public static void runDumbAware(final Project project, final Runnable r) {
    if (DumbService.isDumbAware(r)) {
        r.run();
    } else {
        DumbService.getInstance(project).runWhenSmart(DisposeAwareRunnable.create(r, project));
    }
}
 
Example #6
Source File: ProjectUtils.java    From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 5 votes vote down vote up
/**
 * Runs the DumbService
 * @param project
 * @param r
 */
public static void runDumbAware(final Project project, final Runnable r) {
    if (DumbService.isDumbAware(r)) {
        r.run();
    } else {
        DumbService.getInstance(project).runWhenSmart(DisposeAwareRunnable.create(r, project));
    }
}
 
Example #7
Source File: AsposeMavenUtil.java    From Aspose.OCR-for-Java with MIT License 5 votes vote down vote up
public static void invokeLater(final Project p, final ModalityState state, final Runnable r) {
    if (isNoBackgroundMode()) {
        r.run();
    } else {
        ApplicationManager.getApplication().invokeLater(DisposeAwareRunnable.create(r, p), state);
    }
}