@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 @Override public Stream<P4LocalFile> getLinkedFiles() { List<P4LocalFile> ret = new LinkedList<>(); for (ClientConfigRoot root : getClientConfigRoots()) { ret.addAll(cache.getCachedOpenedFiles(root.getClientConfig())); } return ret.stream(); }
@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; }
protected Stream<Pair<ClientConfig, List<VirtualFile>>> getFilesByConfiguration(@NotNull final Project project, @NotNull final Collection<VirtualFile> files) { final ProjectConfigRegistry registry = ProjectConfigRegistry.getInstance(project); if (registry == null) { return Stream.empty(); } final Map<ClientConfigRoot, List<VirtualFile>> mapping = new HashMap<>(); files.forEach((file) -> { ClientConfigRoot config = registry.getClientFor(file); if (config != null) { List<VirtualFile> mappedFiles = mapping.computeIfAbsent(config, k -> new ArrayList<>()); mappedFiles.add(file); } }); return mapping.entrySet().stream() .map((entry) -> Pair.create(entry.getKey().getClientConfig(), entry.getValue())); }
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)); }
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(); }
@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)); } }
@Nullable @Override public P4LocalFile forDepotPath(@Nullable P4RemoteFile file) { if (file == null) { return null; } for (ClientConfigRoot root : getClientConfigRoots()) { for (P4LocalFile openedFile : cache.getCachedOpenedFiles(root.getClientConfig())) { if (file.equals(openedFile.getDepotPath())) { return openedFile; } } } return null; }
@Nullable @Override public P4LocalFile forIdeFile(@Nullable FilePath file) { if (file == null) { return null; } ClientConfigRoot clientConfig = getClientFor(file); if (clientConfig == null) { return null; } for (P4LocalFile openedFile : cache.getCachedOpenedFiles(clientConfig.getClientConfig())) { if (file.equals(openedFile.getFilePath())) { return openedFile; } } return null; }
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; }
@Override public void actionPerformed(AnActionEvent anActionEvent) { final ClientConfigRoot selRoot = getSelected(ClientConfigRoot.class); if (selRoot != null) { P4ServerComponent.sendCachedPendingRequests(project, selRoot.getClientConfig()) .whenCompleted(c -> LOG.info("Sent pending actions")); } } },
@Override public void actionPerformed(AnActionEvent anActionEvent) { final ClientConfigRoot sel = getSelected(ClientConfigRoot.class); if (sel != null && sel.isOffline()) { ReconnectRequestMessage.requestReconnectToClient(project, sel.getClientConfig().getClientServerRef(), true); } }
protected final void sendClientRemoved(@Nullable ClientConfigRoot state) { if (state != null) { if (LOG.isDebugEnabled()) { LOG.debug("Sending notification that root was removed: " + state.getClientRootDir()); } ClientConfigRemovedMessage.reportClientConfigRemoved(getProject(), this, state.getClientConfig(), state.getProjectVcsRootDir()); } }
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()); } }
@Nullable @Override public String getContent() throws VcsException { try { if (LOG.isDebugEnabled()) { LOG.debug("Loading file content for " + local + " rev " + iRev); } return loader.loadStringContentForLocal( root.getClientConfig().getServerConfig(), clientName, local, iRev.getValue()); } catch (IOException e) { LOG.info("Problem loading file content for " + local + " rev " + iRev, e); throw new VcsException(e); } }
@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())); }
public void goOnline(ClientConfigRoot root) { ClientConfigAddedMessage.sendClientConfigurationAdded(idea.getMockProject(), root.getClientRootDir(), root.getClientConfig()); ServerConnectedMessage.send().serverConnected(new ServerConnectedMessage.ServerConnectedEvent(root.getServerConfig(), true)); }
public void linkP4ChangelistToIdeChangelist(ClientConfigRoot root, P4ChangelistId p4cl, LocalChangeList ide) { CacheComponent cc = CacheComponent.getInstance(idea.getMockProject()); // Use the state object to avoid all the work to populate the cache. ProjectCacheStore.State state = cc.getState(); assertNotNull(state); IdeChangelistCacheStore.LinkedChangelistState linkedState = new IdeChangelistCacheStore.LinkedChangelistState(); linkedState.changelistId = new P4ChangelistIdStore.State(); linkedState.changelistId.id = p4cl.getChangelistId(); linkedState.changelistId.ref = new ClientServerRefStore.State(); linkedState.changelistId.ref.clientName = root.getClientConfig().getClientname(); linkedState.changelistId.ref.serverPort = root.getServerConfig().getServerName().getFullPort(); linkedState.linkedLocalChangeId = ide.getId(); state.changelistState.linkedChangelistMap.add(linkedState); cc.loadState(state); }