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;
}
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;
}
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;
}
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();
}
}
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);
}
Aggregations