KickJava   Java API By Example, From Geeks To Geeks.

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


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.structuremergeviewer.IDiffContainer;
14 import org.eclipse.core.resources.IResource;
15 import org.eclipse.jface.resource.ImageDescriptor;
16 import org.eclipse.team.internal.core.subscribers.ChangeSet;
17 import org.eclipse.team.internal.ui.ITeamUIImages;
18 import org.eclipse.team.internal.ui.TeamUIPlugin;
19
20 /**
21  * Node that represents a Change set in a synchronize page.
22  */

23 public class ChangeSetDiffNode extends SynchronizeModelElement {
24
25     private final ChangeSet set;
26
27     public ChangeSetDiffNode(IDiffContainer parent, ChangeSet set) {
28         super(parent);
29         this.set = set;
30     }
31
32     /* (non-Javadoc)
33      * @see org.eclipse.team.ui.synchronize.ISynchronizeModelElement#getResource()
34      */

35     public IResource getResource() {
36         return null;
37     }
38
39     public ChangeSet getSet() {
40         return set;
41     }
42     
43     /* (non-Javadoc)
44      * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object)
45      */

46     public ImageDescriptor getImageDescriptor(Object JavaDoc object) {
47         return TeamUIPlugin.getImageDescriptor(ITeamUIImages.IMG_CHANGE_SET);
48     }
49
50     /* (non-Javadoc)
51      * @see org.eclipse.compare.structuremergeviewer.DiffNode#getName()
52      */

53     public String JavaDoc getName() {
54         return set.getName();
55     }
56     
57     /* (non-Javadoc)
58      * @see org.eclipse.team.ui.synchronize.SyncInfoModelElement#toString()
59      */

60     public String JavaDoc toString() {
61         return getName();
62     }
63     
64     /* (non-Javadoc)
65      * @see org.eclipse.team.internal.ui.synchronize.SynchronizeModelElement#hashCode()
66      */

67     public int hashCode() {
68         return set.hashCode();
69     }
70     
71     /* (non-Javadoc)
72      * @see org.eclipse.team.internal.ui.synchronize.SynchronizeModelElement#equals(java.lang.Object)
73      */

74     public boolean equals(Object JavaDoc object) {
75         if (object instanceof ChangeSetDiffNode) {
76             return((ChangeSetDiffNode)object).getSet() == set;
77         }
78         return super.equals(object);
79     }
80     
81     /* (non-Javadoc)
82      * @see org.eclipse.team.internal.ui.synchronize.SynchronizeModelElement#getAdapter(java.lang.Class)
83      */

84     public Object JavaDoc getAdapter(Class JavaDoc adapter) {
85         if (adapter.equals(ChangeSet.class)) {
86             return set;
87         }
88         return super.getAdapter(adapter);
89     }
90 }
91
Popular Tags