blob: 7b1ec07dec24825b86044207e434a16489a14e85 (
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
|
/*******************************************************************************
* Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.team.internal.core.subscribers;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.variants.IResourceVariant;
import org.eclipse.team.core.variants.ResourceVariantByteStore;
import org.eclipse.team.core.variants.ResourceVariantTree;
import org.eclipse.team.core.variants.ThreeWaySubscriber;
/**
* Allow access to the base resource variants but do not support refresh
* or modification.
*/
public final class ThreeWayBaseTree extends ResourceVariantTree {
private ThreeWaySubscriber subscriber;
/*
* A resource variant byte store that accesses the base bytes from a three-way
* synchronizer. The modification methods are disabled as the base should
* only be modified in the synchronizer directly.
*/
static class BaseResourceVariantByteStore extends ResourceVariantByteStore {
private ThreeWaySubscriber subscriber;
public BaseResourceVariantByteStore(ThreeWaySubscriber subscriber) {
this.subscriber = subscriber;
}
@Override
public void dispose() {
// Nothing to do
}
@Override
public byte[] getBytes(IResource resource) throws TeamException {
return subscriber.getSynchronizer().getBaseBytes(resource);
}
@Override
public boolean setBytes(IResource resource, byte[] bytes) throws TeamException {
// Base bytes are set directly in the synchronizer
return false;
}
@Override
public boolean flushBytes(IResource resource, int depth) throws TeamException {
// Base bytes are flushed directly in the synchronizer
return false;
}
@Override
public boolean deleteBytes(IResource resource) throws TeamException {
// Base bytes are deleted directly in the synchronizer
return false;
}
@Override
public IResource[] members(IResource resource) throws TeamException {
return subscriber.getSynchronizer().members(resource);
}
}
/**
* Create a base resource variant tree that accesses the base bytes
* from a three-way synchronizer.
* @param subscriber the three-way subscriber
*/
public ThreeWayBaseTree(ThreeWaySubscriber subscriber) {
super(new BaseResourceVariantByteStore(subscriber));
this.subscriber = subscriber;
}
@Override
public IResource[] refresh(IResource[] resources, int depth, IProgressMonitor monitor) throws TeamException {
return new IResource[0];
}
@Override
protected IResourceVariant[] fetchMembers(IResourceVariant variant, IProgressMonitor progress) throws TeamException {
// Refresh not supported
return new IResourceVariant[0];
}
@Override
protected IResourceVariant fetchVariant(IResource resource, int depth, IProgressMonitor monitor) throws TeamException {
// Refresh not supported
return null;
}
@Override
public IResource[] roots() {
return getSubscriber().roots();
}
@Override
public IResourceVariant getResourceVariant(IResource resource) throws TeamException {
return getSubscriber().getResourceVariant(resource, getByteStore().getBytes(resource));
}
private ThreeWaySubscriber getSubscriber() {
return subscriber;
}
}
|