use of com.virtuslab.qual.guieffect.UIThreadUnsafe in project git-machete-intellij-plugin by VirtusLab.
the class BaseOverrideForkPointAction method overrideForkPoint.
@UIThreadUnsafe
private void overrideForkPoint(AnActionEvent anActionEvent, IManagedBranchSnapshot branch, ICommitOfManagedBranch forkPoint) {
val gitRepository = getSelectedGitRepository(anActionEvent);
if (gitRepository.isDefined()) {
val root = gitRepository.get().getRoot();
val project = getProject(anActionEvent);
setOverrideForkPointConfigValues(project, root, branch.getName(), forkPoint, branch.getPointedCommit());
}
getGraphTable(anActionEvent).queueRepositoryUpdateAndModelRefresh();
}
use of com.virtuslab.qual.guieffect.UIThreadUnsafe in project git-machete-intellij-plugin by VirtusLab.
the class BaseSlideOutBranchAction method doSlideOut.
@UIEffect
private void doSlideOut(AnActionEvent anActionEvent, IManagedBranchSnapshot branchToSlideOut) {
LOG.debug(() -> "Entering: branchToSlideOut = ${branchToSlideOut}");
String branchName = branchToSlideOut.getName();
val project = getProject(anActionEvent);
LOG.debug("Refreshing repository state");
new Task.Backgroundable(project, "Deleting branch if required...") {
@Override
@UIThreadUnsafe
public void run(ProgressIndicator indicator) {
deleteBranchIfRequired(anActionEvent, branchName);
}
}.queue();
}
use of com.virtuslab.qual.guieffect.UIThreadUnsafe in project git-machete-intellij-plugin by VirtusLab.
the class BaseSlideOutBranchAction method deleteBranchIfRequired.
@UIThreadUnsafe
private void deleteBranchIfRequired(AnActionEvent anActionEvent, String branchName) {
val gitRepository = getSelectedGitRepository(anActionEvent).getOrNull();
val project = getProject(anActionEvent);
val slidOutBranchIsCurrent = getCurrentBranchNameIfManaged(anActionEvent).map(b -> b.equals(branchName)).getOrElse(false);
if (slidOutBranchIsCurrent) {
LOG.debug("Skipping (optional) local branch deletion because it is equal to current branch");
slideOutBranch(anActionEvent, branchName);
getGraphTable(anActionEvent).queueRepositoryUpdateAndModelRefresh();
IntelliJNotificationCompat.notifySuccess(project, /* title */
"", format(getString("action.GitMachete.BaseSlideOutBranchAction.notification.title.slide-out-success.of-current"), branchName));
} else if (gitRepository != null) {
val root = gitRepository.getRoot();
val configValueOption = getDeleteLocalBranchOnSlideOutGitConfigValue(project, root);
if (configValueOption.isEmpty()) {
UiThreadExecutionCompat.invokeLaterIfNeeded(ModalityState.NON_MODAL, () -> suggestBranchDeletion(anActionEvent, branchName, gitRepository, project));
} else if (configValueOption.isDefined()) {
val shouldDelete = configValueOption.get();
handleBranchDeletionDecision(project, branchName, gitRepository, anActionEvent, shouldDelete);
}
} else {
getGraphTable(anActionEvent).queueRepositoryUpdateAndModelRefresh();
}
}
use of com.virtuslab.qual.guieffect.UIThreadUnsafe in project git-machete-intellij-plugin by VirtusLab.
the class BaseSlideOutBranchAction method suggestBranchDeletion.
@UIEffect
private void suggestBranchDeletion(AnActionEvent anActionEvent, String branchName, GitRepository gitRepository, Project project) {
val slideOutOptions = new DeleteBranchOnSlideOutSuggestionDialog(project).showAndGetSlideOutOptions();
new Task.Backgroundable(project, "Deleting branch if required...") {
@Override
@UIThreadUnsafe
public void run(ProgressIndicator indicator) {
if (slideOutOptions != null) {
handleBranchDeletionDecision(project, branchName, gitRepository, anActionEvent, slideOutOptions.shouldDelete());
if (slideOutOptions.shouldRemember()) {
val value = String.valueOf(slideOutOptions.shouldDelete());
setDeleteLocalBranchOnSlideOutGitConfigValue(project, gitRepository.getRoot(), value);
}
} else {
val title = getString("action.GitMachete.BaseSlideOutBranchAction.notification.title.slide-out-info.canceled");
val message = format(getString("action.GitMachete.BaseSlideOutBranchAction.notification.message.slide-out-info.canceled"), branchName);
IntelliJNotificationCompat.notifyInfo(project, title, message);
}
}
}.queue();
}
use of com.virtuslab.qual.guieffect.UIThreadUnsafe in project git-machete-intellij-plugin by VirtusLab.
the class BaseSlideOutBranchAction method setDeleteLocalBranchOnSlideOutGitConfigValue.
@UIThreadUnsafe
private void setDeleteLocalBranchOnSlideOutGitConfigValue(Project project, VirtualFile root, String value) {
try {
val additionalParameters = "--local";
GitConfigUtil.setValue(project, root, DELETE_LOCAL_BRANCH_ON_SLIDE_OUT_GIT_CONFIG_KEY, value, additionalParameters);
} catch (VcsException e) {
LOG.error("Attempt to set '${DELETE_LOCAL_BRANCH_ON_SLIDE_OUT_GIT_CONFIG_KEY}' git config value failed");
}
}
Aggregations