1 11 package org.eclipse.team.internal.ui.mapping; 12 13 import org.eclipse.core.resources.mapping.ModelProvider; 14 import org.eclipse.jface.action.Action; 15 import org.eclipse.jface.action.IAction; 16 import org.eclipse.jface.resource.ImageDescriptor; 17 import org.eclipse.team.internal.ui.Utils; 18 import org.eclipse.team.ui.TeamUI; 19 import org.eclipse.team.ui.mapping.ITeamContentProviderDescriptor; 20 import org.eclipse.team.ui.mapping.ITeamContentProviderManager; 21 import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; 22 import org.eclipse.team.ui.synchronize.ModelSynchronizeParticipant; 23 24 public class ShowModelProviderAction extends Action { 25 26 private final ISynchronizePageConfiguration configuration; 27 private final ModelProvider provider; 28 29 public ShowModelProviderAction(ISynchronizePageConfiguration configuration, ModelProvider provider) { 30 super(Utils.getLabel(provider), IAction.AS_RADIO_BUTTON); 31 this.configuration = configuration; 32 this.provider = provider; 33 setImageDescriptor(getImageDescriptor(provider)); 34 } 35 36 private ImageDescriptor getImageDescriptor(ModelProvider provider) { 37 ITeamContentProviderManager manager = TeamUI.getTeamContentProviderManager(); 38 ITeamContentProviderDescriptor desc = manager.getDescriptor(provider.getId()); 39 return desc.getImageDescriptor(); 40 } 41 42 public void run() { 43 configuration.setProperty( 44 ModelSynchronizeParticipant.P_VISIBLE_MODEL_PROVIDER, 45 provider.getDescriptor().getId()); 46 } 47 48 public String getProviderId() { 49 return provider.getDescriptor().getId(); 50 } 51 52 } 53 | Popular Tags |