blob: 95a0c3f6d4b3fd9c955cb67a953b6662537fdc6d (
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
|
/*******************************************************************************
* Copyright (c) 2008-2010 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.m2e.core.ui.internal.views.nodes;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.m2e.core.embedder.ArtifactKey;
import org.eclipse.m2e.core.internal.index.IIndex;
import org.eclipse.m2e.core.internal.index.IndexedArtifactFile;
import org.eclipse.m2e.core.internal.index.nexus.NexusIndexManager;
import org.eclipse.m2e.core.ui.internal.MavenImages;
import org.eclipse.swt.graphics.Image;
/**
* IndexedArtifactFileNode
*
* @author dyocum
*/
public class IndexedArtifactFileNode implements IMavenRepositoryNode, IArtifactNode, IAdaptable {
private IndexedArtifactFile artifactFile;
public IndexedArtifactFileNode(IndexedArtifactFile artifactFile){
this.artifactFile = artifactFile;
}
public IndexedArtifactFile getIndexedArtifactFile(){
return this.artifactFile;
}
/* (non-Javadoc)
* @see org.eclipse.m2e.ui.internal.views.IMavenRepositoryNode#getChildren()
*/
public Object[] getChildren() {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.m2e.ui.internal.views.IMavenRepositoryNode#getName()
*/
public String getName() {
String label = artifactFile.artifact;
if(artifactFile.classifier != null) {
label += " : " + artifactFile.classifier; //$NON-NLS-1$
}
if(artifactFile.version != null) {
label += " : " + artifactFile.version; //$NON-NLS-1$
}
return label;
}
/* (non-Javadoc)
* @see org.eclipse.m2e.ui.internal.views.IMavenRepositoryNode#hasChildren()
*/
public boolean hasChildren() {
return false;
}
/* (non-Javadoc)
* @see org.eclipse.m2e.ui.internal.views.nodes.IMavenRepositoryNode#getImage()
*/
public Image getImage() {
if(artifactFile.sourcesExists == IIndex.PRESENT) {
return MavenImages.IMG_VERSION_SRC;
}
return MavenImages.IMG_VERSION;
}
/* (non-Javadoc)
* @see org.eclipse.m2e.ui.internal.views.nodes.IArtifactNode#getDocumentKey()
*/
public String getDocumentKey() {
return NexusIndexManager.getDocumentKey(artifactFile.getArtifactKey());
}
/* (non-Javadoc)
* @see org.eclipse.m2e.ui.internal.views.nodes.IMavenRepositoryNode#isUpdating()
*/
public boolean isUpdating() {
return false;
}
/* (non-Javadoc)
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
*/
public Object getAdapter(Class adapter) {
if (ArtifactKey.class.equals(adapter)) {
return new ArtifactKey(artifactFile.group, artifactFile.artifact, artifactFile.version, artifactFile.classifier);
}
return null;
}
}
|