From d94684dfa0313def9a9b5afdefc0b5e3af6e6350 Mon Sep 17 00:00:00 2001 From: Jens Baumgart Date: Mon, 26 Apr 2010 16:55:58 +0200 Subject: [PATCH] Fix selection handling in AbstractOperationAction Team actions based on AbstractOperationAction were disabled in the Java edtior due to wrong selection handling. The selection is now retrieved in selectionChanged. The operation is now created in the run method. Change-Id: Ia0c961c3f8adde2877d962ee1ff1f6de97776faf Bug: 310440 Signed-off-by: Jens Baumgart Signed-off-by: Chris Aniszczyk --- .../ui/internal/actions/AbstractOperationAction.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/AbstractOperationAction.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/AbstractOperationAction.java index 269dfb40..00b2deca 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/AbstractOperationAction.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/AbstractOperationAction.java @@ -40,21 +40,18 @@ public abstract class AbstractOperationAction implements IObjectActionDelegate { private IWorkspaceRunnable op; - public void selectionChanged(final IAction act, final ISelection sel) { - // work performed in setActivePart - } + private List selection; - public void setActivePart(final IAction act, final IWorkbenchPart part) { - wp = part; - ISelection sel = part.getSite().getPage().getSelection(); - final List selection; + public void selectionChanged(final IAction act, final ISelection sel) { if (sel instanceof IStructuredSelection && !sel.isEmpty()) { selection = ((IStructuredSelection) sel).toList(); } else { selection = Collections.EMPTY_LIST; } - op = createOperation(selection); - act.setEnabled(op != null && wp != null); + } + + public void setActivePart(final IAction act, final IWorkbenchPart part) { + wp = part; } /** @@ -73,6 +70,7 @@ public abstract class AbstractOperationAction implements IObjectActionDelegate { } public void run(final IAction act) { + op = createOperation(selection); if (op != null) { try { try { @@ -101,7 +99,6 @@ public abstract class AbstractOperationAction implements IObjectActionDelegate { if (e instanceof CoreException) { status = ((CoreException) e).getStatus(); - e = status.getException(); } else { status = new Status(IStatus.ERROR, Activator.getPluginId(), 1, msg, e); -- 2.11.4.GIT