use of org.jetbrains.idea.svn.dialogs.ShareDialog in project intellij-community by JetBrains.
the class ShareProjectAction method performImpl.
private static boolean performImpl(@NotNull SvnVcs vcs, @NotNull VirtualFile file) throws VcsException {
ShareDialog shareDialog = new ShareDialog(vcs.getProject(), file.getName());
shareDialog.show();
String parent = shareDialog.getSelectedURL();
if (shareDialog.isOK() && parent != null) {
Ref<Boolean> actionStarted = new Ref<>(Boolean.TRUE);
Exception[] error = new Exception[1];
ShareDialog.ShareTarget shareTarget = shareDialog.getShareTarget();
if (ShareDialog.ShareTarget.useSelected.equals(shareTarget) && !isFolderEmpty(vcs, parent) && YES != showYesNoDialog(vcs.getProject(), "Remote folder \"" + parent + "\" is not empty.\nDo you want to continue sharing?", "Share Directory", getWarningIcon())) {
return false;
}
WorkingCopyFormat format = SvnCheckoutProvider.promptForWCopyFormat(virtualToIoFile(file), vcs.getProject());
actionStarted.set(format != WorkingCopyFormat.UNKNOWN);
// means operation cancelled
if (format == WorkingCopyFormat.UNKNOWN) {
return true;
}
ExclusiveBackgroundVcsAction.run(vcs.getProject(), () -> ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
try {
SvnWorkingCopyFormatHolder.setPresetFormat(format);
SvnTarget checkoutTarget = createFolderStructure(vcs, file, shareTarget, shareDialog.createStandardStructure(), createUrl(parent), shareDialog.getCommitText());
progress(message("share.directory.checkout.back.progress.text", checkoutTarget.getPathOrUrlString()));
ClientFactory factory = SvnCheckoutProvider.getFactory(vcs, format);
factory.createCheckoutClient().checkout(SvnTarget.fromURL(checkoutTarget.getURL()), virtualToIoFile(file), checkoutTarget.getPegRevision(), Depth.INFINITY, false, false, format, null);
addRecursively(vcs, factory, file);
} catch (VcsException e) {
error[0] = e;
} finally {
vcs.invokeRefreshSvnRoots();
SvnWorkingCopyFormatHolder.setPresetFormat(null);
}
}, message("share.directory.title"), true, vcs.getProject()));
if (Boolean.TRUE.equals(actionStarted.get())) {
if (error[0] != null) {
throw new VcsException(error[0].getMessage());
}
showInfoMessage(vcs.getProject(), message("share.directory.info.message", file.getName()), message("share.directory.title"));
}
return true;
}
return false;
}
Aggregations