KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ui > synchronize > RemoteResourceTypedElement


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.team.internal.ui.synchronize;
12
13 import org.eclipse.compare.ITypedElement;
14 import org.eclipse.core.resources.IStorage;
15 import org.eclipse.core.runtime.*;
16 import org.eclipse.team.core.TeamException;
17 import org.eclipse.team.core.variants.IResourceVariant;
18 import org.eclipse.team.internal.core.mapping.ResourceVariantFileRevision;
19 import org.eclipse.team.internal.ui.StorageTypedElement;
20 import org.eclipse.team.internal.ui.history.FileRevisionEditorInput;
21 import org.eclipse.ui.IEditorInput;
22
23 /**
24  * An {@link ITypedElement} wrapper for {@link IResourceVariant} for use with the
25  * Compare framework.
26  */

27 public class RemoteResourceTypedElement extends StorageTypedElement {
28
29     private IResourceVariant remote;
30
31     /**
32      * Creates a new content buffer for the given team node.
33      * @param remote the resource variant
34      * @param encoding the encoding of the contents
35      */

36     public RemoteResourceTypedElement(IResourceVariant remote, String JavaDoc encoding) {
37         super(encoding);
38         Assert.isNotNull(remote);
39         this.remote = remote;
40     }
41
42     /* (non-Javadoc)
43      * @see org.eclipse.compare.ITypedElement#getName()
44      */

45     public String JavaDoc getName() {
46         return remote.getName();
47     }
48     
49     /* (non-Javadoc)
50      * @see org.eclipse.team.internal.ui.StorageTypedElement#getType()
51      */

52     public String JavaDoc getType() {
53         if (remote.isContainer()) {
54             return ITypedElement.FOLDER_TYPE;
55         }
56         return super.getType();
57     }
58
59     /* (non-Javadoc)
60      * @see org.eclipse.team.internal.ui.StorageTypedElement#fetchContents(org.eclipse.core.runtime.IProgressMonitor)
61      */

62     protected IStorage fetchContents(IProgressMonitor monitor) throws TeamException {
63         return remote.getStorage(monitor);
64     }
65     
66     /* (non-Javadoc)
67      * @see org.eclipse.compare.ISharedDocumentAdapter#getDocumentKey(java.lang.Object)
68      */

69     public IEditorInput getDocumentKey(Object JavaDoc element) {
70         if (element == this && getBufferedStorage() != null) {
71             return new FileRevisionEditorInput(new ResourceVariantFileRevision(remote), getBufferedStorage(), getLocalEncoding());
72         }
73         return null;
74     }
75     
76 }
77
Popular Tags