KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ui > mapping > ShowModelProviderAction


1 /*******************************************************************************
2  * Copyright (c) 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

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 JavaDoc getProviderId() {
49         return provider.getDescriptor().getId();
50     }
51
52 }
53
Popular Tags