Search in sources :

Example 56 with Application

use of com.intellij.openapi.application.Application in project android by JetBrains.

the class IdeTestApplication method disposeInstance.

public static synchronized void disposeInstance() {
    if (!isLoaded()) {
        return;
    }
    Application application = ApplicationManager.getApplication();
    if (application != null) {
        if (application instanceof ApplicationEx) {
            ((ApplicationEx) application).exit(true, true);
        } else {
            application.exit();
        }
    }
    ourInstance = null;
}
Also used : ApplicationEx(com.intellij.openapi.application.ex.ApplicationEx) Application(com.intellij.openapi.application.Application)

Example 57 with Application

use of com.intellij.openapi.application.Application in project android by JetBrains.

the class AndroidModuleDependenciesSetupTest method createLibrary.

@NotNull
private Library createLibrary(@NotNull File binaryPath, @NotNull File sourcePath) {
    LibraryTable libraryTable = ProjectLibraryTable.getInstance(getProject());
    LibraryTable.ModifiableModel libraryTableModel = libraryTable.getModifiableModel();
    Library library = libraryTableModel.createLibrary(binaryPath.getName());
    Application application = ApplicationManager.getApplication();
    application.runWriteAction(libraryTableModel::commit);
    Library.ModifiableModel libraryModel = library.getModifiableModel();
    libraryModel.addRoot(pathToIdeaUrl(binaryPath), CLASSES);
    libraryModel.addRoot(pathToIdeaUrl(sourcePath), SOURCES);
    application.runWriteAction(libraryModel::commit);
    return library;
}
Also used : ProjectLibraryTable(com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable) LibraryTable(com.intellij.openapi.roots.libraries.LibraryTable) Library(com.intellij.openapi.roots.libraries.Library) Application(com.intellij.openapi.application.Application) NotNull(org.jetbrains.annotations.NotNull)

Example 58 with Application

use of com.intellij.openapi.application.Application in project android by JetBrains.

the class ArtifactRepositorySearch method start.

@NotNull
public Callback start(@NotNull SearchRequest request) {
    Callback callback = new Callback();
    List<Future<SearchResult>> jobs = Lists.newArrayListWithExpectedSize(myRepositories.size());
    List<SearchResult> results = Lists.newArrayList();
    List<Exception> errors = Lists.newArrayList();
    Application application = ApplicationManager.getApplication();
    application.executeOnPooledThread(() -> {
        for (ArtifactRepository repository : myRepositories) {
            jobs.add(application.executeOnPooledThread(() -> repository.search(request)));
        }
        for (Future<SearchResult> job : jobs) {
            try {
                results.add(Futures.getChecked(job, Exception.class));
            } catch (Exception e) {
                errors.add(e);
            }
        }
        callback.setDone(results, errors);
    });
    return callback;
}
Also used : ActionCallback(com.intellij.openapi.util.ActionCallback) Future(java.util.concurrent.Future) Application(com.intellij.openapi.application.Application) NotNull(org.jetbrains.annotations.NotNull)

Example 59 with Application

use of com.intellij.openapi.application.Application in project android by JetBrains.

the class GradleUtil method stopAllGradleDaemonsAndRestart.

public static void stopAllGradleDaemonsAndRestart() {
    DefaultGradleConnector.close();
    Application application = ApplicationManager.getApplication();
    if (application instanceof ApplicationImpl) {
        ((ApplicationImpl) application).restart(true);
    } else {
        application.restart();
    }
}
Also used : ApplicationImpl(com.intellij.openapi.application.impl.ApplicationImpl) Application(com.intellij.openapi.application.Application)

Example 60 with Application

use of com.intellij.openapi.application.Application in project android by JetBrains.

the class DialogWrapperHost method runSensitiveOperation.

@Override
public void runSensitiveOperation(@NotNull final ProgressIndicator progressIndicator, boolean cancellable, @NotNull final Runnable operation) {
    final Application application = ApplicationManager.getApplication();
    application.assertIsDispatchThread();
    if (!myCurrentProgressIndicator.compareAndSet(null, progressIndicator)) {
        throw new IllegalStateException("Submitting an operation while another is in progress.");
    }
    final JRootPane rootPane = getRootPane();
    rootPane.setDefaultButton(null);
    updateButtons(false, false, true, false);
    Task.Backgroundable task = new Task.Backgroundable(null, myWizard.getWizardActionDescription(), cancellable) {

        @Override
        public void run(@NotNull ProgressIndicator indicator) {
            operation.run();
            // this can't be done in onSuccess because the ModalityState needs to be set
            ApplicationManager.getApplication().invokeAndWait(new Runnable() {

                @Override
                public void run() {
                    updateButtons(false, false, false, true);
                    myCurrentProgressIndicator.set(null);
                }
            }, ModalityState.stateForComponent(myWizard.getContentPane()));
        }
    };
    ProgressManager.getInstance().runProcessWithProgressAsynchronously(task, progressIndicator);
}
Also used : Task(com.intellij.openapi.progress.Task) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) Application(com.intellij.openapi.application.Application) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

Application (com.intellij.openapi.application.Application)188 NotNull (org.jetbrains.annotations.NotNull)23 VirtualFile (com.intellij.openapi.vfs.VirtualFile)21 IOException (java.io.IOException)14 Project (com.intellij.openapi.project.Project)13 Nullable (org.jetbrains.annotations.Nullable)12 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)9 ModalityState (com.intellij.openapi.application.ModalityState)8 Ref (com.intellij.openapi.util.Ref)7 ArrayList (java.util.ArrayList)7 List (java.util.List)6 ApplicationImpl (com.intellij.openapi.application.impl.ApplicationImpl)5 ApplicationManager (com.intellij.openapi.application.ApplicationManager)4 ApplicationEx (com.intellij.openapi.application.ex.ApplicationEx)4 Document (com.intellij.openapi.editor.Document)4 Module (com.intellij.openapi.module.Module)4 Computable (com.intellij.openapi.util.Computable)4 PsiFile (com.intellij.psi.PsiFile)4 File (java.io.File)4 Editor (com.intellij.openapi.editor.Editor)3