From ec45a449c09d439c8e992b7c01b2fe712e4dcb9d Mon Sep 17 00:00:00 2001 From: nik Date: Mon, 26 Oct 2009 13:52:41 +0300 Subject: [PATCH] correctly put web and ejb artifacts in ear artifact && unused classes removed --- .../ModuleWithDependenciesElementType.java | 72 ---------- ...oduleWithDependenciesPackagingElement.java | 127 ------------------ .../elements/PackagingElementFactoryImpl.java | 1 - .../packaging/artifacts/ArtifactType.java | 5 - .../sourceItems/ArtifactSourceItem.java | 4 + 5 files changed, 4 insertions(+), 205 deletions(-) delete mode 100644 java/compiler/impl/src/com/intellij/packaging/impl/elements/ModuleWithDependenciesElementType.java delete mode 100644 java/compiler/impl/src/com/intellij/packaging/impl/elements/ModuleWithDependenciesPackagingElement.java diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/elements/ModuleWithDependenciesElementType.java b/java/compiler/impl/src/com/intellij/packaging/impl/elements/ModuleWithDependenciesElementType.java deleted file mode 100644 index 6e2bc355df99..000000000000 --- a/java/compiler/impl/src/com/intellij/packaging/impl/elements/ModuleWithDependenciesElementType.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.packaging.impl.elements; - -import com.intellij.openapi.module.Module; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.IconLoader; -import com.intellij.packaging.artifacts.Artifact; -import com.intellij.packaging.elements.ComplexPackagingElementType; -import com.intellij.packaging.elements.CompositePackagingElement; -import com.intellij.packaging.ui.ArtifactEditorContext; -import org.jetbrains.annotations.NotNull; - -import javax.swing.*; -import java.util.ArrayList; -import java.util.List; - -/** - * @author nik - */ -public class ModuleWithDependenciesElementType extends ComplexPackagingElementType { - public static final ModuleWithDependenciesElementType MODULE_WITH_DEPENDENCIES_TYPE = new ModuleWithDependenciesElementType(); - - public ModuleWithDependenciesElementType() { - super("module-with-dependencies", "Module With Dependencies"); - } - - @Override - public String getShowContentActionText() { - return "Module with dependencies"; - } - - @Override - public Icon getCreateElementIcon() { - return IconLoader.getIcon("/nodes/ModuleOpen.png"); - } - - @Override - public boolean canCreate(@NotNull ArtifactEditorContext context, @NotNull Artifact artifact) { - return context.getModulesProvider().getModules().length > 0; - } - - @NotNull - public List chooseAndCreate(@NotNull ArtifactEditorContext context, - @NotNull Artifact artifact, - @NotNull CompositePackagingElement parent) { - final List modules = ModuleOutputElementType.chooseModules(context); - final List elements = new ArrayList(); - for (Module module : modules) { - elements.add(new ModuleWithDependenciesPackagingElement(module.getName())); - } - return elements; - } - - @NotNull - public ModuleWithDependenciesPackagingElement createEmpty(@NotNull Project project) { - return new ModuleWithDependenciesPackagingElement(); - } -} diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/elements/ModuleWithDependenciesPackagingElement.java b/java/compiler/impl/src/com/intellij/packaging/impl/elements/ModuleWithDependenciesPackagingElement.java deleted file mode 100644 index 54951bdf4465..000000000000 --- a/java/compiler/impl/src/com/intellij/packaging/impl/elements/ModuleWithDependenciesPackagingElement.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.packaging.impl.elements; - -import com.intellij.openapi.compiler.CompilerBundle; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.roots.*; -import com.intellij.openapi.roots.libraries.Library; -import com.intellij.packaging.elements.ComplexPackagingElement; -import com.intellij.packaging.elements.PackagingElement; -import com.intellij.packaging.elements.PackagingElementFactory; -import com.intellij.packaging.elements.PackagingElementResolvingContext; -import com.intellij.packaging.impl.ui.DelegatedPackagingElementPresentation; -import com.intellij.packaging.impl.ui.ModuleElementPresentation; -import com.intellij.packaging.ui.PackagingElementPresentation; -import com.intellij.packaging.ui.PackagingElementWeights; -import com.intellij.packaging.ui.ArtifactEditorContext; -import com.intellij.packaging.artifacts.ArtifactType; -import com.intellij.util.xmlb.annotations.Attribute; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author nik - */ -public class ModuleWithDependenciesPackagingElement extends ComplexPackagingElement { - private String myModuleName; - - public ModuleWithDependenciesPackagingElement() { - super(ModuleWithDependenciesElementType.MODULE_WITH_DEPENDENCIES_TYPE); - } - - public ModuleWithDependenciesPackagingElement(String moduleName) { - super(ModuleWithDependenciesElementType.MODULE_WITH_DEPENDENCIES_TYPE); - myModuleName = moduleName; - } - - public List> getSubstitution(@NotNull PackagingElementResolvingContext context, @NotNull ArtifactType artifactType) { - final Module module = findModule(context); - - List> elements = new ArrayList>(); - final PackagingElementFactory factory = PackagingElementFactory.getInstance(); - if (module != null) { - final ModuleRootModel rootModel = context.getModulesProvider().getRootModel(module); - for (OrderEntry entry : rootModel.getOrderEntries()) { - if (entry instanceof ModuleSourceOrderEntry) { - elements.add(factory.createModuleOutput(myModuleName, context.getProject())); - } - else if (entry instanceof LibraryOrderEntry) { - final Library library = ((LibraryOrderEntry)entry).getLibrary(); - if (library != null) { - elements.addAll(factory.createLibraryElements(library)); - } - } - else if (entry instanceof ModuleOrderEntry) { - elements.add(new ModuleWithDependenciesPackagingElement(((ModuleOrderEntry)entry).getModuleName())); - } - } - } - - final List> substitution = new ArrayList>(); - for (PackagingElement element : elements) { - final String path = artifactType.getDefaultPathFor(element, context); - if (path != null) { - substitution.add(factory.createParentDirectories(path, element)); - } - } - return substitution; - } - - public PackagingElementPresentation createPresentation(@NotNull ArtifactEditorContext context) { - return new DelegatedPackagingElementPresentation(new ModuleElementPresentation(myModuleName, findModule(context), context) { - @Override - protected String getNodeText() { - return CompilerBundle.message("node.text.0.with.dependencies", getPresentableName()); - } - - @Override - public int getWeight() { - return PackagingElementWeights.ARTIFACT - 10; - } - }); - } - - public boolean isEqualTo(@NotNull PackagingElement element) { - return element instanceof ModuleWithDependenciesPackagingElement && myModuleName != null - && myModuleName.equals(((ModuleWithDependenciesPackagingElement)element).getModuleName()); - } - - public ModuleWithDependenciesPackagingElement getState() { - return this; - } - - public void loadState(ModuleWithDependenciesPackagingElement state) { - myModuleName = state.getModuleName(); - } - - @Nullable - public Module findModule(PackagingElementResolvingContext context) { - return context.getModulesProvider().getModule(myModuleName); - } - - @Attribute("module-name") - public String getModuleName() { - return myModuleName; - } - - public void setModuleName(String moduleName) { - myModuleName = moduleName; - } -} diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/elements/PackagingElementFactoryImpl.java b/java/compiler/impl/src/com/intellij/packaging/impl/elements/PackagingElementFactoryImpl.java index ef3f0ca0bf19..e4569f661bc9 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/elements/PackagingElementFactoryImpl.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/elements/PackagingElementFactoryImpl.java @@ -64,7 +64,6 @@ public class PackagingElementFactoryImpl extends PackagingElementFactory { private static final PackagingElementType[] STANDARD_TYPES = { DIRECTORY_ELEMENT_TYPE, ARCHIVE_ELEMENT_TYPE, LibraryElementType.LIBRARY_ELEMENT_TYPE, ModuleOutputElementType.MODULE_OUTPUT_ELEMENT_TYPE, - //ModuleWithDependenciesElementType.MODULE_WITH_DEPENDENCIES_TYPE, ArtifactElementType.ARTIFACT_ELEMENT_TYPE, FILE_COPY_ELEMENT_TYPE, DIRECTORY_COPY_ELEMENT_TYPE }; diff --git a/java/compiler/openapi/src/com/intellij/packaging/artifacts/ArtifactType.java b/java/compiler/openapi/src/com/intellij/packaging/artifacts/ArtifactType.java index c3ec0bcb3113..533c2adc5657 100644 --- a/java/compiler/openapi/src/com/intellij/packaging/artifacts/ArtifactType.java +++ b/java/compiler/openapi/src/com/intellij/packaging/artifacts/ArtifactType.java @@ -60,11 +60,6 @@ public abstract class ArtifactType { return getDefaultPathFor(sourceItem.getKindOfProducedElements()); } - @Nullable - public String getDefaultPathFor(@NotNull PackagingElement element, @NotNull PackagingElementResolvingContext context) { - return getDefaultPathFor(element.getFilesKind(context)); - } - @Nullable public abstract String getDefaultPathFor(@NotNull PackagingElementOutputKind kind); diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/sourceItems/ArtifactSourceItem.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/sourceItems/ArtifactSourceItem.java index afb8b855c89b..b393f4785910 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/sourceItems/ArtifactSourceItem.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/sourceItems/ArtifactSourceItem.java @@ -64,6 +64,10 @@ public class ArtifactSourceItem extends PackagingSourceItem { return myArtifact.getArtifactType() instanceof JarArtifactType ? PackagingElementOutputKind.JAR_FILES : PackagingElementOutputKind.OTHER; } + public Artifact getArtifact() { + return myArtifact; + } + public int hashCode() { return myArtifact.hashCode(); }