IDEA-113538 Insert Managed Dependency: does not find artifact based on artifact id
authorSergey Evdokimov <sergey.evdokimov@jetbrains.com>
Fri, 13 Sep 2013 15:12:19 +0000 (19:12 +0400)
committerSergey Evdokimov <sergey.evdokimov@jetbrains.com>
Fri, 13 Sep 2013 15:12:42 +0000 (19:12 +0400)
platform/lang-impl/src/com/intellij/ide/util/MemberChooser.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/generate/GenerateDependencyUtil.java

index 7300a222a4c6389f6142752cf9dc5d1b2c8d5725..01b37eb8b2bf37aff10d9af3a444f78d8cfd5e76 100644 (file)
@@ -408,6 +408,22 @@ public class MemberChooser<T extends ClassMember> extends DialogWrapper implemen
     };
   }
 
+  @NotNull
+  protected String convertElementText(@NotNull String originalElementText) {
+    String res = originalElementText;
+
+    int i = res.indexOf(':');
+    if (i >= 0) {
+      res = res.substring(0, i);
+    }
+    i = res.indexOf('(');
+    if (i >= 0) {
+      res = res.substring(0, i);
+    }
+
+    return res;
+  }
+
   protected void installSpeedSearch() {
     final TreeSpeedSearch treeSpeedSearch = new TreeSpeedSearch(myTree, new Convertor<TreePath, String>() {
       @Override
@@ -417,14 +433,7 @@ public class MemberChooser<T extends ClassMember> extends DialogWrapper implemen
         if (lastPathComponent == null) return null;
         String text = lastPathComponent.getDelegate().getText();
         if (text != null) {
-          int i = text.indexOf(':');
-          if (i >= 0) {
-            text = text.substring(0, i);
-          }
-          i = text.indexOf('(');
-          if (i >= 0) {
-            text = text.substring(0, i);
-          }
+          text = convertElementText(text);
         }
         return text;
       }
index f497da2d9c39f0c5fc8dee72cf67b61c0e456d2e..70755d0096b691f4a80e6912f7eb7aa73c830313 100644 (file)
@@ -26,6 +26,7 @@ import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.psi.PsiFile;
 import com.intellij.util.Function;
 import com.intellij.util.containers.ContainerUtil;
+import icons.MavenIcons;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.idea.maven.dom.MavenDomBundle;
@@ -56,7 +57,13 @@ public class GenerateDependencyUtil {
     MemberChooser<MavenDomProjectModelMember> chooser =
       new MemberChooser<MavenDomProjectModelMember>(memberCandidates, true, true, project) {
         protected ShowContainersAction getShowContainersAction() {
-          return new ShowContainersAction(MavenDomBundle.message("chooser.show.project.files"), icons.MavenIcons.MavenProject);
+          return new ShowContainersAction(MavenDomBundle.message("chooser.show.project.files"), MavenIcons.MavenProject);
+        }
+
+        @NotNull
+        @Override
+        protected String convertElementText(@NotNull String originalElementText) {
+          return originalElementText;
         }
 
         protected String getAllContainersNodeName() {
@@ -134,7 +141,7 @@ public class GenerateDependencyUtil {
     private static class MavenDomProjectModelFileMemberChooserObjectBase extends PsiElementMemberChooserObject {
 
       public MavenDomProjectModelFileMemberChooserObjectBase(@NotNull final PsiFile psiFile, @Nullable String projectName) {
-        super(psiFile, StringUtil.isEmptyOrSpaces(projectName) ? psiFile.getName() : projectName, icons.MavenIcons.MavenProject);
+        super(psiFile, StringUtil.isEmptyOrSpaces(projectName) ? psiFile.getName() : projectName, MavenIcons.MavenProject);
       }
     }
   }