diff --git a/plugins/gradle/src/META-INF/plugin.xml b/plugins/gradle/src/META-INF/plugin.xml index 57605dbe1969..679db0b544aa 100644 --- a/plugins/gradle/src/META-INF/plugin.xml +++ b/plugins/gradle/src/META-INF/plugin.xml @@ -38,6 +38,7 @@ + diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleColorAndFontDescriptorsProvider.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleColorAndFontDescriptorsProvider.java index 58af4603635b..458659bac40b 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleColorAndFontDescriptorsProvider.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleColorAndFontDescriptorsProvider.java @@ -20,11 +20,11 @@ public class GradleColorAndFontDescriptorsProvider implements ColorAndFontDescri private static final AttributesDescriptor[] DESCRIPTORS = { new AttributesDescriptor( GradleBundle.message("gradle.sync.change.type.conflict"), - GradleTextAttributes.GRADLE_CHANGE_CONFLICT + GradleTextAttributes.CHANGE_CONFLICT ), new AttributesDescriptor( GradleBundle.message("gradle.sync.change.type.confirmed"), - GradleTextAttributes.GRADLE_CONFIRMED_CONFLICT + GradleTextAttributes.CONFIRMED_CONFLICT ), new AttributesDescriptor( GradleBundle.message("gradle.sync.change.type.gradle"), @@ -36,7 +36,7 @@ public class GradleColorAndFontDescriptorsProvider implements ColorAndFontDescri ), new AttributesDescriptor( GradleBundle.message("gradle.sync.change.type.unchanged"), - GradleTextAttributes.GRADLE_NO_CHANGE + GradleTextAttributes.NO_CHANGE ) }; diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleColorAndFontPreviewPanel.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleColorAndFontPreviewPanel.java index aae66ecd6b45..13f477a17b60 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleColorAndFontPreviewPanel.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleColorAndFontPreviewPanel.java @@ -65,11 +65,11 @@ public class GradleColorAndFontPreviewPanel implements PreviewPanel { DefaultMutableTreeNode root = createNode( projectName, IconLoader.getIcon(ApplicationInfoEx.getInstanceEx().getSmallIconUrl()), - GradleTextAttributes.GRADLE_CHANGE_CONFLICT + GradleTextAttributes.CHANGE_CONFLICT ); String moduleName = GradleBundle.message("gradle.settings.color.text.sample.node.confirmed.name"); - DefaultMutableTreeNode module = createNode(moduleName, GradleIcons.MODULE_ICON, GradleTextAttributes.GRADLE_CONFIRMED_CONFLICT); + DefaultMutableTreeNode module = createNode(moduleName, GradleIcons.MODULE_ICON, GradleTextAttributes.CONFIRMED_CONFLICT); String gradleLibraryName = GradleBundle.message("gradle.settings.color.text.sample.node.gradle.name"); DefaultMutableTreeNode gradleLibrary = createNode( @@ -83,7 +83,7 @@ public class GradleColorAndFontPreviewPanel implements PreviewPanel { ); String syncLibraryName = GradleBundle.message("gradle.settings.color.text.sample.node.sync.name"); - DefaultMutableTreeNode syncLibrary = createNode(syncLibraryName, GradleIcons.LIB_ICON, GradleTextAttributes.GRADLE_NO_CHANGE); + DefaultMutableTreeNode syncLibrary = createNode(syncLibraryName, GradleIcons.LIB_ICON, GradleTextAttributes.NO_CHANGE); module.add(gradleLibrary); module.add(intellijLibrary); diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleTextAttributes.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleTextAttributes.java index 68ce35f81e6b..6df36d98e960 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleTextAttributes.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleTextAttributes.java @@ -42,7 +42,7 @@ public class GradleTextAttributes { * Example: particular module is renamed at the intellij, i.e. 'module.name' property has different (conflicting) * values at the gradle and the intellij. */ - public static final TextAttributesKey GRADLE_CHANGE_CONFLICT = TextAttributesKey.createTextAttributesKey( + public static final TextAttributesKey CHANGE_CONFLICT = TextAttributesKey.createTextAttributesKey( "GRADLE_CHANGE_CONFLICT", new TextAttributes(new Color(238, 0, 0), null, null, null, Font.PLAIN) ); @@ -50,7 +50,7 @@ public class GradleTextAttributes { /** * References color to use for indication that particular setting has the same values at the gradle and intellij. */ - public static final TextAttributesKey GRADLE_NO_CHANGE = TextAttributesKey.createTextAttributesKey( + public static final TextAttributesKey NO_CHANGE = TextAttributesKey.createTextAttributesKey( "GRADLE_NO_CHANGE", new TextAttributes(Color.BLACK, null, null, null, Font.PLAIN) ); @@ -62,7 +62,7 @@ public class GradleTextAttributes { * Example: particular dummy module specific to the local environment is added at the intellij side but we don't want to propagate * that to the gradle side and don't want to see it during the project structures comparison. */ - public static final TextAttributesKey GRADLE_CONFIRMED_CONFLICT = TextAttributesKey.createTextAttributesKey( + public static final TextAttributesKey CONFIRMED_CONFLICT = TextAttributesKey.createTextAttributesKey( "GRADLE_CONFIRMED_CONFLICT", new TextAttributes(Gray._140, null, null, null, Font.PLAIN) ); diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/diff/GradleContentRootStructureChangesCalculator.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/diff/GradleContentRootStructureChangesCalculator.java new file mode 100644 index 000000000000..e5470185934b --- /dev/null +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/diff/GradleContentRootStructureChangesCalculator.java @@ -0,0 +1,35 @@ +package org.jetbrains.plugins.gradle.diff; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.plugins.gradle.model.gradle.GradleContentRoot; +import org.jetbrains.plugins.gradle.model.id.GradleEntityIdMapper; +import org.jetbrains.plugins.gradle.model.intellij.ModuleAwareContentRoot; + +/** + * @author Denis Zhdanov + * @since 2/27/12 7:00 PM + */ +public class GradleContentRootStructureChangesCalculator + implements GradleStructureChangesCalculator +{ + @Override + public void calculate(@NotNull GradleContentRoot gradleEntity, + @NotNull ModuleAwareContentRoot intellijEntity, + @NotNull GradleChangesCalculationContext context) + { + // TODO den implement content root conflict changes here. + } + + @NotNull + @Override + public Object getIntellijKey(@NotNull ModuleAwareContentRoot entity) { + return GradleEntityIdMapper.mapEntityToId(entity); + } + + @NotNull + @Override + public Object getGradleKey(@NotNull GradleContentRoot entity, @NotNull GradleChangesCalculationContext context) { + // TODO den consider the known changes + return GradleEntityIdMapper.mapEntityToId(entity); + } +} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/diff/GradleDiffUtil.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/diff/GradleDiffUtil.java index a70baef647d3..de8e4ccdb7dd 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/diff/GradleDiffUtil.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/diff/GradleDiffUtil.java @@ -52,12 +52,12 @@ public class GradleDiffUtil { @Override public void visit(@NotNull GradleContentRoot contentRoot) { - // TODO den implement + context.register(new GradleContentRootPresenceChange(contentRoot, null)); } @Override public void visit(@NotNull GradleLibrary library) { - // TODO den implement + // Don't show library nodes. } @Override @@ -101,7 +101,7 @@ public class GradleDiffUtil { @Override public void visit(@NotNull ModuleAwareContentRoot contentRoot) { - // TODO den implement + context.register(new GradleContentRootPresenceChange(null, contentRoot)); } @Override diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/diff/GradleModuleStructureChangesCalculator.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/diff/GradleModuleStructureChangesCalculator.java index 1fe1c70a5f79..6caf0d094628 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/diff/GradleModuleStructureChangesCalculator.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/diff/GradleModuleStructureChangesCalculator.java @@ -22,8 +22,10 @@ import com.intellij.openapi.roots.OrderEntry; import com.intellij.openapi.roots.RootPolicy; import org.jetbrains.annotations.NotNull; import org.jetbrains.plugins.gradle.model.gradle.*; +import org.jetbrains.plugins.gradle.model.intellij.ModuleAwareContentRoot; import java.util.ArrayList; +import java.util.Collection; import java.util.List; /** @@ -37,13 +39,16 @@ import java.util.List; public class GradleModuleStructureChangesCalculator implements GradleStructureChangesCalculator { @NotNull private final GradleLibraryDependencyStructureChangesCalculator myLibraryDependencyCalculator; - @NotNull private final GradleModuleDependencyStructureChangesCalculator myModuleDependencyCalculator; + @NotNull private final GradleModuleDependencyStructureChangesCalculator myModuleDependencyCalculator; + @NotNull private final GradleContentRootStructureChangesCalculator myContentRootCalculator; public GradleModuleStructureChangesCalculator(@NotNull GradleLibraryDependencyStructureChangesCalculator libraryDependencyCalculator, - @NotNull GradleModuleDependencyStructureChangesCalculator moduleDependencyCalculator) + @NotNull GradleModuleDependencyStructureChangesCalculator moduleDependencyCalculator, + @NotNull GradleContentRootStructureChangesCalculator calculator) { myLibraryDependencyCalculator = libraryDependencyCalculator; myModuleDependencyCalculator = moduleDependencyCalculator; + myContentRootCalculator = calculator; } @Override @@ -52,7 +57,12 @@ public class GradleModuleStructureChangesCalculator implements GradleStructureCh @NotNull GradleChangesCalculationContext context) { //TODO den process module-local settings - //TODO den process content roots + // Content roots. + final Collection gradleContentRoots = gradleEntity.getContentRoots(); + final Collection intellijContentRoots = context.getPlatformFacade().getContentRoots(intellijEntity); + GradleDiffUtil.calculate(myContentRootCalculator, gradleContentRoots, intellijContentRoots, context); + + // Dependencies. checkDependencies(gradleEntity, intellijEntity, context); } diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/model/gradle/GradleModule.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/model/gradle/GradleModule.java index 9a0622dd7083..eaf1552ade0e 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/model/gradle/GradleModule.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/model/gradle/GradleModule.java @@ -51,6 +51,10 @@ public class GradleModule extends AbstractNamedGradleEntity implements Named { myContentRoots.add(contentRoot); } + public void clearContentRoots() { + myContentRoots.clear(); + } + public boolean isInheritProjectCompileOutputPath() { return myInheritProjectCompileOutputPath; } diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/model/id/GradleContentRootId.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/model/id/GradleContentRootId.java index 918c8167ad03..acc3d19b937c 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/model/id/GradleContentRootId.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/model/id/GradleContentRootId.java @@ -3,8 +3,6 @@ package org.jetbrains.plugins.gradle.model.id; import org.jetbrains.annotations.NotNull; import org.jetbrains.plugins.gradle.model.GradleEntityOwner; import org.jetbrains.plugins.gradle.model.GradleEntityType; -import org.jetbrains.plugins.gradle.model.gradle.GradleContentRoot; -import org.jetbrains.plugins.gradle.model.gradle.GradleModule; import org.jetbrains.plugins.gradle.util.GradleProjectStructureContext; /** @@ -22,26 +20,26 @@ public class GradleContentRootId extends GradleAbstractEntityId { myRootPath = rootPath; } + @NotNull + public String getModuleName() { + return myModuleName; + } + @NotNull public String getRootPath() { return myRootPath; } + @NotNull + public GradleModuleId getModuleId() { + return new GradleModuleId(getOwner(), myModuleName); + } + @Override public Object mapToEntity(@NotNull GradleProjectStructureContext context) { switch (getOwner()) { - case GRADLE: - final GradleModule module = context.getProjectStructureHelper().findGradleModule(myModuleName); - if (module == null) { - return null; - } - for (GradleContentRoot root : module.getContentRoots()) { - if (myRootPath.equals(root.getRootPath())) { - return root; - } - } - return null; - case INTELLIJ: return null; + case GRADLE: return context.getProjectStructureHelper().findGradleContentRoot(this); + case INTELLIJ: return context.getProjectStructureHelper().findIntellijContentRoot(this); } return null; } diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/model/id/GradleSyntheticId.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/model/id/GradleSyntheticId.java index 2fb7aecd68ee..130fd6d997e3 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/model/id/GradleSyntheticId.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/model/id/GradleSyntheticId.java @@ -21,7 +21,7 @@ public class GradleSyntheticId extends GradleAbstractEntityId { @NotNull private final String myText; public GradleSyntheticId(@NotNull String text) { - super(GradleEntityType.SYNTHETIC, GradleEntityOwner.GRADLE/* no matter what owner is used */); + super(GradleEntityType.SYNTHETIC, GradleEntityOwner.INTELLIJ/* no matter what owner is used */); myText = text; } diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/sync/GradleProjectStructureHelper.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/sync/GradleProjectStructureHelper.java index 63f41e11b0b2..306bfeae9a6f 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/sync/GradleProjectStructureHelper.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/sync/GradleProjectStructureHelper.java @@ -10,12 +10,15 @@ import com.intellij.openapi.roots.RootPolicy; import com.intellij.openapi.roots.libraries.Library; import com.intellij.openapi.roots.libraries.LibraryTable; import com.intellij.openapi.util.Ref; +import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.gradle.diff.PlatformFacade; import org.jetbrains.plugins.gradle.model.gradle.*; +import org.jetbrains.plugins.gradle.model.id.GradleContentRootId; import org.jetbrains.plugins.gradle.model.id.GradleLibraryDependencyId; import org.jetbrains.plugins.gradle.model.id.GradleModuleDependencyId; +import org.jetbrains.plugins.gradle.model.intellij.ModuleAwareContentRoot; /** * Thread-safe. @@ -102,6 +105,35 @@ public class GradleProjectStructureHelper extends AbstractProjectComponent { return null; } + @Nullable + public GradleContentRoot findGradleContentRoot(@NotNull GradleContentRootId id) { + final GradleModule module = findGradleModule(id.getModuleName()); + if (module == null) { + return null; + } + for (GradleContentRoot root : module.getContentRoots()) { + if (id.getRootPath().equals(root.getRootPath())) { + return root; + } + } + return null; + } + + @Nullable + public ModuleAwareContentRoot findIntellijContentRoot(@NotNull GradleContentRootId id) { + final Module module = findIntellijModule(id.getModuleName()); + if (module == null) { + return null; + } + for (ModuleAwareContentRoot contentRoot : myFacade.getContentRoots(module)) { + final VirtualFile file = contentRoot.getFile(); + if (file != null && id.getRootPath().equals(file.getPath())) { + return contentRoot; + } + } + return null; + } + @Nullable public Library findIntellijLibrary(@NotNull final GradleLibrary library) { return findIntellijLibrary(library.getName()); diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/sync/GradleProjectStructureTreeModel.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/sync/GradleProjectStructureTreeModel.java index b1a00af0122c..3f74a6e2adb7 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/sync/GradleProjectStructureTreeModel.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/sync/GradleProjectStructureTreeModel.java @@ -8,6 +8,8 @@ import com.intellij.util.containers.hash.HashMap; import org.jetbrains.annotations.NotNull; import org.jetbrains.plugins.gradle.config.GradleTextAttributes; import org.jetbrains.plugins.gradle.diff.*; +import org.jetbrains.plugins.gradle.model.GradleEntityOwner; +import org.jetbrains.plugins.gradle.model.gradle.GradleModule; import org.jetbrains.plugins.gradle.model.id.*; import org.jetbrains.plugins.gradle.model.intellij.ModuleAwareContentRoot; import org.jetbrains.plugins.gradle.ui.GradleProjectStructureNodeComparator; @@ -104,9 +106,7 @@ public class GradleProjectStructureTreeModel extends DefaultTreeModel { final Collection contentRoots = myPlatformFacade.getContentRoots(module); for (ContentEntry entry : contentRoots) { GradleContentRootId contentRootId = GradleEntityIdMapper.mapEntityToId(entry); - GradleProjectStructureNode contentRootNode - = buildNode(contentRootId, getNodeName(contentRootId, contentRoots.size() <= 1)); - moduleNode.add(contentRootNode); + moduleNode.add(buildContentRootNode(contentRootId, contentRoots.size() <= 1)); } // Dependencies @@ -126,7 +126,7 @@ public class GradleProjectStructureTreeModel extends DefaultTreeModel { } @NotNull - private static String getNodeName(@NotNull GradleContentRootId id, boolean singleRoot) { + private static String getContentRootNodeName(@NotNull GradleContentRootId id, boolean singleRoot) { final String name = GradleBundle.message("gradle.import.structure.tree.node.content.root"); if (singleRoot) { return name; @@ -144,12 +144,35 @@ public class GradleProjectStructureTreeModel extends DefaultTreeModel { return myProject; } + @NotNull + private GradleProjectStructureNode buildContentRootNode(@NotNull GradleContentRootId id) { + final boolean singleRoot; + if (id.getOwner() == GradleEntityOwner.GRADLE) { + final GradleModule module = myProjectStructureHelper.findGradleModule(id.getModuleName()); + singleRoot = module == null || module.getContentRoots().size() <= 1; + } + else { + final Module module = myProjectStructureHelper.findIntellijModule(id.getModuleName()); + singleRoot = module == null || myPlatformFacade.getContentRoots(module).size() <= 1; + } + return buildContentRootNode(id, singleRoot); + } + + @NotNull + private GradleProjectStructureNode buildContentRootNode(@NotNull GradleContentRootId id, boolean singleRoot) { + GradleProjectStructureNode result = buildNode(id, getContentRootNodeName(id, singleRoot)); + result.getDescriptor().setToolTip(id.getRootPath()); + return result; + } + + @NotNull private GradleProjectStructureNode buildNode(@NotNull T id, @NotNull String name) { final GradleProjectStructureNode result = new GradleProjectStructureNode(GradleUtil.buildDescriptor(id, name), myNodeComparator); result.addListener(myNodeListener); return result; } + @NotNull private GradleProjectStructureNode getDependenciesNode(@NotNull GradleModuleId id) { final GradleProjectStructureNode cached = myModuleDependencies.get(id.getModuleName()); if (cached != null) { @@ -282,7 +305,23 @@ public class GradleProjectStructureTreeModel extends DefaultTreeModel { } private void processNewContentRootPresenceChange(@NotNull GradleContentRootPresenceChange change) { - // TODO den implement + GradleContentRootId id = change.getGradleEntity(); + TextAttributesKey key = GradleTextAttributes.GRADLE_LOCAL_CHANGE; + if (id == null) { + id = change.getIntellijEntity(); + key = GradleTextAttributes.INTELLIJ_LOCAL_CHANGE; + } + assert id != null; + final GradleProjectStructureNode moduleNode = getModuleNode(id.getModuleId()); + for (GradleProjectStructureNode contentRoot : moduleNode.getChildren(GradleContentRootId.class)) { + if (id.equals(contentRoot.getDescriptor().getElement())) { + contentRoot.setAttributes(key); + return; + } + } + GradleProjectStructureNode contentRootNode = buildContentRootNode(id); + moduleNode.add(contentRootNode); + contentRootNode.setAttributes(key); } private void processObsoleteProjectRenameChange(@NotNull GradleProjectRenameChange change) { @@ -355,7 +394,7 @@ public class GradleProjectStructureTreeModel extends DefaultTreeModel { holder.remove(node); } else { - descriptor.setAttributes(GradleTextAttributes.GRADLE_NO_CHANGE); + descriptor.setAttributes(GradleTextAttributes.NO_CHANGE); holder.correctChildPositionIfNecessary(node); } return; @@ -389,12 +428,37 @@ public class GradleProjectStructureTreeModel extends DefaultTreeModel { moduleNode.removeFromParent(); } else { - moduleNode.setAttributes(GradleTextAttributes.GRADLE_NO_CHANGE); + moduleNode.setAttributes(GradleTextAttributes.NO_CHANGE); } } private void processObsoleteContentRootPresenceChange(@NotNull GradleContentRootPresenceChange change) { - // TODO den implement + GradleContentRootId id = change.getGradleEntity(); + final boolean removeNode; + if (id == null) { + id = change.getIntellijEntity(); + assert id != null; + removeNode = myProjectStructureHelper.findIntellijContentRoot(id) == null; + } + else { + removeNode = myProjectStructureHelper.findGradleContentRoot(id) == null; + } + final GradleProjectStructureNode moduleNode = myModules.get(id.getModuleName()); + if (moduleNode == null) { + return; + } + for (GradleProjectStructureNode contentRootNode : moduleNode.getChildren(GradleContentRootId.class)) { + if (!id.equals(contentRootNode.getDescriptor().getElement())) { + continue; + } + if (removeNode) { + contentRootNode.removeFromParent(); + } + else { + contentRootNode.setAttributes(GradleTextAttributes.NO_CHANGE); + } + return; + } } private class NodeListener implements GradleProjectStructureNode.Listener { diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/ui/GradleProjectStructureNode.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/ui/GradleProjectStructureNode.java index 4c409cd79035..f7bc0a8190e0 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/ui/GradleProjectStructureNode.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/ui/GradleProjectStructureNode.java @@ -177,7 +177,7 @@ public class GradleProjectStructureNode extends Defaul /** * Registers given change within the given node assuming that it is - * {@link GradleTextAttributes#GRADLE_CHANGE_CONFLICT 'conflict change'}. We need to track number of such changes per-node because + * {@link GradleTextAttributes#CHANGE_CONFLICT 'conflict change'}. We need to track number of such changes per-node because * of the following possible situation: *
    * 
    @@ -199,7 +199,7 @@ public class GradleProjectStructureNode extends Defaul final TextAttributesKey key = myDescriptor.getAttributes(); boolean localNode = key == GradleTextAttributes.GRADLE_LOCAL_CHANGE || key == GradleTextAttributes.INTELLIJ_LOCAL_CHANGE; if (!localNode) { - myDescriptor.setAttributes(GradleTextAttributes.GRADLE_CHANGE_CONFLICT); + myDescriptor.setAttributes(GradleTextAttributes.CHANGE_CONFLICT); onNodeChanged(this); } } @@ -212,7 +212,7 @@ public class GradleProjectStructureNode extends Defaul public void removeConflictChange(@NotNull GradleProjectStructureChange change) { myConflictChanges.remove(change); if (myConflictChanges.isEmpty()) { - myDescriptor.setAttributes(GradleTextAttributes.GRADLE_NO_CHANGE); + myDescriptor.setAttributes(GradleTextAttributes.NO_CHANGE); onNodeChanged(this); } } diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/ui/GradleProjectStructureNodeDescriptor.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/ui/GradleProjectStructureNodeDescriptor.java index b983ce7b658c..cf16ddfb7da6 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/ui/GradleProjectStructureNodeDescriptor.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/ui/GradleProjectStructureNodeDescriptor.java @@ -22,7 +22,7 @@ import javax.swing.*; */ public class GradleProjectStructureNodeDescriptor extends PresentableNodeDescriptor { - private TextAttributesKey myAttributes = GradleTextAttributes.GRADLE_NO_CHANGE; + private TextAttributesKey myAttributes = GradleTextAttributes.NO_CHANGE; private final T myId; @@ -63,10 +63,14 @@ public class GradleProjectStructureNodeDescriptor exte if (attributes == GradleTextAttributes.GRADLE_LOCAL_CHANGE) { owner = GradleEntityOwner.GRADLE; } - else if (attributes == GradleTextAttributes.GRADLE_NO_CHANGE || attributes == GradleTextAttributes.INTELLIJ_LOCAL_CHANGE) { + else if (attributes == GradleTextAttributes.NO_CHANGE || attributes == GradleTextAttributes.INTELLIJ_LOCAL_CHANGE) { owner = GradleEntityOwner.INTELLIJ; } myId.setOwner(owner); update(); } + + public void setToolTip(@NotNull String text) { + getTemplatePresentation().setTooltip(text); + } } \ No newline at end of file diff --git a/plugins/gradle/testSources/org/jetbrains/plugins/gradle/sync/GradleProjectStructureChangesModelTest.groovy b/plugins/gradle/testSources/org/jetbrains/plugins/gradle/sync/GradleProjectStructureChangesModelTest.groovy index 355143d908e3..ded1d7efe92f 100644 --- a/plugins/gradle/testSources/org/jetbrains/plugins/gradle/sync/GradleProjectStructureChangesModelTest.groovy +++ b/plugins/gradle/testSources/org/jetbrains/plugins/gradle/sync/GradleProjectStructureChangesModelTest.groovy @@ -552,8 +552,7 @@ public class GradleProjectStructureChangesModelTest extends AbstractGradleTest { } } } } } - // TODO den uncomment - //@Test + @Test public void "local content root importing"() { init( gradle: { @@ -571,8 +570,8 @@ public class GradleProjectStructureChangesModelTest extends AbstractGradleTest { ) checkChanges { presence { - contentRoot(gradle: gradle.contentRoots.values().find { it.rootPath == '1' }) - contentRoot(intellij: intellij.contentRoots.values().find { it.file.path == '3' }) + contentRoot(gradle: gradle.contentRoots.values().flatten().find { it.rootPath.endsWith('1') }) + contentRoot(intellij: intellij.contentRoots.values().flatten().find { it.file.path.endsWith('3') }) } } checkTree { project { @@ -581,5 +580,23 @@ public class GradleProjectStructureChangesModelTest extends AbstractGradleTest { "content-root:2"() "content-root:3"('intellij') } } } + + // Import local content roots. + Closure projectState = { + project { + module { + contentRoot('1') + contentRoot('2') + contentRoot('3') + } } } + setState(intellij: projectState, gradle: projectState) + checkChanges { } // No changes + checkTree { + project { + module { + "content-root:1"() + "content-root:2"() + "content-root:3"() + } } } } } diff --git a/plugins/gradle/testSources/org/jetbrains/plugins/gradle/testutil/AbstractGradleTest.groovy b/plugins/gradle/testSources/org/jetbrains/plugins/gradle/testutil/AbstractGradleTest.groovy index 7d2bba43708c..895bef7eed6d 100644 --- a/plugins/gradle/testSources/org/jetbrains/plugins/gradle/testutil/AbstractGradleTest.groovy +++ b/plugins/gradle/testSources/org/jetbrains/plugins/gradle/testutil/AbstractGradleTest.groovy @@ -44,6 +44,7 @@ public abstract class AbstractGradleTest { container.registerComponentImplementation(GradleProjectStructureHelper) container.registerComponentImplementation(GradleStructureChangesCalculator, GradleProjectStructureChangesCalculator) container.registerComponentImplementation(GradleModuleStructureChangesCalculator) + container.registerComponentImplementation(GradleContentRootStructureChangesCalculator) container.registerComponentImplementation(GradleModuleDependencyStructureChangesCalculator) container.registerComponentImplementation(GradleLibraryDependencyStructureChangesCalculator) container.registerComponentImplementation(GradleLibraryStructureChangesCalculator) diff --git a/plugins/gradle/testSources/org/jetbrains/plugins/gradle/testutil/AbstractProjectBuilder.groovy b/plugins/gradle/testSources/org/jetbrains/plugins/gradle/testutil/AbstractProjectBuilder.groovy index 74749744ae00..263985fd29ad 100644 --- a/plugins/gradle/testSources/org/jetbrains/plugins/gradle/testutil/AbstractProjectBuilder.groovy +++ b/plugins/gradle/testSources/org/jetbrains/plugins/gradle/testutil/AbstractProjectBuilder.groovy @@ -130,6 +130,6 @@ public abstract class AbstractProjectBuilder extends BuilderSupport { private def clear() { reset() - [modules, libraryDependencies, libraries, moduleDependencies]*.clear() + [modules, contentRoots, libraryDependencies, libraries, moduleDependencies]*.clear() } } diff --git a/plugins/gradle/testSources/org/jetbrains/plugins/gradle/testutil/GradleProjectBuilder.groovy b/plugins/gradle/testSources/org/jetbrains/plugins/gradle/testutil/GradleProjectBuilder.groovy index a57ec86d86c5..e3b0ccb32c57 100644 --- a/plugins/gradle/testSources/org/jetbrains/plugins/gradle/testutil/GradleProjectBuilder.groovy +++ b/plugins/gradle/testSources/org/jetbrains/plugins/gradle/testutil/GradleProjectBuilder.groovy @@ -72,6 +72,6 @@ class GradleProjectBuilder extends AbstractProjectBuilder { @Override protected reset() { - modulesCache.values().each { it.clearDependencies() } + modulesCache.values().each { it.clearDependencies(); it.clearContentRoots() } } } diff --git a/plugins/gradle/testSources/org/jetbrains/plugins/gradle/testutil/IntellijProjectBuilder.groovy b/plugins/gradle/testSources/org/jetbrains/plugins/gradle/testutil/IntellijProjectBuilder.groovy index 4a1d27d5dd3a..a58243b8d38e 100644 --- a/plugins/gradle/testSources/org/jetbrains/plugins/gradle/testutil/IntellijProjectBuilder.groovy +++ b/plugins/gradle/testSources/org/jetbrains/plugins/gradle/testutil/IntellijProjectBuilder.groovy @@ -60,7 +60,7 @@ class IntellijProjectBuilder extends AbstractProjectBuilder { @Override protected createContentRoot(module, rootPath, Map paths) { - new ModuleAwareContentRoot(module, [:] as ContentEntry) + new ModuleAwareContentRoot(module, [ getFile: {asVirtualFile(rootPath)} ] as ContentEntry) } @Override diff --git a/plugins/gradle/testSources/org/jetbrains/plugins/gradle/testutil/ProjectStructureChecker.groovy b/plugins/gradle/testSources/org/jetbrains/plugins/gradle/testutil/ProjectStructureChecker.groovy index 4e2caf61aed5..b83162e61cb0 100644 --- a/plugins/gradle/testSources/org/jetbrains/plugins/gradle/testutil/ProjectStructureChecker.groovy +++ b/plugins/gradle/testSources/org/jetbrains/plugins/gradle/testutil/ProjectStructureChecker.groovy @@ -9,7 +9,7 @@ import org.junit.Assert import static junit.framework.Assert.assertEquals import static junit.framework.Assert.fail import org.jetbrains.plugins.gradle.model.GradleEntityOwner -import org.jetbrains.plugins.gradle.model.id.GradleEntityId + import org.jetbrains.plugins.gradle.model.GradleEntityType /** @@ -26,7 +26,7 @@ class ProjectStructureChecker { static def COLORS = [ 'gradle' : GradleTextAttributes.GRADLE_LOCAL_CHANGE, 'intellij' : GradleTextAttributes.INTELLIJ_LOCAL_CHANGE, - 'conflict' : GradleTextAttributes.GRADLE_CHANGE_CONFLICT + 'conflict' : GradleTextAttributes.CHANGE_CONFLICT ] def check(Node expected, DefaultMutableTreeNode actual) { @@ -62,7 +62,7 @@ class ProjectStructureChecker { } def checkMarkup(Node node, GradleProjectStructureNodeDescriptor descriptor) { - def expectedMarkup = COLORS[node.children().find {it instanceof CharSequence}]?: GradleTextAttributes.GRADLE_NO_CHANGE + def expectedMarkup = COLORS[node.children().find {it instanceof CharSequence}]?: GradleTextAttributes.NO_CHANGE assertEquals("node '$descriptor'", expectedMarkup, descriptor.attributes) if (descriptor.element.type != GradleEntityType.SYNTHETIC) { diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/ActivateTaskDialog.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/ActivateTaskDialog.java index 066628101f1f..0f736e68e697 100644 --- a/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/ActivateTaskDialog.java +++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/ActivateTaskDialog.java @@ -179,7 +179,7 @@ public class ActivateTaskDialog extends DialogWrapper { } } } - myMarkAsInProgressBox.setSelected(myMarkAsInProgress && isMarkAsInProgressApplicable()); + myMarkAsInProgressBox.setSelected(myMarkAsInProgress); // refresh change lists ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);