2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com
.intellij
.openapi
.roots
.ui
.configuration
.artifacts
.sourceItems
;
18 import com
.intellij
.packaging
.artifacts
.Artifact
;
19 import com
.intellij
.packaging
.artifacts
.ArtifactPointerManager
;
20 import com
.intellij
.packaging
.artifacts
.ArtifactPointer
;
21 import com
.intellij
.packaging
.elements
.PackagingElement
;
22 import com
.intellij
.packaging
.elements
.PackagingElementFactory
;
23 import com
.intellij
.packaging
.elements
.PackagingElementOutputKind
;
24 import com
.intellij
.packaging
.impl
.artifacts
.JarArtifactType
;
25 import com
.intellij
.packaging
.impl
.ui
.ArtifactElementPresentation
;
26 import com
.intellij
.packaging
.ui
.*;
27 import org
.jetbrains
.annotations
.NotNull
;
29 import java
.util
.Collections
;
30 import java
.util
.List
;
35 public class ArtifactSourceItem
extends PackagingSourceItem
{
36 private final Artifact myArtifact
;
38 public ArtifactSourceItem(@NotNull Artifact artifact
) {
39 myArtifact
= artifact
;
42 public SourceItemPresentation
createPresentation(@NotNull ArtifactEditorContext context
) {
43 final ArtifactPointer pointer
= ArtifactPointerManager
.getInstance(context
.getProject()).create(myArtifact
);
44 return new DelegatedSourceItemPresentation(new ArtifactElementPresentation(pointer
, context
)) {
46 public int getWeight() {
47 return SourceItemWeights
.ARTIFACT_WEIGHT
;
53 public List
<?
extends PackagingElement
<?
>> createElements(@NotNull ArtifactEditorContext context
) {
54 return Collections
.singletonList(PackagingElementFactory
.getInstance().createArtifactElement(myArtifact
, context
.getProject()));
57 public boolean equals(Object obj
) {
58 return obj
instanceof ArtifactSourceItem
&& myArtifact
.equals(((ArtifactSourceItem
)obj
).myArtifact
);
63 public PackagingElementOutputKind
getKindOfProducedElements() {
64 return myArtifact
.getArtifactType() instanceof JarArtifactType ? PackagingElementOutputKind
.JAR_FILES
: PackagingElementOutputKind
.OTHER
;
67 public int hashCode() {
68 return myArtifact
.hashCode();