blob: 8d27dfb7f5e878b36d7fb4be9d0113d2e989a08e (
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
|
/*******************************************************************************
* 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.ccvs.ui.merge;
import java.util.Date;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.team.internal.ccvs.core.CVSTag;
import org.eclipse.team.internal.ccvs.core.util.CVSDateFormatter;
import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants;
import org.eclipse.ui.model.IWorkbenchAdapter;
public class TagElement implements IWorkbenchAdapter, IAdaptable {
CVSTag tag;
public TagElement(CVSTag tag) {
this.tag = tag;
}
public Object[] getChildren(Object o) {
return new Object[0];
}
public Object getAdapter(Class adapter) {
if (adapter == IWorkbenchAdapter.class) return this;
return null;
}
public ImageDescriptor getImageDescriptor(Object object) {
if (tag.getType() == CVSTag.BRANCH || tag == CVSTag.DEFAULT) {
return CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_TAG);
} else if (tag.getType() == CVSTag.DATE){
return CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_DATE);
}else {
return CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_PROJECT_VERSION);
}
}
public String getLabel(Object o) {
if(tag.getType() == CVSTag.DATE){
Date date = tag.asDate();
if (date != null){
return CVSDateFormatter.repoViewTimeStamp(date);
}
}
return tag.getName();
}
public Object getParent(Object o) {
return null;
}
public CVSTag getTag() {
return tag;
}
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
return tag.hashCode();
}
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(Object obj) {
if (obj instanceof TagElement) {
return tag.equals(((TagElement)obj).getTag());
}
return super.equals(obj);
}
}
|