blob: d4eb3dcce74579dc0f0d5cde4e759b49de002a82 (
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
/*******************************************************************************
* 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.ArrayList;
import java.util.Arrays;
import java.util.List;
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.ICVSFolder;
import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants;
import org.eclipse.team.internal.ccvs.ui.Policy;
import org.eclipse.ui.model.IWorkbenchAdapter;
public class TagRootElement implements IWorkbenchAdapter, IAdaptable {
private ICVSFolder project;
private List cachedTags;
private int typeOfTagRoot;
public TagRootElement(ICVSFolder project, int typeOfTagRoot) {
this.typeOfTagRoot = typeOfTagRoot;
this.project = project;
}
public TagRootElement(ICVSFolder project, int typeOfTagRoot, CVSTag[] tags) {
this(project, typeOfTagRoot);
add(tags);
}
public Object[] getChildren(Object o) {
CVSTag[] childTags = new CVSTag[0];
if(cachedTags==null) {
if(typeOfTagRoot==CVSTag.BRANCH) {
childTags = CVSUIPlugin.getPlugin().getRepositoryManager().getKnownTags(project, CVSTag.BRANCH);
} else if(typeOfTagRoot==CVSTag.VERSION) {
childTags = CVSUIPlugin.getPlugin().getRepositoryManager().getKnownTags(project, CVSTag.VERSION);
}else if(typeOfTagRoot==CVSTag.DATE){
childTags = CVSUIPlugin.getPlugin().getRepositoryManager().getKnownTags(project, CVSTag.DATE);
}
} else {
childTags = getTags();
}
TagElement[] result = new TagElement[childTags.length];
for (int i = 0; i < childTags.length; i++) {
result[i] = new TagElement(childTags[i]);
}
return result;
}
public void removeAll() {
if(cachedTags!=null) {
cachedTags.clear();
}
}
public void add(CVSTag tag){
if(cachedTags==null) {
cachedTags = new ArrayList();
}
cachedTags.add(tag);
}
public void add(CVSTag[] tags) {
if(cachedTags==null) {
cachedTags = new ArrayList(tags.length);
}
cachedTags.addAll(Arrays.asList(tags));
}
public void remove(CVSTag tag) {
if(cachedTags!=null) {
cachedTags.remove(tag);
}
}
public CVSTag[] getTags() {
if(cachedTags!=null) {
return (CVSTag[]) cachedTags.toArray(new CVSTag[cachedTags.size()]);
} else {
return new CVSTag[0];
}
}
public Object getAdapter(Class adapter) {
if (adapter == IWorkbenchAdapter.class) return this;
return null;
}
public ImageDescriptor getImageDescriptor(Object object) {
if(typeOfTagRoot==CVSTag.BRANCH) {
return CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_BRANCHES_CATEGORY);
} else if(typeOfTagRoot==CVSTag.DATE){
return CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_DATES_CATEGORY);
}else {
return CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_VERSIONS_CATEGORY);
}
}
public String getLabel(Object o) {
if(typeOfTagRoot==CVSTag.BRANCH) {
return Policy.bind("MergeWizardEndPage.branches"); //$NON-NLS-1$
} else if(typeOfTagRoot==CVSTag.DATE){
return Policy.bind("TagRootElement.0"); //$NON-NLS-1$
}else {
return Policy.bind("VersionsElement.versions"); //$NON-NLS-1$
}
}
public Object getParent(Object o) {
return null;
}
/**
* Gets the typeOfTagRoot.
* @return Returns a int
*/
public int getTypeOfTagRoot() {
return typeOfTagRoot;
}
}
|