Search in sources :

Example 6 with MessageBus

use of com.intellij.util.messages.MessageBus in project ActiveTabHighlighterPlugin by tobszarny.

the class ActiveTabHighlighterComponent method initComponent.

@Override
public void initComponent() {
    logger.debug("Initializing component");
    MessageBus bus = ApplicationManager.getApplication().getMessageBus();
    connection = bus.connect();
    connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new TabHighlighterFileEditorListener());
}
Also used : MessageBus(com.intellij.util.messages.MessageBus)

Example 7 with MessageBus

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

the class GradleSyncStateIntegrationTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    initMocks(this);
    Project project = getProject();
    MessageBus messageBus = mock(MessageBus.class);
    when(messageBus.syncPublisher(GRADLE_SYNC_TOPIC)).thenReturn(mySyncListener);
    mySyncState = new GradleSyncState(project, GradleProjectInfo.getInstance(project), GradleFiles.getInstance(project), messageBus);
}
Also used : Project(com.intellij.openapi.project.Project) MessageBus(com.intellij.util.messages.MessageBus)

Example 8 with MessageBus

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

the class ParsingTestCase method setProjectSdkFromSdkHome.

private void setProjectSdkFromSdkHome(@NotNull String sdkHome) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
    MessageBus messageBus = messageBus();
    registerProjectFileIndex(messageBus);
    ProjectRootManager projectRootManager = registerProjectRootManager();
    assertTrue(pathIsValidSdkHome(sdkHome));
    registerExtensionPoint(OrderRootType.EP_NAME, OrderRootType.class);
    registerExtension(OrderRootType.EP_NAME, new JavadocOrderRootType());
    getApplication().addComponent(VirtualFileManager.class, new VirtualFileManagerImpl(new VirtualFileSystem[] { new MockLocalFileSystem() }, messageBus));
    ProjectJdkTable projectJdkTable = new ProjectJdkTableImpl();
    registerApplicationService(ProjectJdkTable.class, projectJdkTable);
    registerExtensionPoint(com.intellij.openapi.projectRoots.SdkType.EP_NAME, com.intellij.openapi.projectRoots.SdkType.class);
    registerExtension(com.intellij.openapi.projectRoots.SdkType.EP_NAME, new ElixirSdkType());
    Sdk sdk = ElixirSdkType.createMockSdk(sdkHome, elixirSdkRelease());
    projectJdkTable.addJdk(sdk);
    ExtensionsArea area = Extensions.getArea(myProject);
    registerExtensionPoint(area, ProjectExtension.EP_NAME, ProjectExtension.class);
    registerExtensionPoint(FilePropertyPusher.EP_NAME, FilePropertyPusher.class);
    myProject.addComponent(PushedFilePropertiesUpdater.class, new PushedFilePropertiesUpdaterImpl(myProject));
    projectRootManager.setProjectSdk(sdk);
}
Also used : MockLocalFileSystem(com.intellij.mock.MockLocalFileSystem) ProjectJdkTableImpl(com.intellij.openapi.projectRoots.impl.ProjectJdkTableImpl) ExtensionsArea(com.intellij.openapi.extensions.ExtensionsArea) MessageBus(com.intellij.util.messages.MessageBus) VirtualFileSystem(com.intellij.openapi.vfs.VirtualFileSystem) ProjectJdkTable(com.intellij.openapi.projectRoots.ProjectJdkTable) VirtualFileManagerImpl(com.intellij.openapi.vfs.impl.VirtualFileManagerImpl) Sdk(com.intellij.openapi.projectRoots.Sdk) ElixirSdkType(org.elixir_lang.sdk.ElixirSdkType)

Example 9 with MessageBus

use of com.intellij.util.messages.MessageBus in project checkstyle-idea by jshiell.

the class OpLoadConfigurationTest method interceptApplicationNotifications.

private void interceptApplicationNotifications() {
    final MessageBus messageBus = mock(MessageBus.class);
    when(PROJECT.getMessageBus()).thenReturn(messageBus);
    when(messageBus.syncPublisher(Notifications.TOPIC)).thenReturn(notifications);
    final Application application = mock(Application.class);
    when(application.isUnitTestMode()).thenReturn(true);
    when(application.getMessageBus()).thenReturn(messageBus);
    ApplicationManager.setApplication(application, mock(Disposable.class));
}
Also used : Disposable(com.intellij.openapi.Disposable) MessageBus(com.intellij.util.messages.MessageBus) Application(com.intellij.openapi.application.Application)

Example 10 with MessageBus

use of com.intellij.util.messages.MessageBus in project Intellij-Discord-Integration by Almighty-Alpaca.

the class DiscordIntegrationApplicationComponent method initComponent.

@Override
public synchronized void initComponent() {
    try // Fixes problems that crashes JGroups if those two properties aren't properly set
    {
        Locale locale = Locale.getDefault();
        if (System.getProperty("user.language") == null)
            System.setProperty("user.language", locale.getLanguage());
        if (System.getProperty("user.country") == null)
            System.setProperty("user.country", locale.getCountry());
    } catch (Exception e) {
        e.printStackTrace();
    }
    try {
        String props = "fast.xml";
        LOG.trace("DiscordIntegrationApplicationComponent#initComponent()#props = {}", props);
        JChannel channel = new JChannel(props);
        channel.setReceiver(this);
        this.channel = channel;
        channel.connect("JetbrainsDiscordIntegration v" + JetbrainsDiscordIntegration.PROTOCOL_VERSION);
        ReplicatedData data = new ReplicatedData(channel, this);
        this.data = data;
        this.instanceInfo = new InstanceInfo(channel.getAddressAsString(), ApplicationInfo.getInstance());
        LOG.trace("DiscordIntegrationApplicationComponent#initComponent()#this.instanceInfo = {}", this.instanceInfo);
        data.instanceAdd(System.currentTimeMillis(), this.instanceInfo);
        RPC.updatePresence(2, TimeUnit.SECONDS);
    } catch (Exception e) {
        if (this.channel != null) {
            this.channel.close();
            this.channel = null;
        }
        if (this.data != null) {
            this.data.close();
            this.data = null;
        }
        RPC.dispose();
        throw new RuntimeException(e);
    }
    MessageBus bus = ApplicationManager.getApplication().getMessageBus();
    connection = bus.connect();
    connection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, new FileDocumentManagerListener());
    connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileEditorManagerListener());
    EditorEventMulticaster multicaster = EditorFactory.getInstance().getEventMulticaster();
    multicaster.addDocumentListener(this.documentListener = new DocumentListener());
    multicaster.addEditorMouseListener(this.editorMouseListener = new EditorMouseListener());
    checkExperiementalWindowListener();
    VirtualFileManager.getInstance().addVirtualFileListener(this.virtualFileListener = new VirtualFileListener());
}
Also used : Locale(java.util.Locale) JChannel(org.jgroups.JChannel) ReplicatedData(com.almightyalpaca.jetbrains.plugins.discord.data.ReplicatedData) EditorEventMulticaster(com.intellij.openapi.editor.event.EditorEventMulticaster) InstanceInfo(com.almightyalpaca.jetbrains.plugins.discord.data.InstanceInfo) 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