Capture current selection before opening dialogs in replace actions
[egit/eclipse.git] / org.eclipse.egit.core / src / org / eclipse / egit / core / internal / merge / GitCachedResourceVariantTree.java
blobc3c9df409cba1a3eb5a493dba7d065cea380b83b
1 /*******************************************************************************
2 * Copyright (C) 2015, Obeo.
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *******************************************************************************/
9 package org.eclipse.egit.core.internal.merge;
11 import java.util.Set;
13 import org.eclipse.core.resources.IResource;
14 import org.eclipse.core.runtime.IProgressMonitor;
15 import org.eclipse.team.core.TeamException;
16 import org.eclipse.team.core.variants.IResourceVariant;
17 import org.eclipse.team.core.variants.IResourceVariantTree;
19 /**
20 * An immutable resource variant tree backed by a
21 * {@link GitResourceVariantCache}. This will never contact the server.
22 * <p>
23 * This will not react to refreshing calls and shouldn't be used for
24 * synchronization purposes.
25 * </p>
28 * Illegal implementation of IResourceVariantTree : we could also extend the
29 * AbstractResourceVariantTree... but since we don't react to refreshing calls
30 * anyway, we do not need the extra logic it provides.
32 class GitCachedResourceVariantTree implements IResourceVariantTree {
33 private final GitResourceVariantCache cache;
35 public GitCachedResourceVariantTree(GitResourceVariantCache cache) {
36 this.cache = cache;
39 @Override
40 public IResource[] roots() {
41 final Set<IResource> roots = cache.getRoots();
42 return roots.toArray(new IResource[roots.size()]);
45 @Override
46 public IResource[] members(IResource resource) throws TeamException {
47 return cache.members(resource);
50 @Override
51 public IResourceVariant getResourceVariant(IResource resource)
52 throws TeamException {
53 return cache.getVariant(resource);
56 @Override
57 public boolean hasResourceVariant(IResource resource) throws TeamException {
58 return cache.getVariant(resource) != null;
61 @Override
62 public IResource[] refresh(IResource[] resources, int depth,
63 IProgressMonitor monitor) throws TeamException {
64 // This does not react to refresh calls
65 return new IResource[0];
68 @Override
69 public void flushVariants(IResource resource, int depth)
70 throws TeamException {
71 // Empty implementation