aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Muskalla2010-07-02 12:17:58 (EDT)
committerChris Aniszczyk2010-07-06 10:56:36 (EDT)
commite2d8180a27f4b2abdada59128735f12ce4726772 (patch)
treec22dc3355a614548be57d6b0ee38e4034e0411e1
parent27dad6fccaa2da26f95725bba11607f0a11476b8 (diff)
downloadegit-e2d8180a27f4b2abdada59128735f12ce4726772.zip
egit-e2d8180a27f4b2abdada59128735f12ce4726772.tar.gz
egit-e2d8180a27f4b2abdada59128735f12ce4726772.tar.bz2
CCE when deleting branch and cleaned RepositoryViewCommandHandlerrefs/changes/21/1021/4
Introduced getShell on RepositoryViewCommandHandler to easily retrvieve the active Shell. This is used in almost all commands and we can get rid of the getView().getSite().getShell() chain. In addition, the RepositoryViewCommandHandler now uses HandlerUtil to obtain the context variables and propagates possible exceptions to the callers. Bug: 318436 Change-Id: Ie0ef459a857d42aa6f0d1cded51ef27eee7a5494 Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/AddCommand.java4
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/CloneCommand.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/ConfigureFetchCommand.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/ConfigurePushCommand.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/ConfigureRemoteCommand.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/CreateBranchCommand.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/CreateTagCommand.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/DeleteBranchCommand.java6
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/FetchCommand.java4
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/FetchConfiguredRemoteCommand.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/ImportProjectsCommand.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/MergeCommand.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/PasteCommand.java3
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/PushCommand.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/PushConfiguredRemoteCommand.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RemoveCommand.java29
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RemoveRemoteCommand.java6
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RepositoriesViewCommandHandler.java20
18 files changed, 55 insertions, 39 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/AddCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/AddCommand.java
index 768a1b3..8016267 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/AddCommand.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/AddCommand.java
@@ -24,8 +24,8 @@ import org.eclipse.jface.window.Window;
public class AddCommand extends
RepositoriesViewCommandHandler<RepositoryTreeNode> {
public Object execute(ExecutionEvent event) throws ExecutionException {
- RepositorySearchDialog sd = new RepositorySearchDialog(getView(event)
- .getSite().getShell(), util.getConfiguredRepositories());
+ RepositorySearchDialog sd = new RepositorySearchDialog(getShell(event),
+ util.getConfiguredRepositories());
if (sd.open() == Window.OK)
for (String dir : sd.getDirectories())
util.addConfiguredRepository(new File(dir));
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/CloneCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/CloneCommand.java
index 63bb3eb..9c9af89 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/CloneCommand.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/CloneCommand.java
@@ -23,7 +23,7 @@ public class CloneCommand extends
RepositoriesViewCommandHandler<RepositoryTreeNode> {
public Object execute(ExecutionEvent event) throws ExecutionException {
WizardDialog dlg = new WizardDialog(
- getView(event).getSite().getShell(), new GitCloneWizard());
+ getShell(event), new GitCloneWizard());
dlg.open();
return null;
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/ConfigureFetchCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/ConfigureFetchCommand.java
index b5ad394..b166913 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/ConfigureFetchCommand.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/ConfigureFetchCommand.java
@@ -35,7 +35,7 @@ public class ConfigureFetchCommand extends
return null;
WizardDialog dlg = new WizardDialog(
- getView(event).getSite().getShell(), new ConfigureRemoteWizard(
+ getShell(event), new ConfigureRemoteWizard(
selectedNode.getRepository(), configName, false));
dlg.open();
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/ConfigurePushCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/ConfigurePushCommand.java
index e31a932..46361b6 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/ConfigurePushCommand.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/ConfigurePushCommand.java
@@ -35,7 +35,7 @@ public class ConfigurePushCommand extends
return null;
WizardDialog dlg = new WizardDialog(
- getView(event).getSite().getShell(), new ConfigureRemoteWizard(
+ getShell(event), new ConfigureRemoteWizard(
selectedNode.getRepository(), configName, true));
dlg.open();
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/ConfigureRemoteCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/ConfigureRemoteCommand.java
index 78440b4..1eb0b40 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/ConfigureRemoteCommand.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/ConfigureRemoteCommand.java
@@ -25,7 +25,7 @@ public class ConfigureRemoteCommand extends
RemotesNode node = getSelectedNodes(event).get(0);
WizardDialog dlg = new WizardDialog(
- getView(event).getSite().getShell(), new NewRemoteWizard(node
+ getShell(event), new NewRemoteWizard(node
.getRepository()));
dlg.open();
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/CreateBranchCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/CreateBranchCommand.java
index 72c157f..6bb6108 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/CreateBranchCommand.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/CreateBranchCommand.java
@@ -115,7 +115,7 @@ public class CreateBranchCommand extends
return true;
}
};
- new WizardDialog(getView(event).getSite().getShell(), wiz).open();
+ new WizardDialog(getShell(event), wiz).open();
return null;
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/CreateTagCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/CreateTagCommand.java
index 5905b65..a9ed38f 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/CreateTagCommand.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/CreateTagCommand.java
@@ -53,7 +53,7 @@ public class CreateTagCommand extends RepositoriesViewCommandHandler<RepositoryT
final Repository repo = node.getRepository();
if (!repo.getRepositoryState().canCheckout()) {
- MessageDialog.openError(getView(event).getSite().getShell(),
+ MessageDialog.openError(getShell(event),
UIText.TagAction_cannotCheckout, NLS.bind(
UIText.TagAction_repositoryState, repo
.getRepositoryState().getDescription()));
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/DeleteBranchCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/DeleteBranchCommand.java
index 6291368..6919d91 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/DeleteBranchCommand.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/DeleteBranchCommand.java
@@ -25,6 +25,7 @@ import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.RefUpdate;
import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Shell;
/**
* Deletes a branch.
@@ -40,14 +41,15 @@ public class DeleteBranchCommand extends
final RefNode node = getSelectedNodes(event).get(0);
final Ref ref = node.getObject();
- if (!MessageDialog.openConfirm(getView(event).getSite().getShell(),
+ Shell shell = getShell(event);
+ if (!MessageDialog.openConfirm(shell,
UIText.RepositoriesView_ConfirmDeleteTitle, NLS.bind(
UIText.RepositoriesView_ConfirmBranchDeletionMessage,
ref.getName())))
return null;
try {
- new ProgressMonitorDialog(getView(event).getSite().getShell()).run(
+ new ProgressMonitorDialog(shell).run(
false, false, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor)
throws InvocationTargetException,
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/FetchCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/FetchCommand.java
index a3ec5fa..ca9473c 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/FetchCommand.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/FetchCommand.java
@@ -28,8 +28,8 @@ public class FetchCommand extends
RepositoryNode node = getSelectedNodes(event).get(0);
try {
- new WizardDialog(getView(event).getSite().getShell(),
- new FetchWizard(node.getRepository())).open();
+ new WizardDialog(getShell(event), new FetchWizard(
+ node.getRepository())).open();
} catch (URISyntaxException e1) {
Activator.handleError(e1.getMessage(), e1, true);
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/FetchConfiguredRemoteCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/FetchConfiguredRemoteCommand.java
index f33e67f..abc857e 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/FetchConfiguredRemoteCommand.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/FetchConfiguredRemoteCommand.java
@@ -26,7 +26,7 @@ public class FetchConfiguredRemoteCommand extends
RemoteNode remote = (RemoteNode) node.getParent();
new FetchConfiguredRemoteAction(node.getRepository(), remote
- .getObject()).run(getView(event).getSite().getShell());
+ .getObject()).run(getShell(event));
return null;
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/ImportProjectsCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/ImportProjectsCommand.java
index d60608d..c4f0ab7 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/ImportProjectsCommand.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/ImportProjectsCommand.java
@@ -40,7 +40,7 @@ public class ImportProjectsCommand extends
}
WizardDialog dlg = new WizardDialog(
- getView(event).getSite().getShell(),
+ getShell(event),
new GitCreateProjectViaWizardWizard(node.getRepository(), path));
dlg.open();
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/MergeCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/MergeCommand.java
index 2ebdea4..569f57f 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/MergeCommand.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/MergeCommand.java
@@ -73,7 +73,7 @@ public class MergeCommand extends
refName = targetRef;
else {
MergeTargetSelectionDialog mergeTargetSelectionDialog = new MergeTargetSelectionDialog(
- getView(event).getSite().getShell(), repository);
+ getShell(event), repository);
if (mergeTargetSelectionDialog.open() == IDialogConstants.OK_ID) {
refName = mergeTargetSelectionDialog.getRefName();
} else {
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/PasteCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/PasteCommand.java
index 3e3ff38..d4ae6ad 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/PasteCommand.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/PasteCommand.java
@@ -43,8 +43,7 @@ public class PasteCommand extends
Clipboard clip = null;
try {
- clip = new Clipboard(getView(event).getSite().getShell()
- .getDisplay());
+ clip = new Clipboard(getShell(event).getDisplay());
String content = (String) clip.getContents(TextTransfer
.getInstance());
if (content == null) {
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/PushCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/PushCommand.java
index 840d5e5..7dafad2 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/PushCommand.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/PushCommand.java
@@ -27,7 +27,7 @@ public class PushCommand extends RepositoriesViewCommandHandler<RepositoryNode>
RepositoryNode node = getSelectedNodes(event).get(0);
try {
- new WizardDialog(getView(event).getSite().getShell(),
+ new WizardDialog(getShell(event),
new PushWizard(node.getRepository())).open();
} catch (URISyntaxException e1) {
Activator.handleError(e1.getMessage(), e1, true);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/PushConfiguredRemoteCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/PushConfiguredRemoteCommand.java
index 2fad281..799a07a 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/PushConfiguredRemoteCommand.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/PushConfiguredRemoteCommand.java
@@ -26,7 +26,7 @@ public class PushConfiguredRemoteCommand extends
RemoteNode remote = (RemoteNode) node.getParent();
new PushConfiguredRemoteAction(node.getRepository(), remote.getObject())
- .run(getView(event).getSite().getShell(), false);
+ .run(getShell(event), false);
return null;
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RemoveCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RemoveCommand.java
index 4cf74ae..3b21851 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RemoveCommand.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RemoveCommand.java
@@ -31,11 +31,14 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.UIText;
+import org.eclipse.egit.ui.internal.repository.RepositoriesView;
import org.eclipse.egit.ui.internal.repository.tree.RepositoryNode;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
/**
@@ -44,8 +47,8 @@ import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
public class RemoveCommand extends
RepositoriesViewCommandHandler<RepositoryNode> implements IHandler {
public Object execute(final ExecutionEvent event) throws ExecutionException {
- IWorkbenchSiteProgressService service = (IWorkbenchSiteProgressService) getView(
- event).getSite()
+ IWorkbenchSite activeSite = HandlerUtil.getActiveSite(event);
+ IWorkbenchSiteProgressService service = (IWorkbenchSiteProgressService) activeSite
.getService(IWorkbenchSiteProgressService.class);
Job job = new Job("Remove Repositories Job") { //$NON-NLS-1$
@@ -57,7 +60,14 @@ public class RemoveCommand extends
monitor
.setTaskName(UIText.RepositoriesView_DeleteRepoDeterminProjectsMessage);
- for (RepositoryNode node : getSelectedNodes(event)) {
+ List<RepositoryNode> selectedNodes;
+ try {
+ selectedNodes = getSelectedNodes(event);
+ } catch (ExecutionException e) {
+ Activator.logError(e.getMessage(), e);
+ return new Status(IStatus.ERROR, Activator.getPluginId(), e.getMessage(), e);
+ }
+ for (RepositoryNode node : selectedNodes) {
if (node.getRepository().isBare())
continue;
File workDir = node.getRepository().getWorkDir();
@@ -112,12 +122,18 @@ public class RemoveCommand extends
Activator.logError(e1.getMessage(), e1);
}
}
- for (RepositoryNode node : getSelectedNodes(event)) {
+ for (RepositoryNode node : selectedNodes) {
util.removeDir(node.getRepository().getDirectory());
}
Display.getDefault().asyncExec(new Runnable() {
public void run() {
- getView(event).getCommonViewer().refresh();
+ RepositoriesView view;
+ try {
+ view = getView(event);
+ view.getCommonViewer().refresh();
+ } catch (ExecutionException e) {
+ Activator.logError(e.getMessage(), e);
+ }
}
});
@@ -137,8 +153,7 @@ public class RemoveCommand extends
String message = NLS.bind(
UIText.RepositoriesView_ConfirmProjectDeletion_Question,
projectsToDelete.size());
- MessageDialog dlg = new MessageDialog(getView(event).getSite()
- .getShell(),
+ MessageDialog dlg = new MessageDialog(getShell(event),
UIText.RepositoriesView_ConfirmProjectDeletion_WindowTitle,
null, message, MessageDialog.INFORMATION, new String[] {
IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RemoveRemoteCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RemoveRemoteCommand.java
index 15c5ddf..ba34bac 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RemoveRemoteCommand.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RemoveRemoteCommand.java
@@ -31,9 +31,9 @@ public class RemoveRemoteCommand extends
final RemoteNode node = getSelectedNodes(event).get(0);
final String configName = node.getObject();
- boolean ok = MessageDialog.openConfirm(getView(event).getSite()
- .getShell(), UIText.RepositoriesView_ConfirmDeleteRemoteHeader,
- NLS.bind(UIText.RepositoriesView_ConfirmDeleteRemoteMessage,
+ boolean ok = MessageDialog.openConfirm(getShell(event),
+ UIText.RepositoriesView_ConfirmDeleteRemoteHeader, NLS.bind(
+ UIText.RepositoriesView_ConfirmDeleteRemoteMessage,
configName));
if (ok) {
RepositoryConfig config = node.getRepository().getConfig();
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RepositoriesViewCommandHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RepositoriesViewCommandHandler.java
index 4e9dd4c..26345c5 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RepositoriesViewCommandHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RepositoriesViewCommandHandler.java
@@ -15,12 +15,12 @@ import java.util.List;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.RepositoryUtil;
import org.eclipse.egit.ui.internal.repository.RepositoriesView;
-import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.handlers.HandlerUtil;
abstract class RepositoriesViewCommandHandler<T> extends AbstractHandler {
@@ -28,18 +28,18 @@ abstract class RepositoriesViewCommandHandler<T> extends AbstractHandler {
protected final RepositoryUtil util = Activator.getDefault()
.getRepositoryUtil();
- public RepositoriesView getView(ExecutionEvent event) {
- // TODO replace with HandlerUtil checked call when unifying command handling
- Object part = ((IEvaluationContext) event.getApplicationContext())
- .getRoot().getVariable("activePart"); //$NON-NLS-1$ TODO constant for this?
+ public RepositoriesView getView(ExecutionEvent event) throws ExecutionException {
+ IWorkbenchPart part = HandlerUtil.getActivePartChecked(event);
return (RepositoriesView) part;
}
+ public Shell getShell(ExecutionEvent event) {
+ return HandlerUtil.getActiveShell(event);
+ }
+
@SuppressWarnings("unchecked")
- public List<T> getSelectedNodes(ExecutionEvent event) {
- // TODO replace with HandlerUtil checked call when unifying command handling
- TreeSelection selection = (TreeSelection) ((IEvaluationContext) event
- .getApplicationContext()).getRoot().getVariable("selection"); //$NON-NLS-1$ TODO constant for this?
+ public List<T> getSelectedNodes(ExecutionEvent event) throws ExecutionException {
+ IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelectionChecked(event);
return selection.toList();
}