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
.packaging
.elements
;
18 import com
.intellij
.openapi
.extensions
.ExtensionPointName
;
19 import com
.intellij
.openapi
.extensions
.Extensions
;
20 import com
.intellij
.openapi
.project
.Project
;
21 import com
.intellij
.packaging
.artifacts
.Artifact
;
22 import com
.intellij
.packaging
.ui
.ArtifactEditorContext
;
23 import com
.intellij
.packaging
.ui
.PackagingElementPropertiesPanel
;
24 import org
.jetbrains
.annotations
.NonNls
;
25 import org
.jetbrains
.annotations
.NotNull
;
26 import org
.jetbrains
.annotations
.Nullable
;
29 import java
.util
.List
;
34 public abstract class PackagingElementType
<E
extends PackagingElement
<?
>> {
35 public static final ExtensionPointName
<PackagingElementType
> EP_NAME
= ExtensionPointName
.create("com.intellij.packaging.elementType");
36 private final String myId
;
37 private final String myPresentableName
;
39 protected PackagingElementType(@NotNull @NonNls String id
, @NotNull String presentableName
) {
41 myPresentableName
= presentableName
;
44 public final String
getId() {
48 public String
getPresentableName() {
49 return myPresentableName
;
53 public Icon
getCreateElementIcon() {
57 public abstract boolean canCreate(@NotNull ArtifactEditorContext context
, @NotNull Artifact artifact
);
60 public abstract List
<?
extends PackagingElement
<?
>> chooseAndCreate(@NotNull ArtifactEditorContext context
, @NotNull Artifact artifact
,
61 @NotNull CompositePackagingElement
<?
> parent
);
64 public abstract E
createEmpty(@NotNull Project project
);
66 protected static <T
extends PackagingElementType
<?
>> T
getInstance(final Class
<T
> aClass
) {
67 for (PackagingElementType type
: Extensions
.getExtensions(EP_NAME
)) {
68 if (aClass
.isInstance(type
)) {
69 return aClass
.cast(type
);
72 throw new AssertionError();
76 public PackagingElementPropertiesPanel
createElementPropertiesPanel(@NotNull E element
, @NotNull ArtifactEditorContext context
) {