mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-76142: Gradle support - cannot update IDEA projects once one of build.gradle files changes
'Import from gradle' applies GradleProjectStructureNode now
This commit is contained in:
+10
-7
@@ -12,6 +12,7 @@ import org.jetbrains.plugins.gradle.model.*;
|
||||
import org.jetbrains.plugins.gradle.importing.wizard.AbstractImportFromGradleWizardStep;
|
||||
import org.jetbrains.plugins.gradle.ui.GradleProjectStructureNode;
|
||||
import org.jetbrains.plugins.gradle.util.GradleBundle;
|
||||
import org.jetbrains.plugins.gradle.util.GradleConstants;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.TreeSelectionEvent;
|
||||
@@ -173,7 +174,7 @@ public class GradleAdjustImportSettingsStep extends AbstractImportFromGradleWiza
|
||||
Map<GradleEntity, Pair<String, Collection<GradleProjectStructureNode>>> entity2nodes
|
||||
= new HashMap<GradleEntity, Pair<String, Collection<GradleProjectStructureNode>>>();
|
||||
int counter = 0;
|
||||
DefaultMutableTreeNode root = buildNode(project, entity2nodes, counter++);
|
||||
GradleProjectStructureNode<GradleProject> root = buildNode(project, entity2nodes, counter++);
|
||||
|
||||
List<GradleModule> modules = new ArrayList<GradleModule>(project.getModules());
|
||||
Collections.sort(modules, Named.COMPARATOR);
|
||||
@@ -184,15 +185,15 @@ public class GradleAdjustImportSettingsStep extends AbstractImportFromGradleWiza
|
||||
for (GradleModule module : modules) {
|
||||
GradleModule moduleCopy = module.clone(cloneContext);
|
||||
moduleMappings.put(module, moduleCopy);
|
||||
DefaultMutableTreeNode moduleNode = buildNode(module, entity2nodes, counter++);
|
||||
GradleProjectStructureNode<GradleModule> moduleNode = buildNode(module, entity2nodes, counter++);
|
||||
moduleNodes.add(moduleNode);
|
||||
for (GradleContentRoot contentRoot : moduleCopy.getContentRoots()) {
|
||||
moduleNode.add(buildNode(contentRoot, entity2nodes, counter++));
|
||||
}
|
||||
Collection<GradleDependency> dependencies = module.getDependencies();
|
||||
if (!dependencies.isEmpty()) {
|
||||
DefaultMutableTreeNode dependenciesNode
|
||||
= new DefaultMutableTreeNode(GradleBundle.message("gradle.project.structure.tree.node.dependencies"));
|
||||
GradleProjectStructureNode<String> dependenciesNode
|
||||
= new GradleProjectStructureNode<String>(GradleConstants.DEPENDENCIES_NODE_DESCRIPTOR, GradleEntityType.SYNTHETIC);
|
||||
final List<GradleModuleDependency> moduleDependencies = new ArrayList<GradleModuleDependency>();
|
||||
final List<GradleLibraryDependency> libraryDependencies = new ArrayList<GradleLibraryDependency>();
|
||||
GradleEntityVisitor visitor = new GradleEntityVisitorAdapter() {
|
||||
@@ -232,7 +233,8 @@ public class GradleAdjustImportSettingsStep extends AbstractImportFromGradleWiza
|
||||
}
|
||||
else {
|
||||
// Insert intermediate 'modules' and 'libraries' nodes if the project has both libraries and nodes.
|
||||
DefaultMutableTreeNode modulesNode = new DefaultMutableTreeNode(GradleBundle.message("gradle.import.structure.tree.node.modules"));
|
||||
GradleProjectStructureNode<String> modulesNode
|
||||
= new GradleProjectStructureNode<String>(GradleConstants.MODULES_NODE_DESCRIPTOR, GradleEntityType.SYNTHETIC);
|
||||
for (MutableTreeNode node : moduleNodes) {
|
||||
modulesNode.add(node);
|
||||
}
|
||||
@@ -240,7 +242,8 @@ public class GradleAdjustImportSettingsStep extends AbstractImportFromGradleWiza
|
||||
|
||||
List<GradleLibrary> sortedLibraries = new ArrayList<GradleLibrary>(libraries);
|
||||
Collections.sort(sortedLibraries, Named.COMPARATOR);
|
||||
DefaultMutableTreeNode librariesNode = new DefaultMutableTreeNode(GradleBundle.message("gradle.import.structure.tree.node.libraries"));
|
||||
GradleProjectStructureNode<String> librariesNode
|
||||
= new GradleProjectStructureNode<String>(GradleConstants.LIBRARIES_NODE_DESCRIPTOR, GradleEntityType.SYNTHETIC);
|
||||
for (GradleLibrary library : sortedLibraries) {
|
||||
librariesNode.add(buildNode(library, entity2nodes, counter++));
|
||||
}
|
||||
@@ -254,7 +257,7 @@ public class GradleAdjustImportSettingsStep extends AbstractImportFromGradleWiza
|
||||
builder.setModuleMappings(moduleMappings);
|
||||
}
|
||||
|
||||
private <T extends GradleEntity> DefaultMutableTreeNode buildNode(
|
||||
private <T extends GradleEntity> GradleProjectStructureNode<T> buildNode(
|
||||
@NotNull T entity, @NotNull Map<GradleEntity, Pair<String, Collection<GradleProjectStructureNode>>> processed, int counter)
|
||||
{
|
||||
// We build tree node, its settings control and map them altogether. The only trick here is that nodes can reuse the same
|
||||
|
||||
+1
-1
@@ -105,7 +105,7 @@ public class GradleProjectStructureChangesPanel extends GradleToolWindowPanel {
|
||||
}
|
||||
|
||||
private static void applyInitialAppearance(@NotNull Tree tree, @NotNull DefaultMutableTreeNode node) {
|
||||
if (node.getUserObject() == GradleProjectStructureTreeModel.DEPENDENCIES_NODE_DESCRIPTOR) {
|
||||
if (node.getUserObject() == GradleConstants.DEPENDENCIES_NODE_DESCRIPTOR) {
|
||||
tree.expandPath(new TreePath(node.getPath()));
|
||||
return;
|
||||
}
|
||||
|
||||
+3
-10
@@ -15,7 +15,7 @@ import org.jetbrains.plugins.gradle.model.GradleLibraryDependencyId;
|
||||
import org.jetbrains.plugins.gradle.ui.GradleIcons;
|
||||
import org.jetbrains.plugins.gradle.ui.GradleProjectStructureNode;
|
||||
import org.jetbrains.plugins.gradle.ui.GradleProjectStructureNodeDescriptor;
|
||||
import org.jetbrains.plugins.gradle.util.GradleBundle;
|
||||
import org.jetbrains.plugins.gradle.util.GradleConstants;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.tree.DefaultTreeModel;
|
||||
@@ -34,14 +34,7 @@ import java.util.Map;
|
||||
* @since 1/30/12 4:20 PM
|
||||
*/
|
||||
public class GradleProjectStructureTreeModel extends DefaultTreeModel {
|
||||
|
||||
public static final GradleProjectStructureNodeDescriptor<String> DEPENDENCIES_NODE_DESCRIPTOR
|
||||
= new GradleProjectStructureNodeDescriptor<String>(
|
||||
GradleBundle.message("gradle.project.structure.tree.node.dependencies"),
|
||||
GradleBundle.message("gradle.project.structure.tree.node.dependencies"),
|
||||
null
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* ...
|
||||
@@ -144,7 +137,7 @@ public class GradleProjectStructureTreeModel extends DefaultTreeModel {
|
||||
myModules.put(moduleName, moduleNode);
|
||||
}
|
||||
|
||||
GradleProjectStructureNode<String> result = new GradleProjectStructureNode<String>(DEPENDENCIES_NODE_DESCRIPTOR, GradleEntityType.SYNTHETIC);
|
||||
GradleProjectStructureNode<String> result = new GradleProjectStructureNode<String>(GradleConstants.DEPENDENCIES_NODE_DESCRIPTOR, GradleEntityType.SYNTHETIC);
|
||||
moduleNode.add(result);
|
||||
myModuleDependencies.put(moduleName, result);
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.jetbrains.plugins.gradle.util;
|
||||
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.plugins.gradle.ui.GradleProjectStructureNodeDescriptor;
|
||||
|
||||
/**
|
||||
* Holds object representation of icons used at the <code>Gradle</code> plugin.
|
||||
@@ -17,6 +18,28 @@ public class GradleConstants {
|
||||
@NonNls public static final String SYNC_TREE_PLACE = "GRADLE_SYNC_TREE_PLACE";
|
||||
|
||||
@NonNls public static final String ACTION_GROUP_SYNC_TREE = "Gradle.SyncTreeGroup";
|
||||
|
||||
|
||||
public static final GradleProjectStructureNodeDescriptor<String> DEPENDENCIES_NODE_DESCRIPTOR
|
||||
= new GradleProjectStructureNodeDescriptor<String>(
|
||||
GradleBundle.message("gradle.project.structure.tree.node.dependencies"),
|
||||
GradleBundle.message("gradle.project.structure.tree.node.dependencies"),
|
||||
null
|
||||
);
|
||||
|
||||
public static final GradleProjectStructureNodeDescriptor<String> MODULES_NODE_DESCRIPTOR
|
||||
= new GradleProjectStructureNodeDescriptor<String>(
|
||||
GradleBundle.message("gradle.import.structure.tree.node.modules"),
|
||||
GradleBundle.message("gradle.import.structure.tree.node.modules"),
|
||||
null
|
||||
);
|
||||
|
||||
public static final GradleProjectStructureNodeDescriptor<String> LIBRARIES_NODE_DESCRIPTOR
|
||||
= new GradleProjectStructureNodeDescriptor<String>(
|
||||
GradleBundle.message("gradle.import.structure.tree.node.libraries"),
|
||||
GradleBundle.message("gradle.import.structure.tree.node.libraries"),
|
||||
null
|
||||
);
|
||||
|
||||
private GradleConstants() {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user