use of com.intellij.openapi.application.Application in project intellij-community by JetBrains.
the class ExternalSystemNotificationManager method showNotification.
public void showNotification(@NotNull final ProjectSystemId externalSystemId, @NotNull final NotificationData notificationData) {
myUpdater.submit(() -> {
if (myProject.isDisposed())
return;
final Application app = ApplicationManager.getApplication();
Runnable action = () -> {
if (!initializedExternalSystem.contains(externalSystemId)) {
app.runWriteAction(() -> {
if (myProject.isDisposed())
return;
ExternalSystemUtil.ensureToolWindowContentInitialized(myProject, externalSystemId);
initializedExternalSystem.add(externalSystemId);
});
}
if (myProject.isDisposed())
return;
NotificationGroup group;
if (notificationData.getBalloonGroup() == null) {
ExternalProjectsView externalProjectsView = ExternalProjectsManager.getInstance(myProject).getExternalProjectsView(externalSystemId);
group = externalProjectsView instanceof ExternalProjectsViewImpl ? ((ExternalProjectsViewImpl) externalProjectsView).getNotificationGroup() : null;
} else {
final NotificationGroup registeredGroup = NotificationGroup.findRegisteredGroup(notificationData.getBalloonGroup());
group = registeredGroup != null ? registeredGroup : NotificationGroup.balloonGroup(notificationData.getBalloonGroup());
}
if (group == null)
return;
final Notification notification = group.createNotification(notificationData.getTitle(), notificationData.getMessage(), notificationData.getNotificationCategory().getNotificationType(), notificationData.getListener());
myNotifications.add(notification);
if (notificationData.isBalloonNotification()) {
applyNotification(notification);
} else {
addMessage(notification, externalSystemId, notificationData);
}
};
app.invokeLater(action, ModalityState.defaultModalityState(), myProject.getDisposed());
});
}
use of com.intellij.openapi.application.Application in project intellij-community by JetBrains.
the class VcsBalloonProblemNotifier method show.
private static void show(final Project project, final String message, final MessageType type, @Nullable final NamedRunnable[] notificationListener) {
final Application application = ApplicationManager.getApplication();
if (application.isHeadlessEnvironment())
return;
final Runnable showErrorAction = () -> new VcsBalloonProblemNotifier(project, message, type, notificationListener).run();
if (application.isDispatchThread()) {
showErrorAction.run();
} else {
application.invokeLater(showErrorAction);
}
}
use of com.intellij.openapi.application.Application in project intellij-community by JetBrains.
the class CvsTree method loadChildren.
@Override
public void loadChildren(final CvsElement element) {
element.setLoading(true);
myLoadingNodeManager.addTo(myModel, element);
final Application application = ApplicationManager.getApplication();
final ModalityState modalityState = application.getCurrentModalityState();
application.executeOnPooledThread(() -> {
final RemoteResourceDataProvider dataProvider = element.getDataProvider();
dataProvider.fillContentFor(new MyGetContentCallback(element, modalityState, myProject), myErrorCallback);
});
}
use of com.intellij.openapi.application.Application in project intellij-community by JetBrains.
the class ServiceManager method doGetService.
@Nullable
private static <T> T doGetService(ComponentManager componentManager, @NotNull Class<T> serviceClass) {
PicoContainer picoContainer = componentManager.getPicoContainer();
@SuppressWarnings("unchecked") T instance = (T) picoContainer.getComponentInstance(serviceClass.getName());
if (instance == null) {
instance = componentManager.getComponent(serviceClass);
if (instance != null) {
Application app = ApplicationManager.getApplication();
String message = serviceClass.getName() + " requested as a service, but it is a component - convert it to a service or change call to " + (componentManager == app ? "ApplicationManager.getApplication().getComponent()" : "project.getComponent()");
if (app.isUnitTestMode()) {
LOG.error(message);
} else {
LOG.warn(message);
}
}
}
return instance;
}
use of com.intellij.openapi.application.Application in project intellij-community by JetBrains.
the class PropertyGroup method loadIcon.
private static Icon loadIcon(@NonNls String resourceName) {
Icon icon = IconLoader.findIcon(resourceName);
Application application = ApplicationManager.getApplication();
if (icon == null && application != null && application.isUnitTestMode()) {
return new ImageIcon();
}
return icon;
}
Aggregations