aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrançois Rey2012-12-04 15:57:10 (EST)
committerRobin Stocker2012-12-04 16:37:16 (EST)
commitc0bcaa97ea698ca800746ba43fdbf369f9079d42 (patch)
tree13182fb16ebe90f29c13ca1cd8bad366fda96805
parentf3559d8ecb63494119748f95b3f5b6488cec3853 (diff)
downloadegit-c0bcaa97ea698ca800746ba43fdbf369f9079d42.zip
egit-c0bcaa97ea698ca800746ba43fdbf369f9079d42.tar.gz
egit-c0bcaa97ea698ca800746ba43fdbf369f9079d42.tar.bz2
Refactor RepositoryActionHandler to use AdapterUtilsrefs/changes/24/9024/2
Change-Id: I9ace3e73f32c1d7c19d9ceb8495ac4069bf9bb48 Signed-off-by: François Rey <eclipse.org@francois.rey.name> Signed-off-by: Robin Stocker <robin@nibor.org>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/RepositoryActionHandler.java20
1 files changed, 4 insertions, 16 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/RepositoryActionHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/RepositoryActionHandler.java
index ca469f7..6fe0ab5 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/RepositoryActionHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/RepositoryActionHandler.java
@@ -5,6 +5,7 @@
* Copyright (C) 2010, Mathias Kinzler <mathias.kinzler@sap.com>
* Copyright (C) 2011, Dariusz Luksza <dariusz@luksza.org>
* Copyright (C) 2012, Robin Stocker <robin@nibor.org>
+ * Copyright (C) 2012, François Rey <eclipse.org_@_francois_._rey_._name>
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -33,7 +34,6 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.core.resources.mapping.ResourceTraversal;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.PlatformObject;
import org.eclipse.egit.core.AdapterUtils;
@@ -454,7 +454,7 @@ abstract class RepositoryActionHandler extends AbstractHandler {
result = new ArrayList();
Iterator elements = ((IStructuredSelection) selection).iterator();
while (elements.hasNext()) {
- Object adapter = getAdapter(elements.next(), c);
+ Object adapter = AdapterUtils.adapt(elements.next(), c);
if (c.isInstance(adapter))
result.add(adapter);
}
@@ -465,18 +465,6 @@ abstract class RepositoryActionHandler extends AbstractHandler {
return (Object[]) Array.newInstance(c, 0);
}
- private Object getAdapter(Object adaptable, Class c) {
- if (c.isInstance(adaptable))
- return adaptable;
- if (adaptable instanceof IAdaptable) {
- IAdaptable a = (IAdaptable) adaptable;
- Object adapter = a.getAdapter(c);
- if (c.isInstance(adapter))
- return adapter;
- }
- return null;
- }
-
/**
* @param event
* @return the resources in the selection
@@ -509,7 +497,7 @@ abstract class RepositoryActionHandler extends AbstractHandler {
private IResource[] getSelectedResources(IStructuredSelection selection) {
Set<IResource> result = new LinkedHashSet<IResource>();
for (Object o : selection.toList()) {
- IResource resource = (IResource) getAdapter(o, IResource.class);
+ IResource resource = AdapterUtils.adapt(o, IResource.class);
if (resource != null)
result.add(resource);
else
@@ -542,7 +530,7 @@ abstract class RepositoryActionHandler extends AbstractHandler {
}
private List<IResource> extractResourcesFromMapping(Object o) {
- ResourceMapping mapping = (ResourceMapping) getAdapter(o,
+ ResourceMapping mapping = AdapterUtils.adapt(o,
ResourceMapping.class);
if (mapping != null) {
ResourceTraversal[] traversals;