Skip to content

Commit

Permalink
EXM-53634: changed to info message + reused code
Browse files Browse the repository at this point in the history
  • Loading branch information
sorincarbunaru committed Sep 30, 2024
1 parent 9120687 commit 4d7dd63
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions src/main/java/com/oxygenxml/git/OutdatedBranchChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,10 @@ private static synchronized void checkForOutdatedBranches() {

SwingUtilities.invokeLater(() -> {
if (branchesAndTooltips.containsKey(currentBranchName) && branchesAndTooltips.size() == 1) {
MessagePresenterProvider.getBuilder(i18n.getTranslation(Tags.OUTDATED_BRANCHES_DETECTED), DialogType.INFO)
.setMessage(
MessageFormat.format(i18n.getTranslation(Tags.OUTDATED_CURRENT_BRANCH), currentBranchName)
+ "\n\n"
+ MessageFormat.format(i18n.getTranslation(Tags.STASH_IMPORTANT_CHANGES), currentBranchName))
.setOkButtonVisible(false)
.setCancelButtonName(i18n.getTranslation(Tags.CLOSE))
.buildAndShow();
showCurrentBranchRelatedMessage(
MessageFormat.format(i18n.getTranslation(Tags.OUTDATED_CURRENT_BRANCH), currentBranchName)
+ "\n\n"
+ MessageFormat.format(i18n.getTranslation(Tags.STASH_IMPORTANT_CHANGES), currentBranchName));
} else {
showOutdatedBranchesDialog(branchesAndTooltips, currentBranchName);
}
Expand Down Expand Up @@ -209,15 +205,24 @@ private static void tryDeleteBranches(
GitOperationScheduler.getInstance().schedule(deleteBranchesTask);

if (shouldDeleteCurrentBranch) {
MessagePresenterProvider.getBuilder(i18n.getTranslation(Tags.OUTDATED_BRANCHES_DETECTED), DialogType.ERROR)
.setMessage(
MessageFormat.format(i18n.getTranslation(Tags.CANNOT_DELETE_CURRENT_BRANCH), currentBranchName)
+ "\n\n"
+ MessageFormat.format(i18n.getTranslation(Tags.STASH_IMPORTANT_CHANGES), currentBranchName))
.setOkButtonVisible(false)
.setCancelButtonName(i18n.getTranslation(Tags.CLOSE))
.buildAndShow();
showCurrentBranchRelatedMessage(
MessageFormat.format(i18n.getTranslation(Tags.CANNOT_DELETE_CURRENT_BRANCH), currentBranchName)
+ "\n\n"
+ MessageFormat.format(i18n.getTranslation(Tags.STASH_IMPORTANT_CHANGES), currentBranchName));
}
}

/**
* Show a message related to the fact than the current branch cannot be deleted.
*
* @param message The message to show.
*/
private static void showCurrentBranchRelatedMessage(String message) {
MessagePresenterProvider.getBuilder(i18n.getTranslation(Tags.OUTDATED_BRANCHES_DETECTED), DialogType.INFO)
.setMessage(message)
.setOkButtonVisible(false)
.setCancelButtonName(i18n.getTranslation(Tags.CLOSE))
.buildAndShow();
}

}

0 comments on commit 4d7dd63

Please sign in to comment.