diff --git a/java/compiler/impl/src/com/intellij/compiler/CompilerManagerImpl.java b/java/compiler/impl/src/com/intellij/compiler/CompilerManagerImpl.java index d06ee818fc7a..4639eef563b4 100644 --- a/java/compiler/impl/src/com/intellij/compiler/CompilerManagerImpl.java +++ b/java/compiler/impl/src/com/intellij/compiler/CompilerManagerImpl.java @@ -5,7 +5,6 @@ import com.intellij.compiler.impl.javaCompiler.JavaCompiler; import com.intellij.compiler.impl.packagingCompiler.IncrementalPackagingCompiler; import com.intellij.compiler.impl.resourceCompiler.ResourceCompiler; import com.intellij.compiler.impl.rmiCompiler.RmicCompiler; -import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.compiler.*; import com.intellij.openapi.compiler.Compiler; import com.intellij.openapi.extensions.Extensions; @@ -15,7 +14,6 @@ import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.packaging.artifacts.ArtifactManager; import com.intellij.packaging.impl.compiler.IncrementalArtifactsCompiler; import com.intellij.util.ArrayUtil; import com.intellij.util.Chunk; @@ -57,9 +55,7 @@ public class CompilerManagerImpl extends CompilerManager { addCompiler(new ResourceCompiler(project, compilerConfiguration)); addCompiler(new RmicCompiler()); addCompiler(new IncrementalPackagingCompiler()); - if (ArtifactManager.useArtifacts() || ApplicationManager.getApplication().isUnitTestMode()) { - addCompiler(new IncrementalArtifactsCompiler()); - } + addCompiler(new IncrementalArtifactsCompiler()); for(Compiler compiler: Extensions.getExtensions(Compiler.EP_NAME, myProject)) { addCompiler(compiler); diff --git a/java/compiler/impl/src/com/intellij/compiler/actions/BuildArtifactActionGroup.java b/java/compiler/impl/src/com/intellij/compiler/actions/BuildArtifactActionGroup.java index d3c0e6fbe524..16d3e139c861 100644 --- a/java/compiler/impl/src/com/intellij/compiler/actions/BuildArtifactActionGroup.java +++ b/java/compiler/impl/src/com/intellij/compiler/actions/BuildArtifactActionGroup.java @@ -1,14 +1,19 @@ package com.intellij.compiler.actions; -import com.intellij.openapi.actionSystem.*; +import com.intellij.openapi.actionSystem.ActionGroup; +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.project.Project; -import com.intellij.packaging.artifacts.ArtifactManager; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.packaging.artifacts.Artifact; -import com.intellij.util.containers.ContainerUtil; -import com.intellij.util.NotNullFunction; +import com.intellij.packaging.artifacts.ArtifactManager; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.ArrayList; +import java.util.List; + /** * @author nik */ @@ -23,12 +28,13 @@ public class BuildArtifactActionGroup extends ActionGroup { final Project project = e.getData(PlatformDataKeys.PROJECT); if (project == null) return EMPTY_ARRAY; - final Artifact[] artifacts = ArtifactManager.getInstance(project).getArtifacts(); - return ContainerUtil.map2Array(artifacts, AnAction.class, new NotNullFunction() { - @NotNull - public AnAction fun(Artifact artifact) { - return new BuildArtifactAction(project, artifact); + final Artifact[] artifacts = ArtifactManager.getInstance(project).getSortedArtifacts(); + List actions = new ArrayList(); + for (Artifact artifact : artifacts) { + if (!StringUtil.isEmpty(artifact.getOutputPath())) { + actions.add(new BuildArtifactAction(project, artifact)); } - }); + } + return actions.toArray(new AnAction[actions.size()]); } } diff --git a/java/compiler/impl/src/com/intellij/compiler/ant/ProjectBuild.java b/java/compiler/impl/src/com/intellij/compiler/ant/ProjectBuild.java index 498a9a1a9860..8504d37a936d 100644 --- a/java/compiler/impl/src/com/intellij/compiler/ant/ProjectBuild.java +++ b/java/compiler/impl/src/com/intellij/compiler/ant/ProjectBuild.java @@ -54,7 +54,7 @@ public abstract class ProjectBuild extends Generator { myAntProject.add(initTarget, 1); ArtifactsGenerator artifactsGenerator; - if (ArtifactManager.useArtifacts()) { + if (ArtifactManager.getInstance(project).getArtifacts().length > 0) { artifactsGenerator = new ArtifactsGenerator(project, genOptions); } else { diff --git a/java/compiler/impl/src/com/intellij/openapi/deployment/DeploymentUtilImpl.java b/java/compiler/impl/src/com/intellij/openapi/deployment/DeploymentUtilImpl.java index 220d6510466d..53f06711a56e 100644 --- a/java/compiler/impl/src/com/intellij/openapi/deployment/DeploymentUtilImpl.java +++ b/java/compiler/impl/src/com/intellij/openapi/deployment/DeploymentUtilImpl.java @@ -12,7 +12,6 @@ import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleUtil; import com.intellij.openapi.roots.*; -import com.intellij.openapi.roots.impl.OrderEntryUtil; import com.intellij.openapi.roots.libraries.Library; import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.Ref; @@ -413,16 +412,6 @@ public class DeploymentUtilImpl extends DeploymentUtil { } } - public void addModuleOutputJarToParent(@NotNull BuildRecipe instructions, - @NotNull Module module, - @NotNull String relativePath, - @NotNull CompileContext context, - String linkContainerDescription, - @Nullable PackagingFileFilter fileFilter) { - String path = getRelativePathForManifestLinking(relativePath); - addJarJavaModuleOutput(instructions, module, path, context, linkContainerDescription, fileFilter); - } - private static void addJarJavaModuleOutput(BuildRecipe instructions, Module module, String relativePath, @@ -449,38 +438,10 @@ public class DeploymentUtilImpl extends DeploymentUtil { return new LibraryLinkImpl(library, parentModule); } - public PackagingConfiguration createPackagingConfiguration(@NotNull Module module) { - return new PackagingConfigurationImpl(module); - } - public BuildRecipe createBuildRecipe() { return new BuildRecipeImpl(); } - public @Nullable ContainerElement findElementByOrderEntry(PackagingConfiguration packagingConfiguration, OrderEntry entry) { - if (entry instanceof ModuleOrderEntry) { - final Module module = ((ModuleOrderEntry)entry).getModule(); - if (module == null) return null; - - for (ModuleLink link : packagingConfiguration.getContainingModules()) { - if (link.getModule() == module) { - return link; - } - } - } - else if (entry instanceof LibraryOrderEntry) { - final Library library = ((LibraryOrderEntry)entry).getLibrary(); - if (library == null) return null; - - for (LibraryLink link : packagingConfiguration.getContainingLibraries()) { - if (OrderEntryUtil.equals(library, link.getLibrary())) { - return link; - } - } - } - return null; - } - @Nullable public String getConfigFileErrorMessage(final ConfigFile configFile) { if (configFile.getVirtualFile() == null) { diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactImpl.java b/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactImpl.java index 94a1b44d338b..43c3325a4ac4 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactImpl.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactImpl.java @@ -1,5 +1,6 @@ package com.intellij.packaging.impl.artifacts; +import com.intellij.openapi.util.UserDataHolderBase; import com.intellij.packaging.artifacts.ArtifactProperties; import com.intellij.packaging.artifacts.ArtifactPropertiesProvider; import com.intellij.packaging.artifacts.ArtifactType; @@ -16,7 +17,7 @@ import java.util.Map; /** * @author nik */ -public class ArtifactImpl implements ModifiableArtifact { +public class ArtifactImpl extends UserDataHolderBase implements ModifiableArtifact { private CompositePackagingElement myRootElement; private String myName; private boolean myBuildOnMake; diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactManagerImpl.java b/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactManagerImpl.java index 6614272f1a89..381d2b6fb1d5 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactManagerImpl.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactManagerImpl.java @@ -8,8 +8,10 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.ModificationTracker; import com.intellij.openapi.util.Pair; +import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.packaging.artifacts.*; import com.intellij.packaging.elements.*; +import com.intellij.util.containers.ContainerUtil; import com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters; import com.intellij.util.xmlb.XmlSerializer; import gnu.trove.THashSet; @@ -18,10 +20,7 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Set; +import java.util.*; /** * @author nik @@ -36,18 +35,19 @@ import java.util.Set; public class ArtifactManagerImpl extends ArtifactManager implements ProjectComponent, PersistentStateComponent { private static final Logger LOG = Logger.getInstance("#com.intellij.packaging.impl.artifacts.ArtifactManagerImpl"); @NonNls public static final String COMPONENT_NAME = "ArtifactManager"; + @NonNls public static final String PACKAGING_ELEMENT_NAME = "element"; + @NonNls public static final String TYPE_ID_ATTRIBUTE = "id"; private final ArtifactManagerModel myModel = new ArtifactManagerModel(); private final Project myProject; private final DefaultPackagingElementResolvingContext myResolvingContext; private boolean myInsideCommit = false; - @NonNls public static final String PACKAGING_ELEMENT_NAME = "element"; - @NonNls public static final String TYPE_ID_ATTRIBUTE = "id"; private long myModificationCount; private final ModificationTracker myModificationTracker = new ModificationTracker() { public long getModificationCount() { return myModificationCount; } }; + private Map myWatchedOutputs = new HashMap(); public ArtifactManagerImpl(Project project) { myProject = project; @@ -182,6 +182,7 @@ public class ArtifactManagerImpl extends ArtifactManager implements ProjectCompo } public void disposeComponent() { + LocalFileSystem.getInstance().removeWatchedRoots(myWatchedOutputs.values()); } @NotNull @@ -190,6 +191,34 @@ public class ArtifactManagerImpl extends ArtifactManager implements ProjectCompo } public void initComponent() { + updateWatchedRoots(); + } + + private void updateWatchedRoots() { + Set pathsToRemove = new HashSet(myWatchedOutputs.keySet()); + Set toAdd = new HashSet(); + for (Artifact artifact : getArtifacts()) { + final String path = artifact.getOutputPath(); + if (path != null && path.length() > 0) { + pathsToRemove.remove(path); + if (!myWatchedOutputs.containsKey(path)) { + toAdd.add(path); + } + } + } + + List requestsToRemove = new ArrayList(); + for (String path : pathsToRemove) { + final LocalFileSystem.WatchRequest request = myWatchedOutputs.remove(path); + ContainerUtil.addIfNotNull(request, requestsToRemove); + } + + final LocalFileSystem fileSystem = LocalFileSystem.getInstance(); + fileSystem.removeWatchedRoots(requestsToRemove); + final Set newRequests = fileSystem.addRootsToWatch(toAdd, true); + for (LocalFileSystem.WatchRequest request : newRequests) { + myWatchedOutputs.put(request.getRootPath(), request); + } } public void projectOpened() { @@ -198,6 +227,11 @@ public class ArtifactManagerImpl extends ArtifactManager implements ProjectCompo public void projectClosed() { } + @Override + public Artifact[] getSortedArtifacts() { + return myModel.getSortedArtifacts(); + } + @Override public ModifiableArtifactModel createModifiableModel() { ((ArtifactPointerManagerImpl)ArtifactPointerManager.getInstance(myProject)).updateAllPointers(); @@ -278,6 +312,11 @@ public class ArtifactManagerImpl extends ArtifactManager implements ProjectCompo }.execute().getResultObject(); } + @Override + public void addElementsToDirectory(@NotNull Artifact artifact, @NotNull String relativePath, @NotNull PackagingElement element) { + addElementsToDirectory(artifact, relativePath, Collections.singletonList(element)); + } + @Override public void addElementsToDirectory(@NotNull Artifact artifact, @NotNull String relativePath, @NotNull Collection> elements) { @@ -298,15 +337,30 @@ public class ArtifactManagerImpl extends ArtifactManager implements ProjectCompo private static class ArtifactManagerModel extends ArtifactModelBase { private List myArtifactsList = new ArrayList(); + private Artifact[] mySortedArtifacts; public void setArtifactsList(List artifactsList) { myArtifactsList = artifactsList; artifactsChanged(); } + @Override + protected void artifactsChanged() { + super.artifactsChanged(); + mySortedArtifacts = null; + } + protected List getArtifactsList() { return myArtifactsList; } + + public Artifact[] getSortedArtifacts() { + if (mySortedArtifacts == null) { + mySortedArtifacts = getArtifacts().clone(); + Arrays.sort(mySortedArtifacts, ARTIFACT_COMPARATOR); + } + return mySortedArtifacts; + } } } diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactPointerManagerImpl.java b/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactPointerManagerImpl.java index 22d7c29a784c..9caecab44f87 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactPointerManagerImpl.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactPointerManagerImpl.java @@ -57,9 +57,10 @@ public class ArtifactPointerManagerImpl extends ArtifactPointerManager { } public ArtifactPointer create(@NotNull Artifact artifact) { - ArtifactPointerImpl pointer = myPointers.get(artifact.getName()); + final String name = artifact.getName(); + ArtifactPointerImpl pointer = myPointers.get(name); if (pointer == null) { - pointer = new ArtifactPointerImpl(myProject, artifact); + pointer = new ArtifactPointerImpl(myProject, name); myPointers.put(artifact.getName(), pointer); } return pointer; diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactUtil.java b/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactUtil.java index 6cb85943dc13..d12aa6269431 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactUtil.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactUtil.java @@ -2,6 +2,7 @@ package com.intellij.packaging.impl.artifacts; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.CompilerProjectExtension; +import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; @@ -181,19 +182,31 @@ public class ArtifactUtil { return VfsUtil.urlToPath(outputUrl) + "/artifacts/" + FileUtil.sanitizeFileName(artifactName); } - public static boolean processElements(@NotNull List> elements, + public static > boolean processElements(@NotNull List> elements, @NotNull PackagingElementResolvingContext context, @NotNull ArtifactType artifactType, - @NotNull Processor> processor) { + @NotNull final Processor processor) { + return processElements(elements, context, artifactType, new PackagingElementProcessor() { + @Override + public boolean process(@NotNull List> parents, @NotNull E e) { + return processor.process(e); + } + }); + } + + public static > boolean processElements(@NotNull List> elements, + @NotNull PackagingElementResolvingContext context, + @NotNull ArtifactType artifactType, + @NotNull PackagingElementProcessor processor) { for (PackagingElement element : elements) { - if (element instanceof ComplexPackagingElement) { + if (element instanceof ComplexPackagingElement && processor.shouldProcessSubstitution((ComplexPackagingElement)element)) { final List> substitution = ((ComplexPackagingElement)element).getSubstitution(context, artifactType); if (substitution != null && !processElements(substitution, context, artifactType, processor)) { return false; } } - else if (!processor.process(element)) { + else if (!processor.process(FList.>emptyList(), (E)element)) { return false; } } @@ -444,4 +457,22 @@ public class ArtifactUtil { public static boolean isArchiveName(String name) { return name.length() >= 4 && name.charAt(name.length() - 4) == '.' && StringUtil.endsWithIgnoreCase(name, "ar"); } + + public static void removeChildrenRecursively(@NotNull CompositePackagingElement element, @NotNull Condition> condition) { + List> toRemove = new ArrayList>(); + for (PackagingElement child : element.getChildren()) { + if (child instanceof CompositePackagingElement) { + final CompositePackagingElement compositeChild = (CompositePackagingElement)child; + removeChildrenRecursively(compositeChild, condition); + if (compositeChild.getChildren().isEmpty()) { + toRemove.add(child); + } + } + else if (condition.value(child)) { + toRemove.add(child); + } + } + + element.removeChildren(toRemove); + } } diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/PackagingElementProcessor.java b/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/PackagingElementProcessor.java index a0e8c3b7aacc..c1b5d626121a 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/PackagingElementProcessor.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/PackagingElementProcessor.java @@ -1,10 +1,8 @@ package com.intellij.packaging.impl.artifacts; -import com.intellij.openapi.util.text.StringUtil; import com.intellij.packaging.elements.ComplexPackagingElement; import com.intellij.packaging.elements.CompositePackagingElement; import com.intellij.packaging.elements.PackagingElement; -import com.intellij.util.Function; import org.jetbrains.annotations.NotNull; import java.util.List; @@ -23,11 +21,14 @@ public abstract class PackagingElementProcessor> { public abstract boolean process(@NotNull List> parents, @NotNull E e); - protected final String getPathFromRoot(List> parents, String separator) { - return StringUtil.join(parents, new Function, String>() { - public String fun(CompositePackagingElement element) { - return element.getName(); + protected static String getPathFromRoot(List> parents, String separator) { + StringBuilder builder = new StringBuilder(); + for (int i = parents.size() - 1; i >= 0; i--) { + builder.append(parents.get(i).getName()); + if (i > 0) { + builder.append(separator); } - }, separator); + } + return builder.toString(); } } diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/compiler/CopyToDirectoryInstructionCreator.java b/java/compiler/impl/src/com/intellij/packaging/impl/compiler/CopyToDirectoryInstructionCreator.java index 2220b83e028d..205619d33a26 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/compiler/CopyToDirectoryInstructionCreator.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/compiler/CopyToDirectoryInstructionCreator.java @@ -11,25 +11,24 @@ import org.jetbrains.annotations.Nullable; * @author nik */ public class CopyToDirectoryInstructionCreator extends IncrementalCompilerInstructionCreatorBase { - private final ArtifactsProcessingItemsBuilderContext myContext; private final String myOutputPath; private final @Nullable VirtualFile myOutputFile; public CopyToDirectoryInstructionCreator(ArtifactsProcessingItemsBuilderContext context, String outputPath, @Nullable VirtualFile outputFile) { - myContext = context; + super(context); myOutputPath = outputPath; myOutputFile = outputFile; } - public void addFileCopyInstruction(@NotNull VirtualFile file, String outputFileName) { + public void addFileCopyInstruction(@NotNull VirtualFile file, @NotNull String outputFileName) { myContext.addDestination(file, new ExplodedDestinationInfo(myOutputPath + "/" + outputFileName, outputChild(outputFileName))); } - public IncrementalCompilerInstructionCreator subFolder(String directoryName) { + public IncrementalCompilerInstructionCreator subFolder(@NotNull String directoryName) { return new CopyToDirectoryInstructionCreator(myContext, myOutputPath + "/" + directoryName, outputChild(directoryName)); } - public IncrementalCompilerInstructionCreator archive(String archiveFileName) { + public IncrementalCompilerInstructionCreator archive(@NotNull String archiveFileName) { String jarOutputPath = myOutputPath + "/" + archiveFileName; final JarInfo jarInfo = new JarInfo(); VirtualFile outputFile = outputChild(archiveFileName); diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/compiler/IncrementalCompilerInstructionCreatorBase.java b/java/compiler/impl/src/com/intellij/packaging/impl/compiler/IncrementalCompilerInstructionCreatorBase.java index 6bd3558b22be..cc62c4e74910 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/compiler/IncrementalCompilerInstructionCreatorBase.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/compiler/IncrementalCompilerInstructionCreatorBase.java @@ -1,21 +1,36 @@ package com.intellij.packaging.impl.compiler; +import com.intellij.openapi.compiler.make.PackagingFileFilter; import com.intellij.packaging.elements.IncrementalCompilerInstructionCreator; import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * @author nik */ public abstract class IncrementalCompilerInstructionCreatorBase implements IncrementalCompilerInstructionCreator { - public void addDirectoryCopyInstructions(VirtualFile directory) { + protected final ArtifactsProcessingItemsBuilderContext myContext; + + public IncrementalCompilerInstructionCreatorBase(ArtifactsProcessingItemsBuilderContext context) { + myContext = context; + } + + public void addDirectoryCopyInstructions(@NotNull VirtualFile directory) { + addDirectoryCopyInstructions(directory, null); + } + + public void addDirectoryCopyInstructions(@NotNull VirtualFile directory, @Nullable PackagingFileFilter filter) { final VirtualFile[] children = directory.getChildren(); if (children != null) { for (VirtualFile child : children) { - if (!child.isDirectory()) { - addFileCopyInstruction(child, child.getName()); - } - else { - subFolder(child.getName()).addDirectoryCopyInstructions(child); + if (filter == null || filter.accept(child, myContext.getCompileContext())) { + if (!child.isDirectory()) { + addFileCopyInstruction(child, child.getName()); + } + else { + subFolder(child.getName()).addDirectoryCopyInstructions(child, filter); + } } } } diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/compiler/PackIntoArchiveInstructionCreator.java b/java/compiler/impl/src/com/intellij/packaging/impl/compiler/PackIntoArchiveInstructionCreator.java index ee55e3b889c9..3792e6540a17 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/compiler/PackIntoArchiveInstructionCreator.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/compiler/PackIntoArchiveInstructionCreator.java @@ -12,20 +12,19 @@ import org.jetbrains.annotations.NotNull; * @author nik */ public class PackIntoArchiveInstructionCreator extends IncrementalCompilerInstructionCreatorBase { - private final ArtifactsProcessingItemsBuilderContext myContext; private final DestinationInfo myJarDestination; private final JarInfo myJarInfo; private final String myPathInJar; public PackIntoArchiveInstructionCreator(ArtifactsProcessingItemsBuilderContext context, JarInfo jarInfo, String pathInJar, DestinationInfo jarDestination) { - myContext = context; + super(context); myJarInfo = jarInfo; myPathInJar = pathInJar; myJarDestination = jarDestination; } - public void addFileCopyInstruction(@NotNull VirtualFile file, String outputFileName) { + public void addFileCopyInstruction(@NotNull VirtualFile file, @NotNull String outputFileName) { final String pathInJar = childPathInJar(outputFileName); myContext.addDestination(file, new JarDestinationInfo(pathInJar, myJarInfo, myJarDestination)); myJarInfo.addContent(pathInJar, file); @@ -35,11 +34,11 @@ public class PackIntoArchiveInstructionCreator extends IncrementalCompilerInstru return myPathInJar.length() == 0 ? fileName : myPathInJar + "/" + fileName; } - public IncrementalCompilerInstructionCreator subFolder(String directoryName) { + public IncrementalCompilerInstructionCreator subFolder(@NotNull String directoryName) { return new PackIntoArchiveInstructionCreator(myContext, myJarInfo, childPathInJar(directoryName), myJarDestination); } - public IncrementalCompilerInstructionCreator archive(String archiveFileName) { + public IncrementalCompilerInstructionCreator archive(@NotNull String archiveFileName) { final JarInfo jarInfo = new JarInfo(); if (myJarDestination instanceof ExplodedDestinationInfo) { myContext.registerJarFile(jarInfo, myJarDestination.getOutputPath()); diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/elements/ArtifactElementType.java b/java/compiler/impl/src/com/intellij/packaging/impl/elements/ArtifactElementType.java index 9b1195c24bba..b8c882aa76e4 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/elements/ArtifactElementType.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/elements/ArtifactElementType.java @@ -3,6 +3,7 @@ package com.intellij.packaging.impl.elements; import com.intellij.openapi.compiler.CompilerBundle; import com.intellij.openapi.project.Project; import com.intellij.packaging.artifacts.Artifact; +import com.intellij.packaging.artifacts.ArtifactManager; import com.intellij.packaging.artifacts.ArtifactPointerManager; import com.intellij.packaging.elements.CompositePackagingElement; import com.intellij.packaging.elements.PackagingElementType; @@ -70,7 +71,9 @@ public class ArtifactElementType extends PackagingElementType(result); + final ArrayList list = new ArrayList(result); + Collections.sort(list, ArtifactManager.ARTIFACT_COMPARATOR); + return list; } @NotNull diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/elements/FileCopyPackagingElement.java b/java/compiler/impl/src/com/intellij/packaging/impl/elements/FileCopyPackagingElement.java index 2e0bacd9eb60..2e9ba01ea6b8 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/elements/FileCopyPackagingElement.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/elements/FileCopyPackagingElement.java @@ -78,7 +78,7 @@ public class FileCopyPackagingElement extends PackagingElement TOPIC = Topic.create("artifacts changes", ArtifactListener.class); + public static final Comparator ARTIFACT_COMPARATOR = new Comparator() { + public int compare(Artifact o1, Artifact o2) { + return o1.getName().compareToIgnoreCase(o2.getName()); + } + }; public static ArtifactManager getInstance(@NotNull Project project) { return ServiceManager.getService(project, ArtifactManager.class); } + public abstract Artifact[] getSortedArtifacts(); + public abstract ModifiableArtifactModel createModifiableModel(); public abstract PackagingElementResolvingContext getResolvingContext(); @@ -34,13 +41,8 @@ public abstract class ArtifactManager implements ArtifactModel { public abstract void addElementsToDirectory(@NotNull Artifact artifact, @NotNull String relativePath, @NotNull Collection> elements); + public abstract void addElementsToDirectory(@NotNull Artifact artifact, @NotNull String relativePath, + @NotNull PackagingElement element); + public abstract ModificationTracker getModificationTracker(); - - public static boolean useArtifactsForDeployment() { - return Boolean.parseBoolean(System.getProperty("idea.use.artifacts.for.deployment")); - } - - public static boolean useArtifacts() { - return ApplicationManagerEx.getApplicationEx().isInternal(); - } } diff --git a/java/compiler/openapi/src/com/intellij/packaging/elements/CompositePackagingElement.java b/java/compiler/openapi/src/com/intellij/packaging/elements/CompositePackagingElement.java index 5fa26cfe03a6..5f9c07530250 100644 --- a/java/compiler/openapi/src/com/intellij/packaging/elements/CompositePackagingElement.java +++ b/java/compiler/openapi/src/com/intellij/packaging/elements/CompositePackagingElement.java @@ -65,6 +65,11 @@ public abstract class CompositePackagingElement extends PackagingElement i myUnmodifiableChildren = null; } + public void removeChildren(@NotNull Collection> children) { + myChildren.removeAll(children); + myUnmodifiableChildren = null; + } + @NotNull public List> getChildren() { if (myUnmodifiableChildren == null) { diff --git a/java/compiler/openapi/src/com/intellij/packaging/elements/IncrementalCompilerInstructionCreator.java b/java/compiler/openapi/src/com/intellij/packaging/elements/IncrementalCompilerInstructionCreator.java index 69f76f3f8624..f30d7eb4c827 100644 --- a/java/compiler/openapi/src/com/intellij/packaging/elements/IncrementalCompilerInstructionCreator.java +++ b/java/compiler/openapi/src/com/intellij/packaging/elements/IncrementalCompilerInstructionCreator.java @@ -1,18 +1,22 @@ package com.intellij.packaging.elements; +import com.intellij.openapi.compiler.make.PackagingFileFilter; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * @author nik */ public interface IncrementalCompilerInstructionCreator { - void addFileCopyInstruction(@NotNull VirtualFile file, String outputFileName); + void addFileCopyInstruction(@NotNull VirtualFile file, @NotNull String outputFileName); - void addDirectoryCopyInstructions(VirtualFile directory); + void addDirectoryCopyInstructions(@NotNull VirtualFile directory); - IncrementalCompilerInstructionCreator subFolder(String directoryName); + void addDirectoryCopyInstructions(@NotNull VirtualFile directory, @Nullable PackagingFileFilter filter); - IncrementalCompilerInstructionCreator archive(String archiveFileName); + IncrementalCompilerInstructionCreator subFolder(@NotNull String directoryName); + + IncrementalCompilerInstructionCreator archive(@NotNull String archiveFileName); } diff --git a/java/idea-ui/src/com/intellij/facet/impl/ProjectFacetsConfigurator.java b/java/idea-ui/src/com/intellij/facet/impl/ProjectFacetsConfigurator.java index 0080c177dfb3..61ef8662c6b7 100644 --- a/java/idea-ui/src/com/intellij/facet/impl/ProjectFacetsConfigurator.java +++ b/java/idea-ui/src/com/intellij/facet/impl/ProjectFacetsConfigurator.java @@ -272,7 +272,6 @@ public class ProjectFacetsConfigurator implements FacetsProvider, ModuleEditor.C editor.disposeUIResources(); } myProjectData = null; - ((ProjectFacetManagerImpl)ProjectFacetManagerImpl.getInstance(myProject)).fireRunnableOnProjectSettingsClosed(); } @NotNull diff --git a/java/idea-ui/src/com/intellij/jar/BuildJarAction.java b/java/idea-ui/src/com/intellij/jar/BuildJarAction.java deleted file mode 100644 index a9f01cfdc2bd..000000000000 --- a/java/idea-ui/src/com/intellij/jar/BuildJarAction.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.intellij.jar; - -import com.intellij.ide.IdeBundle; -import com.intellij.openapi.actionSystem.AnAction; -import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.actionSystem.PlatformDataKeys; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.ui.Messages; - -import java.util.Collection; - -/** - * @author cdr - */ -public class BuildJarAction extends AnAction { - public void actionPerformed(AnActionEvent e) { - Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext()); - Collection modulesToJar = BuildJarDialog.getModulesToJar(project); - if (modulesToJar.isEmpty()) { - Messages.showErrorDialog(project, IdeBundle.message("jar.no.java.modules.in.project.error"), - IdeBundle.message("jar.no.java.modules.in.project.title")); - return; - } - BuildJarDialog dialog = new BuildJarDialog(project); - dialog.show(); - if (dialog.isOK()) { - BuildJarProjectSettings.getInstance(project).buildJarsWithProgress(); - } - } - - public void update(AnActionEvent e) { - Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext()); - e.getPresentation().setEnabled(project != null); - } -} diff --git a/java/idea-ui/src/com/intellij/jar/BuildJarDialog.form b/java/idea-ui/src/com/intellij/jar/BuildJarDialog.form deleted file mode 100644 index b8d433dac900..000000000000 --- a/java/idea-ui/src/com/intellij/jar/BuildJarDialog.form +++ /dev/null @@ -1,120 +0,0 @@ - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/java/idea-ui/src/com/intellij/jar/BuildJarDialog.java b/java/idea-ui/src/com/intellij/jar/BuildJarDialog.java deleted file mode 100644 index fe4b6d314a36..000000000000 --- a/java/idea-ui/src/com/intellij/jar/BuildJarDialog.java +++ /dev/null @@ -1,437 +0,0 @@ -package com.intellij.jar; - -import com.intellij.execution.configurations.RuntimeConfigurationException; -import com.intellij.facet.impl.DefaultFacetsProvider; -import com.intellij.ide.IdeBundle; -import com.intellij.ide.RecentProjectsManager; -import com.intellij.ide.util.ElementsChooser; -import com.intellij.ide.util.TreeClassChooser; -import com.intellij.ide.util.TreeClassChooserFactory; -import com.intellij.openapi.deployment.DeploymentUtil; -import com.intellij.openapi.deployment.ModuleLink; -import com.intellij.openapi.deployment.PackagingConfiguration; -import com.intellij.openapi.deployment.PackagingMethod; -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.fileTypes.FileType; -import com.intellij.openapi.fileTypes.FileTypeManager; -import com.intellij.openapi.fileTypes.FileTypes; -import com.intellij.openapi.help.HelpManager; -import com.intellij.openapi.module.JavaModuleType; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.module.ModuleManager; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.roots.ModuleRootManager; -import com.intellij.openapi.roots.ui.configuration.DefaultModulesProvider; -import com.intellij.openapi.roots.ui.configuration.packaging.PackagingEditor; -import com.intellij.openapi.roots.ui.configuration.packaging.PackagingEditorImpl; -import com.intellij.openapi.ui.DialogWrapper; -import com.intellij.openapi.ui.LabeledComponent; -import com.intellij.openapi.ui.SplitterProportionsData; -import com.intellij.openapi.ui.TextFieldWithBrowseButton; -import com.intellij.openapi.util.Comparing; -import com.intellij.openapi.util.IconLoader; -import com.intellij.openapi.util.InvalidDataException; -import com.intellij.openapi.util.WriteExternalException; -import com.intellij.openapi.util.io.FileUtil; -import com.intellij.openapi.vfs.VfsUtil; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.openapi.wm.WindowManager; -import com.intellij.peer.PeerFactory; -import com.intellij.psi.JavaPsiFacade; -import com.intellij.psi.PsiClass; -import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.ui.DocumentAdapter; -import com.intellij.ui.GuiUtils; -import com.intellij.util.io.FileTypeFilter; -import gnu.trove.THashMap; -import org.jdom.Element; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; - -import javax.swing.*; -import javax.swing.border.TitledBorder; -import javax.swing.event.DocumentEvent; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; -import javax.swing.filechooser.FileView; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.File; -import java.text.MessageFormat; -import java.util.*; - -/** - * @author cdr - */ -public class BuildJarDialog extends DialogWrapper { - private static final Logger LOG = Logger.getInstance("#com.intellij.j2ee.jar.BuildJarDialog"); - @NonNls private static final String WARNING_TEMPLATE = "{0}: {1}"; - private final Project myProject; - private JPanel myModulesPanel; - private JPanel myEditorPanel; - private TextFieldWithBrowseButton myJarPath; - private TextFieldWithBrowseButton myMainClass; - private JPanel myPanel; - private final Map mySettings = new THashMap(); - private Module myCurrentModule; - private ElementsChooser myElementsChooser; - private JPanel myModuleSettingsPanel; - private LabeledComponent myMainClassComponent; - private LabeledComponent myJarFilePathComponent; - private JCheckBox myBuildJarsOnMake; - private JLabel myWarningLabel; - private final SplitterProportionsData mySplitterProportionsData = PeerFactory.getInstance().getUIHelper().createSplitterProportionsData(); - - protected BuildJarDialog(Project project) { - super(true); - myProject = project; - - setupControls(); - - setTitle(IdeBundle.message("jar.build.dialog.title")); - mySplitterProportionsData.externalizeFromDimensionService(getDimensionKey()); - mySplitterProportionsData.restoreSplitterProportions(myPanel); - getOKAction().putValue(Action.NAME, IdeBundle.message("jar.build.button")); - init(); - updateWarning(); - } - - private void updateWarning() { - for (Map.Entry entry : mySettings.entrySet()) { - try { - final SettingsEditor editor = entry.getValue(); - if (editor.myModule == myCurrentModule) { - editor.saveUI(); - } - editor.checkSettings(); - } - catch (RuntimeConfigurationException e) { - myWarningLabel.setText(MessageFormat.format(WARNING_TEMPLATE, entry.getKey().getName(), e.getMessage())); - myWarningLabel.setVisible(true); - repaint(); - return; - } - } - repaint(); - myWarningLabel.setVisible(false); - } - - protected void doHelpAction() { - HelpManager.getInstance().invokeHelp("editing.generateJarFiles"); - } - protected Action[] createActions() { - return new Action[]{getOKAction(), getCancelAction(), getHelpAction()}; - } - - public static Collection getModulesToJar(Project project) { - final Module[] modules = ModuleManager.getInstance(project).getModules(); - ArrayList result = new ArrayList(); - for (Module module : modules) { - if (module.getModuleType() instanceof JavaModuleType) { - result.add(module); - } - } - Collections.sort(result, new Comparator() { - public int compare(final Module o1, final Module o2) { - return o1.getName().compareToIgnoreCase(o2.getName()); - } - }); - return result; - - } - - private void setupControls() { - myWarningLabel.setIcon(IconLoader.getIcon("/runConfigurations/configurationWarning.png")); - - myBuildJarsOnMake.setSelected(BuildJarProjectSettings.getInstance(myProject).isBuildJarOnMake()); - - myJarPath = myJarFilePathComponent.getComponent(); - myMainClass = myMainClassComponent.getComponent(); - - myElementsChooser = new ElementsChooser(true) { - @Override - protected String getItemText(@NotNull final Module value) { - return value.getName(); - } - }; - myElementsChooser.setColorUnmarkedElements(false); - myModulesPanel.setLayout(new BorderLayout()); - myModulesPanel.add(myElementsChooser, BorderLayout.CENTER); - - final Collection modules = getModulesToJar(myProject); - for (final Module module : modules) { - BuildJarSettings buildJarSettings = BuildJarSettings.getInstance(module); - myElementsChooser.addElement(module, buildJarSettings.isBuildJar(), new ChooserElementProperties(module)); - } - myElementsChooser.addListSelectionListener(new ListSelectionListener() { - public void valueChanged(ListSelectionEvent e) { - if (myCurrentModule != null) { - saveEditor(myCurrentModule); - } - - Module selectedModule = myElementsChooser.getSelectedElement(); - myCurrentModule = selectedModule; - if (selectedModule != null) { - BuildJarSettings buildJarSettings = BuildJarSettings.getInstance(selectedModule); - SettingsEditor settingsEditor = mySettings.get(selectedModule); - if (settingsEditor == null) { - settingsEditor = new SettingsEditor(selectedModule, buildJarSettings); - mySettings.put(selectedModule, settingsEditor); - } - settingsEditor.refreshControls(); - boolean isBuildJar = myElementsChooser.getMarkedElements().contains(selectedModule); - GuiUtils.enableChildren(myModuleSettingsPanel, isBuildJar); - settingsEditor.rebuildTree(); - TitledBorder titledBorder = (TitledBorder)myModuleSettingsPanel.getBorder(); - titledBorder.setTitle(IdeBundle.message("jar.build.module.0.jar.settings", selectedModule.getName())); - myModuleSettingsPanel.repaint(); - } - } - }); - myElementsChooser.addElementsMarkListener(new ElementsChooser.ElementsMarkListener() { - public void elementMarkChanged(final Module element, final boolean isMarked) { - GuiUtils.enableChildren(myModuleSettingsPanel, isMarked); - SettingsEditor settingsEditor = mySettings.get(element); - if (isMarked) { - setDefaultJarPath(); - if (settingsEditor != null) { - PackagingConfiguration configuration = settingsEditor.getEditor().getModifiedConfiguration(); - if (configuration.getElements().length == 0) { - ModuleLink moduleLink = DeploymentUtil.getInstance().createModuleLink(element, element); - moduleLink.setPackagingMethod(PackagingMethod.COPY_FILES); - moduleLink.setURI("/"); - configuration.addOrReplaceElement(moduleLink); - } - } - } - - if (settingsEditor != null) { - settingsEditor.rebuildTree(); - } - } - }); - myJarPath.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - String lastFilePath = myJarPath.getText(); - String path = lastFilePath == null ? RecentProjectsManager.getInstance().getLastProjectPath() : lastFilePath; - File file = new File(path); - if (!file.exists()) { - path = file.getParent(); - } - JFileChooser fileChooser = new JFileChooser(path); - FileView fileView = new FileView() { - public Icon getIcon(File f) { - if (f.isDirectory()) return super.getIcon(f); - FileType fileType = FileTypeManager.getInstance().getFileTypeByFileName(f.getName()); - return fileType.getIcon(); - } - }; - fileChooser.setFileView(fileView); - fileChooser.setMultiSelectionEnabled(false); - fileChooser.setAcceptAllFileFilterUsed(false); - fileChooser.setDialogTitle(IdeBundle.message("jar.build.save.title")); - fileChooser.addChoosableFileFilter(new FileTypeFilter(FileTypes.ARCHIVE)); - - if (fileChooser.showSaveDialog(WindowManager.getInstance().suggestParentWindow(myProject)) != JFileChooser.APPROVE_OPTION) { - return; - } - file = fileChooser.getSelectedFile(); - if (file == null) return; - myJarPath.setText(file.getPath()); - } - }); - - myMainClass.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - String mainClass = myMainClass.getText(); - GlobalSearchScope scope = createMainClassScope(); - PsiClass aClass = JavaPsiFacade.getInstance(myProject).findClass(mainClass, scope); - TreeClassChooserFactory factory = TreeClassChooserFactory.getInstance(myProject); - final TreeClassChooser dialog = - factory.createNoInnerClassesScopeChooser(IdeBundle.message("jar.build.main.class.title"), scope, null, aClass); - dialog.showDialog(); - final PsiClass psiClass = dialog.getSelectedClass(); - if (psiClass != null && psiClass.getQualifiedName() != null) { - myMainClass.setText(psiClass.getQualifiedName()); - } - updateWarning(); - } - }); - myMainClass.getTextField().getDocument().addDocumentListener(new DocumentAdapter() { - protected void textChanged(DocumentEvent e) { - updateWarning(); - } - }); - - SwingUtilities.invokeLater(new Runnable() { - public void run() { - Module element = myElementsChooser.getElementAt(0); - myElementsChooser.selectElements(Collections.singletonList(element)); - } - }); - GuiUtils.replaceJSplitPaneWithIDEASplitter(myPanel); - } - - private GlobalSearchScope createMainClassScope() { - GlobalSearchScope result = null; - for (Module module : mySettings.keySet()) { - GlobalSearchScope scope = GlobalSearchScope.moduleWithLibrariesScope(module); - if (result == null) { - result = scope; - } - else { - result = result.uniteWith(scope); - } - } - return result != null ? result : GlobalSearchScope.allScope(myProject); - } - - public JComponent getPreferredFocusedComponent() { - return myJarPath; - } - - private void setDefaultJarPath() { - if (!Comparing.strEqual(myJarPath.getText(), "") || myCurrentModule == null) { - return; - } - VirtualFile[] contentRoots = ModuleRootManager.getInstance(myCurrentModule).getContentRoots(); - if (contentRoots.length == 0) return; - VirtualFile contentRoot = contentRoots[0]; - if (contentRoot == null) return; - VirtualFile moduleFile = myCurrentModule.getModuleFile(); - if (moduleFile == null) return; - String jarPath = FileUtil.toSystemDependentName(contentRoot.getPath() + "/" + moduleFile.getNameWithoutExtension() + ".jar"); - myJarPath.setText(jarPath); - } - - protected JComponent createCenterPanel() { - return myPanel; - } - - protected String getDimensionServiceKey() { - return "#com.intellij.j2ee.jar.BuildJarDialog"; - } - - public void dispose() { - mySplitterProportionsData.saveSplitterProportions(myPanel); - mySplitterProportionsData.externalizeToDimensionService(getDimensionKey()); - for (SettingsEditor editor : mySettings.values()) { - editor.dispose(); - } - super.dispose(); - } - - protected void doOKAction() { - if (myCurrentModule != null) { - saveEditor(myCurrentModule); - } - for (SettingsEditor editor : mySettings.values()) { - editor.apply(); - } - BuildJarProjectSettings.getInstance(myProject).setBuildJarOnMake(myBuildJarsOnMake.isSelected()); - super.doOKAction(); - } - - private void saveEditor(final Module module) { - SettingsEditor settingsEditor = mySettings.get(module); - if (settingsEditor != null) { - settingsEditor.saveUI(); - } - } - - private class SettingsEditor { - private final Module myModule; - private final BuildJarSettings myBuildJarSettings; - private final BuildJarSettings myModifiedBuildJarSettings; - private final PackagingEditor myEditor; - - public SettingsEditor(@NotNull Module module, @NotNull BuildJarSettings buildJarSettings) { - myModule = module; - myBuildJarSettings = buildJarSettings; - - myModifiedBuildJarSettings = new BuildJarSettings(module); - copySettings(buildJarSettings, myModifiedBuildJarSettings); - - DefaultModulesProvider modulesProvider = new DefaultModulesProvider(myProject); - PackagingConfiguration originalConfiguration = myBuildJarSettings.getPackagingConfiguration(); - PackagingConfiguration modifiedConfiguration = myModifiedBuildJarSettings.getPackagingConfiguration(); - JarPackagingEditorPolicy editorPolicy = new JarPackagingEditorPolicy(module); - JarPackagingTreeBuilder treeBuilder = new JarPackagingTreeBuilder(module); - myEditor = new PackagingEditorImpl(originalConfiguration, modifiedConfiguration, modulesProvider, DefaultFacetsProvider.INSTANCE, - editorPolicy, treeBuilder, false); - myEditor.reset(); - myEditor.createMainComponent(); - } - - private void refreshControls() { - myEditorPanel.removeAll(); - myEditorPanel.setLayout(new BorderLayout()); - myEditorPanel.add(myEditor.getMainPanel(), BorderLayout.CENTER); - myEditorPanel.revalidate(); - - myJarPath.setText(FileUtil.toSystemDependentName(VfsUtil.urlToPath(myModifiedBuildJarSettings.getJarUrl()))); - myMainClass.setText(myModifiedBuildJarSettings.getMainClass()); - } - - public void dispose() { - } - - public void apply() { - copySettings(myModifiedBuildJarSettings, myBuildJarSettings); - } - - public void rebuildTree() { - getEditor().rebuildTree(); - } - - public PackagingEditor getEditor() { - return myEditor; - } - - public void saveUI() { - myEditor.saveData(); - String url = VfsUtil.pathToUrl(FileUtil.toSystemIndependentName(myJarPath.getText())); - myModifiedBuildJarSettings.setJarUrl(url); - boolean isBuildJar = myElementsChooser.getMarkedElements().contains(myModule); - myModifiedBuildJarSettings.setBuildJar(isBuildJar); - myModifiedBuildJarSettings.setMainClass(myMainClass.getText()); - } - - - public void checkSettings() throws RuntimeConfigurationException { - myModifiedBuildJarSettings.checkSettings(); - } - } - - private static void copySettings(BuildJarSettings from, BuildJarSettings to) { - @NonNls Element element = new Element("dummy"); - try { - from.writeExternal(element); - } - catch (WriteExternalException ignored) { - } - try { - to.readExternal(element); - } - catch (InvalidDataException e) { - LOG.error(e); - } - } - - private static class ChooserElementProperties implements ElementsChooser.ElementProperties { - private final Module myModule; - - public ChooserElementProperties(final Module module) { - myModule = module; - } - - public Icon getIcon() { - return myModule.getModuleType().getNodeIcon(false); - } - - public Color getColor() { - return null; - } - } -} diff --git a/java/idea-ui/src/com/intellij/jar/BuildJarProjectSettings.java b/java/idea-ui/src/com/intellij/jar/BuildJarProjectSettings.java deleted file mode 100644 index f08ee333874c..000000000000 --- a/java/idea-ui/src/com/intellij/jar/BuildJarProjectSettings.java +++ /dev/null @@ -1,270 +0,0 @@ -package com.intellij.jar; - -import com.intellij.CommonBundle; -import com.intellij.ide.IdeBundle; -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.application.ReadAction; -import com.intellij.openapi.application.Result; -import com.intellij.openapi.compiler.CompileContext; -import com.intellij.openapi.compiler.CompilerManager; -import com.intellij.openapi.compiler.CompilerMessageCategory; -import com.intellij.openapi.compiler.DummyCompileContext; -import com.intellij.openapi.compiler.make.*; -import com.intellij.openapi.components.*; -import com.intellij.openapi.deployment.DeploymentUtil; -import com.intellij.openapi.deployment.LibraryLink; -import com.intellij.openapi.deployment.ModuleLink; -import com.intellij.openapi.deployment.PackagingConfiguration; -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.module.ModuleManager; -import com.intellij.openapi.progress.ProcessCanceledException; -import com.intellij.openapi.progress.ProgressIndicator; -import com.intellij.openapi.progress.ProgressManager; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.ui.Messages; -import com.intellij.openapi.util.Comparing; -import com.intellij.openapi.util.DefaultJDOMExternalizer; -import com.intellij.openapi.util.InvalidDataException; -import com.intellij.openapi.util.WriteExternalException; -import com.intellij.openapi.util.io.FileUtil; -import com.intellij.openapi.vfs.VfsUtil; -import com.intellij.openapi.wm.WindowManager; -import gnu.trove.THashSet; -import org.jdom.Element; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.Set; -import java.util.jar.Attributes; -import java.util.jar.JarOutputStream; -import java.util.jar.Manifest; - -/** - * @author cdr - */ -@State( - name = "BuildJarProjectSettings", - storages = { - @Storage(id = "default", file = "$PROJECT_FILE$") - ,@Storage(id = "dir", file = "$PROJECT_CONFIG_DIR$/compiler.xml", scheme = StorageScheme.DIRECTORY_BASED) - } -) -public class BuildJarProjectSettings implements PersistentStateComponent, ProjectComponent { - private static final Logger LOG = Logger.getInstance("#com.intellij.jar.BuildJarProjectSettings"); - - public boolean BUILD_JARS_ON_MAKE = false; - @NonNls private static final String MAIN_CLASS = Attributes.Name.MAIN_CLASS.toString(); - @NonNls private static final String JAR_EXTENSION = ".jar"; - @NonNls public static final String BUILD_JAR_PROJECT_SETTINGS_COMPONENT_NAME = "BuildJarProjectSettings"; - private final Project myProject; - - public static BuildJarProjectSettings getInstance(Project project) { - return project.getComponent(BuildJarProjectSettings.class); - } - - public BuildJarProjectSettings(Project project) { - myProject = project; - } - - public Element getState() { - try { - final Element e = new Element("state"); - DefaultJDOMExternalizer.writeExternal(this, e); - return e; - } - catch (WriteExternalException e1) { - LOG.error(e1); - return null; - } - } - - public void loadState(Element state) { - try { - DefaultJDOMExternalizer.readExternal(this, state); - } - catch (InvalidDataException e) { - LOG.error(e); - } - } - - public boolean isBuildJarOnMake() { - return BUILD_JARS_ON_MAKE; - } - - public void projectOpened() { - if (BUILD_JARS_ON_MAKE) { - CompilerManager compilerManager = CompilerManager.getInstance(myProject); - compilerManager.addCompiler(JarCompiler.getInstance()); - } - } - - public void projectClosed() { - } - - @NonNls @NotNull - public String getComponentName() { - return BUILD_JAR_PROJECT_SETTINGS_COMPONENT_NAME; - } - - public void initComponent() { - - } - - public void disposeComponent() { - - } - - public void setBuildJarOnMake(final boolean buildJar) { - if (buildJar != BUILD_JARS_ON_MAKE) { - CompilerManager compilerManager = CompilerManager.getInstance(myProject); - if (buildJar) { - compilerManager.addCompiler(JarCompiler.getInstance()); - } - else { - compilerManager.removeCompiler(JarCompiler.getInstance()); - } - } - BUILD_JARS_ON_MAKE = buildJar; - } - - public void buildJarsWithProgress() { - ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable(){ - public void run() { - buildJars(ProgressManager.getInstance().getProgressIndicator()); - } - }, IdeBundle.message("jar.build.progress.title"), true, myProject); - } - - private void buildJars(final ProgressIndicator progressIndicator) { - Module[] modules = ModuleManager.getInstance(myProject).getModules(); - try { - for (Module module : modules) { - BuildJarSettings buildJarSettings = BuildJarSettings.getInstance(module); - if (buildJarSettings == null || !buildJarSettings.isBuildJar()) continue; - String presentableJarPath = "'" + FileUtil.toSystemDependentName(VfsUtil.urlToPath(buildJarSettings.getJarUrl() + "'")); - if (progressIndicator != null) { - progressIndicator.setText(IdeBundle.message("jar.build.progress", presentableJarPath)); - } - buildJar(module, buildJarSettings,progressIndicator, null); - WindowManager.getInstance().getStatusBar(myProject).setInfo(IdeBundle.message("jar.build.success.message", presentableJarPath)); - } - } - catch (ProcessCanceledException e) { - WindowManager.getInstance().getStatusBar(myProject).setInfo(IdeBundle.message("jar.build.cancelled")); - } - catch (final IOException e) { - ApplicationManager.getApplication().invokeLater(new Runnable(){ - public void run() { - Messages.showErrorDialog(myProject, e.toString(), IdeBundle.message("jar.build.error.title")); - } - }); - } - } - - static void buildJar(final Module module, final BuildJarSettings buildJarSettings, final ProgressIndicator progressIndicator, - @Nullable CompileContext context) throws IOException { - String jarPath = buildJarSettings.getJarUrl(); - final File jarFile = new File(VfsUtil.urlToPath(jarPath)); - jarFile.delete(); - - FileUtil.createParentDirs(jarFile); - BuildRecipe buildRecipe = new ReadAction() { - protected void run(final Result result) { - result.setResult(getBuildRecipe(module, buildJarSettings)); - } - }.execute().getResultObject(); - Manifest manifest = DeploymentUtil.getInstance().createManifest(buildRecipe); - String mainClass = buildJarSettings.getMainClass(); - if (manifest != null && !Comparing.strEqual(mainClass, null)) { - manifest.getMainAttributes().putValue(MAIN_CLASS,mainClass); - } - - // write temp file and rename it to the jar to avoid deployment of incomplete jar. SCR #30303 - final File tempFile; - try { - tempFile = File.createTempFile("___"+ FileUtil.getNameWithoutExtension(jarFile), JAR_EXTENSION, jarFile.getParentFile()); - } - catch (IOException e) { - final String errorMessage = - IdeBundle.message("error.message.jar.build.cannot.create.temporary.file.in.0", jarFile.getParentFile().getAbsolutePath()); - if (context != null) { - context.addMessage(CompilerMessageCategory.ERROR, errorMessage, null, -1, -1); - } - else { - Messages.showErrorDialog(module.getProject(), errorMessage, CommonBundle.getErrorTitle()); - } - return; - } - final JarOutputStream jarOutputStream = manifest == null ? - new JarOutputStream(new BufferedOutputStream(new FileOutputStream(tempFile))) : - new JarOutputStream(new BufferedOutputStream(new FileOutputStream(tempFile)), manifest); - - final Set tempWrittenRelativePaths = new THashSet(); - final BuildRecipe dependencies = DeploymentUtil.getInstance().createBuildRecipe(); - try { - buildRecipe.visitInstructionsWithExceptions(new BuildInstructionVisitor() { - public boolean visitInstruction(BuildInstruction instruction) throws IOException { - ProgressManager.getInstance().checkCanceled(); - if (instruction instanceof FileCopyInstruction) { - FileCopyInstruction fileCopyInstruction = (FileCopyInstruction)instruction; - File file = fileCopyInstruction.getFile(); - if (file == null || !file.exists()) return true; - String presentablePath = FileUtil.toSystemDependentName(file.getPath()); - if (progressIndicator != null) { - progressIndicator.setText2(IdeBundle.message("jar.build.processing.file.progress", presentablePath)); - } - } - //todo[nik] use IncrementalPackagingCompiler instead - instruction.addFilesToJar(DummyCompileContext.getInstance(), tempFile, jarOutputStream, dependencies, tempWrittenRelativePaths, null); - return true; - } - }, false); - buildRecipe.visitInstructionsWithExceptions(new BuildInstructionVisitor() { - public boolean visitJarAndCopyBuildInstruction(final JarAndCopyBuildInstruction instruction) throws Exception { - instruction.deleteTemporaryJars(); - return true; - } - }, false); - } - catch (ProcessCanceledException e) { - throw e; - } - catch (Exception e) { - LOG.error(e); - } - finally { - jarOutputStream.close(); - try { - FileUtil.rename(tempFile, jarFile); - } - catch (IOException e) { - ApplicationManager.getApplication().invokeLater(new Runnable(){ - public void run() { - String message = IdeBundle.message("jar.build.cannot.overwrite.error", FileUtil.toSystemDependentName(jarFile.getPath()), - FileUtil.toSystemDependentName(tempFile.getPath())); - Messages.showErrorDialog(module.getProject(), message, IdeBundle.message("jar.build.error.title")); - } - }); - } - } - } - - static BuildRecipe getBuildRecipe(final Module module, final BuildJarSettings buildJarSettings) { - final DummyCompileContext compileContext = DummyCompileContext.getInstance(); - PackagingConfiguration packagingConfiguration = buildJarSettings.getPackagingConfiguration(); - BuildRecipe buildRecipe = DeploymentUtil.getInstance().createBuildRecipe(); - LibraryLink[] libraries = packagingConfiguration.getContainingLibraries(); - for (LibraryLink libraryLink : libraries) { - DeploymentUtil.getInstance().addLibraryLink(compileContext, buildRecipe, libraryLink, module, null); - } - ModuleLink[] modules = packagingConfiguration.getContainingModules(); - DeploymentUtil.getInstance().addJavaModuleOutputs(module, modules, buildRecipe, compileContext, null, IdeBundle.message("jar.build.module.presentable.name", module.getName())); - return buildRecipe; - } -} diff --git a/java/idea-ui/src/com/intellij/jar/BuildJarRefactoringListenerProvider.java b/java/idea-ui/src/com/intellij/jar/BuildJarRefactoringListenerProvider.java deleted file mode 100644 index df4551bc7b0c..000000000000 --- a/java/idea-ui/src/com/intellij/jar/BuildJarRefactoringListenerProvider.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.intellij.jar; - -import com.intellij.openapi.module.Module; -import com.intellij.openapi.module.ModuleManager; -import com.intellij.openapi.project.Project; -import com.intellij.psi.PsiClass; -import com.intellij.psi.PsiElement; -import com.intellij.refactoring.listeners.RefactoringElementListener; -import com.intellij.refactoring.listeners.RefactoringElementListenerComposite; -import com.intellij.refactoring.listeners.RefactoringElementListenerProvider; -import org.jetbrains.annotations.NotNull; - -public class BuildJarRefactoringListenerProvider implements RefactoringElementListenerProvider { - private Project myProject; - - public BuildJarRefactoringListenerProvider(Project project) { - myProject = project; - } - - public RefactoringElementListener getListener(PsiElement element) { - if (element instanceof PsiClass) { - String className = ((PsiClass)element).getQualifiedName(); - if (className == null) return null; - - final Module[] modules = ModuleManager.getInstance(myProject).getModules(); - RefactoringElementListenerComposite listener = null; - for (Module module : modules) { - final BuildJarSettings settings = BuildJarSettings.getInstance(module); - final String mainClass = settings.getMainClass(); - if (className.equals(mainClass)) { - if (listener == null) { - listener = new RefactoringElementListenerComposite(); - } - listener.addListener(new MainClassRefactoringListener(settings)); - } - } - return listener; - } - return null; - } - - private static class MainClassRefactoringListener implements RefactoringElementListener { - private final BuildJarSettings mySettings; - - public MainClassRefactoringListener(final BuildJarSettings settings) { - mySettings = settings; - } - - public void elementMoved(@NotNull PsiElement newElement) { - mySettings.setMainClass(((PsiClass)newElement).getQualifiedName()); - } - - public void elementRenamed(@NotNull PsiElement newElement) { - mySettings.setMainClass(((PsiClass)newElement).getQualifiedName()); - } - } -} diff --git a/java/idea-ui/src/com/intellij/jar/BuildJarSettings.java b/java/idea-ui/src/com/intellij/jar/BuildJarSettings.java deleted file mode 100644 index db38ded64cc8..000000000000 --- a/java/idea-ui/src/com/intellij/jar/BuildJarSettings.java +++ /dev/null @@ -1,140 +0,0 @@ -package com.intellij.jar; - -import com.intellij.execution.ExecutionBundle; -import com.intellij.execution.configurations.RuntimeConfigurationError; -import com.intellij.execution.configurations.RuntimeConfigurationException; -import com.intellij.ide.IdeBundle; -import com.intellij.openapi.deployment.DeploymentUtil; -import com.intellij.openapi.deployment.PackagingConfiguration; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.module.ModuleComponent; -import com.intellij.openapi.util.InvalidDataException; -import com.intellij.openapi.util.JDOMExternalizable; -import com.intellij.openapi.util.JDOMExternalizer; -import com.intellij.openapi.util.WriteExternalException; -import com.intellij.openapi.util.io.FileUtil; -import com.intellij.openapi.vfs.VfsUtil; -import com.intellij.psi.JavaPsiFacade; -import com.intellij.psi.PsiClass; -import com.intellij.psi.PsiManager; -import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.psi.util.PsiMethodUtil; -import org.jdom.Element; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; - -/** - * @author cdr - */ -public class BuildJarSettings implements ModuleComponent, JDOMExternalizable { - @NonNls public static final String ELEMENT_CONTAINER_INFO = "containerInfo"; - @NonNls public static final String BUILD_JAR_SETTINGS_COMPONENT_NAME = "BuildJarSettings"; - @NonNls public static final String JAR_URL_ATTRIBUTE = "jarUrl"; - @NonNls public static final String MAIN_CLASS_ATTRIBUTE = "mainClass"; - private final PackagingConfiguration myPackagingConfiguration; - private final Module myModule; - private String myJarUrl = ""; - private boolean myBuildJar; - private String myMainClass = ""; - - public static BuildJarSettings getInstance(Module module) { - return module.getComponent(BuildJarSettings.class); - } - public BuildJarSettings(Module module) { - myModule = module; - myPackagingConfiguration = DeploymentUtil.getInstance().createPackagingConfiguration(myModule); - } - - public boolean isBuildJar() { - return myBuildJar; - } - - public String getMainClass() { - return myMainClass; - } - - public void readExternal(Element element) throws InvalidDataException { - Element settings = element.getChild(ELEMENT_CONTAINER_INFO); - if (settings != null) { - myPackagingConfiguration.readExternal(settings); - } - myJarUrl = JDOMExternalizer.readString(element, JAR_URL_ATTRIBUTE); - if (myJarUrl == null) { - final String jarPath = JDOMExternalizer.readString(element, "jarPath"); - if (jarPath != null) { - myJarUrl = VfsUtil.pathToUrl(FileUtil.toSystemIndependentName(jarPath)); - } - } - myBuildJar = JDOMExternalizer.readBoolean(element, "buildJar"); - myMainClass = JDOMExternalizer.readString(element, MAIN_CLASS_ATTRIBUTE); - } - - public void writeExternal(Element element) throws WriteExternalException { - if (!myBuildJar) throw new WriteExternalException(); - Element settings = new Element(ELEMENT_CONTAINER_INFO); - element.addContent(settings); - myPackagingConfiguration.writeExternal(settings); - JDOMExternalizer.write(element, JAR_URL_ATTRIBUTE, myJarUrl); - JDOMExternalizer.write(element, "buildJar", myBuildJar); - JDOMExternalizer.write(element, MAIN_CLASS_ATTRIBUTE, myMainClass); - } - - public PackagingConfiguration getPackagingConfiguration() { - return myPackagingConfiguration; - } - - public String getJarUrl() { - return myJarUrl; - } - - public void setJarUrl(final String jarUrl) { - myJarUrl = jarUrl; - } - public void projectOpened() { - - } - - public void projectClosed() { - - } - - public void moduleAdded() { - - } - - @NonNls @NotNull - public String getComponentName() { - return BUILD_JAR_SETTINGS_COMPONENT_NAME; - } - - public void initComponent() { - - } - - public void disposeComponent() { - - } - - public void setBuildJar(final boolean buildJar) { - myBuildJar = buildJar; - } - - public void setMainClass(final String mainClass) { - myMainClass = mainClass; - } - - public void checkSettings() throws RuntimeConfigurationException { - if (myMainClass != null && myMainClass.length() > 0) { - final PsiManager psiManager = PsiManager.getInstance(myModule.getProject()); - final PsiClass aClass = JavaPsiFacade.getInstance(psiManager.getProject()) - .findClass(myMainClass, GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(myModule)); - if (aClass == null) { - throw new RuntimeConfigurationError(IdeBundle.message("jar.build.class.not.found", myMainClass)); - } - - if (!PsiMethodUtil.hasMainMethod(aClass)) { - throw new RuntimeConfigurationError(ExecutionBundle.message("main.method.not.found.in.class.error.message", myMainClass)); - } - } - } -} diff --git a/java/idea-ui/src/com/intellij/jar/JarCompiler.java b/java/idea-ui/src/com/intellij/jar/JarCompiler.java deleted file mode 100644 index 24204833a2ad..000000000000 --- a/java/idea-ui/src/com/intellij/jar/JarCompiler.java +++ /dev/null @@ -1,246 +0,0 @@ -package com.intellij.jar; - -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.compiler.CompileContext; -import com.intellij.openapi.compiler.CompileScope; -import com.intellij.openapi.compiler.PackagingCompiler; -import com.intellij.openapi.compiler.ValidityState; -import com.intellij.openapi.compiler.make.BuildInstructionVisitor; -import com.intellij.openapi.compiler.make.BuildRecipe; -import com.intellij.openapi.compiler.make.FileCopyInstruction; -import com.intellij.openapi.deployment.ModuleLink; -import com.intellij.openapi.deployment.PackagingConfiguration; -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.module.ModuleManager; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.Comparing; -import com.intellij.openapi.util.Computable; -import com.intellij.openapi.util.io.FileUtil; -import com.intellij.openapi.vfs.LocalFileSystem; -import com.intellij.openapi.vfs.VfsUtil; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.util.ArrayUtil; -import com.intellij.util.io.IOUtil; -import gnu.trove.THashSet; -import gnu.trove.TObjectLongHashMap; -import gnu.trove.TObjectLongProcedure; -import org.jetbrains.annotations.NotNull; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.File; -import java.io.IOException; -import java.util.Collection; - -public class JarCompiler implements PackagingCompiler { - private static final Logger LOG = Logger.getInstance("#com.intellij.jar.JarCompiler"); - private static final JarCompiler INSTANCE = new JarCompiler(); - - public static JarCompiler getInstance() { - return INSTANCE; - } - - public void processOutdatedItem(final CompileContext context, String url, final ValidityState state) { - if (state != null) { - ApplicationManager.getApplication().runReadAction(new Runnable() { - public void run() { - MyValState valState = (MyValState)state; - String jarPath = valState.getOutputJarUrl(); - if (jarPath != null) { - FileUtil.delete(new File(VfsUtil.urlToPath(jarPath))); - } - } - }); - } - } - - public ValidityState createValidityState(DataInput in) throws IOException { - return new MyValState(in); - } - - static class MyValState implements ValidityState { - private final String myModuleName; - private final String[] sourceUrls; - private final long[] timestamps; - private final String outputJarUrl; - private final long outputJarTimestamp; - - public MyValState(final Module module) { - myModuleName = module.getName(); - final BuildJarSettings jarSettings = BuildJarSettings.getInstance(module); - outputJarUrl = jarSettings.getJarUrl(); - outputJarTimestamp = new File(VfsUtil.urlToPath(outputJarUrl)).lastModified(); - final TObjectLongHashMap url2Timestamps = new TObjectLongHashMap(); - ApplicationManager.getApplication().runReadAction(new Runnable(){ - public void run() { - BuildRecipe buildRecipe = BuildJarProjectSettings.getBuildRecipe(module, jarSettings); - buildRecipe.visitInstructions(new BuildInstructionVisitor() { - public boolean visitFileCopyInstruction(FileCopyInstruction instruction) throws Exception { - File source = instruction.getFile(); - VirtualFile virtualFile = LocalFileSystem.getInstance().findFileByPath(FileUtil.toSystemIndependentName(source.getPath())); - if (virtualFile != null) { - addFilesToMap(virtualFile, url2Timestamps); - } - return true; - } - }, false); - } - }); - sourceUrls = ArrayUtil.newStringArray(url2Timestamps.size()); - timestamps = new long[url2Timestamps.size()]; - TObjectLongProcedure iterator = new TObjectLongProcedure() { - int i = 0; - public boolean execute(final String url, final long timestamp) { - sourceUrls[i] = url; - timestamps[i] = timestamp; - i++; - return true; - } - }; - url2Timestamps.forEachEntry(iterator); - } - - private static void addFilesToMap(final VirtualFile virtualFile, final TObjectLongHashMap url2Timestamps) { - if (virtualFile.isDirectory()) { - VirtualFile[] children = virtualFile.getChildren(); - for (VirtualFile child : children) { - addFilesToMap(child, url2Timestamps); - } - } - else { - long timestamp = virtualFile.getModificationStamp(); - url2Timestamps.put(virtualFile.getUrl(), timestamp); - } - } - - public MyValState(final DataInput is) throws IOException { - myModuleName = IOUtil.readString(is); - int size = is.readInt(); - sourceUrls = ArrayUtil.newStringArray(size); - timestamps = new long[size]; - for (int i=0;i(){ - public ProcessingItem[] compute() { - final CompileScope compileScope = context.getCompileScope(); - final Module[] affectedModules = compileScope.getAffectedModules(); - if (affectedModules.length == 0) return ProcessingItem.EMPTY_ARRAY; - Project project = affectedModules[0].getProject(); - Module[] modules = ModuleManager.getInstance(project).getModules(); - Collection modulesToRebuild = new THashSet(); - for (Module module : modules) { - BuildJarSettings jarSettings = BuildJarSettings.getInstance(module); - if (jarSettings == null || !jarSettings.isBuildJar()) continue; - PackagingConfiguration packagingConfiguration = jarSettings.getPackagingConfiguration(); - ModuleLink[] containingModules = packagingConfiguration.getContainingModules(); - for (ModuleLink moduleLink : containingModules) { - Module containingModule = moduleLink.getModule(); - if (ArrayUtil.find(affectedModules, containingModule) != -1) { - modulesToRebuild.add(module); - } - } - } - - ProcessingItem[] result = new ProcessingItem[modulesToRebuild.size()]; - int i=0; - for (Module moduleToBuild : modulesToRebuild) { - if (moduleToBuild.getModuleFile() == null) continue; - result[i++] = new MyProcItem(moduleToBuild); - } - return result; - } - }); - } - - public ProcessingItem[] process(final CompileContext context, final ProcessingItem[] items) { - try { - for (ProcessingItem item : items) { - MyProcItem procItem = (MyProcItem)item; - Module module = procItem.getModule(); - BuildJarSettings jarSettings = BuildJarSettings.getInstance(module); - BuildJarProjectSettings.buildJar(module, jarSettings, context.getProgressIndicator(), context); - } - } - catch (IOException e) { - LOG.error(e); - } - return items; - } - - @NotNull - public String getDescription() { - return "jar compile"; - } - - public boolean validateConfiguration(CompileScope scope) { - return true; - } -} diff --git a/java/idea-ui/src/com/intellij/jar/JarPackagingEditorPolicy.java b/java/idea-ui/src/com/intellij/jar/JarPackagingEditorPolicy.java deleted file mode 100644 index db2aceaa4cb7..000000000000 --- a/java/idea-ui/src/com/intellij/jar/JarPackagingEditorPolicy.java +++ /dev/null @@ -1,94 +0,0 @@ -package com.intellij.jar; - -import com.intellij.openapi.deployment.*; -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.module.StdModuleTypes; -import com.intellij.openapi.roots.ModuleRootManager; -import com.intellij.openapi.roots.libraries.Library; -import com.intellij.openapi.roots.ui.configuration.packaging.PackagingEditor; -import com.intellij.openapi.roots.ui.configuration.packaging.PackagingEditorPolicy; -import com.intellij.openapi.roots.ui.configuration.packaging.PackagingEditorUtil; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; - -import java.util.List; - -/** - * @author nik - */ -public class JarPackagingEditorPolicy extends PackagingEditorPolicy { - private static final Logger LOG = Logger.getInstance("#com.intellij.jar.JarPackagingEditorPolicy"); - @NonNls private static final String JAR_EXTENSION = ".jar"; - private static final PackagingMethod[] COPY_OR_JAR_PACKAGING_METHODS = new PackagingMethod[]{ - PackagingMethod.COPY_FILES, - PackagingMethod.JAR_AND_COPY_FILE, - PackagingMethod.JAR_AND_COPY_FILE_AND_LINK_VIA_MANIFEST - }; - private static final PackagingMethod[] COPY_PACKAGING_METHODS = new PackagingMethod[]{ - PackagingMethod.COPY_FILES, - PackagingMethod.COPY_FILES_AND_LINK_VIA_MANIFEST - }; - - public JarPackagingEditorPolicy(final @NotNull Module module) { - super(module); - } - - protected PackagingMethod[] getAllowedPackagingMethodsForLibrary(LibraryLink libraryLink) { - return libraryLink.hasDirectoriesOnly() ? COPY_OR_JAR_PACKAGING_METHODS : COPY_PACKAGING_METHODS; - } - - protected PackagingMethod[] getAllowedPackagingMethodsForModule(@NotNull Module module) { - if (StdModuleTypes.JAVA.equals(module.getModuleType())) { - return COPY_OR_JAR_PACKAGING_METHODS; - } - return PackagingMethod.EMPTY_ARRAY; - } - - protected ContainerElement[] getModifiedElements(final PackagingEditor packagingEditor) { - return packagingEditor.getModifiedConfiguration().getElements(); - } - - protected PackagingMethod[] getPackagingMethodForUnresolvedElement(final ContainerElement element) { - return PackagingMethod.EMPTY_ARRAY; - } - - public void setDefaultAttributes(ContainerElement element) { - if (element instanceof LibraryLink) { - element.setPackagingMethod(PackagingMethod.DO_NOT_PACKAGE); - } - if (element instanceof ModuleLink) { - PackagingMethod[] allowedDeploymentMethods = getAllowedPackagingMethods(element); - if (allowedDeploymentMethods.length < 1) { - LOG.error("illegal Packaging methods for " + element); - } - element.setPackagingMethod(allowedDeploymentMethods[0]); - } - element.setURI(suggestDefaultRelativePath(element)); - } - - public String suggestDefaultRelativePath(ContainerElement element) { - PackagingMethod packagingMethod = element.getPackagingMethod(); - if (packagingMethod == PackagingMethod.DO_NOT_PACKAGE) return NOT_APPLICABLE; - boolean targetIsJar = packagingMethod == PackagingMethod.JAR_AND_COPY_FILE - || packagingMethod == PackagingMethod.JAR_AND_COPY_FILE_AND_LINK_VIA_MANIFEST; - String relativePath = "/"; - if (targetIsJar && element instanceof ModuleLink) { - relativePath = DeploymentUtil.appendToPath(relativePath, element.getPresentableName()); - if (!relativePath.endsWith(JAR_EXTENSION)) { - relativePath += JAR_EXTENSION; - } - } - return relativePath; - } - - protected List getSuitableModules(final PackagingEditor packagingEditor) { - List moduleList = PackagingEditorUtil.getModulesFromDependentOrderEntries(ModuleRootManager.getInstance(getModule())); - moduleList.add(getModule()); - return moduleList; - } - - protected List getSuitableLibraries(final PackagingEditor packagingEditor) { - return PackagingEditorUtil.getLibrariesFromDependentOrderEntries(ModuleRootManager.getInstance(getModule())); - } -} diff --git a/java/idea-ui/src/com/intellij/jar/JarPackagingTreeBuilder.java b/java/idea-ui/src/com/intellij/jar/JarPackagingTreeBuilder.java deleted file mode 100644 index 3886ad70e71e..000000000000 --- a/java/idea-ui/src/com/intellij/jar/JarPackagingTreeBuilder.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.intellij.jar; - -import com.intellij.openapi.deployment.ContainerElement; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.roots.ui.configuration.packaging.PackagingArtifact; -import com.intellij.openapi.roots.ui.configuration.packaging.PackagingTreeBuilder; -import com.intellij.openapi.roots.ui.configuration.projectRoot.ModuleStructureConfigurable; -import com.intellij.ui.ColoredTreeCellRenderer; -import com.intellij.ui.SimpleTextAttributes; -import com.intellij.util.Icons; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * @author nik - */ -public class JarPackagingTreeBuilder extends PackagingTreeBuilder { - private final Module myModule; - - public JarPackagingTreeBuilder(final Module module) { - myModule = module; - } - - public PackagingArtifact createRootArtifact() { - return new PackagingArtifact() { - @NotNull - @Override - public String getOutputFileName() { - return myModule.getName(); - } - - @Override - public void render(@NotNull final ColoredTreeCellRenderer renderer, final SimpleTextAttributes mainAttributes, final SimpleTextAttributes commentAttributes) { - renderer.setIcon(Icons.JAR_ICON); - renderer.append(myModule.getName() + ".jar", mainAttributes); - } - - @Override - public void navigate(final ModuleStructureConfigurable configurable, @Nullable final ContainerElement element) { - } - - @Override - public String getDisplayName() { - return myModule.getName(); - } - }; - } -} diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectStructureConfigurable.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectStructureConfigurable.java index 669ac43b3c8b..069fb2bb004e 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectStructureConfigurable.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectStructureConfigurable.java @@ -22,7 +22,6 @@ import com.intellij.openapi.util.ActionCallback; import com.intellij.openapi.util.IconLoader; import com.intellij.openapi.wm.ex.IdeFocusTraversalPolicy; import com.intellij.packaging.artifacts.Artifact; -import com.intellij.packaging.artifacts.ArtifactManager; import com.intellij.ui.components.panels.Wrapper; import com.intellij.ui.navigation.BackAction; import com.intellij.ui.navigation.ForwardAction; @@ -198,9 +197,7 @@ public class ProjectStructureConfigurable extends BaseConfigurable implements Se } private void addArtifactsConfig() { - if (ArtifactManager.useArtifacts()) { - addConfigurable(myArtifactsStructureConfigurable); - } + addConfigurable(myArtifactsStructureConfigurable); } public ArtifactsStructureConfigurable getArtifactsStructureConfigurable() { diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/AddPackagingElementAction.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/AddPackagingElementAction.java deleted file mode 100644 index eed74bcf6386..000000000000 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/AddPackagingElementAction.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.intellij.openapi.roots.ui.configuration.packaging; - -import org.jetbrains.annotations.NotNull; - -import javax.swing.*; - -/** - * @author nik -*/ -public abstract class AddPackagingElementAction { - private final String myText; - private final Icon myIcon; - - protected AddPackagingElementAction(final String text, final Icon icon) { - myText = text; - myIcon = icon; - } - - public String getText() { - return myText; - } - - public Icon getIcon() { - return myIcon; - } - - public abstract boolean isEnabled(@NotNull PackagingEditor editor); - - public abstract void perform(final PackagingEditor packagingEditor); -} diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/AddPackagingElementPopupStep.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/AddPackagingElementPopupStep.java deleted file mode 100644 index f177a78d4969..000000000000 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/AddPackagingElementPopupStep.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.intellij.openapi.roots.ui.configuration.packaging; - -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.application.ModalityState; -import com.intellij.openapi.ui.popup.PopupStep; -import com.intellij.openapi.ui.popup.util.BaseListPopupStep; -import org.jetbrains.annotations.NotNull; - -import javax.swing.*; -import java.util.List; - -/** - * @author nik -*/ -class AddPackagingElementPopupStep extends BaseListPopupStep { - private final PackagingEditor myEditor; - - public AddPackagingElementPopupStep(final PackagingEditor editor, final List addActions) { - super(null, addActions); - myEditor = editor; - } - - @Override - public PopupStep onChosen(final AddPackagingElementAction selectedValue, final boolean finalChoice) { - ApplicationManager.getApplication().invokeLater(new Runnable() { - public void run() { - selectedValue.perform(myEditor); - } - }, ModalityState.stateForComponent(myEditor.getMainPanel())); - return FINAL_CHOICE; - } - - @Override - public boolean isSelectable(final AddPackagingElementAction value) { - return value.isEnabled(myEditor); - } - - @Override - public Icon getIconFor(final AddPackagingElementAction aValue) { - return aValue.getIcon(); - } - - @NotNull - @Override - public String getTextFor(final AddPackagingElementAction value) { - return value.getText(); - } -} diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/ArchiveNode.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/ArchiveNode.java deleted file mode 100644 index 13a14907f49a..000000000000 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/ArchiveNode.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.intellij.openapi.roots.ui.configuration.packaging; - -import com.intellij.ui.ColoredTreeCellRenderer; -import com.intellij.ui.SimpleTextAttributes; -import com.intellij.util.Icons; -import com.intellij.openapi.roots.ui.configuration.projectRoot.ModuleStructureConfigurable; -import org.jetbrains.annotations.NotNull; - -/** - * @author nik - */ -class ArchiveNode extends PackagingTreeNode { - private final String myArchiveName; - - ArchiveNode(final String archiveName, final PackagingArtifact owner) { - super(owner); - myArchiveName = archiveName; - } - - @NotNull - public String getOutputFileName() { - return myArchiveName; - } - - public double getWeight() { - return PackagingNodeWeights.ARCHIVE; - } - - public void render(@NotNull final ColoredTreeCellRenderer renderer) { - renderer.setIcon(Icons.JAR_ICON); - renderer.append(myArchiveName, SimpleTextAttributes.REGULAR_ATTRIBUTES); - } - - public boolean canNavigate() { - return false; - } - - public void navigate(final ModuleStructureConfigurable configurable) { - } - - public Object getSourceObject() { - return null; - } -} diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/DirectoryNode.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/DirectoryNode.java deleted file mode 100644 index 9d5e493efb29..000000000000 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/DirectoryNode.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.intellij.openapi.roots.ui.configuration.packaging; - -import com.intellij.ui.ColoredTreeCellRenderer; -import com.intellij.ui.SimpleTextAttributes; -import com.intellij.util.Icons; -import com.intellij.openapi.roots.ui.configuration.projectRoot.ModuleStructureConfigurable; -import org.jetbrains.annotations.NotNull; - -/** - * @author nik - */ -class DirectoryNode extends PackagingTreeNode { - private final String myDirectoryName; - - DirectoryNode(final String directoryName, PackagingArtifact owner) { - super(owner); - myDirectoryName = directoryName; - } - - @NotNull - public String getOutputFileName() { - return myDirectoryName; - } - - public double getWeight() { - return PackagingNodeWeights.DIRECTORY; - } - - public void render(@NotNull final ColoredTreeCellRenderer renderer) { - renderer.setIcon(Icons.FOLDER_ICON); - renderer.append(myDirectoryName, SimpleTextAttributes.REGULAR_ATTRIBUTES); - } - - public boolean canNavigate() { - return false; - } - - public void navigate(final ModuleStructureConfigurable configurable) { - } - - public Object getSourceObject() { - return null; - } -} diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/LibraryFileNode.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/LibraryFileNode.java deleted file mode 100644 index 66010a6da244..000000000000 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/LibraryFileNode.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.intellij.openapi.roots.ui.configuration.packaging; - -import com.intellij.openapi.deployment.LibraryLink; -import com.intellij.openapi.roots.libraries.Library; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.ui.ColoredTreeCellRenderer; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * @author nik - */ -class LibraryFileNode extends LibraryNodeBase { - private final VirtualFile myFile; - private final Library myLibrary; - - LibraryFileNode(final @NotNull VirtualFile file, final @NotNull Library library, @NotNull LibraryLink libraryLink, final @Nullable PackagingArtifact owner) { - super(owner, libraryLink); - myFile = file; - myLibrary = library; - } - - @NotNull - public String getOutputFileName() { - return myFile.getName(); - } - - public double getWeight() { - return PackagingNodeWeights.FILE; - } - - public void render(@NotNull final ColoredTreeCellRenderer renderer) { - PackagingEditorUtil.renderLibraryFile(renderer, myLibrary, myFile, getMainAttributes(), getCommentAttributes()); - } - - public VirtualFile getFile() { - return myFile; - } -} diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/LibraryNode.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/LibraryNode.java deleted file mode 100644 index 5fb6ede19482..000000000000 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/LibraryNode.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.intellij.openapi.roots.ui.configuration.packaging; - -import com.intellij.openapi.deployment.LibraryLink; -import com.intellij.openapi.roots.OrderRootType; -import com.intellij.openapi.roots.libraries.Library; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.ui.ColoredTreeCellRenderer; -import com.intellij.ui.SimpleTextAttributes; -import org.jetbrains.annotations.NotNull; - -/** - * @author nik - */ -class LibraryNode extends LibraryNodeBase { - LibraryNode(final LibraryLink libraryLink, PackagingArtifact owner) { - super(owner, libraryLink); - } - - @NotNull - public String getOutputFileName() { - return myLibraryLink.getPresentableName(); - } - - public double getWeight() { - return PackagingNodeWeights.LIBRARY; - } - - @Override - public String getSearchName() { - Library library = myLibraryLink.getLibrary(); - if (library == null) { - return myLibraryLink.getPresentableName(); - } - String name = library.getName(); - if (name != null) { - return name; - } - VirtualFile[] files = library.getFiles(OrderRootType.CLASSES); - if (files.length > 0) { - return files[0].getName(); - } - return super.getSearchName(); - } - - @Override - public int compareTo(final PackagingTreeNode node) { - return getSearchName().compareToIgnoreCase(node.getSearchName()); - } - - public void render(@NotNull final ColoredTreeCellRenderer renderer) { - Library library = myLibraryLink.getLibrary(); - if (library == null) { - String libraryName = myLibraryLink.getPresentableName(); - renderer.append(libraryName, SimpleTextAttributes.ERROR_ATTRIBUTES); - } - else { - PackagingEditorUtil.renderLibraryNode(renderer, library, getMainAttributes(), getCommentAttributes()); - } - - } - - public boolean canNavigate() { - return true; - } -} diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/LibraryNodeBase.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/LibraryNodeBase.java deleted file mode 100644 index 6ae32c1d3771..000000000000 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/LibraryNodeBase.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.intellij.openapi.roots.ui.configuration.packaging; - -import com.intellij.openapi.deployment.ContainerElement; -import com.intellij.openapi.deployment.LibraryLink; -import com.intellij.openapi.project.ProjectBundle; -import com.intellij.openapi.roots.ui.configuration.projectRoot.ModuleStructureConfigurable; -import com.intellij.openapi.roots.ui.configuration.ModulesConfigurator; -import com.intellij.openapi.roots.ModuleRootModel; -import com.intellij.openapi.roots.LibraryOrderEntry; -import com.intellij.openapi.roots.impl.OrderEntryUtil; -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.module.Module; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * @author nik - */ -abstract class LibraryNodeBase extends PackagingTreeNode { - private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.roots.ui.configuration.packaging.LibraryNodeBase"); - protected final LibraryLink myLibraryLink; - - public LibraryNodeBase(final @Nullable PackagingArtifact owner, @NotNull LibraryLink libraryLink) { - super(owner); - myLibraryLink = libraryLink; - } - - @Override - public ContainerElement getContainerElement() { - return myLibraryLink; - } - - public boolean canNavigate() { - return true; - } - - @Override - public String getTooltipText() { - if (belongsToIncludedArtifact()) { - PackagingArtifact owner = getOwner(); - LOG.assertTrue(owner != null); - return ProjectBundle.message("node.text.packaging.included.from.0", owner.getDisplayName()); - } - return null; - } - - public void navigate(final ModuleStructureConfigurable configurable) { - Module parentModule = myLibraryLink.getParentModule(); - - final PackagingArtifact owner = getOwner(); - if (owner != null) { - owner.navigate(configurable, myLibraryLink); - } - else { - ModulesConfigurator modulesConfigurator = configurable.getContext().getModulesConfigurator(); - ModuleRootModel rootModel = modulesConfigurator.getRootModel(parentModule); - LibraryOrderEntry orderEntry = OrderEntryUtil.findLibraryOrderEntry(rootModel, myLibraryLink.getLibrary(), true, modulesConfigurator); - configurable.selectOrderEntry(orderEntry != null ? orderEntry.getOwnerModule() : parentModule, orderEntry); - } - } - - public Object getSourceObject() { - return myLibraryLink.getLibrary(); - } - - public LibraryLink getLibraryLink() { - return myLibraryLink; - } - -} diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/ModuleOutputBaseNode.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/ModuleOutputBaseNode.java deleted file mode 100644 index 1ec00c76b932..000000000000 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/ModuleOutputBaseNode.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.intellij.openapi.roots.ui.configuration.packaging; - -import com.intellij.openapi.deployment.ContainerElement; -import com.intellij.openapi.deployment.ModuleLink; -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.project.ProjectBundle; -import com.intellij.openapi.roots.ModuleOrderEntry; -import com.intellij.openapi.roots.ModuleRootModel; -import com.intellij.openapi.roots.impl.OrderEntryUtil; -import com.intellij.openapi.roots.ui.configuration.ModulesConfigurator; -import com.intellij.openapi.roots.ui.configuration.projectRoot.ModuleStructureConfigurable; -import org.jetbrains.annotations.Nullable; - -/** - * @author nik - */ -abstract class ModuleOutputBaseNode extends PackagingTreeNode { - private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.roots.ui.configuration.packaging.ModuleOutputBaseNode"); - protected final ModuleLink myModuleLink; - - public ModuleOutputBaseNode(final @Nullable PackagingArtifact owner, final ModuleLink moduleLink) { - super(owner); - myModuleLink = moduleLink; - } - - public ModuleLink getModuleLink() { - return myModuleLink; - } - - public boolean canNavigate() { - return true; - } - - public void navigate(final ModuleStructureConfigurable configurable) { - Module parentModule = myModuleLink.getParentModule(); - - PackagingArtifact owner = getOwner(); - if (owner != null) { - owner.navigate(configurable, myModuleLink); - } - else { - ModulesConfigurator modulesConfigurator = configurable.getContext().getModulesConfigurator(); - ModuleRootModel rootModel = modulesConfigurator.getRootModel(parentModule); - ModuleOrderEntry orderEntry = OrderEntryUtil.findModuleOrderEntry(rootModel, myModuleLink.getModule(), true, modulesConfigurator); - configurable.selectOrderEntry(orderEntry != null ? orderEntry.getOwnerModule() : parentModule, orderEntry); - } - } - - public double getWeight() { - return PackagingNodeWeights.MODULE; - } - - @Override - public String getTooltipText() { - if (belongsToIncludedArtifact()) { - PackagingArtifact owner = getOwner(); - LOG.assertTrue(owner != null); - return ProjectBundle.message("node.text.packaging.included.from.0", owner.getDisplayName()); - } - return null; - } - - public Object getSourceObject() { - return myModuleLink.getModule(); - } - - public ContainerElement getContainerElement() { - return myModuleLink; - } -} diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/ModuleOutputNode.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/ModuleOutputNode.java deleted file mode 100644 index da3eb3ac296c..000000000000 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/ModuleOutputNode.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.intellij.openapi.roots.ui.configuration.packaging; - -import com.intellij.openapi.deployment.ModuleLink; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.project.ProjectBundle; -import com.intellij.ui.ColoredTreeCellRenderer; -import com.intellij.ui.SimpleTextAttributes; -import org.jetbrains.annotations.NotNull; - -/** - * @author nik - */ -class ModuleOutputNode extends ModuleOutputBaseNode { - - ModuleOutputNode(final ModuleLink moduleLink, final PackagingArtifact owner) { - super(owner, moduleLink); - } - - @NotNull - public String getOutputFileName() { - return myModuleLink.getName(); - } - - public void render(@NotNull final ColoredTreeCellRenderer renderer) { - final Module module = myModuleLink.getModule(); - if (module == null) { - renderer.append(myModuleLink.getName(), SimpleTextAttributes.ERROR_ATTRIBUTES); - } - else { - renderer.append(module.getName(), getMainAttributes()); - renderer.setIcon(module.getModuleType().getNodeIcon(false)); - } - renderer.append(" " + ProjectBundle.message("node.text.packaging.compile.output"), getCommentAttributes()); - } - -} diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingArtifact.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingArtifact.java deleted file mode 100644 index 8df7e9b43bf6..000000000000 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingArtifact.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.intellij.openapi.roots.ui.configuration.packaging; - -import com.intellij.ui.ColoredTreeCellRenderer; -import com.intellij.ui.SimpleTextAttributes; -import com.intellij.openapi.deployment.ContainerElement; -import com.intellij.openapi.roots.ui.configuration.projectRoot.ModuleStructureConfigurable; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * @author nik - */ -public abstract class PackagingArtifact { - - @NotNull - public abstract String getOutputFileName(); - - public abstract void render(@NotNull ColoredTreeCellRenderer renderer, final SimpleTextAttributes mainAttributes, - final SimpleTextAttributes commentAttributes); - - public abstract void navigate(ModuleStructureConfigurable configurable, @Nullable ContainerElement element); - - public abstract String getDisplayName(); - - @Nullable - public ContainerElement getContainerElement() { - return null; - } -} diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingArtifactNode.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingArtifactNode.java deleted file mode 100644 index 7756d6fd6f2a..000000000000 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingArtifactNode.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.intellij.openapi.roots.ui.configuration.packaging; - -import com.intellij.ui.ColoredTreeCellRenderer; -import com.intellij.openapi.deployment.ContainerElement; -import com.intellij.openapi.roots.ui.configuration.projectRoot.ModuleStructureConfigurable; -import org.jetbrains.annotations.NotNull; - -/** - * @author nik - */ -public class PackagingArtifactNode extends PackagingTreeNode { - private final PackagingArtifact myArtifact; - - PackagingArtifactNode(final PackagingArtifact artifact, PackagingArtifact owner) { - super(owner); - myArtifact = artifact; - } - - public PackagingArtifact getArtifact() { - return myArtifact; - } - - @NotNull - public String getOutputFileName() { - return myArtifact.getOutputFileName(); - } - - public double getWeight() { - return PackagingNodeWeights.ARTIFACT; - } - - public void render(@NotNull final ColoredTreeCellRenderer renderer) { - myArtifact.render(renderer, getMainAttributes(), getCommentAttributes()); - } - - public boolean canNavigate() { - return true; - } - - public void navigate(final ModuleStructureConfigurable configurable) { - myArtifact.navigate(configurable, null); - } - - public Object getSourceObject() { - return null; - } - - @Override - public ContainerElement getContainerElement() { - return myArtifact.getContainerElement(); - } -} diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingEditor.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingEditor.java deleted file mode 100644 index c2369d234197..000000000000 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingEditor.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.intellij.openapi.roots.ui.configuration.packaging; - -import com.intellij.openapi.deployment.ContainerElement; -import com.intellij.openapi.deployment.PackagingConfiguration; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.roots.libraries.Library; -import com.intellij.openapi.roots.OrderEntry; -import org.jetbrains.annotations.NotNull; - -import javax.swing.*; -import java.util.List; -import java.util.Set; - -/** - * @author nik - */ -public interface PackagingEditor { - - void saveData(); - - void moduleStateChanged(); - - ContainerElement[] getModifiedElements(); - - boolean isModified(); - - void reset(); - - JComponent createMainComponent(); - - JPanel getMainPanel(); - - void addModules(final List modules); - - void addLibraries(final List libraries); - - PackagingConfiguration getModifiedConfiguration(); - - void rebuildTree(); - - void addElement(ContainerElement element); - - void selectElement(@NotNull ContainerElement toSelect, final boolean requestFocus); - - void processNewOrderEntries(final Set newEntries); - - void addListener(@NotNull PackagingEditorListener listener); - - void removeListener(@NotNull PackagingEditorListener listener); -} diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingEditorImpl.form b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingEditorImpl.form deleted file mode 100644 index 98d9d7d1fe98..000000000000 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingEditorImpl.form +++ /dev/null @@ -1,91 +0,0 @@ - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingEditorImpl.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingEditorImpl.java deleted file mode 100644 index f62a3382f761..000000000000 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingEditorImpl.java +++ /dev/null @@ -1,536 +0,0 @@ -package com.intellij.openapi.roots.ui.configuration.packaging; - -import com.intellij.ide.CommonActionsManager; -import com.intellij.ide.DefaultTreeExpander; -import com.intellij.openapi.actionSystem.*; -import com.intellij.openapi.deployment.*; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.project.ProjectBundle; -import com.intellij.openapi.roots.LibraryOrderEntry; -import com.intellij.openapi.roots.OrderEntry; -import com.intellij.openapi.roots.libraries.Library; -import com.intellij.openapi.roots.ui.configuration.FacetsProvider; -import com.intellij.openapi.roots.ui.configuration.ModulesProvider; -import com.intellij.openapi.roots.ui.configuration.projectRoot.FindUsagesInProjectStructureActionBase; -import com.intellij.openapi.roots.ui.configuration.projectRoot.ModuleStructureConfigurable; -import com.intellij.openapi.ui.popup.JBPopupFactory; -import com.intellij.openapi.util.Comparing; -import com.intellij.openapi.util.Ref; -import com.intellij.openapi.wm.IdeFocusManager; -import com.intellij.ui.*; -import com.intellij.ui.treeStructure.Tree; -import com.intellij.ui.awt.RelativePoint; -import com.intellij.util.containers.Convertor; -import com.intellij.util.ui.tree.TreeUtil; -import com.intellij.util.EventDispatcher; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.TestOnly; - -import javax.swing.*; -import javax.swing.event.TreeSelectionEvent; -import javax.swing.event.TreeSelectionListener; -import javax.swing.tree.DefaultTreeModel; -import javax.swing.tree.TreePath; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.*; -import java.util.List; - -/** - * @author nik - */ -public class PackagingEditorImpl implements PackagingEditor { - private static final Convertor SPEED_SEARCH_CONVERTOR = new Convertor() { - public String convert(final TreePath path) { - Object o = path.getLastPathComponent(); - if (o instanceof PackagingTreeNode) { - return ((PackagingTreeNode)o).getSearchName(); - } - return ""; - } - }; - private final PackagingConfiguration myOriginalConfiguration; - private final PackagingConfiguration myModifiedConfiguration; - private final ModulesProvider myModulesProvider; - private final FacetsProvider myFacetsProvider; - private final PackagingEditorPolicy myPolicy; - private Tree myTree; - private RootNode myRoot; - private DefaultTreeModel myTreeModel; - private final PackagingTreeBuilder myBuilder; - private JPanel myMainPanel; - private JPanel myTreePanel; - private JButton myAddButton; - private JButton myRemoveButton; - private JButton myEditButton; - private JCheckBox myShowIncludedCheckBox; - private JCheckBox myShowLibraryFilesCheckBox; - private PackagingArtifact myRootArtifact; - private final Project myProject; - private PackagingTreeParameters myTreeParameters; - private final EventDispatcher myDispatcher = EventDispatcher.create(PackagingEditorListener.class); - - public PackagingEditorImpl(final PackagingConfiguration originalConfiguration, - final PackagingConfiguration modifiedConfiguration, - final ModulesProvider modulesProvider, final FacetsProvider facetsProvider, final PackagingEditorPolicy policy, - final PackagingTreeBuilder builder, final boolean showIncludedCheckboxVisible) { - myOriginalConfiguration = originalConfiguration; - myModifiedConfiguration = modifiedConfiguration; - myModulesProvider = modulesProvider; - myFacetsProvider = facetsProvider; - myPolicy = policy; - myBuilder = builder; - myProject = myPolicy.getModule().getProject(); - setTreeParameters(myBuilder.getDefaultParameters()); - - myAddButton.addActionListener(new ActionListener() { - public void actionPerformed(final ActionEvent e) { - JBPopupFactory.getInstance().createListPopup(new AddPackagingElementPopupStep(PackagingEditorImpl.this, myPolicy.getAddActions())).showUnderneathOf(myAddButton); - } - }); - myEditButton.addActionListener(new ActionListener() { - public void actionPerformed(final ActionEvent e) { - PackagingElementsToEditInfo elementsToEdit = getSelectedElements().getElementsToEdit(myPolicy); - if (elementsToEdit != null) { - editElement(elementsToEdit); - } - } - }); - myRemoveButton.addActionListener(new ActionListener() { - public void actionPerformed(final ActionEvent e) { - removeSelectedElements(); - } - }); - ActionListener actionListener = new ActionListener() { - public void actionPerformed(final ActionEvent e) { - myTreeParameters = new PackagingTreeParameters(myShowIncludedCheckBox.isSelected(), myShowLibraryFilesCheckBox.isSelected()); - myBuilder.updateParameters(myTreeParameters); - rebuildTree(); - } - }; - myShowIncludedCheckBox.addActionListener(actionListener); - myShowLibraryFilesCheckBox.addActionListener(actionListener); - myShowIncludedCheckBox.setVisible(showIncludedCheckboxVisible); - } - - public void removeSelectedElements() { - SelectedPackagingElements selectedElements = getSelectedElements(); - if (!selectedElements.showRemovingWarning(this)) return; - - saveData(); - for (ContainerElement containerElement : selectedElements.getContainerElements()) { - myModifiedConfiguration.removeContainerElement(containerElement); - } - for (PackagingArtifact owner : selectedElements.getOwners()) { - ContainerElement element = owner.getContainerElement(); - if (element != null) { - myModifiedConfiguration.removeContainerElement(element); - } - } - rebuildTree(); - } - - public PackagingArtifact getRootArtifact() { - return myRootArtifact; - } - - private SelectedPackagingElements getSelectedElements() { - PackagingTreeNode[] treeNodes = myTree.getSelectedNodes(PackagingTreeNode.class, null); - return new SelectedPackagingElements(treeNodes); - } - - public void addModules(final List modules) { - if (modules.isEmpty()) return; - - saveData(); - modules.removeAll(Arrays.asList(myModifiedConfiguration.getContainingIdeaModules())); - ContainerElement last = null; - for (Module module : modules) { - ModuleLink element = DeploymentUtil.getInstance().createModuleLink(module, myPolicy.getModule()); - addElement(element); - last = element; - } - rebuildTree(); - if (last != null) { - selectElement(last, false); - } - } - - private void editElement(final @NotNull PackagingElementsToEditInfo elementsToEdit) { - saveData(); - boolean ok = PackagingElementPropertiesComponent.showDialog(elementsToEdit, myMainPanel, myPolicy, myDispatcher.getMulticaster()); - if (ok) { - rebuildTree(); - selectElements(elementsToEdit.getElements()); - } - } - - @TestOnly - @Nullable - public PackagingElementPropertiesComponent editSelectedElements() { - SelectedPackagingElements selectedElements = getSelectedElements(); - if (selectedElements == null) return null; - - PackagingElementsToEditInfo elementsInfo = selectedElements.getElementsToEdit(myPolicy); - if (elementsInfo == null) return null; - - return PackagingElementPropertiesComponent.createPropertiesComponent(elementsInfo, myPolicy, null); - } - - private void selectElements(final List elements) { - //todo[nik] - selectElement(elements.get(0), false); - } - - public void addElement(final ContainerElement element) { - if (myPolicy.isAllowedToPackage(element)) { - myPolicy.setDefaultAttributes(element); - PackagingMethod method = element.getPackagingMethod(); - if (method == PackagingMethod.DO_NOT_PACKAGE) { - //todo[nik] is it correct? - PackagingMethod[] methods = myPolicy.getAllowedPackagingMethods(element); - element.setPackagingMethod(methods[0]); - element.setURI(myPolicy.suggestDefaultRelativePath(element)); - } - myModifiedConfiguration.addOrReplaceElement(element); - } - } - - public void selectElement(@NotNull final ContainerElement toSelect, final boolean requestFocus) { - PackagingTreeNode node = findNodeByElement(toSelect); - if (node != null) { - TreeUtil.selectNode(myTree, node); - if (requestFocus) { - IdeFocusManager.getInstance(myProject).requestFocus(myTree, true); - } - } - } - - public void processNewOrderEntries(final Set newEntries) { - List libraries = new ArrayList(); - for (OrderEntry entry : newEntries) { - if (entry instanceof LibraryOrderEntry) { - libraries.add(((LibraryOrderEntry)entry).getLibrary()); - } - } - myPolicy.processNewLibraries(this, libraries); - } - - public void addListener(@NotNull final PackagingEditorListener listener) { - myDispatcher.addListener(listener); - } - - public void removeListener(@NotNull final PackagingEditorListener listener) { - myDispatcher.removeListener(listener); - } - - @TestOnly - public boolean selectNodes(@NotNull @NonNls final String... nodeNames) { - final List toSelect = new ArrayList(); - TreeUtil.traverseDepth(myRoot, new TreeUtil.Traverse() { - public boolean accept(final Object node) { - if (node instanceof PackagingTreeNode) { - PackagingTreeNode packagingNode = (PackagingTreeNode)node; - if (Arrays.asList(nodeNames).contains(packagingNode.getOutputFileName())) { - toSelect.add(packagingNode); - } - } - return true; - } - }); - myTree.getSelectionModel().clearSelection(); - for (PackagingTreeNode node : toSelect) { - myTree.getSelectionModel().addSelectionPath(new TreePath(node.getPath())); - } - return toSelect.size() == nodeNames.length; - } - - @Nullable - private PackagingTreeNode findNodeByElement(final ContainerElement toSelect) { - final Ref ref = Ref.create(null); - TreeUtil.traverseDepth(myRoot, new TreeUtil.Traverse() { - public boolean accept(final Object node) { - if (node instanceof PackagingTreeNode) { - PackagingTreeNode packagingNode = (PackagingTreeNode)node; - ContainerElement element = packagingNode.getContainerElement(); - if (toSelect.equals(element)) { - ref.set(packagingNode); - return false; - } - } - return true; - } - }); - return ref.get(); - } - - public Tree getTree() { - return myTree; - } - - public void addLibraries(final List libraries) { - if (libraries.isEmpty()) return; - - saveData(); - libraries.removeAll(Arrays.asList(myModifiedConfiguration.getContainingLibraries())); - ContainerElement last = null; - for (Library library : libraries) { - LibraryLink libraryLink = DeploymentUtil.getInstance().createLibraryLink(library, myPolicy.getModule()); - addElement(libraryLink); - last = libraryLink; - } - rebuildTree(); - if (last != null) { - selectElement(last, false); - } - } - - public void setTreeParameters(PackagingTreeParameters parameters) { - myShowIncludedCheckBox.setSelected(parameters.isShowIncludedContent()); - myShowLibraryFilesCheckBox.setSelected(parameters.isShowLibraryFiles()); - myTreeParameters = parameters; - } - - public void rebuildTree() { - PackagingTreeState state = PackagingTreeState.saveState(myTree); - myRoot.removeAllChildren(); - myRootArtifact = myBuilder.createRootArtifact(); - PackagingArtifactNode root = PackagingTreeNodeFactoryOld.createArtifactNode(myRootArtifact, myRoot, null); - for (ContainerElement element : getPackagedElements()) { - myBuilder.createNodes(root, element, null, myTreeParameters); - } - myTreeModel.nodeStructureChanged(myRoot); - TreeUtil.sort(myTreeModel, new Comparator() { - public int compare(final PackagingTreeNode node1, final PackagingTreeNode node2) { - double weight1 = node1.getWeight(); - double weight2 = node2.getWeight(); - if (weight1 < weight2) return -1; - if (weight1 > weight2) return 1; - - return node1.compareTo(node2); - } - }); - state.restoreState(myTree); - } - - public void saveData() { - - } - - public void moduleStateChanged() { - if (myPolicy.removeObsoleteElements(this)) { - rebuildTree(); - } - } - - public PackagingConfiguration getModifiedConfiguration() { - return myModifiedConfiguration; - } - - public ContainerElement[] getModifiedElements() { - return myModifiedConfiguration.getElements(myModulesProvider, myFacetsProvider, true, true, true); - } - - public boolean isModified() { - final ContainerElement[] elements1 = getPackagedElements(); - final ContainerElement[] elements2 = myOriginalConfiguration.getElements(myModulesProvider, myFacetsProvider, true, true, false); - return !Comparing.haveEqualElements(elements1, elements2); - } - - private ContainerElement[] getPackagedElements() { - return myModifiedConfiguration.getElements(myModulesProvider, myFacetsProvider, true, true, false); - } - - public void reset() { - final ContainerElement[] elements = myOriginalConfiguration.getElements(myModulesProvider, myFacetsProvider, true, true, true); - ContainerElement[] newElements = new ContainerElement[elements.length]; - for (int i = 0; i < elements.length; i++) { - newElements[i] = elements[i].clone(); - } - myModifiedConfiguration.setElements(newElements); - if (myTree != null) { - rebuildTree(); - } - } - - public JComponent createMainComponent() { - myMainPanel.setMinimumSize(new Dimension(-1, 250)); - myRoot = new RootNode(); - myTreeModel = new DefaultTreeModel(myRoot); - myTree = new Tree(myTreeModel) { - @Override - public String getToolTipText(final MouseEvent event) { - TreePath path = myTree.getPathForLocation(event.getX(), event.getY()); - if (path != null) { - return ((PackagingTreeNode)path.getLastPathComponent()).getTooltipText(); - } - return super.getToolTipText(); - } - }; - myTree.setRootVisible(false); - myTree.setShowsRootHandles(true); - myTree.setCellRenderer(new PackagingTreeCellRenderer()); - myTreePanel.add(ScrollPaneFactory.createScrollPane(myTree), BorderLayout.CENTER); - new TreeSpeedSearch(myTree, SPEED_SEARCH_CONVERTOR, true); - myTree.addTreeSelectionListener(new TreeSelectionListener() { - public void valueChanged(final TreeSelectionEvent e) { - updateButtons(); - } - }); - myTree.addMouseListener(new PackagingTreeMouseListener()); - - DefaultActionGroup actionGroup = new DefaultActionGroup(); - actionGroup.add(new MyNavigateAction()); - actionGroup.add(new MyFindUsagesAction()); - - actionGroup.add(Separator.getInstance()); - CommonActionsManager actionsManager = CommonActionsManager.getInstance(); - DefaultTreeExpander treeExpander = new DefaultTreeExpander(myTree); - actionGroup.add(actionsManager.createExpandAllAction(treeExpander, myTree)); - actionGroup.add(actionsManager.createCollapseAllAction(treeExpander, myTree)); - - PopupHandler.installPopupHandler(myTree, actionGroup, ActionPlaces.UNKNOWN, ActionManager.getInstance()); - TreeToolTipHandler.install(myTree); - ToolTipManager.sharedInstance().registerComponent(myTree); - rebuildTree(); - TreeUtil.expandAll(myTree); - updateButtons(); - return myMainPanel; - } - - private void updateButtons() { - SelectedPackagingElements selectedElements = getSelectedElements(); - List elements = selectedElements.getContainerElements(); - Set artifacts = selectedElements.getOwners(); - myRemoveButton.setEnabled(!elements.isEmpty() || !artifacts.isEmpty()); - PackagingElementsToEditInfo elementsToEdit = selectedElements.getElementsToEdit(myPolicy); - myEditButton.setEnabled(elementsToEdit != null && PackagingElementPropertiesComponent.isEnabled(elementsToEdit)); - } - - public JPanel getMainPanel() { - return myMainPanel; - } - - public PackagingTreeNode getRoot() { - return myRoot; - } - - private void navigate(PackagingTreeNode treeNode) { - treeNode.navigate(ModuleStructureConfigurable.getInstance(myProject)); - } - - private static class RootNode extends PackagingTreeNode { - private RootNode() { - super(null); - } - - @NotNull - public String getOutputFileName() { - return ""; - } - - public double getWeight() { - return 0; - } - - public void render(@NotNull final ColoredTreeCellRenderer renderer) { - } - - public boolean canNavigate() { - return false; - } - - public void navigate(final ModuleStructureConfigurable configurable) { - } - - public Object getSourceObject() { - return null; - } - } - - private class PackagingTreeMouseListener extends MouseAdapter { - @Override - public void mouseClicked(final MouseEvent e) { - if (e.getClickCount() == 2) { - PackagingTreeNode[] nodes = myTree.getSelectedNodes(PackagingTreeNode.class, null); - if (nodes.length == 1) { - PackagingTreeNode node = nodes[0]; - if (node.getChildren().isEmpty()) { - ContainerElement element = node.getContainerElement(); - if (element != null) { - if (node.getOwner() == null) { - editElement(new PackagingElementsToEditInfo(element, myPolicy)); - } - else { - navigate(node); - } - } - } - } - } - } - } - - private static class PackagingTreeCellRenderer extends ColoredTreeCellRenderer { - public void customizeCellRenderer(final JTree tree, - final Object value, - final boolean selected, - final boolean expanded, - final boolean leaf, - final int row, - final boolean hasFocus) { - PackagingTreeNode node = (PackagingTreeNode)value; - node.render(this); - setEnabled(tree.isEnabled()); - } - } - - private class MyNavigateAction extends AnAction { - private MyNavigateAction() { - super(ProjectBundle.message("action.name.facet.navigate")); - registerCustomShortcutSet(CommonShortcuts.getEditSource(), myTree); - } - - public void update(final AnActionEvent e) { - PackagingTreeNode[] treeNodes = myTree.getSelectedNodes(PackagingTreeNode.class, null); - e.getPresentation().setEnabled(treeNodes.length == 1 && treeNodes[0].canNavigate()); - } - - public void actionPerformed(final AnActionEvent e) { - PackagingTreeNode[] treeNodes = myTree.getSelectedNodes(PackagingTreeNode.class, null); - if (treeNodes.length == 1) { - navigate(treeNodes[0]); - } - } - } - - private class MyFindUsagesAction extends FindUsagesInProjectStructureActionBase { - public MyFindUsagesAction() { - super(myTree, myProject); - } - - protected boolean isEnabled() { - PackagingTreeNode[] treeNodes = myTree.getSelectedNodes(PackagingTreeNode.class, null); - return treeNodes.length == 1 && treeNodes[0].getSourceObject() != null; - } - - protected Object getSelectedObject() { - PackagingTreeNode[] treeNodes = myTree.getSelectedNodes(PackagingTreeNode.class, null); - return treeNodes.length == 1 ? treeNodes[0].getSourceObject() : null; - } - - protected RelativePoint getPointToShowResults() { - final int selectedRow = myTree.getSelectionRows()[0]; - final Rectangle rowBounds = myTree.getRowBounds(selectedRow); - final Point location = rowBounds.getLocation(); - location.y += rowBounds.height; - return new RelativePoint(myTree, location); - } - } -} diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingEditorListener.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingEditorListener.java deleted file mode 100644 index 2728a5e0b221..000000000000 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingEditorListener.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.intellij.openapi.roots.ui.configuration.packaging; - -import com.intellij.openapi.deployment.ContainerElement; -import org.jetbrains.annotations.NotNull; - -import java.util.EventListener; - -/** - * @author nik -*/ -public interface PackagingEditorListener extends EventListener { - - void packagingMethodChanged(@NotNull ContainerElement element); - -} diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingEditorPolicy.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingEditorPolicy.java deleted file mode 100644 index 78dd9c3cdd42..000000000000 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingEditorPolicy.java +++ /dev/null @@ -1,216 +0,0 @@ -package com.intellij.openapi.roots.ui.configuration.packaging; - -import com.intellij.ide.IdeBundle; -import com.intellij.openapi.deployment.*; -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.module.StdModuleTypes; -import com.intellij.openapi.project.ProjectBundle; -import com.intellij.openapi.roots.libraries.Library; -import com.intellij.openapi.roots.ui.configuration.libraryEditor.ChooseModulesDialog; -import com.intellij.util.Icons; -import com.intellij.util.containers.ContainerUtil; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import javax.swing.*; -import java.util.*; - -/** - * @author nik - */ -public abstract class PackagingEditorPolicy { - private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.roots.ui.configuration.packaging.PackagingEditorPolicy"); - public static final String NOT_APPLICABLE = IdeBundle.message("text.not.applicable"); - private final Module myModule; - - protected PackagingEditorPolicy(final @NotNull Module module) { - myModule = module; - } - - protected abstract PackagingMethod[] getAllowedPackagingMethodsForLibrary(LibraryLink libraryLink); - - protected abstract PackagingMethod[] getAllowedPackagingMethodsForModule(@NotNull Module module); - - public abstract void setDefaultAttributes(ContainerElement element); - - public abstract String suggestDefaultRelativePath(ContainerElement element); - - protected abstract List getSuitableModules(final PackagingEditor packagingEditor); - - protected abstract List getSuitableLibraries(final PackagingEditor packagingEditor); - - protected abstract ContainerElement[] getModifiedElements(PackagingEditor packagingEditor); - - public boolean isRelativePathCellEditable(final ContainerElement element) { - return element instanceof LibraryLink - || element instanceof ModuleLink && ((ModuleLink)element).getModule() != null; - } - - @Nullable - public AdditionalPropertiesConfigurable getAdditionalPropertiesConfigurable(@NotNull ContainerElement element) { - return null; - } - - public PackagingMethod[] getAllowedPackagingMethods(ContainerElement element) { - if (element instanceof LibraryLink) { - final LibraryLink libraryLink = (LibraryLink)element; - if (libraryLink.getLibrary() == null) { - return getPackagingMethodForUnresolvedElement(libraryLink); - } - return getAllowedPackagingMethodsForLibrary(libraryLink); - } - if (element instanceof ModuleLink) { - final ModuleLink moduleLink = (ModuleLink)element; - final Module module = moduleLink.getModule(); - if (module != null) { - return getAllowedPackagingMethodsForModule(module); - } - return getPackagingMethodForUnresolvedElement(moduleLink); - } - LOG.assertTrue(false, "unexpected element: " + element.getClass()); - return null; - } - - protected PackagingMethod[] getPackagingMethodForUnresolvedElement(final ContainerElement element) { - final PackagingMethod method = element.getPackagingMethod(); - if (method == PackagingMethod.DO_NOT_PACKAGE) { - return PackagingMethod.EMPTY_ARRAY; - } - return new PackagingMethod[]{method}; - } - - public boolean isAllowedToPackage(ContainerElement element) { - return getAllowedPackagingMethods(element).length > 0; - } - - @NotNull - public Module getModule() { - return myModule; - } - - protected List getAddActions() { - List actions = new ArrayList(); - actions.add(new AddPackagingElementAction(ProjectBundle.message("action.name.packaging.add.library"), Icons.LIBRARY_ICON) { - public boolean isEnabled(@NotNull final PackagingEditor editor) { - return !getLibrariesToAdd(editor).isEmpty(); - } - - public void perform(final PackagingEditor packagingEditor) { - List libraries = getLibrariesToAdd(packagingEditor); - ContainerUtil.removeDuplicates(libraries); - ChooseLibrariesDialog dialog = new ChooseLibrariesDialog(packagingEditor.getMainPanel(), - ProjectBundle.message("dialog.title.packaging.choose.library"), libraries); - dialog.show(); - if (dialog.isOK()) { - packagingEditor.addLibraries(dialog.getChosenElements()); - } - } - }); - actions.add(new AddPackagingElementAction(ProjectBundle.message("action.name.packaging.add.module"), StdModuleTypes.JAVA.getNodeIcon(false)) { - public boolean isEnabled(@NotNull final PackagingEditor editor) { - return !getModulesToAdd(editor).isEmpty(); - } - - public void perform(final PackagingEditor packagingEditor) { - List moduleList = getModulesToAdd(packagingEditor); - ContainerUtil.removeDuplicates(moduleList); - ChooseModulesDialog dialog = new ChooseModulesDialog(packagingEditor.getMainPanel(), moduleList, - ProjectBundle.message("dialog.title.packaging.choose.module")); - dialog.show(); - List modules = new ArrayList(dialog.getChosenElements()); - if (dialog.isOK()) { - packagingEditor.addModules(modules); - } - } - }); - return actions; - } - - private List getLibrariesToAdd(final PackagingEditor editor) { - List libraries = new ArrayList(getSuitableLibraries(editor)); - Set addedLibraries = new HashSet(); - for (ContainerElement element : getModifiedElements(editor)) { - if (element instanceof LibraryLink) { - addedLibraries.add(((LibraryLink)element).getLibrary()); - } - } - libraries.removeAll(addedLibraries); - return libraries; - } - - private List getModulesToAdd(final PackagingEditor editor) { - List moduleList = new ArrayList(getSuitableModules(editor)); - Set addedModules = new HashSet(); - for (ContainerElement element : getModifiedElements(editor)) { - if (element instanceof ModuleLink) { - addedModules.add(((ModuleLink)element).getModule()); - } - } - moduleList.removeAll(addedModules); - return moduleList; - } - - public boolean removeObsoleteElements(final PackagingEditor packagingEditor) { - boolean modelChanged = false; - Set libraries = new HashSet(getSuitableLibraries(packagingEditor)); - Set modules = new HashSet(getSuitableModules(packagingEditor)); - List elements = new ArrayList(Arrays.asList(getModifiedElements(packagingEditor))); - PackagingConfiguration configuration = packagingEditor.getModifiedConfiguration(); - for (ContainerElement element : elements) { - boolean remove = false; - if (element instanceof LibraryLink) { - Library library = ((LibraryLink)element).getLibrary(); - remove = library != null && !libraries.contains(library); - } - else if (element instanceof ModuleLink) { - Module module = ((ModuleLink)element).getModule(); - remove = module != null && !modules.contains(module); - } - if (remove) { - configuration.removeContainerElement(element); - modelChanged = true; - } - } - return modelChanged; - } - - public String getElementText(final ContainerElement element) { - if (element instanceof LibraryLink) { - final LibraryLink libraryLink = (LibraryLink)element; - Library library = libraryLink.getLibrary(); - if (library != null) { - return PackagingEditorUtil.getLibraryDescription(library); - } - } - if (element instanceof ModuleLink) { - final ModuleLink moduleLink = (ModuleLink)element; - return ProjectBundle.message("text.module.link.description.0.module", moduleLink.getName()); - } - return element.getPresentableName(); - } - - public void processNewLibraries(final PackagingEditor editor, final List libraries) { - List toAdd = new ArrayList(); - Set suitable = new HashSet(getLibrariesToAdd(editor)); - for (Library library : libraries) { - if (suitable.contains(library) && shouldAddSilently(library)) { - toAdd.add(library); - } - } - editor.addLibraries(toAdd); - } - - protected boolean shouldAddSilently(final Library library) { - return false; - } - - protected static abstract class AdditionalPropertiesConfigurable { - - public abstract JComponent getLabelsComponent(); - public abstract JComponent getFieldsComponent(); - - public abstract void resetFrom(ContainerElement element); - public abstract void applyTo(ContainerElement element); - } -} diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingEditorUtil.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingEditorUtil.java index e558b47793e9..693a552bfeba 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingEditorUtil.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingEditorUtil.java @@ -1,24 +1,12 @@ package com.intellij.openapi.roots.ui.configuration.packaging; -import com.intellij.openapi.module.Module; import com.intellij.openapi.project.ProjectBundle; -import com.intellij.openapi.roots.*; -import com.intellij.openapi.roots.impl.OrderEntryUtil; -import com.intellij.openapi.roots.impl.libraries.LibraryImpl; +import com.intellij.openapi.roots.OrderRootType; import com.intellij.openapi.roots.libraries.Library; -import com.intellij.openapi.roots.libraries.LibraryTable; -import com.intellij.openapi.roots.ui.util.OrderEntryCellAppearanceUtils; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.ui.ColoredTreeCellRenderer; -import com.intellij.ui.SimpleTextAttributes; -import com.intellij.util.Icons; import com.intellij.packaging.impl.ui.LibraryElementPresentation; import org.jetbrains.annotations.NotNull; -import java.util.List; -import java.util.ArrayList; -import java.util.Collection; - /** * @author nik */ @@ -26,76 +14,6 @@ public class PackagingEditorUtil { private PackagingEditorUtil() { } - public static void renderLibraryNode(final ColoredTreeCellRenderer renderer, final Library library, - final SimpleTextAttributes mainAttributes, final SimpleTextAttributes commentAttributes) { - String name = library.getName(); - if (name != null) { - renderer.setIcon(Icons.LIBRARY_ICON); - renderer.append(name, mainAttributes); - renderer.append(LibraryElementPresentation.getLibraryTableComment(library), commentAttributes); - } - else { - VirtualFile[] files = library.getFiles(OrderRootType.CLASSES); - if (files.length > 0) { - VirtualFile file = files[0]; - renderer.setIcon(file.getIcon()); - renderer.append(file.getName(), mainAttributes); - renderer.append(LibraryElementPresentation.getLibraryTableComment(library), commentAttributes); - } - else { - OrderEntryCellAppearanceUtils.forLibrary(library).customize(renderer); - } - } - } - - public static void renderLibraryFile(final ColoredTreeCellRenderer renderer, final Library library, final VirtualFile file, - final SimpleTextAttributes mainAttributes, final SimpleTextAttributes commentAttributes) { - renderer.setIcon(file.getIcon()); - renderer.append(file.getName(), mainAttributes); - String name = library.getName(); - LibraryTable table = library.getTable(); - if (name != null) { - StringBuilder comment = new StringBuilder(); - comment.append(" ('").append(name).append("' "); - comment.append(LibraryElementPresentation.getLibraryTableDisplayName(library)); - comment.append(")"); - renderer.append(comment.toString(), commentAttributes); - } - else if (table == null) { - Module module = ((LibraryImpl)library).getModule(); - String comment; - if (module == null) { - comment = " (" + LibraryElementPresentation.getLibraryTableDisplayName(library) + ")"; - } - else { - comment = " " + ProjectBundle.message("node.text.library.of.module", module.getName()); - } - renderer.append(comment, commentAttributes); - } - } - - public static String getLibraryDescription(final @NotNull Library library) { - String name = library.getName(); - VirtualFile[] files = library.getFiles(OrderRootType.CLASSES); - if (name != null) { - return "'" + name + "' " + LibraryElementPresentation.getLibraryTableDisplayName(library); - } - else if (files.length > 0) { - Module module = ((LibraryImpl)library).getModule(); - final String description; - if (module == null) { - description = "(" + LibraryElementPresentation.getLibraryTableDisplayName(library) + ")"; - } - else { - description = ProjectBundle.message("node.text.library.of.module", module.getName()); - } - return files[0].getName() + " " + description; - } - else { - return ProjectBundle.message("library.empty.item"); - } - } - public static String getLibraryItemText(final @NotNull Library library, final boolean includeTableName) { String name = library.getName(); VirtualFile[] files = library.getFiles(OrderRootType.CLASSES); @@ -110,31 +28,4 @@ public class PackagingEditorUtil { } } - public static List getModulesFromDependentOrderEntries(final @NotNull ModuleRootModel rootModel) { - List moduleList = new ArrayList(); - Collection orderEntries = OrderEntryUtil.getDependentOrderEntries(rootModel); - for (OrderEntry orderEntry : orderEntries) { - if (orderEntry instanceof ModuleOrderEntry) { - Module module = ((ModuleOrderEntry)orderEntry).getModule(); - if (module != null) { - moduleList.add(module); - } - } - } - - return moduleList; - } - - public static List getLibrariesFromDependentOrderEntries(final @NotNull ModuleRootModel rootModel) { - List libraries = new ArrayList(); - for (OrderEntry orderEntry : OrderEntryUtil.getDependentOrderEntries(rootModel)) { - if (orderEntry instanceof LibraryOrderEntry) { - Library library = ((LibraryOrderEntry)orderEntry).getLibrary(); - if (library != null) { - libraries.add(library); - } - } - } - return libraries; - } } diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingElementPropertiesComponent.form b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingElementPropertiesComponent.form deleted file mode 100644 index 4942a65f27ac..000000000000 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingElementPropertiesComponent.form +++ /dev/null @@ -1,79 +0,0 @@ - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingElementPropertiesComponent.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingElementPropertiesComponent.java deleted file mode 100644 index 72a93fade9ee..000000000000 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingElementPropertiesComponent.java +++ /dev/null @@ -1,224 +0,0 @@ -package com.intellij.openapi.roots.ui.configuration.packaging; - -import com.intellij.openapi.deployment.ContainerElement; -import com.intellij.openapi.deployment.PackagingMethod; -import com.intellij.openapi.project.ProjectBundle; -import com.intellij.openapi.ui.DialogWrapper; -import com.intellij.openapi.util.io.FileUtil; -import com.intellij.openapi.util.Pair; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.TestOnly; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.List; -import java.util.Map; -import java.util.HashMap; -import java.util.ArrayList; - -/** - * @author nik - */ -public class PackagingElementPropertiesComponent { - private JPanel myMainPanel; - private JComboBox myPackagingMethodBox; - private JTextField myOutputPathField; - private JLabel myPackagingMethodLabel; - private JLabel myOutputPathLabel; - private JLabel myElementNameLabel; - private JPanel myLabelsPanel; - private JPanel myFieldPanel; - private final PackagingEditorPolicy myEditorPolicy; - private PackagingMethod myLastSelectedMethod; - private PackagingEditorPolicy.AdditionalPropertiesConfigurable myAdditionalPropertiesConfigurable; - private final PackagingElementsToEditInfo myElementsInfo; - private Map myPathTails; - private final PackagingEditorListener myListener; - - private PackagingElementPropertiesComponent(PackagingElementsToEditInfo elementsInfo, PackagingEditorPolicy editorPolicy, - final @Nullable PackagingEditorListener listener) { - myElementsInfo = elementsInfo; - myListener = listener; - myElementNameLabel.setText(elementsInfo.getElementText()); - myEditorPolicy = editorPolicy; - if (elementsInfo.getAllowedPackagingMethods().length > 1 && elementsInfo.getPackagingMethod() != null) { - for (PackagingMethod method : elementsInfo.getAllowedPackagingMethods()) { - myPackagingMethodBox.addItem(method); - } - myPackagingMethodBox.setRenderer(new PackagingMethodListCellRenderer()); - myPackagingMethodBox.setSelectedItem(myLastSelectedMethod = elementsInfo.getPackagingMethod()); - myPackagingMethodBox.addActionListener(new ActionListener() { - public void actionPerformed(final ActionEvent e) { - updateOutputPath(); - } - }); - } - else { - myPackagingMethodBox.setVisible(false); - myPackagingMethodLabel.setVisible(false); - } - - String outputPath = elementsInfo.getRelativePath(); - myPathTails = elementsInfo.getPathTails(); - if (outputPath != null) { - myOutputPathField.setText(outputPath); - } - else { - myOutputPathField.setVisible(false); - myOutputPathLabel.setVisible(false); - } - List elements = elementsInfo.getElements(); - if (elements.size() == 1) { - ContainerElement element = elements.get(0); - myAdditionalPropertiesConfigurable = editorPolicy.getAdditionalPropertiesConfigurable(element); - if (myAdditionalPropertiesConfigurable != null) { - myLabelsPanel.add(myAdditionalPropertiesConfigurable.getLabelsComponent(), BorderLayout.CENTER); - myFieldPanel.add(myAdditionalPropertiesConfigurable.getFieldsComponent(), BorderLayout.CENTER); - myAdditionalPropertiesConfigurable.resetFrom(element); - } - } - } - - private void updateOutputPath() { - PackagingMethod method = getSelectedMethod(); - if (method != myLastSelectedMethod && method != null) { - Map paths = new HashMap(); - for (ContainerElement element : myElementsInfo.getElements()) { - PackagingMethod oldMethod = element.getPackagingMethod(); - element.setPackagingMethod(method); - paths.put(element, myEditorPolicy.suggestDefaultRelativePath(element)); - element.setPackagingMethod(oldMethod); - } - Pair> pair = PackagingElementsToEditInfo.getPrefixAndSuffixes(paths, myEditorPolicy); - if (pair != null) { - myOutputPathField.setText(pair.getFirst()); - myPathTails = pair.getSecond(); - } - myOutputPathField.setEnabled(pair != null); - myLastSelectedMethod = method; - } - } - - @TestOnly - public JTextField getOutputPathField() { - return myOutputPathField; - } - - public JPanel getMainPanel() { - return myMainPanel; - } - - public void applyChanges() { - PackagingMethod packagingMethod = getSelectedMethod(); - List changedElements = new ArrayList(); - if (packagingMethod != null && myElementsInfo.getPackagingMethod() != null) { - for (ContainerElement element : myElementsInfo.getElements()) { - element.setPackagingMethod(packagingMethod); - } - } - String text = myOutputPathField.getText(); - if (text.length() == 0) { - text = "/"; - } - if (myElementsInfo.getRelativePath() != null) { - for (ContainerElement element : myElementsInfo.getElements()) { - String path = text; - if (myPathTails != null) { - String tail = myPathTails.get(element); - if (tail.startsWith("/")) { - tail = tail.substring(1); - } - if (!path.endsWith("/")) { - path += "/"; - } - path += tail; - } - if (path.length() > 1 && path.endsWith("/")) { - path = path.substring(0, path.length() - 1); - } - element.setURI(FileUtil.toSystemIndependentName(path)); - } - } - if (myAdditionalPropertiesConfigurable != null && myElementsInfo.getElements().size() == 1) { - myAdditionalPropertiesConfigurable.applyTo(myElementsInfo.getElements().get(0)); - } - if (myListener != null) { - for (ContainerElement changedElement : changedElements) { - myListener.packagingMethodChanged(changedElement); - } - } - } - - @Nullable - private PackagingMethod getSelectedMethod() { - return (PackagingMethod)myPackagingMethodBox.getSelectedItem(); - } - - @TestOnly - public JComboBox getPackagingMethodBox() { - return myPackagingMethodBox; - } - - public static boolean isEnabled(PackagingElementsToEditInfo elementsToEdit) { - boolean showPackagingMethodBox = elementsToEdit.getAllowedPackagingMethods().length > 1 && elementsToEdit.getPackagingMethod() != null; - boolean showOutputPathField = elementsToEdit.getRelativePath() != null; - return showOutputPathField || showPackagingMethodBox; - } - - @Nullable - public static PackagingElementPropertiesComponent createPropertiesComponent(PackagingElementsToEditInfo elementsToEdit, - PackagingEditorPolicy editorPolicy, - final PackagingEditorListener listener) { - if (!isEnabled(elementsToEdit)) return null; - - return new PackagingElementPropertiesComponent(elementsToEdit, editorPolicy, listener); - } - - public static boolean showDialog(final PackagingElementsToEditInfo elementsToEdit, JPanel component, PackagingEditorPolicy policy, - final PackagingEditorListener listener) { - PackagingElementPropertiesComponent propertiesComponent = createPropertiesComponent(elementsToEdit, policy, listener); - if (propertiesComponent == null) { - return false; - } - - PackagingElementPropertiesDialog dialog = new PackagingElementPropertiesDialog(component, propertiesComponent); - dialog.show(); - return dialog.isOK(); - } - - private class PackagingMethodListCellRenderer extends DefaultListCellRenderer { - @Override - public Component getListCellRendererComponent(final JList list, - Object value, - final int index, - final boolean isSelected, - final boolean cellHasFocus) { - ContainerElement element = myElementsInfo.getElements().get(0); - value = element.getDescriptionForPackagingMethod((PackagingMethod)value); - return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - } - } - - public static class PackagingElementPropertiesDialog extends DialogWrapper { - private final PackagingElementPropertiesComponent myPropertiesComponent; - - public PackagingElementPropertiesDialog(JComponent parent, PackagingElementPropertiesComponent propertiesComponent) { - super(parent, false); - setTitle(ProjectBundle.message("dialog.title.packaging.edit.properties")); - myPropertiesComponent = propertiesComponent; - init(); - } - - protected JComponent createCenterPanel() { - return myPropertiesComponent.getMainPanel(); - } - - @Override - protected void doOKAction() { - myPropertiesComponent.applyChanges(); - super.doOKAction(); - } - } -} diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingElementsToEditInfo.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingElementsToEditInfo.java deleted file mode 100644 index ec9000ec073f..000000000000 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingElementsToEditInfo.java +++ /dev/null @@ -1,155 +0,0 @@ -package com.intellij.openapi.roots.ui.configuration.packaging; - -import com.intellij.openapi.deployment.ContainerElement; -import com.intellij.openapi.deployment.PackagingMethod; -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.project.ProjectBundle; -import com.intellij.openapi.util.Pair; -import com.intellij.openapi.util.text.StringUtil; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.*; - -class PackagingElementsToEditInfo { - private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.roots.ui.configuration.packaging.PackagingElementsToEditInfo"); - private final List myElements; - private final PackagingMethod myPackagingMethod; - private final String myRelativePath; - private final PackagingMethod[] myAllowedPackagingMethods; - private final String myElementText; - private Map myPathTails; - - public PackagingElementsToEditInfo(final ContainerElement element, @NotNull PackagingEditorPolicy policy) { - myElements = Collections.singletonList(element); - myRelativePath = policy.isRelativePathCellEditable(element) ? element.getURI() : null; - myPackagingMethod = element.getPackagingMethod(); - myAllowedPackagingMethods = policy.getAllowedPackagingMethods(element); - myElementText = policy.getElementText(element); - } - - public PackagingElementsToEditInfo(final Set elements, @NotNull PackagingEditorPolicy policy) { - LOG.assertTrue(elements.size() > 1); - myElements = new ArrayList(elements); - myPackagingMethod = getCommonPackagingMethod(elements); - String commonPath = getCommonRelativePath(elements, policy); - if (commonPath == null) { - final Map elementsToPaths = new HashMap(); - for (ContainerElement element : elements) { - elementsToPaths.put(element, element.getURI()); - } - Pair> pair = getPrefixAndSuffixes(elementsToPaths, policy); - if (pair != null) { - commonPath = pair.getFirst(); - myPathTails = pair.getSecond(); - } - } - myRelativePath = commonPath; - myAllowedPackagingMethods = getAllowedPackagingMethods(elements, policy); - myElementText = ProjectBundle.message("element.description.0.items", elements.size()); - } - - public List getElements() { - return myElements; - } - - @Nullable - public PackagingMethod getPackagingMethod() { - return myPackagingMethod; - } - - @Nullable - public String getRelativePath() { - return myRelativePath; - } - - @Nullable - public Map getPathTails() { - return myPathTails; - } - - @NotNull - public PackagingMethod[] getAllowedPackagingMethods() { - return myAllowedPackagingMethods; - } - - public String getElementText() { - return myElementText; - } - - @NotNull - private static PackagingMethod[] getAllowedPackagingMethods(final Set elements, final PackagingEditorPolicy policy) { - List methods = null; - for (ContainerElement element : elements) { - List otherMethods = Arrays.asList(policy.getAllowedPackagingMethods(element)); - if (methods == null) { - methods = new ArrayList(otherMethods); - } - else { - methods.retainAll(otherMethods); - } - } - return methods != null ? methods.toArray(new PackagingMethod[methods.size()]) : PackagingMethod.EMPTY_ARRAY; - } - - @Nullable - public static Pair> getPrefixAndSuffixes(final Map elementsToPaths, final PackagingEditorPolicy policy) { - String prefix = null; - for (Map.Entry entry : elementsToPaths.entrySet()) { - if (!policy.isRelativePathCellEditable(entry.getKey())) { - return null; - } - String path = entry.getValue(); - if (prefix == null) { - prefix = path; - } - else { - prefix = StringUtil.commonPrefix(prefix, path); - if (!path.equals(prefix) && !StringUtil.startsWithConcatenationOf(path, prefix, "/")) { - int i = prefix.lastIndexOf('/'); - prefix = i != -1 ? prefix.substring(0, i) : ""; - } - } - } - if (prefix == null) { - return null; - } - Map map = new HashMap(); - for (Map.Entry entry : elementsToPaths.entrySet()) { - String path = entry.getValue(); - map.put(entry.getKey(), path.substring(prefix.length())); - } - return Pair.create(prefix, map); - } - - @Nullable - private static String getCommonRelativePath(final Set elements, final PackagingEditorPolicy policy) { - String path = null; - for (ContainerElement element : elements) { - if (!policy.isRelativePathCellEditable(element)) { - return null; - } - if (path == null) { - path = element.getURI(); - } - else if (!path.equals(element.getURI())) { - return null; - } - } - return path; - } - - @Nullable - private static PackagingMethod getCommonPackagingMethod(final Set elements) { - PackagingMethod method = null; - for (ContainerElement element : elements) { - if (method == null) { - method = element.getPackagingMethod(); - } - else if (!method.equals(element.getPackagingMethod())) { - return null; - } - } - return method; - } -} diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingNodeWeights.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingNodeWeights.java deleted file mode 100644 index 7631ef3b2dbd..000000000000 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingNodeWeights.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.intellij.openapi.roots.ui.configuration.packaging; - -/** - * @author nik - */ -public class PackagingNodeWeights { - public static final double ARTIFACT = 0; - public static final double DIRECTORY = 1; - public static final double FILE = 2; - public static final double ARCHIVE = FILE; - public static final double MODULE = FILE; - public static final double LIBRARY = FILE; - - - private PackagingNodeWeights() { - } -} diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingTreeBuilder.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingTreeBuilder.java deleted file mode 100644 index 137bfa4bf041..000000000000 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingTreeBuilder.java +++ /dev/null @@ -1,132 +0,0 @@ -package com.intellij.openapi.roots.ui.configuration.packaging; - -import com.intellij.openapi.deployment.ContainerElement; -import com.intellij.openapi.deployment.LibraryLink; -import com.intellij.openapi.deployment.ModuleLink; -import com.intellij.openapi.deployment.PackagingMethod; -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.roots.OrderRootType; -import com.intellij.openapi.roots.libraries.Library; -import com.intellij.openapi.vfs.VirtualFile; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.NonNls; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * @author nik - */ -public abstract class PackagingTreeBuilder { - private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.roots.ui.configuration.packaging.PackagingTreeBuilder"); - - public abstract PackagingArtifact createRootArtifact(); - - @NotNull - public PackagingTreeParameters getDefaultParameters() { - return new PackagingTreeParameters(false, false); - } - - public void updateParameters(final @NotNull PackagingTreeParameters treeParameters) { - } - - @NotNull - public List createNodes(@NotNull PackagingArtifactNode artifactRoot, @NotNull ContainerElement element, - final PackagingArtifact owner, final PackagingTreeParameters parameters) { - if (element instanceof LibraryLink) { - return createLibraryNodes((LibraryLink)element, artifactRoot, owner, parameters); - } - if (element instanceof ModuleLink) { - return Collections.singletonList(createModuleNode((ModuleLink)element, artifactRoot, owner)); - } - LOG.error("unknown element: " + element.getClass()); - return Collections.emptyList(); - } - - @NotNull - private static List createLibraryNodes(final LibraryLink libraryLink, final PackagingArtifactNode root, final PackagingArtifact owner, - final PackagingTreeParameters parameters) { - PackagingTreeNode parent = getOrCreateParentNode(libraryLink, root, owner); - if (parameters.isShowLibraryFiles()) { - Library library = libraryLink.getLibrary(); - if (library != null) { - VirtualFile[] files = library.getFiles(OrderRootType.CLASSES); - List nodes = new ArrayList(); - for (VirtualFile file : files) { - nodes.add(PackagingTreeNodeFactoryOld.createLibraryFileNode(file, library, libraryLink, parent, owner)); - } - return nodes; - } - } - return Collections.singletonList(PackagingTreeNodeFactoryOld.createLibraryNode(libraryLink, parent, owner)); - } - - protected static PackagingTreeNode getOrCreateParentNode(final ContainerElement element, final PackagingArtifactNode root, final PackagingArtifact owner) { - PackagingMethod method = element.getPackagingMethod(); - PackagingTreeNode parent; - String path = element.getURI(); - if (path == null) { - LOG.error("path==null for " + element + ", method = " + element.getPackagingMethod()); - } - - path = fixPath(element, method, path); - - if (method == PackagingMethod.JAR_AND_COPY_FILE) { - parent = PackagingTreeNodeFactoryOld.getOrCreateArchiveNode(path, root, owner); - } - else if (method == PackagingMethod.JAR_AND_COPY_FILE_AND_LINK_VIA_MANIFEST) { - parent = PackagingTreeNodeFactoryOld.getOrCreateArchiveNode(path, root.getParent(), owner); - } - else if (method == PackagingMethod.COPY_FILES_AND_LINK_VIA_MANIFEST) { - parent = PackagingTreeNodeFactoryOld.getOrCreateDirectoryNode(path, root.getParent(), owner); - } - else { - parent = PackagingTreeNodeFactoryOld.getOrCreateDirectoryNode(path, root, owner); - } - return parent; - } - - private static String fixPath(final ContainerElement element, final PackagingMethod method, final String path) { - if (element instanceof LibraryLink) { - final LibraryLink libraryLink = (LibraryLink)element; - @NonNls String jarSuffix = ".jar"; - if ((method == PackagingMethod.COPY_FILES_AND_LINK_VIA_MANIFEST || method == PackagingMethod.COPY_FILES) - && libraryLink.getUrls().size() == 1 && LibraryLink.MODULE_LEVEL.equals(libraryLink.getLevel()) && path.endsWith(jarSuffix)) { - int index = path.lastIndexOf('/'); - if (index >= 0) { - return path.substring(0, index); - } - else { - return ""; - } - } - } - return path; - } - - @NotNull - private static PackagingTreeNode createModuleNode(ModuleLink moduleLink, PackagingArtifactNode root, final PackagingArtifact owner) { - PackagingMethod method = moduleLink.getPackagingMethod(); - if (method == PackagingMethod.JAR_AND_COPY_FILE_AND_LINK_VIA_MANIFEST || method == PackagingMethod.JAR_AND_COPY_FILE) { - String path = moduleLink.getURI(); - int i = path.lastIndexOf('/'); - String jarName = path.substring(i+1); - PackagingTreeNode parent = root; - if (i != -1) { - String parentPath = path.substring(0, i); - if (method == PackagingMethod.JAR_AND_COPY_FILE) { - parent = PackagingTreeNodeFactoryOld.getOrCreateDirectoryNode(parentPath, root, owner); - } - else { - parent = PackagingTreeNodeFactoryOld.getOrCreateDirectoryNode(parentPath, root.getParent(), owner); - } - } - return PackagingTreeNodeFactoryOld.createPackedModuleOutputNode(moduleLink, jarName, parent, owner); - } - PackagingTreeNode parent = getOrCreateParentNode(moduleLink, root, owner); - return PackagingTreeNodeFactoryOld.createModuleOutputNode(moduleLink, parent, owner); - } -} - - diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingTreeNode.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingTreeNode.java deleted file mode 100644 index cb1cdf6ba5e6..000000000000 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingTreeNode.java +++ /dev/null @@ -1,97 +0,0 @@ -package com.intellij.openapi.roots.ui.configuration.packaging; - -import com.intellij.ui.ColoredTreeCellRenderer; -import com.intellij.ui.SimpleTextAttributes; -import com.intellij.openapi.deployment.ContainerElement; -import com.intellij.openapi.roots.ui.configuration.projectRoot.ModuleStructureConfigurable; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import javax.swing.tree.DefaultMutableTreeNode; -import java.util.ArrayList; -import java.util.List; - -/** - * @author nik - */ -public abstract class PackagingTreeNode extends DefaultMutableTreeNode implements Comparable { - private final PackagingArtifact myOwner; - - protected PackagingTreeNode(final @Nullable PackagingArtifact owner) { - myOwner = owner; - } - - @NotNull - public abstract String getOutputFileName(); - - public abstract double getWeight(); - - public String getSearchName() { - return getOutputFileName(); - } - - public abstract void render(@NotNull ColoredTreeCellRenderer renderer); - - public abstract boolean canNavigate(); - - public abstract void navigate(ModuleStructureConfigurable configurable); - - @Nullable - public abstract Object getSourceObject(); - - @Nullable - public String getTooltipText() { - return null; - } - - public int compareTo(final PackagingTreeNode node) { - return getOutputFileName().compareToIgnoreCase(node.getOutputFileName()); - } - - @Nullable - public PackagingArtifact getOwner() { - return myOwner; - } - - @Nullable - public ContainerElement getContainerElement() { - return null; - } - - @Nullable - public PackagingTreeNode findChildByName(final @NotNull String outputFileName) { - for (int i = 0; i < getChildCount(); i++) { - PackagingTreeNode node = (PackagingTreeNode)getChildAt(i); - if (node.getOutputFileName().equals(outputFileName)) { - return node; - } - } - return null; - } - - @Override - public PackagingTreeNode getParent() { - return (PackagingTreeNode)super.getParent(); - } - - @NotNull - public List getChildren() { - List children = new ArrayList(getChildCount()); - for (int i = 0; i < getChildCount(); i++) { - children.add((PackagingTreeNode)getChildAt(i)); - } - return children; - } - - protected SimpleTextAttributes getMainAttributes() { - return !belongsToIncludedArtifact() ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.GRAY_ATTRIBUTES; - } - - protected SimpleTextAttributes getCommentAttributes() { - return !belongsToIncludedArtifact() ? SimpleTextAttributes.GRAY_ATTRIBUTES : SimpleTextAttributes.GRAY_ITALIC_ATTRIBUTES; - } - - protected boolean belongsToIncludedArtifact() { - return myOwner != null; - } -} diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingTreeNodeFactoryOld.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingTreeNodeFactoryOld.java deleted file mode 100644 index dc739fd0a3ca..000000000000 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingTreeNodeFactoryOld.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.intellij.openapi.roots.ui.configuration.packaging; - -import com.intellij.openapi.deployment.LibraryLink; -import com.intellij.openapi.deployment.ModuleLink; -import com.intellij.openapi.roots.libraries.Library; -import com.intellij.openapi.vfs.VirtualFile; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.StringTokenizer; - -/** - * @author nik - */ -public class PackagingTreeNodeFactoryOld { - private PackagingTreeNodeFactoryOld() { - } - - @NotNull - public static PackagingTreeNode getOrCreateDirectoryNode(@NotNull String path, @NotNull PackagingTreeNode root, PackagingArtifact owner) { - StringTokenizer tokenizer = new StringTokenizer(path, "/"); - PackagingTreeNode current = root; - while (tokenizer.hasMoreTokens()) { - String name = tokenizer.nextToken(); - if (name.length() == 0 || name.equals(".")) continue; - - PackagingTreeNode child = current.findChildByName(name); - if (child == null) { - child = new DirectoryNode(name, owner); - current.add(child); - } - current = child; - } - return current; - } - - @NotNull - public static PackagingTreeNode getOrCreateArchiveNode(@NotNull String path, @NotNull PackagingTreeNode root, PackagingArtifact owner) { - int i = path.lastIndexOf('/'); - String archiveName = path.substring(i+1); - PackagingTreeNode parent = i != -1 ? getOrCreateDirectoryNode(path.substring(0, i), root, owner) : root; - PackagingTreeNode child = parent.findChildByName(archiveName); - if (child == null) { - child = new ArchiveNode(archiveName, owner); - parent.add(child); - } - return child; - } - - @NotNull - public static PackagingTreeNode createLibraryNode(@NotNull LibraryLink libraryLink, @NotNull PackagingTreeNode parent, final PackagingArtifact owner) { - for (PackagingTreeNode child : parent.getChildren()) { - if (child instanceof LibraryNode && ((LibraryNode)child).getLibraryLink().equals(libraryLink)) { - return child; - } - } - LibraryNode node = new LibraryNode(libraryLink, owner); - parent.add(node); - return node; - } - - @NotNull - public static PackagingTreeNode createPackedModuleOutputNode(@NotNull ModuleLink moduleLink, String jarName, @NotNull PackagingTreeNode parent, final PackagingArtifact owner) { - for (PackagingTreeNode child : parent.getChildren()) { - if (child instanceof PackedModuleOutputNode && ((PackedModuleOutputNode)child).getModuleLink().equals(moduleLink)) { - return child; - } - } - PackedModuleOutputNode node = new PackedModuleOutputNode(moduleLink, jarName, owner); - parent.add(node); - return node; - } - - @NotNull - public static PackagingTreeNode createModuleOutputNode(@NotNull ModuleLink moduleLink, @NotNull PackagingTreeNode parent, final PackagingArtifact owner) { - for (PackagingTreeNode child : parent.getChildren()) { - if (child instanceof ModuleOutputNode && ((ModuleOutputNode)child).getModuleLink().equals(moduleLink)) { - return child; - } - } - ModuleOutputNode node = new ModuleOutputNode(moduleLink, owner); - parent.add(node); - return node; - } - - public static PackagingArtifactNode createArtifactNode(@NotNull PackagingArtifact artifact, @NotNull PackagingTreeNode parent, - PackagingArtifact owner) { - PackagingArtifactNode node = new PackagingArtifactNode(artifact, owner); - parent.add(node); - return node; - } - - public static PackagingTreeNode createLibraryFileNode(@NotNull VirtualFile file, @NotNull Library library, @NotNull LibraryLink libraryLink, - @NotNull PackagingTreeNode parent, @Nullable PackagingArtifact owner) { - for (PackagingTreeNode child : parent.getChildren()) { - if (child instanceof LibraryFileNode && ((LibraryFileNode)child).getFile().equals(file)) { - return child; - } - } - LibraryFileNode node = new LibraryFileNode(file, library, libraryLink, owner); - parent.add(node); - return node; - } -} diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingTreeParameters.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingTreeParameters.java deleted file mode 100644 index 2ecbc2f66fba..000000000000 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingTreeParameters.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.intellij.openapi.roots.ui.configuration.packaging; - -import com.intellij.util.xmlb.annotations.Attribute; -import com.intellij.util.xmlb.annotations.Tag; - -/** - * @author nik - */ -@Tag("packaging-tree") -public class PackagingTreeParameters { - private boolean myShowIncludedContent; - private boolean myShowLibraryFiles; - - public PackagingTreeParameters() { - } - - public PackagingTreeParameters(final boolean showIncludedContent, final boolean showLibraryFiles) { - myShowIncludedContent = showIncludedContent; - myShowLibraryFiles = showLibraryFiles; - } - - @Attribute("show-included-content") - public boolean isShowIncludedContent() { - return myShowIncludedContent; - } - - @Attribute("show-library-files") - public boolean isShowLibraryFiles() { - return myShowLibraryFiles; - } - - public void setShowIncludedContent(final boolean showIncludedContent) { - myShowIncludedContent = showIncludedContent; - } - - public void setShowLibraryFiles(final boolean showLibraryFiles) { - myShowLibraryFiles = showLibraryFiles; - } -} diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingTreeState.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingTreeState.java deleted file mode 100644 index 6662411752b0..000000000000 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackagingTreeState.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.intellij.openapi.roots.ui.configuration.packaging; - -import com.intellij.ui.treeStructure.Tree; -import com.intellij.util.ArrayUtil; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import javax.swing.tree.TreePath; -import java.util.Map; -import java.util.HashMap; -import java.util.List; -import java.util.ArrayList; - -/** - * @author nik - */ -public class PackagingTreeState { - private final PackagingNodeState myRootState; - private final List mySelectedPaths; - - private PackagingTreeState(Tree tree) { - myRootState = saveState(tree, (PackagingTreeNode)tree.getModel().getRoot()); - mySelectedPaths = new ArrayList(); - TreePath[] treePaths = tree.getSelectionPaths(); - if (treePaths != null) { - for (TreePath path : treePaths) { - Object[] pathElements = path.getPath(); - String[] names = ArrayUtil.newStringArray(pathElements.length); - for (int i = 0; i < pathElements.length; i++) { - names[i] = ((PackagingTreeNode)pathElements[i]).getOutputFileName(); - } - mySelectedPaths.add(names); - } - } - } - - public static PackagingTreeState saveState(Tree tree) { - return new PackagingTreeState(tree); - } - - public void restoreState(Tree tree) { - if (myRootState != null) { - expandNodes(tree, (PackagingTreeNode)tree.getModel().getRoot(), myRootState); - } - - List paths = new ArrayList(); - for (String[] selectedPath : mySelectedPaths) { - PackagingTreeNode node = (PackagingTreeNode)tree.getModel().getRoot(); - TreePath path = new TreePath(node); - for (int i = 1; i < selectedPath.length; i++) { - node = node.findChildByName(selectedPath[i]); - if (node == null) break; - path = path.pathByAddingChild(node); - } - if (path.getPathCount() > 1) { - paths.add(path); - } - } - tree.setSelectionPaths(paths.toArray(new TreePath[paths.size()])); - } - - private static void expandNodes(final Tree tree, final PackagingTreeNode node, final PackagingNodeState nodeState) { - TreePath path = new TreePath(node.getPath()); - if (!tree.isExpanded(path)) { - tree.expandPath(path); - } - for (PackagingTreeNode child : node.getChildren()) { - PackagingNodeState childState = nodeState.findChild(child.getOutputFileName()); - if (childState != null) { - expandNodes(tree, child, childState); - } - } - } - - @Nullable - private static PackagingNodeState saveState(final Tree tree, final PackagingTreeNode node) { - if (tree.isExpanded(new TreePath(node.getPath()))) { - List children = node.getChildren(); - if (!children.isEmpty()) { - PackagingNodeState nodeState = new PackagingNodeState(node.getOutputFileName()); - for (PackagingTreeNode child : children) { - PackagingNodeState childState = saveState(tree, child); - if (childState != null) { - nodeState.addChild(childState); - } - } - return nodeState; - } - } - return null; - } - - private static class PackagingNodeState { - private final String myName; - private Map myChildren; - - private PackagingNodeState(final String name) { - myName = name; - } - - public void addChild(@NotNull PackagingNodeState childState) { - if (myChildren == null) { - myChildren = new HashMap(); - } - myChildren.put(childState.myName, childState); - } - - public boolean isExpanded() { - return myChildren != null && !myChildren.isEmpty(); - } - - @Nullable - private PackagingNodeState findChild(String name) { - return myChildren != null ? myChildren.get(name) : null; - } - } -} diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackedModuleOutputNode.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackedModuleOutputNode.java deleted file mode 100644 index 3515a482f529..000000000000 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/PackedModuleOutputNode.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.intellij.openapi.roots.ui.configuration.packaging; - -import com.intellij.openapi.deployment.ModuleLink; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.project.ProjectBundle; -import com.intellij.openapi.util.IconLoader; -import com.intellij.ui.ColoredTreeCellRenderer; -import com.intellij.ui.SimpleTextAttributes; -import org.jetbrains.annotations.NotNull; - -import javax.swing.*; - -/** - * @author nik - */ -class PackedModuleOutputNode extends ModuleOutputBaseNode { - private static final Icon MODULE_JAR_ICON = IconLoader.getIcon("/nodes/moduleJar.png"); - private final String myJarFileName; - - PackedModuleOutputNode(@NotNull ModuleLink moduleLink, String jarFileName, PackagingArtifact owner) { - super(owner, moduleLink); - myJarFileName = jarFileName; - } - - @NotNull - public String getOutputFileName() { - return myJarFileName; - } - - public void render(@NotNull final ColoredTreeCellRenderer renderer) { - Module module = myModuleLink.getModule(); - renderer.setIcon(MODULE_JAR_ICON); - if (module != null) { - renderer.append(myJarFileName, getMainAttributes()); - renderer.append(getComment(module.getName()), getCommentAttributes()); - } - else { - renderer.append(myJarFileName, SimpleTextAttributes.ERROR_ATTRIBUTES); - renderer.append(getComment(myModuleLink.getName()), getCommentAttributes()); - } - } - - private static String getComment(final String name) { - return " " + ProjectBundle.message("node.text.packed.0.compile.output", name); - } -} diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/SelectedPackagingElements.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/SelectedPackagingElements.java deleted file mode 100644 index 1fd9fd307cde..000000000000 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/packaging/SelectedPackagingElements.java +++ /dev/null @@ -1,139 +0,0 @@ -package com.intellij.openapi.roots.ui.configuration.packaging; - -import com.intellij.openapi.deployment.ContainerElement; -import com.intellij.openapi.deployment.LibraryLink; -import com.intellij.openapi.project.ProjectBundle; -import com.intellij.openapi.roots.OrderRootType; -import com.intellij.openapi.roots.libraries.Library; -import com.intellij.openapi.ui.Messages; -import com.intellij.openapi.util.Comparing; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.util.containers.BidirectionalMap; -import com.intellij.util.containers.ContainerUtil; -import org.jetbrains.annotations.Nullable; - -import java.util.*; - -/** - * @author nik -*/ -class SelectedPackagingElements { - private final List myContainerElements = new ArrayList(); - private final Set myOwners = new HashSet(); - private final Collection myParentLibraryLinks; - - public SelectedPackagingElements(final PackagingTreeNode[] treeNodes) { - BidirectionalMap selectedFiles = new BidirectionalMap(); - Set fullySelectedLibraries = new HashSet(); - for (PackagingTreeNode treeNode : treeNodes) { - ContainerElement containerElement = treeNode.getContainerElement(); - if (containerElement == null) continue; - - if (treeNode instanceof LibraryFileNode) { - LibraryFileNode node = (LibraryFileNode)treeNode; - selectedFiles.put(node.getFile(), node.getLibraryLink()); - } - else if (containerElement instanceof LibraryLink) { - fullySelectedLibraries.add((LibraryLink)containerElement); - } - PackagingArtifact owner = treeNode.getOwner(); - if (owner != null && owner.getContainerElement() != null) { - myOwners.add(owner); - } - else { - myContainerElements.add(containerElement); - } - } - - for (LibraryLink libraryLink : selectedFiles.values()) { - Library library = libraryLink.getLibrary(); - if (library != null) { - VirtualFile[] roots = library.getFiles(OrderRootType.CLASSES); - List files = selectedFiles.getKeysByValue(libraryLink); - if (Comparing.haveEqualElements(files, Arrays.asList(roots))) { - fullySelectedLibraries.add(libraryLink); - } - } - } - - for (LibraryLink libraryLink : fullySelectedLibraries) { - selectedFiles.removeValue(libraryLink); - } - myParentLibraryLinks = selectedFiles.values(); - ContainerUtil.removeDuplicates(myContainerElements); - } - - public Collection getParentLibraryLinks() { - return myParentLibraryLinks; - } - - public List getContainerElements() { - return myContainerElements; - } - - public Set getOwners() { - return myOwners; - } - - public boolean showRemovingWarning(final PackagingEditorImpl editor) { - Set owners = getOwners(); - Collection parentLibraryLinks = getParentLibraryLinks(); - if (!parentLibraryLinks.isEmpty()) { - StringBuilder librariesNames = new StringBuilder(); - for (LibraryLink link : parentLibraryLinks) { - if (librariesNames.length() > 0) librariesNames.append(", "); - librariesNames.append('\'').append(link.getPresentableName()).append('\''); - } - String message = ProjectBundle.message("message.text.individial.files.cannot.be.removed.from.packaging.do.you.want.to.remove.the.whole.libraries", - librariesNames.toString(), parentLibraryLinks.size()); - int answer = Messages.showYesNoDialog(editor.getMainPanel(), message, ProjectBundle.message("dialog.title.packaging.remove.included"), null); - if (answer != 0) { - return false; - } - } - - if (!owners.isEmpty()) { - String message; - if (owners.size() == 1 && getContainerElements().isEmpty()) { - PackagingArtifact artifact = owners.iterator().next(); - message = ProjectBundle.message("message.text.packaging.selected.item.belongs.to.0.do.you.want.to.exlude.1.from.2", - artifact.getDisplayName(), artifact.getDisplayName(), editor.getRootArtifact().getDisplayName()); - } - else { - StringBuilder ownersBuffer = new StringBuilder(); - for (PackagingArtifact owner : owners) { - if (ownersBuffer.length() > 0) { - ownersBuffer.append(", "); - } - ownersBuffer.append(owner.getDisplayName()); - } - message = ProjectBundle.message("message.text.packaging.do.you.want.to.exlude.0.from.1", ownersBuffer, editor.getRootArtifact().getDisplayName()); - } - int answer = Messages.showYesNoDialog(editor.getMainPanel(), message, ProjectBundle.message("dialog.title.packaging.remove.included"), null); - if (answer != 0) { - return false; - } - } - return true; - } - - @Nullable - public PackagingElementsToEditInfo getElementsToEdit(final PackagingEditorPolicy policy) { - Set elements = new HashSet(myContainerElements); - for (PackagingArtifact owner : myOwners) { - ContainerElement element = owner.getContainerElement(); - if (element != null) { - elements.add(element); - } - } - if (elements.isEmpty()) { - return null; - } - if (elements.size() == 1) { - return new PackagingElementsToEditInfo(elements.iterator().next(), policy); - } - - return new PackagingElementsToEditInfo(elements, policy); - } - -} diff --git a/platform/icons/src/nodes/copyOfFolder.png b/platform/icons/src/nodes/copyOfFolder.png index cd189d1187df..b4c66afd4e86 100644 Binary files a/platform/icons/src/nodes/copyOfFolder.png and b/platform/icons/src/nodes/copyOfFolder.png differ diff --git a/platform/lang-impl/src/com/intellij/conversion/ConversionContext.java b/platform/lang-impl/src/com/intellij/conversion/ConversionContext.java index 803fd26ccf53..9e368bf5593e 100644 --- a/platform/lang-impl/src/com/intellij/conversion/ConversionContext.java +++ b/platform/lang-impl/src/com/intellij/conversion/ConversionContext.java @@ -35,4 +35,7 @@ public interface ConversionContext { @Nullable ComponentManagerSettings getCompilerSettings(); + + @Nullable + ComponentManagerSettings getProjectRootManagerSettings(); } diff --git a/platform/lang-impl/src/com/intellij/conversion/ModuleSettings.java b/platform/lang-impl/src/com/intellij/conversion/ModuleSettings.java index ae8efd3d92a1..8b30ea156789 100644 --- a/platform/lang-impl/src/com/intellij/conversion/ModuleSettings.java +++ b/platform/lang-impl/src/com/intellij/conversion/ModuleSettings.java @@ -6,6 +6,7 @@ import org.jetbrains.annotations.Nullable; import java.io.File; import java.util.Collection; +import java.util.List; /** * @author nik @@ -31,4 +32,11 @@ public interface ModuleSettings extends ComponentManagerSettings { @NotNull Collection getSourceRoots(boolean includeTests); + + @NotNull + Collection getContentRoots(); + + void addExcludedFolder(@NotNull File directory); + + List getModuleLibraryRootUrls(String libraryName); } diff --git a/platform/lang-impl/src/com/intellij/conversion/impl/ConversionContextImpl.java b/platform/lang-impl/src/com/intellij/conversion/impl/ConversionContextImpl.java index 67508d817301..6064149856bb 100644 --- a/platform/lang-impl/src/com/intellij/conversion/impl/ConversionContextImpl.java +++ b/platform/lang-impl/src/com/intellij/conversion/impl/ConversionContextImpl.java @@ -46,6 +46,7 @@ public class ConversionContextImpl implements ConversionContext { private RunManagerSettingsImpl myRunManagerSettings; private File mySettingsBaseDir; private ComponentManagerSettings myCompilerManagerSettings; + private ComponentManagerSettings myProjectRootManagerSettings; public ConversionContextImpl(String projectPath) throws CannotConvertException { myProjectFile = new File(projectPath); @@ -68,6 +69,32 @@ public class ConversionContextImpl implements ConversionContext { myModuleFiles = findModuleFiles(JDomConvertingUtil.loadDocument(modulesFile).getRootElement()); } + public Set getAllProjectFiles() { + final HashSet files = new HashSet(Arrays.asList(myModuleFiles)); + if (myStorageScheme == StorageScheme.DEFAULT) { + files.add(myProjectFile); + files.add(myWorkspaceFile); + } + else { + addFilesRecursively(mySettingsBaseDir, files); + } + return files; + } + + private static void addFilesRecursively(File file, Set files) { + if (file.isDirectory()) { + final File[] children = file.listFiles(); + if (children != null) { + for (File child : children) { + addFilesRecursively(child, files); + } + } + } + else if (StringUtil.endsWithIgnoreCase(file.getName(), ".xml") && !file.getName().startsWith(".")) { + files.add(file); + } + } + @NotNull public File getProjectBaseDir() { return myProjectBaseDir; @@ -97,21 +124,36 @@ public class ConversionContextImpl implements ConversionContext { @NotNull public String expandPath(@NotNull String path, @NotNull ModuleSettingsImpl moduleSettings) { + return createExpandMacroMap(moduleSettings).substitute(path, true, null); + } + + private ExpandMacroToPathMap createExpandMacroMap(@Nullable ModuleSettingsImpl moduleSettings) { final ExpandMacroToPathMap map = createExpandMacroMap(); - final String modulePath = FileUtil.toSystemIndependentName(moduleSettings.getModuleFile().getParentFile().getAbsolutePath()); - map.addMacroExpand(PathMacrosImpl.MODULE_DIR_MACRO_NAME, modulePath); - return map.substitute(path, true, null); + if (moduleSettings != null) { + final String modulePath = FileUtil.toSystemIndependentName(moduleSettings.getModuleFile().getParentFile().getAbsolutePath()); + map.addMacroExpand(PathMacrosImpl.MODULE_DIR_MACRO_NAME, modulePath); + } + return map; } @NotNull public String collapsePath(@NotNull String path) { - ReplacePathToMacroMap map = new ReplacePathToMacroMap(); - final String projectDir = FileUtil.toSystemIndependentName(myProjectBaseDir.getAbsolutePath()); - map.addMacroReplacement(projectDir, PathMacrosImpl.PROJECT_DIR_MACRO_NAME); - PathMacrosImpl.getInstanceEx().addMacroReplacements(map); + ReplacePathToMacroMap map = createCollapseMacroMap(PathMacrosImpl.PROJECT_DIR_MACRO_NAME, myProjectBaseDir); return map.substitute(path, SystemInfo.isFileSystemCaseSensitive, null); } + public String collapsePath(@NotNull String path, @NotNull ModuleSettingsImpl moduleSettings) { + final ReplacePathToMacroMap map = createCollapseMacroMap(PathMacrosImpl.MODULE_DIR_MACRO_NAME, moduleSettings.getModuleFile().getParentFile()); + return map.substitute(path, SystemInfo.isFileSystemCaseSensitive, null); + } + + private static ReplacePathToMacroMap createCollapseMacroMap(final String macroName, final File dir) { + ReplacePathToMacroMap map = new ReplacePathToMacroMap(); + map.addMacroReplacement(FileUtil.toSystemIndependentName(dir.getAbsolutePath()), macroName); + PathMacrosImpl.getInstanceEx().addMacroReplacements(map); + return map; + } + public Collection getLibraryClassRoots(@NotNull String name, @NotNull String level) { try { Element libraryElement = null; @@ -123,19 +165,7 @@ public class ConversionContextImpl implements ConversionContext { } if (libraryElement != null) { - //todo[nik] support jar directories - final Element classesChild = libraryElement.getChild("CLASSES"); - if (classesChild != null) { - final List roots = JDomConvertingUtil.getChildren(classesChild, "root"); - List files = new ArrayList(); - final ExpandMacroToPathMap pathMap = createExpandMacroMap(); - for (Element root : roots) { - final String url = root.getAttributeValue("url"); - final String path = VfsUtil.urlToPath(url); - files.add(new File(PathUtil.getLocalPath(pathMap.substitute(path, true, null)))); - } - return files; - } + return getClassRoots(libraryElement, null); } return Collections.emptyList(); @@ -145,26 +175,54 @@ public class ConversionContextImpl implements ConversionContext { } } - public ComponentManagerSettings getCompilerSettings() { - if (myCompilerManagerSettings == null) { - try { - File file; - if (myStorageScheme == StorageScheme.DEFAULT) { - file = myProjectFile; - } - else { - file = new File(mySettingsBaseDir, "compiler.xml"); - } - myCompilerManagerSettings = new ComponentManagerSettingsImpl(file, this); - } - catch (CannotConvertException e) { - LOG.info(e); - return null; + public List getClassRoots(Element libraryElement, ModuleSettingsImpl moduleSettings) { + List files = new ArrayList(); + //todo[nik] support jar directories + final Element classesChild = libraryElement.getChild("CLASSES"); + if (classesChild != null) { + final List roots = JDomConvertingUtil.getChildren(classesChild, "root"); + final ExpandMacroToPathMap pathMap = createExpandMacroMap(moduleSettings); + for (Element root : roots) { + final String url = root.getAttributeValue("url"); + final String path = VfsUtil.urlToPath(url); + files.add(new File(PathUtil.getLocalPath(pathMap.substitute(path, true, null)))); } } + return files; + } + + public ComponentManagerSettings getCompilerSettings() { + if (myCompilerManagerSettings == null) { + myCompilerManagerSettings = createProjectSettings("compiler.xml"); + } return myCompilerManagerSettings; } + public ComponentManagerSettings getProjectRootManagerSettings() { + if (myProjectRootManagerSettings == null) { + myProjectRootManagerSettings = createProjectSettings("misc.xml"); + } + return myProjectRootManagerSettings; + } + + @Nullable + private ComponentManagerSettingsImpl createProjectSettings(final String fileName) { + try { + File file; + if (myStorageScheme == StorageScheme.DEFAULT) { + file = myProjectFile; + } + else { + file = new File(mySettingsBaseDir, fileName); + } + return new ComponentManagerSettingsImpl(file, this); + } + catch (CannotConvertException e) { + LOG.info(e); + return null; + } + } + @Nullable private Element findGlobalLibraryElement(String name) throws CannotConvertException { final File file = PathManager.getOptionsFile("applicationLibraries"); diff --git a/platform/lang-impl/src/com/intellij/conversion/impl/ConversionServiceImpl.java b/platform/lang-impl/src/com/intellij/conversion/impl/ConversionServiceImpl.java index aefbd35aff2a..420b54bc0b89 100644 --- a/platform/lang-impl/src/com/intellij/conversion/impl/ConversionServiceImpl.java +++ b/platform/lang-impl/src/com/intellij/conversion/impl/ConversionServiceImpl.java @@ -22,6 +22,7 @@ import com.intellij.util.graph.DFSTBuilder; import com.intellij.util.graph.GraphGenerator; import com.intellij.util.xmlb.XmlSerializer; import com.intellij.util.xmlb.annotations.AbstractCollection; +import com.intellij.util.xmlb.annotations.MapAnnotation; import com.intellij.util.xmlb.annotations.Tag; import org.jdom.Document; import org.jetbrains.annotations.NotNull; @@ -153,7 +154,43 @@ public class ConversionServiceImpl extends ConversionService { private List getSortedConverters(final ConversionContextImpl context) throws CannotConvertException { final CachedConversionResult conversionResult = loadCachedConversionResult(context.getProjectFile()); - return createConversionRunners(context, conversionResult.myAppliedConverters); + final Map oldMap = conversionResult.myProjectFilesTimestamps; + Map newMap = getProjectFilesMap(context); + boolean changed = false; + LOG.debug("Checking project files"); + for (Map.Entry entry : newMap.entrySet()) { + final String path = entry.getKey(); + final Long oldValue = oldMap.get(path); + if (oldValue == null) { + LOG.debug(" new file: " + path); + changed = true; + } + else if (!entry.getValue().equals(oldValue)) { + LOG.debug(" changed file: " + path); + changed = true; + } + } + + final Set performedConversionIds; + if (changed) { + performedConversionIds = Collections.emptySet(); + LOG.debug("Project files were modified."); + } + else { + performedConversionIds = conversionResult.myAppliedConverters; + LOG.debug("Project files are up to date. Applied converters: " + performedConversionIds); + } + return createConversionRunners(context, performedConversionIds); + } + + private static Map getProjectFilesMap(ConversionContextImpl context) { + final Map map = new HashMap(); + for (File file : context.getAllProjectFiles()) { + if (file.exists()) { + map.put(file.getAbsolutePath(), file.lastModified()); + } + } + return map; } private List createConversionRunners(ConversionContextImpl context, final Set performedConversionIds) { @@ -179,14 +216,21 @@ public class ConversionServiceImpl extends ConversionService { return runners; } + public void saveConversionResult(String projectPath) { + try { + saveConversionResult(new ConversionContextImpl(projectPath)); + } + catch (CannotConvertException e) { + LOG.info(e); + } + } + private void saveConversionResult(ConversionContextImpl context) { - final CachedConversionResult conversionResult = loadCachedConversionResult(context.getProjectFile()); + final CachedConversionResult conversionResult = new CachedConversionResult(); for (ConverterProvider provider : ConverterProvider.EP_NAME.getExtensions()) { conversionResult.myAppliedConverters.add(provider.getId()); } - for (File file : context.getNonExistingModuleFiles()) { - conversionResult.myNotConvertedModules.add(file.getAbsolutePath()); - } + conversionResult.myProjectFilesTimestamps = getProjectFilesMap(context); final File infoFile = getConversionInfoFile(context.getProjectFile()); infoFile.getParentFile().mkdirs(); try { @@ -280,13 +324,13 @@ public class ConversionServiceImpl extends ConversionService { @Tag("conversion") public static class CachedConversionResult { - @Tag("applied-converters") - @AbstractCollection(surroundWithTag = false, elementTag = "converter", elementValueAttribute = "id") + @Tag("applied-converters") @AbstractCollection(surroundWithTag = false, elementTag = "converter", elementValueAttribute = "id") public Set myAppliedConverters = new HashSet(); - @Tag("not-converted-modules") - @AbstractCollection(surroundWithTag = false, elementTag = "module", elementValueAttribute = "path") - public Set myNotConvertedModules = new HashSet(); + @Tag("project-files") + @MapAnnotation(surroundWithTag = false, surroundKeyWithTag = false, surroundValueWithTag = false, entryTagName = "file", + keyAttributeName = "path", valueAttributeName = "timestamp") + public Map myProjectFilesTimestamps = new HashMap(); } private class ConverterProvidersGraph implements GraphGenerator.SemiGraph { diff --git a/platform/lang-impl/src/com/intellij/conversion/impl/ModuleSettingsImpl.java b/platform/lang-impl/src/com/intellij/conversion/impl/ModuleSettingsImpl.java index b8cf8bad3dd1..2bb255a5c2b7 100644 --- a/platform/lang-impl/src/com/intellij/conversion/impl/ModuleSettingsImpl.java +++ b/platform/lang-impl/src/com/intellij/conversion/impl/ModuleSettingsImpl.java @@ -1,23 +1,28 @@ package com.intellij.conversion.impl; import com.intellij.conversion.CannotConvertException; +import com.intellij.conversion.ComponentManagerSettings; import com.intellij.conversion.ModuleSettings; import com.intellij.facet.FacetManagerImpl; import com.intellij.ide.highlighter.ModuleFileType; import com.intellij.ide.impl.convert.JDomConvertingUtil; import com.intellij.openapi.module.impl.ModuleImpl; +import com.intellij.openapi.roots.impl.*; +import com.intellij.openapi.roots.impl.ModuleLibraryOrderEntryImpl; +import com.intellij.openapi.roots.impl.libraries.LibraryImpl; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.util.io.FileUtil; -import com.intellij.openapi.roots.impl.ContentEntryImpl; -import com.intellij.openapi.roots.impl.SourceFolderImpl; import com.intellij.openapi.vfs.VfsUtil; import org.jdom.Element; +import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.File; +import java.io.IOException; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.List; /** @@ -25,6 +30,7 @@ import java.util.List; */ public class ModuleSettingsImpl extends ComponentManagerSettingsImpl implements ModuleSettings { private String myModuleName; + @NonNls private static final String MODULE_ROOT_MANAGER_COMPONENT = "NewModuleRootManager"; public ModuleSettingsImpl(File moduleFile, ConversionContextImpl context) throws CannotConvertException { super(moduleFile, context); @@ -69,17 +75,90 @@ public class ModuleSettingsImpl extends ComponentManagerSettingsImpl implements @NotNull public Collection getSourceRoots(boolean includeTests) { - final Element rootManager = getComponentElement("NewModuleRootManager"); final List result = new ArrayList(); - for (Element contentRoot : JDomConvertingUtil.getChildren(rootManager, ContentEntryImpl.ELEMENT_NAME)) { + for (Element contentRoot : getContentRootElements()) { for (Element sourceFolder : JDomConvertingUtil.getChildren(contentRoot, SourceFolderImpl.ELEMENT_NAME)) { boolean isTestFolder = Boolean.parseBoolean(sourceFolder.getAttributeValue(SourceFolderImpl.TEST_SOURCE_ATTR)); if (includeTests || !isTestFolder) { - final String path = VfsUtil.urlToPath(sourceFolder.getAttributeValue(SourceFolderImpl.URL_ATTR)); - result.add(new File(FileUtil.toSystemDependentName(expandPath(path)))); + result.add(getFile(sourceFolder.getAttributeValue(SourceFolderImpl.URL_ATTRIBUTE))); } } } return result; } + + private List getContentRootElements() { + return JDomConvertingUtil.getChildren(getComponentElement(MODULE_ROOT_MANAGER_COMPONENT), ContentEntryImpl.ELEMENT_NAME); + } + + @NotNull + public Collection getContentRoots() { + final List result = new ArrayList(); + for (Element contentRoot : getContentRootElements()) { + String path = VfsUtil.urlToPath(contentRoot.getAttributeValue(ContentEntryImpl.URL_ATTRIBUTE)); + result.add(new File(FileUtil.toSystemDependentName(expandPath(path)))); + } + return result; + } + + public void addExcludedFolder(@NotNull File directory) { + final ComponentManagerSettings rootManagerSettings = myContext.getProjectRootManagerSettings(); + if (rootManagerSettings != null) { + final Element projectRootManager = rootManagerSettings.getComponentElement("ProjectRootManager"); + if (projectRootManager != null) { + final Element outputElement = projectRootManager.getChild("output"); + if (outputElement != null) { + final String outputUrl = outputElement.getAttributeValue("url"); + if (outputUrl != null) { + final File outputFile = getFile(outputUrl); + try { + if (FileUtil.isAncestor(outputFile, directory, false)) { + return; + } + } + catch (IOException ignored) { + } + } + } + } + } + for (Element contentRoot : getContentRootElements()) { + final File root = getFile(contentRoot.getAttributeValue(ContentEntryImpl.URL_ATTRIBUTE)); + try { + if (FileUtil.isAncestor(root, directory, true)) { + addExcludedFolder(directory, contentRoot); + } + } + catch (IOException ignored) { + } + } + } + + public List getModuleLibraryRootUrls(String libraryName) { + final Element component = getComponentElement(MODULE_ROOT_MANAGER_COMPONENT); + for (Element element : JDomConvertingUtil.getChildren(component, OrderEntryFactory.ORDER_ENTRY_ELEMENT_NAME)) { + if (ModuleLibraryOrderEntryImpl.ENTRY_TYPE.equals(element.getAttributeValue(OrderEntryFactory.ORDER_ENTRY_TYPE_ATTR))) { + final Element library = element.getChild(LibraryImpl.ELEMENT); + if (library != null && libraryName.equals(library.getAttributeValue(LibraryImpl.LIBRARY_NAME_ATTR))) { + return myContext.getClassRoots(library, this); + } + } + } + return Collections.emptyList(); + } + + private void addExcludedFolder(File directory, Element contentRoot) throws IOException { + for (Element excludedFolder : JDomConvertingUtil.getChildren(contentRoot, ExcludeFolderImpl.ELEMENT_NAME)) { + final File excludedDir = getFile(excludedFolder.getAttributeValue(ExcludeFolderImpl.URL_ATTRIBUTE)); + if (FileUtil.isAncestor(excludedDir, directory, false)) { + return; + } + } + String path = myContext.collapsePath(FileUtil.toSystemIndependentName(directory.getAbsolutePath()), this); + contentRoot.addContent(new Element(ExcludeFolderImpl.ELEMENT_NAME).setAttribute(ExcludeFolderImpl.URL_ATTRIBUTE, VfsUtil.pathToUrl(path))); + } + + private File getFile(String url) { + return new File(FileUtil.toSystemDependentName(expandPath(VfsUtil.urlToPath(url)))); + } } diff --git a/platform/lang-impl/src/com/intellij/conversion/impl/ui/ConvertProjectDialog.form b/platform/lang-impl/src/com/intellij/conversion/impl/ui/ConvertProjectDialog.form index dffa96178678..24883a068fdd 100644 --- a/platform/lang-impl/src/com/intellij/conversion/impl/ui/ConvertProjectDialog.form +++ b/platform/lang-impl/src/com/intellij/conversion/impl/ui/ConvertProjectDialog.form @@ -3,7 +3,7 @@ - + @@ -16,7 +16,7 @@ - + diff --git a/platform/lang-impl/src/com/intellij/conversion/impl/ui/ConvertProjectDialog.java b/platform/lang-impl/src/com/intellij/conversion/impl/ui/ConvertProjectDialog.java index 1a940c5b683a..fc8bcabd4b8e 100644 --- a/platform/lang-impl/src/com/intellij/conversion/impl/ui/ConvertProjectDialog.java +++ b/platform/lang-impl/src/com/intellij/conversion/impl/ui/ConvertProjectDialog.java @@ -122,7 +122,7 @@ public class ConvertProjectDialog extends DialogWrapper { } } - private String getFilesString(List files) { + private static String getFilesString(List files) { StringBuilder buffer = new StringBuilder(); for (File file : files) { buffer.append(file.getAbsolutePath()).append("
"); diff --git a/platform/lang-impl/src/com/intellij/facet/impl/ProjectFacetManagerImpl.java b/platform/lang-impl/src/com/intellij/facet/impl/ProjectFacetManagerImpl.java index 976d8654f87d..6e0d0b57b6ee 100644 --- a/platform/lang-impl/src/com/intellij/facet/impl/ProjectFacetManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/facet/impl/ProjectFacetManagerImpl.java @@ -34,7 +34,6 @@ public class ProjectFacetManagerImpl extends ProjectFacetManagerEx implements Pe @NonNls public static final String COMPONENT_NAME = "ProjectFacetManager"; private static final Logger LOG = Logger.getInstance("#com.intellij.facet.impl.ProjectFacetManagerImpl"); private ProjectFacetManagerState myState = new ProjectFacetManagerState(); - private final List myRunnablesToRunOnProjectSettingsClosed = new ArrayList(); private Project myProject; public ProjectFacetManagerImpl(Project project) { @@ -94,17 +93,6 @@ public class ProjectFacetManagerImpl extends ProjectFacetManagerEx implements Pe } } - //todo[nik] remove - public void registerRunnableToRunOnProjectSettingsClosed(@NotNull Runnable runnable) { - myRunnablesToRunOnProjectSettingsClosed.add(runnable); - } - - public void fireRunnableOnProjectSettingsClosed() { - for (Runnable runnable : myRunnablesToRunOnProjectSettingsClosed) { - runnable.run(); - } - } - @Tag("default-facet-configuration") public static class DefaultFacetConfigurationState { private Element myDefaultConfiguration; diff --git a/platform/lang-impl/src/com/intellij/ide/impl/convert/JDomConvertingUtil.java b/platform/lang-impl/src/com/intellij/ide/impl/convert/JDomConvertingUtil.java index 5111a1ca8e46..1d8420986889 100644 --- a/platform/lang-impl/src/com/intellij/ide/impl/convert/JDomConvertingUtil.java +++ b/platform/lang-impl/src/com/intellij/ide/impl/convert/JDomConvertingUtil.java @@ -42,7 +42,7 @@ public class JDomConvertingUtil { throw new CannotConvertException(file.getAbsolutePath() + ": " + e.getMessage(), e); } catch (IOException e) { - throw new CannotConvertException(e.getMessage(), e); + throw new CannotConvertException(file.getAbsolutePath() + ": " + e.getMessage(), e); } } diff --git a/platform/lang-impl/src/com/intellij/ide/impl/convert/ProjectFileVersion.java b/platform/lang-impl/src/com/intellij/ide/impl/convert/ProjectFileVersion.java index fdbd4560d53b..988dfbcf520a 100644 --- a/platform/lang-impl/src/com/intellij/ide/impl/convert/ProjectFileVersion.java +++ b/platform/lang-impl/src/com/intellij/ide/impl/convert/ProjectFileVersion.java @@ -9,7 +9,6 @@ import com.intellij.openapi.project.Project; /** * @author nik */ -@Deprecated public abstract class ProjectFileVersion { public static ProjectFileVersion getInstance(Project project) { return project.getComponent(ProjectFileVersion.class); diff --git a/platform/lang-impl/src/com/intellij/ide/impl/convert/ProjectFileVersionImpl.java b/platform/lang-impl/src/com/intellij/ide/impl/convert/ProjectFileVersionImpl.java index 1fc73f30b715..f71d7339304d 100644 --- a/platform/lang-impl/src/com/intellij/ide/impl/convert/ProjectFileVersionImpl.java +++ b/platform/lang-impl/src/com/intellij/ide/impl/convert/ProjectFileVersionImpl.java @@ -4,19 +4,21 @@ package com.intellij.ide.impl.convert; -import com.intellij.openapi.components.PersistentStateComponent; -import com.intellij.openapi.components.ProjectComponent; -import com.intellij.openapi.components.State; -import com.intellij.openapi.components.Storage; +import com.intellij.conversion.ConversionService; +import com.intellij.conversion.impl.ConversionServiceImpl; +import com.intellij.openapi.components.*; +import com.intellij.openapi.components.impl.stores.IProjectStore; +import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.project.ex.ProjectEx; +import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; /** * @author nik - * - * DO NOT CONVERT THIS COMPONENT TO SERVICE. ITS CONFIGURATION IS ACCESSED VIA JDOM BEFORE PROJECT OPENING */ -//todo[nik] remove @State( name = ProjectFileVersionImpl.COMPONENT_NAME, storages = { @@ -27,7 +29,13 @@ import org.jetbrains.annotations.NotNull; } ) public class ProjectFileVersionImpl extends ProjectFileVersion implements ProjectComponent, PersistentStateComponent { + private static final Logger LOG = Logger.getInstance("#com.intellij.ide.impl.convert.ProjectFileVersionImpl"); @NonNls public static final String COMPONENT_NAME = "ProjectFileVersion"; + private Project myProject; + + public ProjectFileVersionImpl(Project project) { + myProject = project; + } public void projectOpened() { } @@ -45,6 +53,22 @@ public class ProjectFileVersionImpl extends ProjectFileVersion implements Projec } public void disposeComponent() { + if (myProject.isDefault()) return; + final IProjectStore stateStore = ((ProjectEx)myProject).getStateStore(); + final String filePath; + if (stateStore.getStorageScheme() == StorageScheme.DEFAULT) { + filePath = stateStore.getProjectFilePath(); + } + else { + final VirtualFile baseDir = stateStore.getProjectBaseDir(); + filePath = baseDir != null ? baseDir.getPath() : null; + } + if (filePath != null) { + ((ConversionServiceImpl)ConversionService.getInstance()).saveConversionResult(FileUtil.toSystemDependentName(filePath)); + } + else { + LOG.info("Cannot save conversion result: filePath == null"); + } } public ProjectFileVersionState getState() { diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/ContentEntryImpl.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/ContentEntryImpl.java index 17e986d0f8c4..5e4748e95293 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/ContentEntryImpl.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/ContentEntryImpl.java @@ -30,7 +30,7 @@ public class ContentEntryImpl extends RootModelComponentBase implements ContentE private final LinkedHashSet mySourceFolders = new LinkedHashSet(); private final TreeSet myExcludeFolders = new TreeSet(ContentFolderComparator.INSTANCE); private final TreeSet myExcludedOutputFolders = new TreeSet(ContentFolderComparator.INSTANCE); - @NonNls private static final String URL_ATTR = "url"; + @NonNls public static final String URL_ATTRIBUTE = "url"; ContentEntryImpl(VirtualFile file, RootModelImpl m) { this(file.getUrl(), m); @@ -49,7 +49,7 @@ public class ContentEntryImpl extends RootModelComponentBase implements ContentE private static String getUrlFrom(Element e) throws InvalidDataException { LOG.assertTrue(ELEMENT_NAME.equals(e.getName())); - String url = e.getAttributeValue(URL_ATTR); + String url = e.getAttributeValue(URL_ATTRIBUTE); if (url == null) throw new InvalidDataException(); return url; } @@ -292,7 +292,7 @@ public class ContentEntryImpl extends RootModelComponentBase implements ContentE public void writeExternal(Element element) throws WriteExternalException { assert !isDisposed(); LOG.assertTrue(ELEMENT_NAME.equals(element.getName())); - element.setAttribute(URL_ATTR, myRoot.getUrl()); + element.setAttribute(URL_ATTRIBUTE, myRoot.getUrl()); for (final SourceFolder sourceFolder : mySourceFolders) { if (sourceFolder instanceof SourceFolderImpl) { final Element subElement = new Element(SourceFolderImpl.ELEMENT_NAME); diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/ContentFolderBaseImpl.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/ContentFolderBaseImpl.java index a4de7756a555..2c44160c3d32 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/ContentFolderBaseImpl.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/ContentFolderBaseImpl.java @@ -18,7 +18,7 @@ public abstract class ContentFolderBaseImpl extends RootModelComponentBase imple private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.roots.impl.SimpleContentFolderBaseImpl"); private final VirtualFilePointer myFilePointer; protected final ContentEntryImpl myContentEntry; - @NonNls public static final String URL_ATTR = "url"; + @NonNls public static final String URL_ATTRIBUTE = "url"; ContentFolderBaseImpl(VirtualFile file, ContentEntryImpl contentEntry) { this(VirtualFilePointerManager.getInstance().create(file, contentEntry.getRootModel().getModule(), contentEntry.getRootModel().myVirtualFilePointerListener), contentEntry); @@ -37,7 +37,7 @@ public abstract class ContentFolderBaseImpl extends RootModelComponentBase imple } private static String getUrlFrom(Element element) throws InvalidDataException { - String url = element.getAttributeValue(URL_ATTR); + String url = element.getAttributeValue(URL_ATTRIBUTE); if (url == null) throw new InvalidDataException(); return url; } @@ -65,7 +65,7 @@ public abstract class ContentFolderBaseImpl extends RootModelComponentBase imple protected void writeFolder(Element element, String elementName) { LOG.assertTrue(element.getName().equals(elementName)); - element.setAttribute(URL_ATTR, myFilePointer.getUrl()); + element.setAttribute(URL_ATTRIBUTE, myFilePointer.getUrl()); } @NotNull diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/ExcludeFolderImpl.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/ExcludeFolderImpl.java index 5e14d0fda10f..7dfbaf9400dd 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/ExcludeFolderImpl.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/ExcludeFolderImpl.java @@ -16,7 +16,7 @@ import org.jetbrains.annotations.NotNull; public class ExcludeFolderImpl extends ContentFolderBaseImpl implements ClonableContentFolder, UserDefinedExcludeFolder { private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.roots.impl.SimpleExcludeFolderImpl"); - @NonNls static final String ELEMENT_NAME = "excludeFolder"; + @NonNls public static final String ELEMENT_NAME = "excludeFolder"; ExcludeFolderImpl(@NotNull VirtualFile file, @NotNull ContentEntryImpl contentEntry) { super(file, contentEntry); diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/ModuleLibraryOrderEntryImpl.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/ModuleLibraryOrderEntryImpl.java index da04e87b7715..13f0b6abd262 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/ModuleLibraryOrderEntryImpl.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/ModuleLibraryOrderEntryImpl.java @@ -18,10 +18,10 @@ import org.jetbrains.annotations.NotNull; * Library entry for module ("in-place") libraries * @author dsl */ -class ModuleLibraryOrderEntryImpl extends LibraryOrderEntryBaseImpl implements LibraryOrderEntry, ClonableOrderEntry, WritableOrderEntry { +public class ModuleLibraryOrderEntryImpl extends LibraryOrderEntryBaseImpl implements LibraryOrderEntry, ClonableOrderEntry, WritableOrderEntry { private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.roots.impl.LibraryOrderEntryImpl"); private final Library myLibrary; - @NonNls static final String ENTRY_TYPE = "module-library"; + @NonNls public static final String ENTRY_TYPE = "module-library"; private boolean myExported; @NonNls private static final String EXPORTED_ATTR = "exported"; diff --git a/platform/util/src/com/intellij/openapi/util/io/FileUtil.java b/platform/util/src/com/intellij/openapi/util/io/FileUtil.java index 06f35be68324..2e0c04e57912 100644 --- a/platform/util/src/com/intellij/openapi/util/io/FileUtil.java +++ b/platform/util/src/com/intellij/openapi/util/io/FileUtil.java @@ -58,16 +58,24 @@ public class FileUtil { if (base.equals(file)) return "."; - String basePath = base.getAbsolutePath(); - if (!basePath.endsWith(File.separator)) basePath += File.separatorChar; final String filePath = file.getAbsolutePath(); + String basePath = base.getAbsolutePath(); + return getRelativePath(basePath, filePath, File.separatorChar); + } + + public static String getRelativePath(String basePath, String filePath, final char separator) { + return getRelativePath(basePath, filePath, separator, SystemInfo.isFileSystemCaseSensitive); + } + + public static String getRelativePath(String basePath, String filePath, final char separator, final boolean caseSensitive) { + if (!StringUtil.endsWithChar(basePath, separator)) basePath += separator; int len = 0; int lastSeparatorIndex = 0; // need this for cases like this: base="/temp/abcde/base" and file="/temp/ab" - String basePathToCompare = SystemInfo.isFileSystemCaseSensitive ? basePath : basePath.toLowerCase(); - String filePathToCompare = SystemInfo.isFileSystemCaseSensitive ? filePath : filePath.toLowerCase(); + String basePathToCompare = caseSensitive ? basePath : basePath.toLowerCase(); + String filePathToCompare = caseSensitive ? filePath : filePath.toLowerCase(); while (len < filePath.length() && len < basePath.length() && filePathToCompare.charAt(len) == basePathToCompare.charAt(len)) { - if (basePath.charAt(len) == File.separatorChar) { + if (basePath.charAt(len) == separator) { lastSeparatorIndex = len; } len++; @@ -77,9 +85,9 @@ public class FileUtil { StringBuilder relativePath = new StringBuilder(); for (int i=len; i < basePath.length(); i++) { - if (basePath.charAt(i) == File.separatorChar) { + if (basePath.charAt(i) == separator) { relativePath.append(".."); - relativePath.append(File.separatorChar); + relativePath.append(separator); } } relativePath.append(filePath.substring(lastSeparatorIndex + 1)); diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/ArtifactExternalDependenciesImporter.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/ArtifactExternalDependenciesImporter.java index d0ad959b6dc5..82a88f0f0632 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/ArtifactExternalDependenciesImporter.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/ArtifactExternalDependenciesImporter.java @@ -1,13 +1,14 @@ package org.jetbrains.idea.maven.importing; -import com.intellij.packaging.impl.artifacts.ArtifactUtil; -import com.intellij.packaging.impl.artifacts.PackagingElementProcessor; import com.intellij.openapi.roots.ui.configuration.artifacts.ManifestFilesInfo; +import com.intellij.openapi.util.Pair; import com.intellij.packaging.artifacts.Artifact; import com.intellij.packaging.artifacts.ModifiableArtifactModel; import com.intellij.packaging.elements.CompositePackagingElement; import com.intellij.packaging.elements.PackagingElement; import com.intellij.packaging.elements.PackagingElementResolvingContext; +import com.intellij.packaging.impl.artifacts.ArtifactUtil; +import com.intellij.packaging.impl.artifacts.PackagingElementProcessor; import com.intellij.packaging.impl.elements.ArtifactElementType; import com.intellij.packaging.impl.elements.ArtifactPackagingElement; import com.intellij.packaging.ui.ManifestFileConfiguration; @@ -41,6 +42,7 @@ public class ArtifactExternalDependenciesImporter { public void applyChanges(ModifiableArtifactModel artifactModel, final PackagingElementResolvingContext context) { myManifestFiles.saveManifestFiles(); + final List, List>>> elementsToInclude = new ArrayList, List>>>(); for (Artifact artifact : artifactModel.getArtifacts()) { ArtifactUtil.processPackagingElements(artifact, ArtifactElementType.ARTIFACT_ELEMENT_TYPE, new PackagingElementProcessor() { @Override @@ -51,12 +53,16 @@ public class ArtifactExternalDependenciesImporter { final CompositePackagingElement parent = parents.get(0); final List> elements = myExternalDependencies.get(included); if (elements != null) { - parent.addOrFindChildren(elements); + elementsToInclude.add(Pair.create(parent, elements)); } } return true; } }, context, false); } + + for (Pair, List>> pair : elementsToInclude) { + pair.getFirst().addOrFindChildren(pair.getSecond()); + } } } diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenTestCase.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenTestCase.java index 68633572b0e2..fd7e17de0c86 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenTestCase.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenTestCase.java @@ -65,6 +65,7 @@ public abstract class MavenTestCase extends UsefulTestCase { ApplicationManager.getApplication().runWriteAction(new Runnable() { public void run() { + try { setUpInWriteAction(); } diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml index 60fa3a4b8e46..197b520772e4 100644 --- a/resources/src/META-INF/IdeaPlugin.xml +++ b/resources/src/META-INF/IdeaPlugin.xml @@ -1062,7 +1062,6 @@ - diff --git a/resources/src/componentSets/Core.xml b/resources/src/componentSets/Core.xml index 5a728faaabc6..eb8205a63d9e 100644 --- a/resources/src/componentSets/Core.xml +++ b/resources/src/componentSets/Core.xml @@ -45,10 +45,6 @@ com.intellij.pom.java.impl.PomJavaAspectImpl
- - com.intellij.jar.BuildJarProjectSettings - - com.intellij.openapi.roots.impl.PushedFilePropertiesUpdater @@ -56,9 +52,4 @@ - - - com.intellij.jar.BuildJarSettings - - diff --git a/resources/src/idea/IdeaActions.xml b/resources/src/idea/IdeaActions.xml index 999cd89addb6..6fc92e087289 100644 --- a/resources/src/idea/IdeaActions.xml +++ b/resources/src/idea/IdeaActions.xml @@ -192,7 +192,6 @@ -