Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2016-04-01 00:25:48 +0000
committerSergey Prigogin2016-04-01 00:25:48 +0000
commitc2ddef86459fa7c27108248a6b5b0daa33c9ae75 (patch)
tree72020cfd72a497e06e4a704973af6358cb789894 /bundles/org.eclipse.team.ui
parent7d0b201368e91209b32a427f1467277d69b65e7f (diff)
downloadeclipse.platform.team-c2ddef86459fa7c27108248a6b5b0daa33c9ae75.tar.gz
eclipse.platform.team-c2ddef86459fa7c27108248a6b5b0daa33c9ae75.tar.xz
eclipse.platform.team-c2ddef86459fa7c27108248a6b5b0daa33c9ae75.zip
Bug 490832 - Remove Utils.getAdapter(Object, Class, boolean) in favor of
Diffstat (limited to 'bundles/org.eclipse.team.ui')
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java24
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryView.java5
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/WorkspaceTeamStateProvider.java9
3 files changed, 8 insertions, 30 deletions
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java
index dd7df1675..84a48abd8 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java
@@ -669,28 +669,8 @@ public class Utils {
return getResources(elements, null, true /* isContributed */, true /* isIncudeMappings */);
}
- public static Object getAdapter(Object element, Class adapterType, boolean load) {
- if (adapterType.isInstance(element))
- return element;
- if (element instanceof IAdaptable) {
- Object adapted = ((IAdaptable) element).getAdapter(adapterType);
- if (adapterType.isInstance(adapted))
- return adapted;
- }
- if (load) {
- Object adapted = Platform.getAdapterManager().loadAdapter(element, adapterType.getName());
- if (adapterType.isInstance(adapted))
- return adapted;
- } else {
- Object adapted = Platform.getAdapterManager().getAdapter(element, adapterType);
- if (adapterType.isInstance(adapted))
- return adapted;
- }
- return null;
- }
-
- public static Object getAdapter(Object element, Class adapterType) {
- return getAdapter(element, adapterType, false);
+ public static <T> T getAdapter(Object element, Class<T> adapterType) {
+ return Adapters.adapt(element, adapterType, false);
}
/**
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryView.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryView.java
index 68855930b..802b2cb76 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryView.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryView.java
@@ -15,6 +15,7 @@ import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.jface.action.*;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
@@ -594,11 +595,11 @@ public class GenericHistoryView extends PageBookView implements IHistoryView, IP
} else {
IFileHistoryProvider fileHistory = teamProvider.getFileHistoryProvider();
if (fileHistory != null) {
- IHistoryPageSource source = (IHistoryPageSource)Utils.getAdapter(fileHistory, IHistoryPageSource.class,true);
+ IHistoryPageSource source = Adapters.adapt(fileHistory, IHistoryPageSource.class);
if (source != null)
return source;
}
- return (IHistoryPageSource)Utils.getAdapter(teamProvider, IHistoryPageSource.class,true);
+ return Adapters.adapt(teamProvider, IHistoryPageSource.class);
}
}
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/WorkspaceTeamStateProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/WorkspaceTeamStateProvider.java
index 8608d419c..1f68671f5 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/WorkspaceTeamStateProvider.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/WorkspaceTeamStateProvider.java
@@ -16,8 +16,7 @@ import java.util.Map;
import org.eclipse.core.resources.*;
import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.core.resources.mapping.ResourceMappingContext;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.*;
import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.team.core.RepositoryProviderType;
import org.eclipse.team.internal.core.*;
@@ -119,16 +118,14 @@ public class WorkspaceTeamStateProvider extends TeamStateProvider
private ITeamStateProvider getDecoratedStateProvider(Object element) {
RepositoryProviderType type = getProviderType(element);
if (type != null)
- return (ITeamStateProvider) Utils.getAdapter(type,
- ITeamStateProvider.class);
+ return Utils.getAdapter(type, ITeamStateProvider.class);
return null;
}
private ITeamStateProvider getDecoratedStateProviderForId(String id) {
RepositoryProviderType type = getProviderTypeForId(id);
if (type != null)
- return (ITeamStateProvider) Utils.getAdapter(type,
- ITeamStateProvider.class, true);
+ return Adapters.adapt(type, ITeamStateProvider.class);
return null;
}

Back to the top