use of com.intellij.openapi.application.Application in project intellij-plugins by JetBrains.
the class RenderActionQueue method execute.
private void execute(RenderAction renderAction) {
if (suspended) {
assert !wasPending;
wasPending = true;
return;
}
renderAction.result.doWhenProcessed(this);
Application application = ApplicationManager.getApplication();
boolean isDispatchThread = application.isDispatchThread();
if (renderAction.isNeedEdt()) {
if (isDispatchThread) {
renderAction.run();
} else {
application.invokeLater(renderAction);
}
} else {
if (isDispatchThread) {
application.executeOnPooledThread(renderAction);
} else {
renderAction.run();
}
}
}
use of com.intellij.openapi.application.Application in project android by JetBrains.
the class AndroidGradleNotification method showBalloon.
public void showBalloon(@NotNull String title, @NotNull String text, @NotNull NotificationType type, @NotNull NotificationGroup group, @Nullable NotificationListener listener) {
Notification notification = group.createNotification(title, text, type, listener);
Runnable notificationTask = () -> {
if (!myProject.isDisposed() && myProject.isOpen()) {
Notification old = myNotification;
if (old != null) {
boolean similar = Objects.equal(notification.getContent(), old.getContent());
if (similar) {
old.expire();
}
}
myNotification = notification;
notification.notify(myProject);
}
};
Application application = ApplicationManager.getApplication();
if (application.isDispatchThread()) {
notificationTask.run();
} else {
application.invokeLater(notificationTask);
}
}
use of com.intellij.openapi.application.Application in project android by JetBrains.
the class ForcedPluginPreviewVersionUpgradeDialog method setTestDialog.
@TestOnly
public static TestDialog setTestDialog(@NotNull TestDialog newValue) {
Application application = ApplicationManager.getApplication();
if (application != null) {
getLog().assertTrue(application.isUnitTestMode(), "This method is available for tests only");
}
TestDialog oldValue = ourTestImplementation;
ourTestImplementation = newValue;
return oldValue;
}
use of com.intellij.openapi.application.Application in project android by JetBrains.
the class BuildVariantView method updateContents.
public void updateContents() {
GradleSyncState syncState = GradleSyncState.getInstance(myProject);
if (syncState.isSyncInProgress() && !syncState.isSyncSkipped()) {
projectImportStarted();
return;
}
final List<Object[]> rows = Lists.newArrayList();
final List<BuildVariantItem[]> variantNamesPerRow = Lists.newArrayList();
for (Module module : getGradleModulesWithAndroidProjects()) {
AndroidFacet androidFacet = AndroidFacet.getInstance(module);
NdkFacet ndkFacet = NdkFacet.getInstance(module);
// getGradleModules() returns only relevant modules.
assert androidFacet != null || ndkFacet != null;
String variantName = null;
if (androidFacet != null) {
JpsAndroidModuleProperties facetProperties = androidFacet.getProperties();
variantName = facetProperties.SELECTED_BUILD_VARIANT;
}
BuildVariantItem[] variantNames = getVariantItems(module);
if (variantNames != null) {
if (androidFacet != null) {
AndroidModuleModel androidModel = AndroidModuleModel.get(module);
// AndroidModel may be null when applying a quick fix (e.g. "Fix Gradle version")
if (androidModel != null) {
variantName = androidModel.getSelectedVariant().getName();
}
} else {
// As only the modules backed by either AndroidGradleModel or NativeAndroidGradleModel are shown in the Build Variants View,
// when a module is not backed by AndroidGradleModel, it surely contains a valid NativeAndroidGradleModel.
NdkModuleModel ndkModuleModel = NdkModuleModel.get(module);
if (ndkModuleModel != null) {
variantName = ndkModuleModel.getSelectedVariant().getName();
}
}
variantNamesPerRow.add(variantNames);
}
if (variantName != null) {
Object[] row = { module, variantName };
rows.add(row);
}
}
Runnable setModelTask = () -> getVariantsTable().setModel(rows, variantNamesPerRow);
Application application = ApplicationManager.getApplication();
if (application.isDispatchThread()) {
setModelTask.run();
} else {
application.invokeLater(setModelTask);
}
}
use of com.intellij.openapi.application.Application in project android by JetBrains.
the class InstallOperation method promptToRetry.
/**
* Shows a retry prompt. Throws an exception to stop the setup process if the user preses cancel or returns normally otherwise.
*/
protected final void promptToRetry(@NotNull final String prompt, @NotNull String failureDescription, @Nullable Exception e) throws WizardException {
final AtomicBoolean response = new AtomicBoolean(false);
Application application = ApplicationManager.getApplication();
application.invokeAndWait(new Runnable() {
@Override
public void run() {
int i = Messages.showYesNoDialog(null, prompt, "Android Studio Setup", "Retry", "Cancel", Messages.getErrorIcon());
response.set(i == Messages.YES);
}
}, application.getAnyModalityState());
if (!response.get()) {
Throwables.propagateIfInstanceOf(e, WizardException.class);
throw new WizardException(failureDescription, e);
} else {
myContext.print(failureDescription + "\n", ConsoleViewContentType.ERROR_OUTPUT);
}
}
Aggregations