Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 9cdcf528c90aa8b48a96cb5c5d2f57a5b4b8dbd9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/*******************************************************************************
 * Copyright (c) 2006 IBM Corporation and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 * IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.team.ui.mapping;

import org.eclipse.core.resources.mapping.RemoteResourceMappingContext;
import org.eclipse.core.resources.mapping.ResourceMappingContext;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdapterManager;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.team.core.RepositoryProviderType;
import org.eclipse.team.core.diff.IDiff;
import org.eclipse.team.core.diff.IThreeWayDiff;
import org.eclipse.team.ui.synchronize.SubscriberTeamStateProvider;
import org.eclipse.team.ui.synchronize.TeamStateProvider;

/**
 * A team state provider is used by the {@link SynchronizationStateTester}
 * to obtain the team state for model elements. A team
 * state provider is associated with a {@link RepositoryProviderType} using the
 * adaptable mechanism. A default decoration provider that uses the subscriber
 * of the type is provided.
 * <p>
 * This interface is not intended to be implemented by clients. Clients should
 * instead subclass {@link TeamStateProvider} or
 * {@link SubscriberTeamStateProvider}.
 *
 * @see IAdapterManager
 * @see RepositoryProviderType
 * @see RepositoryProviderType#getSubscriber()
 * @see TeamStateProvider
 * @see SubscriberTeamStateProvider
 * @see SynchronizationStateTester
 *
 * @since 3.2
 */
public interface ITeamStateProvider {

	/**
	 * A state mask that can be passed to the {@link #getStateDescription(Object, int, String[], IProgressMonitor)}
	 * method to indicate that only the decorated state flags are desired. It is equivalent to
	 * passing he mask returned from {@link #getDecoratedStateMask(Object)};
	 */
	public static final int USE_DECORATED_STATE_MASK = -1;

	/**
	 * Return whether decoration is enabled for the given model element. If
	 * decoration is not enabled, the model does not need to fire label change
	 * events when the team state of the element changes.
	 *
	 * @param element
	 *            the model element
	 * @return whether decoration is enabled for the given model element
	 */
	public boolean isDecorationEnabled(Object element);

	/**
	 * Return whether the given element has any decorated state.
	 *
	 * @param element
	 *            the element being decorated
	 * @return whether the given element has any decorated state
	 * @throws CoreException
	 */
	public boolean hasDecoratedState(Object element) throws CoreException;

	/**
	 * Return the mask that indicates what state the appropriate team decorator
	 * is capable of decorating. Clients can used this to obtain the current
	 * decorated state from
	 * {@link #getStateDescription(Object, int, String[], IProgressMonitor)} in
	 * order to determine if the decorated state has changed.
	 *
	 * <p>
	 * The state mask can consist of the following standard flags:
	 * <ul>
	 * <li>The diff kinds of {@link IDiff#ADD}, {@link IDiff#REMOVE} and
	 * {@link IDiff#CHANGE}.
	 * <li>The directions {@link IThreeWayDiff#INCOMING} and
	 * {@link IThreeWayDiff#OUTGOING}.
	 * </ul>
	 * For convenience sake, if there are no kind flags but there is at least
	 * one direction flag then all kinds are assumed.
	 * <p>
	 * The mask can also consist of flag bits that are unique to the repository
	 * provider associated with the resources that the element maps to.
	 *
	 * @param element
	 *            the model element to be decorated
	 * @return the mask that indicates what state the appropriate team decorator
	 *         will decorate
	 * @see IDiff
	 * @see IThreeWayDiff
	 */
	public int getDecoratedStateMask(Object element);

	/**
	 * Return the set of property identifiers that represent the set of
	 * properties that the team decorator would decorate for the given model
	 * element.
	 *
	 * @param element
	 *            the model element to be decorated
	 * @return the set of decorated properties
	 */
	public String[] getDecoratedProperties(Object element);

	/**
	 * Return the state description for the given element. A <code>null</code>
	 * is return if the element is not decorated or if decoration is disabled.
	 * Only the portion of the synchronization state covered by
	 * <code>stateMask</code> is returned. The <code>stateMask</code> should
	 * be {@link #USE_DECORATED_STATE_MASK} or the mask returned from
	 * {@link #getDecoratedStateMask(Object)} and the requested properties
	 * should be <code>null</code> or the value returned from
	 * {@link #getDecoratedProperties(Object)} if the client wishes to obtain
	 * the current decorated state.
	 *
	 * @param element
	 *            the model element
	 * @param stateMask
	 *            the mask that identifies which synchronization state flags are
	 *            desired if present
	 * @param properties
	 *            the set of properties that should be included in the result or
	 *            <code>null</code> if the decorated properties are desired
	 * @param monitor
	 *            a progress monitor
	 * @return the state for the given element or <code>null</code>
	 * @throws CoreException
	 */
	public ITeamStateDescription getStateDescription(Object element,
			int stateMask, String[] properties, IProgressMonitor monitor)
			throws CoreException;

	/**
	 * Return a resource mapping context that gives access to the remote state
	 * of the resources associated with the provider. If a
	 * {@link RemoteResourceMappingContext} is returned, then the client may
	 * access the remote state.
	 *
	 * @param element
	 *            the element for which remote contents are desired
	 *
	 * @return a resource mapping context that gives access to the remote state
	 *         of the resources associated with the provider
	 */
	public ResourceMappingContext getResourceMappingContext(Object element);

	/**
	 * Add a decorated state change listener to the provider.
	 * Adding the same listener more than once has no effect.
	 *
	 * @param listener
	 *            the listener
	 */
	public void addDecoratedStateChangeListener(
			ITeamStateChangeListener listener);

	/**
	 * Remove the decorated state change listener to the provider.
	 * Removing a listener that is not registered has no effect.
	 *
	 * @param listener
	 *            the listener
	 */
	public void removeDecoratedStateChangeListener(
			ITeamStateChangeListener listener);

}

Back to the top