KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > ui > mappings > CVSModelSynchronizeParticipant


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.ccvs.ui.mappings;
12
13 import org.eclipse.core.resources.mapping.ModelProvider;
14 import org.eclipse.jface.preference.PreferencePage;
15 import org.eclipse.jface.viewers.ILabelDecorator;
16 import org.eclipse.team.core.mapping.provider.SynchronizationContext;
17 import org.eclipse.team.internal.ccvs.core.mapping.ChangeSetModelProvider;
18 import org.eclipse.team.internal.ccvs.ui.CVSUIMessages;
19 import org.eclipse.team.internal.ccvs.ui.ComparePreferencePage;
20 import org.eclipse.team.internal.ccvs.ui.subscriber.CVSParticipantLabelDecorator;
21 import org.eclipse.team.internal.ui.synchronize.IChangeSetProvider;
22 import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
23 import org.eclipse.team.ui.synchronize.ModelSynchronizeParticipant;
24
25 public abstract class CVSModelSynchronizeParticipant extends ModelSynchronizeParticipant {
26
27     public static PreferencePage[] addCVSPreferencePages(PreferencePage[] inheritedPages) {
28         PreferencePage[] pages = new PreferencePage[inheritedPages.length + 1];
29         for (int i = 0; i < inheritedPages.length; i++) {
30             pages[i] = inheritedPages[i];
31         }
32         pages[pages.length - 1] = new ComparePreferencePage();
33         pages[pages.length - 1].setTitle(CVSUIMessages.CVSParticipant_2);
34         return pages;
35     }
36
37     public CVSModelSynchronizeParticipant() {
38         super();
39     }
40
41     public CVSModelSynchronizeParticipant(SynchronizationContext context) {
42         super(context);
43     }
44
45     public PreferencePage[] getPreferencePages() {
46         return addCVSPreferencePages(super.getPreferencePages());
47     }
48     
49     public ModelProvider[] getEnabledModelProviders() {
50         ModelProvider[] enabledProviders = super.getEnabledModelProviders();
51         if (this instanceof IChangeSetProvider) {
52             for (int i = 0; i < enabledProviders.length; i++) {
53                 ModelProvider provider = enabledProviders[i];
54                 if (provider.getId().equals(ChangeSetModelProvider.ID))
55                     return enabledProviders;
56             }
57             ModelProvider[] extended = new ModelProvider[enabledProviders.length + 1];
58             for (int i = 0; i < enabledProviders.length; i++) {
59                 extended[i] = enabledProviders[i];
60             }
61             ChangeSetModelProvider provider = ChangeSetModelProvider.getProvider();
62             if (provider == null)
63                 return enabledProviders;
64             extended[extended.length - 1] = provider;
65             return extended;
66         }
67         return enabledProviders;
68     }
69
70     protected ILabelDecorator getLabelDecorator(ISynchronizePageConfiguration configuration) {
71         return new CVSParticipantLabelDecorator(configuration);
72     }
73     
74     protected void initializeConfiguration(ISynchronizePageConfiguration configuration) {
75         super.initializeConfiguration(configuration);
76         configuration.addLabelDecorator(getLabelDecorator(configuration));
77     }
78 }
79
Popular Tags