blob: 82298b97cb59d65a1f07d3859573192ae7e65839 (
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
|
package org.eclipse.team.internal.ui.target;
import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.target.Site;
import org.eclipse.team.internal.ui.TeamUIPlugin;
import org.eclipse.team.ui.ISharedImages;
import org.eclipse.team.ui.TeamImages;
import org.eclipse.ui.model.IWorkbenchAdapter;
public class SiteElement implements IWorkbenchAdapter, IAdaptable {
private Site site;
private boolean showFiles = true;
public SiteElement(Site site) {
this.site = site;
}
public SiteElement(Site site, boolean showFiles) {
this.site = site;
this.showFiles = showFiles;
}
public Site getSite() {
return site;
}
public Object getAdapter(Class adapter) {
if (adapter == IWorkbenchAdapter.class) return this;
return null;
}
public int hashCode() {
return site.hashCode();
}
public Object[] getChildren(Object o) {
try {
return new RemoteResourceElement(site.getRemoteResource(), showFiles).getChildren(this);
} catch (TeamException e) {
TeamUIPlugin.handle(e);
return new Object[0];
}
}
public ImageDescriptor getImageDescriptor(Object object) {
return TeamImages.getImageDescriptor(ISharedImages.IMG_SITE_ELEMENT);
}
public String getLabel(Object o) {
return getSite().getDisplayName();
}
public Object getParent(Object o) {
return null;
}
public boolean equals(Object obj) {
if(obj == null) return false;
if(!(obj instanceof SiteElement)) return false;
Site otherSite = ((SiteElement)obj).getSite();
return getSite().equals(otherSite);
}
}
|