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