Search in sources :

Example 41 with Application

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());
    });
}
Also used : ExternalProjectsViewImpl(com.intellij.openapi.externalSystem.view.ExternalProjectsViewImpl) ExternalProjectsView(com.intellij.openapi.externalSystem.view.ExternalProjectsView) NotificationGroup(com.intellij.notification.NotificationGroup) Application(com.intellij.openapi.application.Application) Notification(com.intellij.notification.Notification)

Example 42 with Application

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);
    }
}
Also used : NamedRunnable(com.intellij.openapi.util.NamedRunnable) Application(com.intellij.openapi.application.Application)

Example 43 with Application

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);
    });
}
Also used : ModalityState(com.intellij.openapi.application.ModalityState) Application(com.intellij.openapi.application.Application)

Example 44 with Application

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;
}
Also used : PicoContainer(org.picocontainer.PicoContainer) Application(com.intellij.openapi.application.Application) Nullable(org.jetbrains.annotations.Nullable)

Example 45 with Application

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;
}
Also used : Application(com.intellij.openapi.application.Application)

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