mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote branch 'origin/master'
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
<applicationService serviceInterface="org.jetbrains.plugins.gradle.diff.GradleStructureChangesCalculator"
|
||||
serviceImplementation="org.jetbrains.plugins.gradle.diff.GradleProjectStructureChangesCalculator"/>
|
||||
<applicationService serviceImplementation="org.jetbrains.plugins.gradle.diff.GradleModuleStructureChangesCalculator"/>
|
||||
<applicationService serviceImplementation="org.jetbrains.plugins.gradle.diff.GradleContentRootStructureChangesCalculator"/>
|
||||
<applicationService serviceImplementation="org.jetbrains.plugins.gradle.diff.GradleModuleDependencyStructureChangesCalculator"/>
|
||||
<applicationService serviceImplementation="org.jetbrains.plugins.gradle.diff.GradleLibraryStructureChangesCalculator"/>
|
||||
<applicationService serviceImplementation="org.jetbrains.plugins.gradle.diff.GradleLibraryDependencyStructureChangesCalculator"/>
|
||||
|
||||
+3
-3
@@ -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
|
||||
)
|
||||
};
|
||||
|
||||
|
||||
+3
-3
@@ -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);
|
||||
|
||||
@@ -42,7 +42,7 @@ public class GradleTextAttributes {
|
||||
* Example: particular module is renamed at the intellij, i.e. <code>'module.name'</code> 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)
|
||||
);
|
||||
|
||||
+35
@@ -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<GradleContentRoot, ModuleAwareContentRoot>
|
||||
{
|
||||
@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);
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
+13
-3
@@ -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<GradleModule, Module> {
|
||||
|
||||
@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<GradleContentRoot> gradleContentRoots = gradleEntity.getContentRoots();
|
||||
final Collection<ModuleAwareContentRoot> intellijContentRoots = context.getPlatformFacade().getContentRoots(intellijEntity);
|
||||
GradleDiffUtil.calculate(myContentRootCalculator, gradleContentRoots, intellijContentRoots, context);
|
||||
|
||||
// Dependencies.
|
||||
checkDependencies(gradleEntity, intellijEntity, context);
|
||||
}
|
||||
|
||||
|
||||
@@ -51,6 +51,10 @@ public class GradleModule extends AbstractNamedGradleEntity implements Named {
|
||||
myContentRoots.add(contentRoot);
|
||||
}
|
||||
|
||||
public void clearContentRoots() {
|
||||
myContentRoots.clear();
|
||||
}
|
||||
|
||||
public boolean isInheritProjectCompileOutputPath() {
|
||||
return myInheritProjectCompileOutputPath;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+32
@@ -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());
|
||||
|
||||
+72
-8
@@ -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<ModuleAwareContentRoot> contentRoots = myPlatformFacade.getContentRoots(module);
|
||||
for (ContentEntry entry : contentRoots) {
|
||||
GradleContentRootId contentRootId = GradleEntityIdMapper.mapEntityToId(entry);
|
||||
GradleProjectStructureNode<GradleContentRootId> 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<GradleContentRootId> 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<GradleContentRootId> buildContentRootNode(@NotNull GradleContentRootId id, boolean singleRoot) {
|
||||
GradleProjectStructureNode<GradleContentRootId> result = buildNode(id, getContentRootNodeName(id, singleRoot));
|
||||
result.getDescriptor().setToolTip(id.getRootPath());
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private <T extends GradleEntityId> GradleProjectStructureNode<T> buildNode(@NotNull T id, @NotNull String name) {
|
||||
final GradleProjectStructureNode<T> result = new GradleProjectStructureNode<T>(GradleUtil.buildDescriptor(id, name), myNodeComparator);
|
||||
result.addListener(myNodeListener);
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private GradleProjectStructureNode<GradleSyntheticId> getDependenciesNode(@NotNull GradleModuleId id) {
|
||||
final GradleProjectStructureNode<GradleSyntheticId> 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<GradleModuleId> moduleNode = getModuleNode(id.getModuleId());
|
||||
for (GradleProjectStructureNode<GradleContentRootId> contentRoot : moduleNode.getChildren(GradleContentRootId.class)) {
|
||||
if (id.equals(contentRoot.getDescriptor().getElement())) {
|
||||
contentRoot.setAttributes(key);
|
||||
return;
|
||||
}
|
||||
}
|
||||
GradleProjectStructureNode<GradleContentRootId> 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<GradleModuleId> moduleNode = myModules.get(id.getModuleName());
|
||||
if (moduleNode == null) {
|
||||
return;
|
||||
}
|
||||
for (GradleProjectStructureNode<GradleContentRootId> 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 {
|
||||
|
||||
@@ -177,7 +177,7 @@ public class GradleProjectStructureNode<T extends GradleEntityId> 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:
|
||||
* <pre>
|
||||
* <ol>
|
||||
@@ -199,7 +199,7 @@ public class GradleProjectStructureNode<T extends GradleEntityId> 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<T extends GradleEntityId> 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);
|
||||
}
|
||||
}
|
||||
|
||||
+6
-2
@@ -22,7 +22,7 @@ import javax.swing.*;
|
||||
*/
|
||||
public class GradleProjectStructureNodeDescriptor<T extends GradleEntityId> extends PresentableNodeDescriptor<T> {
|
||||
|
||||
private TextAttributesKey myAttributes = GradleTextAttributes.GRADLE_NO_CHANGE;
|
||||
private TextAttributesKey myAttributes = GradleTextAttributes.NO_CHANGE;
|
||||
|
||||
private final T myId;
|
||||
|
||||
@@ -63,10 +63,14 @@ public class GradleProjectStructureNodeDescriptor<T extends GradleEntityId> 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);
|
||||
}
|
||||
}
|
||||
+21
-4
@@ -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"()
|
||||
} } }
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -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)
|
||||
|
||||
+1
-1
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -72,6 +72,6 @@ class GradleProjectBuilder extends AbstractProjectBuilder {
|
||||
|
||||
@Override
|
||||
protected reset() {
|
||||
modulesCache.values().each { it.clearDependencies() }
|
||||
modulesCache.values().each { it.clearDependencies(); it.clearContentRoots() }
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
+3
-3
@@ -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) {
|
||||
|
||||
@@ -179,7 +179,7 @@ public class ActivateTaskDialog extends DialogWrapper {
|
||||
}
|
||||
}
|
||||
}
|
||||
myMarkAsInProgressBox.setSelected(myMarkAsInProgress && isMarkAsInProgressApplicable());
|
||||
myMarkAsInProgressBox.setSelected(myMarkAsInProgress);
|
||||
|
||||
// refresh change lists
|
||||
ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);
|
||||
|
||||
Reference in New Issue
Block a user