Search in sources :

Example 6 with UIThreadUnsafe

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();
}
Also used : lombok.val(lombok.val) UIThreadUnsafe(com.virtuslab.qual.guieffect.UIThreadUnsafe)

Example 7 with UIThreadUnsafe

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();
}
Also used : lombok.val(lombok.val) Task(com.intellij.openapi.progress.Task) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) GitMacheteBundle.getString(com.virtuslab.gitmachete.frontend.resourcebundles.GitMacheteBundle.getString) UIThreadUnsafe(com.virtuslab.qual.guieffect.UIThreadUnsafe) UIEffect(org.checkerframework.checker.guieffect.qual.UIEffect)

Example 8 with UIThreadUnsafe

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();
    }
}
Also used : lombok.val(lombok.val) ActionUtils.getQuotedStringOrCurrent(com.virtuslab.gitmachete.frontend.actions.common.ActionUtils.getQuotedStringOrCurrent) IntelliJNotificationCompat(com.virtuslab.gitmachete.frontend.compat.IntelliJNotificationCompat) VirtualFile(com.intellij.openapi.vfs.VirtualFile) ModalityState(com.intellij.openapi.application.ModalityState) DeleteBranchOnSlideOutSuggestionDialog(com.virtuslab.gitmachete.frontend.actions.dialogs.DeleteBranchOnSlideOutSuggestionDialog) Presentation(com.intellij.openapi.actionSystem.Presentation) IManagedBranchSnapshot(com.virtuslab.gitmachete.backend.api.IManagedBranchSnapshot) IExpectsKeyGitMacheteRepository(com.virtuslab.gitmachete.frontend.actions.expectedkeys.IExpectsKeyGitMacheteRepository) Task(com.intellij.openapi.progress.Task) Option(io.vavr.control.Option) UIThreadUnsafe(com.virtuslab.qual.guieffect.UIThreadUnsafe) Project(com.intellij.openapi.project.Project) GitConfigUtil(git4idea.config.GitConfigUtil) BranchLayoutException(com.virtuslab.branchlayout.api.BranchLayoutException) VcsException(com.intellij.openapi.vcs.VcsException) GitRepository(git4idea.repo.GitRepository) Path(java.nio.file.Path) GitVfsUtils.getMacheteFilePath(com.virtuslab.gitmachete.frontend.vfsutils.GitVfsUtils.getMacheteFilePath) GitBrancher(git4idea.branch.GitBrancher) lombok.val(lombok.val) CustomLog(lombok.CustomLog) GitMacheteBundle.getString(com.virtuslab.gitmachete.frontend.resourcebundles.GitMacheteBundle.getString) UiThreadExecutionCompat(com.virtuslab.gitmachete.frontend.compat.UiThreadExecutionCompat) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) UIEffect(org.checkerframework.checker.guieffect.qual.UIEffect) GitMacheteBundle.format(com.virtuslab.gitmachete.frontend.resourcebundles.GitMacheteBundle.format) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) IEnhancedLambdaLogger(com.virtuslab.logger.IEnhancedLambdaLogger) Collections(java.util.Collections) UIThreadUnsafe(com.virtuslab.qual.guieffect.UIThreadUnsafe)

Example 9 with UIThreadUnsafe

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();
}
Also used : lombok.val(lombok.val) DeleteBranchOnSlideOutSuggestionDialog(com.virtuslab.gitmachete.frontend.actions.dialogs.DeleteBranchOnSlideOutSuggestionDialog) Task(com.intellij.openapi.progress.Task) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) UIThreadUnsafe(com.virtuslab.qual.guieffect.UIThreadUnsafe) UIEffect(org.checkerframework.checker.guieffect.qual.UIEffect)

Example 10 with UIThreadUnsafe

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");
    }
}
Also used : lombok.val(lombok.val) VcsException(com.intellij.openapi.vcs.VcsException) UIThreadUnsafe(com.virtuslab.qual.guieffect.UIThreadUnsafe)

Aggregations

UIThreadUnsafe (com.virtuslab.qual.guieffect.UIThreadUnsafe)27 lombok.val (lombok.val)25 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)8 Task (com.intellij.openapi.progress.Task)8 GitMacheteBundle.getString (com.virtuslab.gitmachete.frontend.resourcebundles.GitMacheteBundle.getString)8 UIEffect (org.checkerframework.checker.guieffect.qual.UIEffect)6 VcsException (com.intellij.openapi.vcs.VcsException)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 GitCoreException (com.virtuslab.gitcore.api.GitCoreException)3 GitMacheteException (com.virtuslab.gitmachete.backend.api.GitMacheteException)3 Nullable (org.checkerframework.checker.nullness.qual.Nullable)3 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)2 AccessToken (com.intellij.openapi.application.AccessToken)2 Project (com.intellij.openapi.project.Project)2 PsiFile (com.intellij.psi.PsiFile)2 IManagedBranchSnapshot (com.virtuslab.gitmachete.backend.api.IManagedBranchSnapshot)2 DeleteBranchOnSlideOutSuggestionDialog (com.virtuslab.gitmachete.frontend.actions.dialogs.DeleteBranchOnSlideOutSuggestionDialog)2 IExpectsKeyGitMacheteRepository (com.virtuslab.gitmachete.frontend.actions.expectedkeys.IExpectsKeyGitMacheteRepository)2 IEnhancedLambdaLogger (com.virtuslab.logger.IEnhancedLambdaLogger)2 GitRebaseParams (git4idea.branch.GitRebaseParams)2