Skip to content

Commit 67dcfc1

Browse files
authored
Merge pull request #8936 from mbien/fix-git-context-menu_delivery
Fixes git DeleteBranchAction activation logic.
2 parents fb18907 + 4a1086b commit 67dcfc1

File tree

3 files changed

+7
-23
lines changed

3 files changed

+7
-23
lines changed

ide/git/src/org/netbeans/modules/git/ui/branch/Bundle.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ LBL_DeleteBranchAction.progressName=Deleting Branch {0}
3232
LBL_DeleteBranchAction.notMerged=Branch Not Fully Merged
3333
MSG_DeleteBranchAction.notMerged=Branch {0} has not been fully merged yet.\n\
3434
Do you still want to delete the branch?
35+
MSG_DeleteBranchAction.noOtherBranches=Repository does not have any other branches
3536
LBL_DeleteBranchAction.confirmation=Delete Branch
36-
MSG_DeleteBranchAction.confirmation=Do you really want to delete branch {0}
37+
MSG_DeleteBranchAction.confirmation=Do you really want to delete branch {0}?
3738
CreateBranchPanel.cbCheckoutBranch.text=Check&out Created Branch
3839
CreateBranchPanel.cbCheckoutBranch.TTtext=Checkout the branch right after it is created
3940

ide/git/src/org/netbeans/modules/git/ui/branch/DeleteBranchAction.java

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import org.netbeans.modules.git.client.GitClientExceptionHandler;
2323
import java.io.File;
2424
import java.util.HashMap;
25-
import java.util.Map;
2625
import java.util.logging.Level;
2726
import java.util.logging.Logger;
2827
import org.netbeans.libs.git.GitBranch;
@@ -38,7 +37,6 @@
3837
import org.openide.NotifyDescriptor;
3938
import org.openide.awt.ActionID;
4039
import org.openide.awt.ActionRegistration;
41-
import org.openide.nodes.Node;
4240
import org.openide.util.NbBundle;
4341

4442
/**
@@ -58,6 +56,9 @@ protected void performAction(File repository, File[] roots, VCSContext context)
5856
branches.remove(info.getActiveBranch().getName());
5957

6058
if (branches.isEmpty()) {
59+
DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(
60+
NbBundle.getMessage(DeleteBranchAction.class, "MSG_DeleteBranchAction.noOtherBranches")
61+
));
6162
return;
6263
}
6364

@@ -67,23 +68,6 @@ protected void performAction(File repository, File[] roots, VCSContext context)
6768
}
6869
}
6970

70-
@Override
71-
protected boolean enable(Node[] activatedNodes) {
72-
if (!super.enable(activatedNodes)) {
73-
return false;
74-
}
75-
76-
// require 2+ branches
77-
Map.Entry<File, File[]> actionRoots = getActionRoots(getCurrentContext(activatedNodes));
78-
if (actionRoots != null) {
79-
RepositoryInfo info = RepositoryInfo.getInstance(actionRoots.getKey());
80-
81-
return info != null && info.getBranches().size() > 1;
82-
}
83-
84-
return false;
85-
}
86-
8771
public void deleteBranch(final File repository, final String branchName) {
8872
NotifyDescriptor nd = new NotifyDescriptor.Confirmation(NbBundle.getMessage(DeleteBranchAction.class, "MSG_DeleteBranchAction.confirmation", branchName), //NOI18N
8973
NbBundle.getMessage(DeleteBranchAction.class, "LBL_DeleteBranchAction.confirmation"), //NOI18N

ide/git/src/org/netbeans/modules/git/utils/GitUtils.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -417,9 +417,8 @@ public static Set<File> getRepositoryRoots (Collection<File> roots) {
417417
}
418418

419419
/**
420-
*
421-
* @param ctx
422-
* @return
420+
* Returns the repository and its roots. May open a selection dialog if
421+
* there is more than one repository in the provided context.
423422
*/
424423
public static HashMap.SimpleImmutableEntry<File, File[]> getActionRoots(VCSContext ctx) {
425424
Set<File> rootsSet = ctx.getRootFiles();

0 commit comments

Comments
 (0)