public void write(ClientConfig config, Consumer<ClientQueryCacheStore> fun) throws InterruptedException { lockTimeout.withWriteLock(lock, () -> { ClientQueryCacheStore store = clientQueryCache.get(config.getClientServerRef()); if (store == null) { store = new ClientQueryCacheStore(config.getClientServerRef()); clientQueryCache.put(config.getClientServerRef(), store); } fun.accept(store); }); }
@Nullable public <T> T read(ClientConfig config, T defaultValue, Function<ClientQueryCacheStore, T> fun) throws InterruptedException { return lockTimeout.withReadLock(lock, () -> { ClientQueryCacheStore store = clientQueryCache.get(config.getClientServerRef()); if (store != null) { return fun.apply(store); } return defaultValue; }); }
public void read(ClientConfig config, Consumer<ClientQueryCacheStore> fun) throws InterruptedException { lockTimeout.withReadLock(lock, () -> { ClientQueryCacheStore store = clientQueryCache.get(config.getClientServerRef()); if (store != null) { fun.accept(store); } }); }
@Override public Stream<ActionChoice> copyActions(ClientConfig clientConfig) throws InterruptedException { return copyActions(clientConfig.getClientServerRef()); }
public static String getSourceId(ClientConfig config) { return getSourceId(config.getClientServerRef()); }
@NotNull public static P4ChangelistId getActiveChangelistFor(@NotNull ClientConfigRoot root, @NotNull Map<ClientServerRef, P4ChangelistId> ids) { ClientServerRef ref = root.getClientConfig().getClientServerRef(); P4ChangelistId ret = ids.get(ref); if (ret == null) { ret = P4ChangelistIdImpl.createDefaultChangelistId(ref); ids.put(ref, ret); } return ret; } }
@NotNull private P4ChangelistId getActiveChangelistFor(ClientConfigRoot root, Map<ClientServerRef, P4ChangelistId> ids) { ClientServerRef ref = root.getClientConfig().getClientServerRef(); P4ChangelistId ret = ids.get(ref); if (ret == null) { ret = P4ChangelistIdImpl.createDefaultChangelistId(ref); ids.put(ref, ret); } return ret; }
private RootNode createRootNode(ClientConfigRoot root) { RootNode fileRoot = new RootNode(root, new DefaultMutableTreeNode(root, true)); // The client root details should never change, so only add them when the root itself is added. // They are never included in the content map. fileRoot.fileRoot.add(new DefaultMutableTreeNode( root.getClientConfig().getClientServerRef().getServerName(), false)); fileRoot.fileRoot.add(new DefaultMutableTreeNode( root.getClientConfig().getClientServerRef(), false)); fileRoot.fileRoot.add(fileRoot.pendingNode); add(fileRoot.fileRoot); return fileRoot; }
public static ListOpenedFilesChangesResult createListOpenedFilesChangesResult( @NotNull ClientConfig config, @NotNull List<IChangelist> changes, @NotNull List<IExtendedFileSpec> pendingChangelistFiles, @NotNull Map<Integer, List<IFileSpec>> shelvedFiles, @NotNull List<IExtendedFileSpec> openedDefaultChangelistFiles) { return new ListOpenedFilesChangesResult(config, createOpenedFiles(config.getClientServerRef(), pendingChangelistFiles, openedDefaultChangelistFiles), createOpenedChanges(config, changes, pendingChangelistFiles, shelvedFiles, openedDefaultChangelistFiles)); }
@NotNull @Override public Collection<P4LocalFile> getCachedOpenedFiles(@NotNull ClientConfig config) { return openFiles.computeIfAbsent(config.getClientServerRef(), k -> new ArrayList<>()); }
@NotNull public static RepositoryLocation getLocationFor(@NotNull FilePath root, @NotNull ClientConfigRoot clientRoot, @NotNull ListFilesDetailsResult details) { if (details.getFiles().isEmpty()) { String clientName = clientRoot.getClientConfig().getClientname(); if (clientName == null) { // TODO bundle string clientName = "<unknown>"; } return new LocalRepositoryLocation(clientRoot.getClientConfig().getClientServerRef(), clientName, root); } return new P4RepositoryLocationImpl(clientRoot.getClientConfig().getClientServerRef(), details.getFiles().get(0)); } }
public boolean isOnline(@Nullable ClientServerRef clientServerRef) { if (clientServerRef == null) { return false; } for (ClientConfigRoot configRoot: getRegisteredStates()) { if (clientServerRef.equals(configRoot.getClientConfig().getClientServerRef())) { return configRoot.isOnline(); } } return false; }
private void cleanupClientState(@NotNull ClientConfigRoot removed) { ClientServerRef clientServerRef = removed.getClientConfig().getClientServerRef(); boolean didRemove = false; synchronized (registeredClients) { ClientRef ref = registeredClients.get(clientServerRef); if (ref != null && ref.removeClientConfigRoot()) { registeredClients.remove(clientServerRef); didRemove = true; } } if (didRemove) { deregisterServerForConfig(removed.getClientConfig()); } removed.dispose(); }
private P4CommandRunner.QueryAnswer<ListFileHistoryResult> getHistory( @NotNull ClientConfigRoot root, FilePath file, int revisionCount) { return P4ServerComponent .query(project, root.getClientConfig().getServerConfig(), new ListFileHistoryQuery( root.getClientConfig().getClientServerRef(), file, revisionCount)); }
@Override public void actionPerformed(AnActionEvent anActionEvent) { final ClientConfigRoot sel = getSelected(ClientConfigRoot.class); if (sel != null && sel.isOffline()) { ReconnectRequestMessage.requestReconnectToClient(project, sel.getClientConfig().getClientServerRef(), true); } }
private P4ChangelistId createChangelistId(IChangelist change, ClientConfig clientConfig) { return new P4ChangelistIdImpl(change.getId(), clientConfig.getClientServerRef()); } }
public MockP4RemoteChangelist withConfig(ClientConfig cc) { csRef = cc.getClientServerRef(); //clientname = cc.getClientname(); //serverName = csRef.getServerName(); username = cc.getServerConfig().getUsername(); summary = null; return this; }
@Override public void actionPerformed(AnActionEvent anActionEvent) { final ClientConfigRoot sel = getSelected(ClientConfigRoot.class); if (sel != null && sel.isOnline()) { UserSelectedOfflineMessage.send(project).userSelectedServerOffline( new UserSelectedOfflineMessage.OfflineEvent( sel.getClientConfig().getClientServerRef().getServerName())); } }
public void goOffline(ClientConfigRoot root) { UserSelectedOfflineMessage.send(idea.getMockProject()).userSelectedServerOffline( new UserSelectedOfflineMessage.OfflineEvent( root.getClientConfig().getClientServerRef().getServerName())); }
@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); }