1 11 package org.eclipse.team.internal.ui; 12 13 import org.eclipse.compare.structuremergeviewer.DiffNode; 14 import org.eclipse.core.resources.mapping.ModelProvider; 15 import org.eclipse.core.runtime.IAdapterFactory; 16 import org.eclipse.team.core.RepositoryProviderType; 17 import org.eclipse.team.core.history.IFileRevision; 18 import org.eclipse.team.core.mapping.IResourceMappingMerger; 19 import org.eclipse.team.core.mapping.ISynchronizationScopeParticipantFactory; 20 import org.eclipse.team.internal.ui.history.FileRevisionEditorInput; 21 import org.eclipse.team.internal.ui.mapping.*; 22 import org.eclipse.team.internal.ui.synchronize.DiffNodeWorkbenchAdapter; 23 import org.eclipse.team.ui.mapping.ISynchronizationCompareAdapter; 24 import org.eclipse.team.ui.mapping.ITeamStateProvider; 25 import org.eclipse.ui.model.IWorkbenchAdapter; 26 27 public class TeamAdapterFactory implements IAdapterFactory { 28 29 private DiffNodeWorkbenchAdapter diffNodeAdapter = new DiffNodeWorkbenchAdapter(); 30 31 private static final ISynchronizationCompareAdapter COMPARE_ADAPTER = new ResourceModelPersistenceAdapter(); 32 33 36 public Object getAdapter(Object adaptableObject, Class adapterType) { 37 if(adaptableObject instanceof DiffNode && adapterType == IWorkbenchAdapter.class) { 38 return diffNodeAdapter; 39 } 40 if (adaptableObject instanceof ModelProvider) { 41 ModelProvider provider = (ModelProvider) adaptableObject; 42 if (provider.getDescriptor().getId().equals(ModelProvider.RESOURCE_MODEL_PROVIDER_ID)) { 43 if (adapterType == IResourceMappingMerger.class) { 44 return new DefaultResourceMappingMerger((ModelProvider)adaptableObject); 45 } 46 if (adapterType == ISynchronizationScopeParticipantFactory.class) { 47 return new ResourceModelScopeParticipantFactory((ModelProvider)adaptableObject); 48 } 49 } 50 } 51 if (adaptableObject instanceof ModelProvider && adapterType == ISynchronizationCompareAdapter.class) { 52 return COMPARE_ADAPTER; 53 } 54 if (adaptableObject instanceof RepositoryProviderType && adapterType == ITeamStateProvider.class) { 55 RepositoryProviderType rpt = (RepositoryProviderType) adaptableObject; 56 return TeamUIPlugin.getPlugin().getDecoratedStateProvider(rpt); 57 } 58 59 if (IFileRevision.class == adapterType && adaptableObject instanceof FileRevisionEditorInput) { 60 return ((FileRevisionEditorInput)adaptableObject).getFileRevision(); 61 } 62 return null; 63 } 64 65 68 public Class [] getAdapterList() { 69 return new Class [] { 70 IWorkbenchAdapter.class, 71 IResourceMappingMerger.class, 72 ISynchronizationCompareAdapter.class, 73 ISynchronizationScopeParticipantFactory.class, 74 ITeamStateProvider.class , 75 IFileRevision.class 76 }; 77 } 78 } 79 | Popular Tags |