Skip to content

Commit

Permalink
Additional progress reporting during workspace search
Browse files Browse the repository at this point in the history
  • Loading branch information
ForNeVeR authored and mfilippov committed Aug 14, 2020
1 parent c299ccb commit 1cdaf0a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ Tfvc.Lock.Dialog.LockButton=Lock
Tfvc.Lock.Dialog.UnlockButton=Unlock

# TFVC Import Workspace Action
Actions.Tfvc.DetermineWorkspace.Title=Looking for Possible TFVC Workspaces
Actions.Tfvc.ImportWorkspace.Title=Import TFVC Workspace
Tfvc.WorkspaceNotDetected=Workspace could not be determined from the current directory. Make sure you have the right directory selected and the right Visual Studio TF client configured.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE_NAME)
@NonNls
public static final String KEY_TFVC_ACTION_ADD_TO_TFIGNORE = "Tfvc.Action.AddToTfIgnore";
@NonNls
public static final String KEY_TFVC_DETERMINE_WORKSPACE_TITLE = "Actions.Tfvc.DetermineWorkspace.Title";
@NonNls
public static final String KEY_TFVC_IMPORT_WORKSPACE_TITLE = "Actions.Tfvc.ImportWorkspace.Title";
@NonNls
public static final String KEY_TFVC_REPOSITORY_IMPORT_ERROR = "Tfvc.RepositoryImportError";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.options.ShowSettingsUtil;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.progress.impl.ProgressManagerImpl;
import com.intellij.openapi.project.Project;
Expand Down Expand Up @@ -50,6 +51,7 @@
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.atomic.AtomicReference;

import static java.util.stream.Collectors.toList;

Expand Down Expand Up @@ -86,12 +88,19 @@ public void enable(@NotNull Collection<? extends VcsRoot> vcsRoots) {
return;
}

Path workspacePath = determineWorkspaceDirectory(Paths.get(basePath));
VirtualFile workspaceFile = ObjectUtils.notNull(
LocalFileSystem.getInstance().findFileByIoFile(workspacePath.toFile()));
AtomicReference<VirtualFile> workspaceFile = new AtomicReference<>();
ProgressManager.getInstance().run(new Task.Modal(myProject, TfPluginBundle.message(TfPluginBundle.KEY_TFVC_DETERMINE_WORKSPACE_TITLE), true) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
Path workspacePath = determineWorkspaceDirectory(Paths.get(basePath), indicator);
workspaceFile.set(ObjectUtils.notNull(
LocalFileSystem.getInstance().findFileByIoFile(workspacePath.toFile())));
indicator.checkCanceled();
}
});

if (initOrNotifyError(workspaceFile))
addVcsRoot(workspaceFile);
if (initOrNotifyError(workspaceFile.get()))
addVcsRoot(workspaceFile.get());
}

private void showVsAuthenticationErrorDialog(Path path) {
Expand All @@ -117,10 +126,12 @@ private CompletionStage<Workspace> getVsWorkspaceAsync(Path vsClient, Path path)
}

@NotNull
private Path determineWorkspaceDirectory(@NotNull Path projectBasePath) {
private Path determineWorkspaceDirectory(@NotNull Path projectBasePath, @NotNull ProgressIndicator indicator) {
Path vsClient = VisualStudioTfvcClient.getOrDetectPath(PropertyService.getInstance());
Path path = projectBasePath;
do {
indicator.checkCanceled();

Workspace workspace = null;
try {
ourLogger.info("Analyzing path \"" + path + "\" using TF Everywhere client");
Expand Down

0 comments on commit 1cdaf0a

Please sign in to comment.