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
|
/*******************************************************************************
* 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.internal.ui.synchronize.compare;
import org.eclipse.compare.ITypedElement;
import org.eclipse.compare.structuremergeviewer.DiffNode;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.subscribers.ISubscriberResource;
import org.eclipse.team.core.subscribers.SyncInfo;
import org.eclipse.team.internal.ui.Policy;
public class SyncInfoDiffNode extends DiffNode {
/**
* Create an ITypedElement for the given local resource. The returned ITypedElement
* will prevent edited of outgoing deletions.
*/
public static ITypedElement createTypeElement(IResource resource, final int kind) {
if(resource != null && resource.exists()) {
return new LocalResourceTypedElement(resource) {
public boolean isEditable() {
if(SyncInfo.getDirection(kind) == SyncInfo.OUTGOING && SyncInfo.getChange(kind) == SyncInfo.DELETION) {
return false;
}
return super.isEditable();
}
};
}
return null;
}
/**
* Create an ITypedElement for the given remote resource. The contents for the remote resource
* will be retrieved from the given IStorage which is a local cache used to buffer the remote contents
*/
public static ITypedElement createTypeElement(ISubscriberResource remoteResource) {
return new RemoteResourceTypedElement(remoteResource);
}
/**
* Creates a new diff node.
*/
public SyncInfoDiffNode(ITypedElement base, ITypedElement local, ITypedElement remote, int syncKind) {
super(syncKind, base, local, remote);
}
/**
* Cache the contents for the base and remote.
* @param monitor
*/
public void cacheContents(IProgressMonitor monitor) throws TeamException {
ITypedElement base = getAncestor();
ITypedElement remote = getRight();
int work = Math.min((remote== null ? 0 : 50) + (base == null ? 0 : 50), 10);
monitor.beginTask(null, work);
try {
if (base != null && base instanceof RemoteResourceTypedElement) {
((RemoteResourceTypedElement)base).cacheContents(Policy.subMonitorFor(monitor, 50));
}
if (remote != null && remote instanceof RemoteResourceTypedElement) {
((RemoteResourceTypedElement)remote).cacheContents(Policy.subMonitorFor(monitor, 50));
}
} finally {
monitor.done();
}
}
}
|