Search in sources :

Example 16 with MessageBus

use of com.intellij.util.messages.MessageBus in project intellij-community by JetBrains.

the class PowerSaveModeNotifier method notifyOnPowerSaveMode.

static void notifyOnPowerSaveMode(@Nullable Project project) {
    if (PropertiesComponent.getInstance().getBoolean(IGNORE_POWER_SAVE_MODE)) {
        return;
    }
    Notification notification = POWER_SAVE_MODE.createNotification("Power save mode is on", "Code insight and background tasks are disabled.", NotificationType.WARNING, null);
    notification.addAction(new NotificationAction("Do Not Show Again") {

        @Override
        public void actionPerformed(@NotNull AnActionEvent e, @NotNull Notification notification) {
            PropertiesComponent.getInstance().setValue(IGNORE_POWER_SAVE_MODE, true);
            notification.expire();
        }
    });
    notification.addAction(new NotificationAction("Disable Power Save Mode") {

        @Override
        public void actionPerformed(@NotNull AnActionEvent e, @NotNull Notification notification) {
            PowerSaveMode.setEnabled(false);
            notification.expire();
        }
    });
    notification.notify(project);
    Balloon balloon = notification.getBalloon();
    if (balloon != null) {
        MessageBus bus = project == null ? ApplicationManager.getApplication().getMessageBus() : project.getMessageBus();
        MessageBusConnection connection = bus.connect();
        connection.subscribe(PowerSaveMode.TOPIC, () -> notification.expire());
        Disposer.register(balloon, connection);
    }
}
Also used : MessageBus(com.intellij.util.messages.MessageBus) MessageBusConnection(com.intellij.util.messages.MessageBusConnection) NotificationAction(com.intellij.notification.NotificationAction) Balloon(com.intellij.openapi.ui.popup.Balloon) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) Notification(com.intellij.notification.Notification)

Example 17 with MessageBus

use of com.intellij.util.messages.MessageBus in project intellij-elixir by KronicDeth.

the class ParsingTestCase method registerModuleManager.

private void registerModuleManager(MessageBus messageBus) throws ClassNotFoundException, IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchMethodException {
    Class<?> moduleManagerComponentClass = Class.forName("com.intellij.openapi.module.impl.ModuleManagerComponent");
    Constructor<?> moduleManagerComponentConstructor;
    ModuleManager moduleManager = null;
    try {
        // IntelliJ > 2016.3
        moduleManagerComponentConstructor = moduleManagerComponentClass.getConstructor(Project.class);
        moduleManager = (ModuleManager) moduleManagerComponentConstructor.newInstance(myProject);
    } catch (NoSuchMethodException e1) {
        try {
            // IntelliJ 2016.3
            moduleManagerComponentConstructor = moduleManagerComponentClass.getConstructor(Project.class, MessageBus.class);
            moduleManager = (ModuleManager) moduleManagerComponentConstructor.newInstance(myProject, messageBus);
        } catch (NoSuchMethodException e2) {
            moduleManagerComponentConstructor = moduleManagerComponentClass.getConstructor(Project.class, ProgressManager.class, MessageBus.class);
            moduleManager = (ModuleManager) moduleManagerComponentConstructor.newInstance(myProject, new ProgressManagerImpl(), messageBus);
        }
    }
    myProject.registerService(ModuleManager.class, moduleManager);
}
Also used : Project(com.intellij.openapi.project.Project) MessageBus(com.intellij.util.messages.MessageBus) ProgressManager(com.intellij.openapi.progress.ProgressManager) ProgressManagerImpl(com.intellij.openapi.progress.impl.ProgressManagerImpl) ModuleManager(com.intellij.openapi.module.ModuleManager)

Example 18 with MessageBus

use of com.intellij.util.messages.MessageBus in project flutter-intellij by flutter.

the class FlutterViewMessages method sendDebugActive.

public static void sendDebugActive(@NotNull Project project, @NotNull FlutterApp app, @NotNull VmService vmService) {
    final MessageBus bus = project.getMessageBus();
    final FlutterDebugNotifier publisher = bus.syncPublisher(FLUTTER_DEBUG_TOPIC);
    app.setVmService(vmService);
    assert (app.getFlutterDebugProcess() != null);
    app.setPerfService(new PerfService(app.getFlutterDebugProcess(), vmService));
    publisher.debugActive(new FlutterDebugEvent(app, vmService));
}
Also used : MessageBus(com.intellij.util.messages.MessageBus) PerfService(io.flutter.perf.PerfService)

Example 19 with MessageBus

use of com.intellij.util.messages.MessageBus in project sonarlint-intellij by SonarSource.

the class SonarLintTestUtils method mockMessageBus.

public static MessageBusConnection mockMessageBus(ComponentManager mockedComponentManager) {
    MessageBusConnection connection = mock(MessageBusConnection.class);
    MessageBus bus = mock(MessageBus.class);
    when(bus.connect(mockedComponentManager)).thenReturn(connection);
    when(bus.connect()).thenReturn(connection);
    when(mockedComponentManager.getMessageBus()).thenReturn(bus);
    return connection;
}
Also used : MessageBusConnection(com.intellij.util.messages.MessageBusConnection) MessageBus(com.intellij.util.messages.MessageBus)

Aggregations

MessageBus (com.intellij.util.messages.MessageBus)19 Project (com.intellij.openapi.project.Project)4 MessageBusConnection (com.intellij.util.messages.MessageBusConnection)3 Application (com.intellij.openapi.application.Application)2 InstanceInfo (com.almightyalpaca.jetbrains.plugins.discord.data.InstanceInfo)1 ReplicatedData (com.almightyalpaca.jetbrains.plugins.discord.data.ReplicatedData)1 BuildManager (com.intellij.compiler.server.BuildManager)1 DefaultMessageHandler (com.intellij.compiler.server.DefaultMessageHandler)1 MockLocalFileSystem (com.intellij.mock.MockLocalFileSystem)1 Notification (com.intellij.notification.Notification)1 NotificationAction (com.intellij.notification.NotificationAction)1 Disposable (com.intellij.openapi.Disposable)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 ApplicationActivationListener (com.intellij.openapi.application.ApplicationActivationListener)1 Editor (com.intellij.openapi.editor.Editor)1 EditorFactory (com.intellij.openapi.editor.EditorFactory)1 EditorEventMulticaster (com.intellij.openapi.editor.event.EditorEventMulticaster)1 ExtensionsArea (com.intellij.openapi.extensions.ExtensionsArea)1 ModuleManager (com.intellij.openapi.module.ModuleManager)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1