Skip to main content
summaryrefslogtreecommitdiffstats
blob: 580b214f77f2212039e1bea9aaeddd787f03cec6 (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
/*******************************************************************************
 * Copyright (c) 2000, 2003 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials 
 * are made available under the terms of the Common Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/cpl-v10.html
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.team.core.subscribers;

import org.eclipse.core.resources.IResource;

/**
 * A team delta represents changes in the team state.
 *
 * @see IResource
 * @see ITeamProvider
 */
public class TeamDelta {
	
	/*====================================================================
	 * Constants defining the kinds of team changes to resources:
	 *====================================================================*/

	/**
	 * Delta kind constant indicating that the resource has not been changed in any way
	 * @see IResourceDelta#getKind
	 */
	public static final int NO_CHANGE = 0;

	/**
	 * Delta kind constant (bit mask) indicating that the synchronization state of a resource has changed.
	 */
	public static final int SYNC_CHANGED = 0x1;

	/**
	 * Delta kind constant (bit mask) indicating that a team provider has been configured on the resource.
	 * @see IResourceDelta#getKind
	 */
	public static final int PROVIDER_CONFIGURED = 0x2;
	
	/**
	 * Delta kind constant (bit mask) indicating that a team provider has been de-configured on the resource.
	 * @see IResourceDelta#getKind
	 */	
	public static final int PROVIDER_DECONFIGURED = 0x4;

	private TeamSubscriber subscriber; 
	private int flags;
	private IResource resource; 
	
	public TeamDelta(TeamSubscriber subscriber, int flags, IResource resource) {
		this.subscriber = subscriber;
		this.flags = flags;
		this.resource = resource;
	}

	public int getFlags() {
		return flags;
	}

	public IResource getResource() {
		return resource;
	}

	public TeamSubscriber getSubscriber() {
		return subscriber;
	}
	
	/**
	 * Returns an array of deltas for the resources with TeamDelta.SYNC_CHANGED
	 * as the change type.
	 * @param resources the resources whose sync info has changed
	 * @return
	 */
	public static TeamDelta[] asSyncChangedDeltas(TeamSubscriber subscriber, IResource[] resources) {
		TeamDelta[] deltas = new TeamDelta[resources.length];
		for (int i = 0; i < resources.length; i++) {
			IResource resource = resources[i];
			deltas[i] = new TeamDelta(subscriber, TeamDelta.SYNC_CHANGED, resource);
		}
		return deltas;
	}
}

Back to the top