public static void addListener(@NotNull MessageBusClient.ProjectClient client, @NotNull Object listenerOwner, @NotNull Listener listener) { addListener(client, TOPIC, listener, Listener.class, listenerOwner); }
protected final void sendClientAdded(@Nullable ClientConfigRoot state) { if (state != null) { if (LOG.isDebugEnabled()) { LOG.debug("Sending notification that root was added: " + state.getClientRootDir()); } ClientConfigAddedMessage.sendClientConfigurationAdded(getProject(), state.getClientRootDir(), state.getClientConfig()); } }
/** * Should only be called by {@link net.groboclown.p4.server.api.ProjectConfigRegistry}. Doesn't conform to * the "send(Project)" standard API, because it can trigger 2 events. * * @param project project to send the message on. */ public static void sendClientConfigurationAdded(@NotNull Project project, @Nullable VirtualFile root, @NotNull ClientConfig clientConfig) { ServerListener serverListener = ApplicationMessage.getListener(SERVER_TOPIC); if (serverListener != null) { serverListener.serverConfigAdded(new ServerConfigAddedEvent(clientConfig.getServerConfig())); } getListener(project, TOPIC, DEFAULT_LISTENER).clientConfigurationAdded(new ClientConfigAddedEvent( root, clientConfig)); }
ClientConfigAddedMessage.addListener(projClient, this, (e) -> clientConfigs.put(e.getRoot(), e.getClientConfig())); ClientConfigRemovedMessage.addListener(projClient, this, (event) -> clientConfigs.remove(event.getVcsRootDir())); ClientConfigAddedMessage.addServerListener(appClient, this,
@Override public void projectOpened(Project project) { MessageBusClient.ProjectClient projectMbClient = MessageBusClient.forProject(project, InvalidPasswordMonitorComponent.this); ClientConfigAddedMessage.addListener(projectMbClient, this, e -> forgetLoginProblem(e.getClientConfig().getServerConfig())); ClientConfigRemovedMessage.addListener(projectMbClient, this, event -> forgetLoginProblem(event.getClientConfig().getServerConfig())); }
public void goOnline(ClientConfigRoot root) { ClientConfigAddedMessage.sendClientConfigurationAdded(idea.getMockProject(), root.getClientRootDir(), root.getClientConfig()); ServerConnectedMessage.send().serverConnected(new ServerConnectedMessage.ServerConnectedEvent(root.getServerConfig(), true)); }
@Test void removeClientConfig_registered() { ProjectConfigRegistry registry = new ProjectConfigRegistryImpl(idea.getMockProject()); final List<ClientConfig> added = new ArrayList<>(); final List<ClientConfig> removed = new ArrayList<>(); MessageBusClient.ProjectClient client = MessageBusClient.forProject(idea.getMockProject(), idea.getMockProject()); ClientConfigAddedMessage.addListener(client, this, e -> added.add(e.getClientConfig())); ClientConfigRemovedMessage.addListener(client, this, (e) -> removed.add(e.getClientConfig())); ClientConfig config = createClientConfig(); VirtualFile root = MockVirtualFileSystem.createRoot(); registry.addClientConfig(config, root); assertEquals(1, added.size()); added.clear(); registry.removeClientConfigAt(root); assertEquals(0, added.size()); assertEquals(1, removed.size()); assertSame(config, removed.get(0)); ClientConfig fetchedState = registry.getRegisteredClientConfigState(config.getClientServerRef()); assertNull(fetchedState); }
@Test void projectClosed() { ProjectConfigRegistry registry = new ProjectConfigRegistryImpl(idea.getMockProject()); final List<ClientConfig> added = new ArrayList<>(); final List<ClientConfig> removed = new ArrayList<>(); MessageBusClient.ProjectClient client = MessageBusClient.forProject(idea.getMockProject(), idea.getMockProject()); ClientConfigAddedMessage.addListener(client, this, e -> added.add(e.getClientConfig())); ClientConfigRemovedMessage.addListener(client, this, (e) -> removed.add(e.getClientConfig())); ClientConfig config = createClientConfig(); VirtualFile root = MockVirtualFileSystem.createRoot(); registry.addClientConfig(config, root); assertEquals(1, added.size()); added.clear(); registry.projectClosed(); assertEquals(0, added.size()); assertEquals(1, removed.size()); assertSame(config, removed.get(0)); ClientConfig fetchedState = registry.getRegisteredClientConfigState(config.getClientServerRef()); assertNull(fetchedState); // closing the project should turn off further registration removed.clear(); assertThrows(Throwable.class, () -> registry.addClientConfig(config, root)); assertEquals(0, added.size()); assertThrows(Throwable.class, () -> registry.removeClientConfigAt(root)); assertEquals(0, removed.size()); }
@Test void disposeComponent() { ProjectConfigRegistry registry = new ProjectConfigRegistryImpl(idea.getMockProject()); final List<ClientConfig> added = new ArrayList<>(); final List<ClientConfig> removed = new ArrayList<>(); MessageBusClient.ProjectClient client = MessageBusClient.forProject(idea.getMockProject(), idea.getMockProject()); ClientConfigAddedMessage.addListener(client, this, e -> added.add(e.getClientConfig())); ClientConfigRemovedMessage.addListener(client, this, (e) -> removed.add(e.getClientConfig())); ClientConfig config = createClientConfig(); VirtualFile root = MockVirtualFileSystem.createRoot(); registry.addClientConfig(config, root); assertEquals(1, added.size()); added.clear(); registry.disposeComponent(); assertEquals(0, added.size()); assertEquals(1, removed.size()); assertSame(config, removed.get(0)); ClientConfig fetchedState = registry.getRegisteredClientConfigState(config.getClientServerRef()); assertNull(fetchedState); // closing the project should turn off further registration removed.clear(); assertThrows(Throwable.class, () -> registry.addClientConfig(config, root)); assertEquals(0, added.size()); assertThrows(Throwable.class, () -> registry.removeClientConfigAt(root)); assertEquals(0, removed.size()); }
@Test void removeClientConfig_notRegistered() { ProjectConfigRegistry registry = new ProjectConfigRegistryImpl(idea.getMockProject()); final List<ClientConfig> removed = new ArrayList<>(); MessageBusClient.ProjectClient client = MessageBusClient.forProject(idea.getMockProject(), idea.getMockProject()); ClientConfigAddedMessage.addListener(client, this, e -> fail("should not have added anything")); ClientConfigRemovedMessage.addListener(client, this, (e) -> removed.add(e.getClientConfig())); ClientConfig config = createClientConfig(); registry.removeClientConfigAt(MockVirtualFileSystem.createRoot()); assertEquals(0, removed.size()); ClientConfig fetchedState = registry.getRegisteredClientConfigState(config.getClientServerRef()); assertNull(fetchedState); }
@Test void addClientConfig_new() { ProjectConfigRegistry registry = new ProjectConfigRegistryImpl(idea.getMockProject()); final List<ClientConfig> added = new ArrayList<>(); MessageBusClient.ProjectClient client = MessageBusClient.forProject(idea.getMockProject(), idea.getMockProject()); ClientConfigAddedMessage.addListener(client, this, e -> added.add(e.getClientConfig())); ClientConfigRemovedMessage.addListener(client, this, (event) -> fail("incorrectly called remove")); ClientConfig config = createClientConfig(); VirtualFile root = MockVirtualFileSystem.createRoot(); registry.addClientConfig(config, root); assertEquals(1, added.size()); assertSame(config, added.get(0)); ClientConfig fetchedState = registry.getRegisteredClientConfigState(config.getClientServerRef()); assertNotNull(fetchedState); assertSame(config, fetchedState); }
final List<ClientConfig> removed = new ArrayList<>(); MessageBusClient.ProjectClient client = MessageBusClient.forProject(idea.getMockProject(), idea.getMockProject()); ClientConfigAddedMessage.addListener(client, this, e -> added.add(e.getClientConfig())); ClientConfigRemovedMessage.addListener(client, this, (e) -> removed.add(e.getClientConfig())); ClientConfig config = createClientConfig();
MessageBusClient.ProjectClient clientBus = MessageBusClient.forProject(project, parentDisposable); ClientConfigAddedMessage.addListener(clientBus, cacheId, e -> refresh()); ClientConfigRemovedMessage.addListener(clientBus, cacheId, event -> refresh()); ServerConnectedMessage.addListener(appBus, cacheId, (e) -> refresh());