Skip to main content
summaryrefslogtreecommitdiffstats
blob: 5317e1973f1c8ba77463a192e6eb223c162f4ed7 (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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
package org.eclipse.team.core.sync;

/*
 * (c) Copyright IBM Corp. 2000, 2001.
 * All Rights Reserved.
 */

import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.team.core.TeamException;

/**
 * A <code>ILocalSyncElement</code> describes the relative synchronization of a <b>local</b> 
 * resource using a <b>base</b> resource for comparison.
 * <p>
 * Differences between the base and local resources are classified as <b>outgoing changes</b>; 
 * if there is a difference, the local resource is considered the <b>outgoing resource</b>. </p>
 * 
 * @see IRemoteSyncElement
 */
public interface ILocalSyncElement {
	
	/*====================================================================
	 * Constants defining synchronization types:  
	 *====================================================================*/

	/**
	 * Sync constant (value 0) indicating element is in sync.
	 */
	public static final int IN_SYNC = 0;
	
	/**
	 * Sync constant (value 1) indicating that one side was added.
	 */
	public static final int ADDITION = 1;
	
	/**
	 * Sync constant (value 2) indicating that one side was deleted.
	 */
	public static final int DELETION = 2;
	
	/**
	 * Sync constant (value 3) indicating that one side was changed.
	 */
	public static final int CHANGE = 3;

	/**
	 * Bit mask for extracting the change type.
	 */
	public static final int CHANGE_MASK = CHANGE;
	
	/*====================================================================
	 * Constants defining synchronization direction: 
	 *====================================================================*/
	
	/**
	 * Sync constant (value 4) indicating a change to the local resource.
	 */
	public static final int OUTGOING = 4;
	
	/**
	 * Sync constant (value 8) indicating a change to the remote resource.
	 */
	public static final int INCOMING = 8;
	
	/**
	 * Sync constant (value 12) indicating a change to both the remote and local resources.
	 */
	public static final int CONFLICTING = 12;
	
	/**
	 * Bit mask for extracting the synchronization direction. 
	 */
	public static final int DIRECTION_MASK = CONFLICTING;
	
	/*====================================================================
	 * Constants defining synchronization conflict types:
	 *====================================================================*/
	
	/**
	 * Sync constant (value 16) indication that both the local and remote resources have changed 
	 * relative to the base but their contents are the same. 
	 */
	public static final int PSEUDO_CONFLICT = 16;
	
	/**
	 * Sync constant (value 32) indicating that both the local and remote resources have changed 
	 * relative to the base but their content changes do not conflict (e.g. source file changes on different 
	 * lines). These conflicts could be merged automatically.
	 */
	public static final int AUTOMERGE_CONFLICT = 32;
	
	/**
	 * Sync constant (value 64) indicating that both the local and remote resources have changed relative 
	 * to the base and their content changes conflict (e.g. local and remote resource have changes on 
	 * same lines). These conflicts can only be correctly resolved by the user.
	 */
	public static final int MANUAL_CONFLICT = 64;
	
	/*====================================================================
	 * Constants defining synchronization granularity:
	 *====================================================================*/	
	 
	/**
	 * Constant (value 1) to only consider timestamp comparisons (e.g. isDirty) when 
	 * calculating the synchronization kind. This is the faster sync compare option but it can result in false 
	 * conflicts.
	 */
	public static final int GRANULARITY_TIMESTAMP = 1;

	/**
	 * Constant (value 2) indicating to consider file contents when calculating the synchronization kind. This 
	 * synchronization mode will perform a content comparison only after timestamp operations (isDirty) 
	 * indicate a change. This mode allows conflicts types to be correctly identified.
	 */
	public static final int GRANULARITY_CONTENTS = 2;
	
	/**
 	 * Answer a string that describes the simple name of the sync node,  which is suitable 
 	 * for display to a user.  The name will be used in UI operations, so it is expected that 
 	 * implementations will cache this value.
 	 * 
	 * @return the simple name that identifies the resource within its parent container.
	 */
	public String getName();
	
	/**
	 * Answer if the sync node is a container and may have children.
	 * 
 	 * @return <code>true</code> if the remote resource is a container, and <code>
	 * false</code> if it is not.
	 */
	public boolean isContainer();

	/**
	 * Answers the local sync element of this node. Returns a non-existing local
	 * resource handle if the local resource does not exist in the workspace. 
	 * 
	 * @return the local resource handle in this node. There should always be a local
	 * resource available, however the resource may not exist.
	 */
	public IResource getLocal();

	/**
	 * Answers the base sync element of this node. Returns <code>null</code> 
	 * if there is no base (e.g. conflicting add).
	 * 
	 * @return the base resource in this node, or <code>null</code> is there
	 * is none.
	 */
	public IRemoteResource getBase();
	
	/**
	 * Answers if the local resource currently has a different timestamp to the base timestamp
	 * for this resource.
	 * 
	 * @param resource the resource to test.
	 * @return <code>true</code> if the resource has a different modification
	 * timestamp, and <code>false</code> otherwise. If a base does not exist, this method
	 * must return <code>false</code>.
	 */
	public boolean isDirty();
	
	/**
	 * Answers if the remote resource state is checked-out. If the resource has never been checked in this
	 * method will return <code>true</code>.
	 * <p>
	 * It is undefined whether this method tests for a resource being checked out to this workspace
	 * or any workspace.</p>
	 * 
	 * @param resource the local resource to test.
	 * @return <code>true</code> if the resource is checked-out and <code>false</code> if it is not.
	 * @see checkout(IResource[], int, IProgressMonitor)
	 * @see refreshState(IResource[], int, IProgressMonitor)
	 */
	public boolean isCheckedOut();
	
	/**
	 * Answers whether the resource has a corresponding remote resource.
	 * <p>
	 * Before a resource is checked-in, the resource will occur locally but not remotely, and calls to this
	 * method will return <code>false</code>.  Once a local resource is checked in (and assuming the local
	 * local resource is not moved or the remote resource deleted) there will be a corresponding remote
	 * resource and this method returns <code>true</code>.</p>
	 * 
	 * @param resource the local resource to test.
	 * @return <code>true</code> if the local resource has a corresponding remote resource,
	 * and <code>false</code> otherwise.
	 */
	public boolean hasRemote();
	
	/**
	 * Answers and array of <code>ILocalSyncElement</code> elements that are immediate 
	 * children of this sync element, in no particular order. The returned sync nodes are
	 * a combination of the nodes represented by the sync element (e.g. local, base, remote).
	 * 
 	 * @param progress a progress monitor to indicate the duration of the operation, or
	 * <code>null</code> if progress reporting is not required.
	 * 
	 * @return array of immediate children of this sync node. 
	 */
	public ILocalSyncElement[] members(IProgressMonitor monitor) throws TeamException;
	
	/**
	 * Performs a synchronization calculation on the given element based on the local and base 
	 * resources. Returns an integer describing the synchronization state of this element.
	 * 
	 * @param granularity the granularity at which the elements of this sync element
	 * should be compared. On of <code>GRANULARITY_TIMESTAMP</code>, or 
	 * <code>GRANULARITY_CONTENTS</code>.
 	 * @param progress a progress monitor to indicate the duration of the operation, or
	 * <code>null</code> if progress reporting is not required.
	 * 
	 * @return an integer describing the synchronization state of this element.
	 */
	public int getSyncKind(int granularity, IProgressMonitor progress);	
}

Back to the top