Merge branch 'master' of git.labs.intellij.net:idea/community
authorDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Thu, 11 Aug 2011 12:18:25 +0000 (16:18 +0400)
committerDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Thu, 11 Aug 2011 12:18:25 +0000 (16:18 +0400)
66 files changed:
java/debugger/impl/src/com/intellij/debugger/ui/RunHotswapDialog.java
java/idea-ui/src/com/intellij/ide/impl/ProjectStructureSelectInTarget.java [moved from java/idea-ui/src/com/intellij/ide/impl/ProjectSettingsSelectInTarget.java with 66% similarity]
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/IdeaProjectSettingsService.java
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ModulesConfigurator.java
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectStructureConfigurable.java
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/ArtifactEditorContextImpl.java
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/dependencyAnalysis/AnalyzeDependenciesComponent.java
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/AddExistingCustomLibraryAction.java
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/CreateCustomLibraryAction.java
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/CustomLibraryActionBase.java
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ModuleConfigurable.java
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ModuleStructureConfigurable.java
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/daemon/UsageInModuleClasspath.java
platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationManager.java
platform/lang-impl/src/com/intellij/framework/detection/impl/FrameworkDetectionProcessor.java
platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/NamedLibraryElementNode.java
platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/PsiDirectoryNode.java
platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/PsiFileNode.java
platform/lang-impl/src/com/intellij/openapi/roots/libraries/LibraryNavigatable.java
platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/ProjectSettingsService.java
platform/lang-impl/src/com/intellij/psi/stubs/StubTree.java
platform/lang-impl/src/com/intellij/psi/stubs/StubUpdatingIndex.java
platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndex.java
platform/lang-impl/src/com/intellij/util/indexing/FileContent.java
platform/lang-impl/src/com/intellij/util/indexing/FileContentImpl.java [new file with mode: 0644]
platform/lang-impl/src/com/intellij/util/indexing/SubstitutedFileType.java
platform/platform-impl/src/com/intellij/diagnostic/IdeErrorsDialog.java
platform/platform-impl/src/com/intellij/diagnostic/errordialog/DetailsTabForm.java
platform/platform-resources-en/src/messages/ActionsBundle.properties
platform/platform-resources-en/src/tips/CtrlShiftI.html
platform/platform-resources-en/src/tips/FileStructurePopup.html
platform/platform-resources-en/src/tips/ImagesLookup.html
platform/platform-resources-en/src/tips/QuickJavaDoc.html
platform/platform-resources-en/src/tips/QuickJavaDocInLookups.html
platform/platform-resources/src/idea/LangActions.xml
platform/platform-resources/src/idea/PlatformActions.xml
platform/vcs-impl/src/com/intellij/openapi/vcs/update/UpdateOrStatusOptionsDialog.java
plugins/git4idea/src/git4idea/status/GitUntrackedFilesHolder.java
plugins/gradle/src/META-INF/plugin.xml
plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/GradleContentRoot.java [new file with mode: 0644]
plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/GradleDependency.java [new file with mode: 0644]
plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/GradleDependencyVisitor.java [new file with mode: 0644]
plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/GradleLibraryDependency.java [new file with mode: 0644]
plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/GradleModule.java
plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/GradleModuleDependency.java [new file with mode: 0644]
plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/GradleModuleImpl.java [deleted file]
plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/GradleProject.java
plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/LibraryPathType.java [new file with mode: 0644]
plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/SourceType.java [new file with mode: 0644]
plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/impl/AbstractGradleDependency.java [new file with mode: 0644]
plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/impl/GradleContentRootImpl.java [new file with mode: 0644]
plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/impl/GradleLibraryDependencyImpl.java [new file with mode: 0644]
plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/impl/GradleModuleDependencyImpl.java [new file with mode: 0644]
plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/impl/GradleModuleImpl.java [new file with mode: 0644]
plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/impl/GradleProjectImpl.java [moved from plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/GradleProjectImpl.java with 57% similarity]
plugins/gradle/src/org/jetbrains/plugins/gradle/importing/wizard/GradleProjectImportBuilder.java
plugins/gradle/src/org/jetbrains/plugins/gradle/remote/GradleApiFacade.java [moved from plugins/gradle/src/org/jetbrains/plugins/gradle/remote/api/GradleApiFacade.java with 96% similarity]
plugins/gradle/src/org/jetbrains/plugins/gradle/remote/GradleApiFacadeManager.java
plugins/gradle/src/org/jetbrains/plugins/gradle/remote/GradleProjectResolver.java [moved from plugins/gradle/src/org/jetbrains/plugins/gradle/remote/api/GradleProjectResolver.java with 96% similarity]
plugins/gradle/src/org/jetbrains/plugins/gradle/remote/RemoteGradleProcessSettings.java [moved from plugins/gradle/src/org/jetbrains/plugins/gradle/remote/api/RemoteGradleProcessSettings.java with 94% similarity]
plugins/gradle/src/org/jetbrains/plugins/gradle/remote/RemoteGradleService.java [moved from plugins/gradle/src/org/jetbrains/plugins/gradle/remote/api/RemoteGradleService.java with 89% similarity]
plugins/gradle/src/org/jetbrains/plugins/gradle/remote/impl/GradleApiFacadeImpl.java
plugins/gradle/src/org/jetbrains/plugins/gradle/remote/impl/GradleProjectResolverImpl.java
plugins/properties/testSrc/com/intellij/lang/properties/xml/XmlPropertiesIndexTest.java
resources-en/src/messages/DebuggerBundle.properties
resources/src/idea/RichPlatformPlugin.xml

index 5e0cbeba3862d0132c710a3a0e397c6fb6a517c1..36a5351162e6fc9b39ba9057401541f173c7322f 100644 (file)
@@ -114,13 +114,8 @@ public class RunHotswapDialog extends OptionsDialog {
       label.setIconTextGap(7);
     }
     if (myDisplayHangWarning) {
-      final JLabel warningLabel = new JLabel(DebuggerBundle.message("hotswap.dialog.hang.warning"));
+      final JLabel warningLabel = new JLabel("WARNING! " + DebuggerBundle.message("hotswap.dialog.hang.warning"));
       warningLabel.setUI(new MultiLineLabelUI());
-      final Icon warningIcon = UIUtil.getWarningIcon();
-      if (warningIcon != null) {
-        warningLabel.setIcon(warningIcon);
-        warningLabel.setIconTextGap(7);
-      }
       panel.add(warningLabel, BorderLayout.SOUTH);
     }
     return panel;
similarity index 66%
rename from java/idea-ui/src/com/intellij/ide/impl/ProjectSettingsSelectInTarget.java
rename to java/idea-ui/src/com/intellij/ide/impl/ProjectStructureSelectInTarget.java
index a707b0fea08101d52d319f5c40c222a17ebe316c..f4dba9026f52498a0f392daddd67b552fbb16253 100644 (file)
@@ -25,9 +25,12 @@ import com.intellij.openapi.module.Module;
 import com.intellij.openapi.module.ModuleManager;
 import com.intellij.openapi.project.DumbAware;
 import com.intellij.openapi.project.Project;
-import com.intellij.openapi.projectRoots.Sdk;
-import com.intellij.openapi.roots.*;
+import com.intellij.openapi.roots.OrderEntry;
+import com.intellij.openapi.roots.ProjectFileIndex;
+import com.intellij.openapi.roots.ProjectRootManager;
+import com.intellij.openapi.roots.libraries.LibraryUtil;
 import com.intellij.openapi.roots.ui.configuration.ModulesConfigurator;
+import com.intellij.openapi.roots.ui.configuration.ProjectSettingsService;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.openapi.vfs.WrappingVirtualFile;
 import org.jetbrains.annotations.NotNull;
@@ -35,12 +38,11 @@ import org.jetbrains.annotations.Nullable;
 
 import java.util.Collection;
 import java.util.Iterator;
-import java.util.List;
 
 /**
  * @author nik
  */
-public class ProjectSettingsSelectInTarget implements SelectInTarget, DumbAware {
+public class ProjectStructureSelectInTarget implements SelectInTarget, DumbAware {
   public boolean canSelect(final SelectInContext context) {
     final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(context.getProject()).getFileIndex();
     final VirtualFile file = context.getVirtualFile();
@@ -54,7 +56,6 @@ public class ProjectSettingsSelectInTarget implements SelectInTarget, DumbAware
   public void selectIn(final SelectInContext context, final boolean requestFocus) {
     final Project project = context.getProject();
     final VirtualFile file = context.getVirtualFile();
-    final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
 
     final Module module;
     final Facet facet;
@@ -64,8 +65,9 @@ public class ProjectSettingsSelectInTarget implements SelectInTarget, DumbAware
       module = facet == null? null : facet.getModule();
     }
     else {
+      final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
       module = fileIndex.getModuleForFile(file);
-      facet = findFacet(project, file, fileIndex);
+      facet = fileIndex.isInSourceContent(file) ? null : findFacet(project, file);
     }
     if (module != null || facet != null) {
       ApplicationManager.getApplication().invokeLater(new Runnable() {
@@ -74,64 +76,30 @@ public class ProjectSettingsSelectInTarget implements SelectInTarget, DumbAware
             ModulesConfigurator.showFacetSettingsDialog(facet, null);
           }
           else {
-            ModulesConfigurator.showDialog(project, module.getName(), null, false);
+            ProjectSettingsService.getInstance(project).openModuleSettings(module);
           }
         }
       });
       return;
     }
 
-    final LibraryOrderEntry libraryOrderEntry = findLibrary(file, fileIndex);
-    if (libraryOrderEntry != null) {
+    final OrderEntry orderEntry = LibraryUtil.findLibraryEntry(file, project);
+    if (orderEntry != null) {
       ApplicationManager.getApplication().invokeLater(new Runnable() {
         public void run() {
-          ModulesConfigurator.showLibrarySettings(project, libraryOrderEntry);
-        }
-      });
-      return;
-    }
-
-    final Sdk jdk = findJdk(file, fileIndex);
-    if (jdk != null) {
-      ApplicationManager.getApplication().invokeLater(new Runnable() {
-        public void run() {
-          ModulesConfigurator.showSdkSettings(project, jdk);
+          ProjectSettingsService.getInstance(project).openLibraryOrSdkSettings(orderEntry);
         }
       });
     }
   }
 
   @Nullable
-  private static LibraryOrderEntry findLibrary(final VirtualFile file, final ProjectFileIndex fileIndex) {
-    List<OrderEntry> entries = fileIndex.getOrderEntriesForFile(file);
-    for (OrderEntry entry : entries) {
-      if (entry instanceof LibraryOrderEntry) {
-        return (LibraryOrderEntry)entry;
-      }
-    }
-    return null;
-  }
-
-  @Nullable
-  private static Sdk findJdk(final VirtualFile file, final ProjectFileIndex fileIndex) {
-    List<OrderEntry> entries = fileIndex.getOrderEntriesForFile(file);
-    for (OrderEntry entry : entries) {
-      if (entry instanceof JdkOrderEntry) {
-        return ((JdkOrderEntry)entry).getJdk();
-      }
-    }
-    return null;
-  }
-
-  @Nullable
-  private static Facet findFacet(final @NotNull Project project, final @NotNull VirtualFile file, final @NotNull ProjectFileIndex fileIndex) {
-    if (!fileIndex.isInSourceContent(file)) {
-      for (FacetTypeId id : FacetTypeRegistry.getInstance().getFacetTypeIds()) {
-        if (hasFacetWithRoots(project, id)) {
-          Facet facet = FacetFinder.getInstance(project).findFacet(file, id);
-          if (facet != null) {
-            return facet;
-          }
+  private static Facet findFacet(final @NotNull Project project, final @NotNull VirtualFile file) {
+    for (FacetTypeId id : FacetTypeRegistry.getInstance().getFacetTypeIds()) {
+      if (hasFacetWithRoots(project, id)) {
+        Facet facet = FacetFinder.getInstance(project).findFacet(file, id);
+        if (facet != null) {
+          return facet;
         }
       }
     }
index ed1cbe542a1b8ce1d9cf39b791c092f81b172684..cb44dfd80ecb51cf90616798cb7edccdeff81e01 100644 (file)
@@ -16,7 +16,6 @@
 package com.intellij.openapi.roots.ui.configuration;
 
 import com.intellij.ide.projectView.impl.ModuleGroup;
-import com.intellij.ide.projectView.impl.nodes.NamedLibraryElement;
 import com.intellij.ide.util.projectWizard.JdkChooserPanel;
 import com.intellij.openapi.module.Module;
 import com.intellij.openapi.options.ShowSettingsUtil;
@@ -85,21 +84,20 @@ public class IdeaProjectSettingsService extends ProjectSettingsService {
     ShowSettingsUtil.getInstance().editConfigurable(myProject, ProjectStructureConfigurable.getInstance(myProject), new Runnable() {
       @Override
       public void run() {
-        ModuleStructureConfigurable.getInstance(myProject).selectOrderEntry(module, orderEntry);
+        ProjectStructureConfigurable.getInstance(myProject).selectOrderEntry(module, orderEntry);
       }
     });
   }
 
   @Override
-  public boolean canOpenProjectLibrarySettings(NamedLibraryElement value) {
+  public boolean canOpenLibraryOrSdkSettings(OrderEntry orderEntry) {
     return true;
   }
 
-  public void openProjectLibrarySettings(final NamedLibraryElement element) {
+  public void openLibraryOrSdkSettings(@NotNull final OrderEntry orderEntry) {
     final ProjectStructureConfigurable config = ProjectStructureConfigurable.getInstance(myProject);
     ShowSettingsUtil.getInstance().editConfigurable(myProject, config, new Runnable() {
       public void run() {
-        final OrderEntry orderEntry = element.getOrderEntry();
         if (orderEntry instanceof JdkOrderEntry) {
           config.select(((JdkOrderEntry)orderEntry).getJdk(), true);
         } else {
index 1a52495c5c2a2be128c7a2a555b7b496fef4707f..c5a5be9693f36207c37658b368e9aa5ff403d6b9 100644 (file)
@@ -35,7 +35,6 @@ import com.intellij.openapi.project.Project;
 import com.intellij.openapi.project.ProjectBundle;
 import com.intellij.openapi.projectRoots.Sdk;
 import com.intellij.openapi.roots.ContentEntry;
-import com.intellij.openapi.roots.LibraryOrderEntry;
 import com.intellij.openapi.roots.ModifiableRootModel;
 import com.intellij.openapi.roots.ModuleRootModel;
 import com.intellij.openapi.roots.impl.ProjectRootManagerImpl;
@@ -519,24 +518,6 @@ public class ModulesConfigurator implements ModulesProvider, ModuleEditor.Change
     return myModified || myFacetsConfigurator.isModified();
   }
 
-  public static boolean showSdkSettings(@NotNull Project project, final Sdk sdk) {
-    final ProjectStructureConfigurable configurable = ProjectStructureConfigurable.getInstance(project);
-    return ShowSettingsUtil.getInstance().editConfigurable(project, configurable, new Runnable() {
-      public void run() {
-        configurable.select(sdk, true);
-      }
-    });
-  }
-
-  public static boolean showLibrarySettings(@NotNull Project project, @NotNull final LibraryOrderEntry library) {
-    final ProjectStructureConfigurable configurable = ProjectStructureConfigurable.getInstance(project);
-    return ShowSettingsUtil.getInstance().editConfigurable(project, configurable, new Runnable() {
-      public void run() {
-        configurable.select(library, true);
-      }
-    });
-  }
-
   public static boolean showArtifactSettings(@NotNull Project project, @Nullable final Artifact artifact) {
     final ProjectStructureConfigurable configurable = ProjectStructureConfigurable.getInstance(project);
     return ShowSettingsUtil.getInstance().editConfigurable(project, configurable, new Runnable() {
index c149f5e66a080fc9e49d26c2958bacde62f9bc38..1db3b05fecf35755f57c99ec1dcc81f009ee096e 100644 (file)
@@ -20,6 +20,7 @@ import com.intellij.ide.util.PropertiesComponent;
 import com.intellij.openapi.actionSystem.*;
 import com.intellij.openapi.components.ServiceManager;
 import com.intellij.openapi.module.Module;
+import com.intellij.openapi.module.ModuleConfigurationEditor;
 import com.intellij.openapi.module.ModuleManager;
 import com.intellij.openapi.options.BaseConfigurable;
 import com.intellij.openapi.options.Configurable;
@@ -30,6 +31,7 @@ import com.intellij.openapi.project.ProjectBundle;
 import com.intellij.openapi.project.ProjectManager;
 import com.intellij.openapi.projectRoots.Sdk;
 import com.intellij.openapi.roots.LibraryOrderEntry;
+import com.intellij.openapi.roots.OrderEntry;
 import com.intellij.openapi.roots.libraries.Library;
 import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar;
 import com.intellij.openapi.roots.ui.configuration.artifacts.ArtifactsStructureConfigurable;
@@ -420,15 +422,32 @@ public class ProjectStructureConfigurable extends BaseConfigurable implements Se
   public ActionCallback select(@NotNull LibraryOrderEntry libraryOrderEntry, final boolean requestFocus) {
     final Library lib = libraryOrderEntry.getLibrary();
     if (lib == null || lib.getTable() == null) {
-      Place place = createPlaceFor(myModulesConfig);
-      place.putPath(BaseStructureConfigurable.TREE_OBJECT, libraryOrderEntry.getOwnerModule());
-      return navigateTo(place, requestFocus);
+      return selectOrderEntry(libraryOrderEntry.getOwnerModule(), libraryOrderEntry);
     }
     Place place = createPlaceFor(getConfigurableFor(lib));
     place.putPath(BaseStructureConfigurable.TREE_NAME, libraryOrderEntry.getLibraryName());
     return navigateTo(place, requestFocus);
   }
 
+  public ActionCallback selectOrderEntry(@NotNull final Module module, @Nullable final OrderEntry orderEntry) {
+    return select(module.getName(), null, true).doWhenDone(new Runnable() {
+      public void run() {
+        final MasterDetailsComponent.MyNode node = ModuleStructureConfigurable.getInstance(myProject).findModuleNode(module);
+        if (node != null) {
+          ModuleConfigurable moduleConfigurable = (ModuleConfigurable)node.getConfigurable();
+          ModuleEditor moduleEditor = moduleConfigurable.getModuleEditor();
+          moduleEditor.setSelectedTabName(ClasspathEditor.NAME);
+          if (orderEntry != null) {
+            ModuleConfigurationEditor editor = moduleEditor.getEditor(ClasspathEditor.NAME);
+            if (editor instanceof ClasspathEditor) {
+              ((ClasspathEditor)editor).selectOrderEntry(orderEntry);
+            }
+          }
+        }
+      }
+    });
+  }
+
   public ActionCallback navigateTo(@Nullable final Place place, final boolean requestFocus) {
     final Configurable toSelect = (Configurable)place.getPath(CATEGORY);
 
index 25ed97cb012f08ee663a1a86b8dbc647cc4fa965..e55af48bc8bb0dbef20d48a4f4c3c4a3da18fe01 100644 (file)
@@ -30,7 +30,6 @@ import com.intellij.openapi.roots.ui.configuration.ChooseModulesDialog;
 import com.intellij.openapi.roots.ui.configuration.FacetsProvider;
 import com.intellij.openapi.roots.ui.configuration.ModulesProvider;
 import com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable;
-import com.intellij.openapi.roots.ui.configuration.projectRoot.ModuleStructureConfigurable;
 import com.intellij.packaging.artifacts.Artifact;
 import com.intellij.packaging.artifacts.ArtifactModel;
 import com.intellij.packaging.artifacts.ArtifactType;
@@ -124,7 +123,7 @@ public class ArtifactEditorContextImpl implements ArtifactEditorContext {
             final ModuleLibraryOrderEntryImpl libraryEntry = (ModuleLibraryOrderEntryImpl)entry;
             if (libraryName != null && libraryName.equals(libraryEntry.getLibraryName())
                || libraryName == null && library.equals(libraryEntry.getLibrary())) {
-              ModuleStructureConfigurable.getInstance(getProject()).selectOrderEntry(module, libraryEntry);
+              ProjectStructureConfigurable.getInstance(getProject()).selectOrderEntry(module, libraryEntry);
               return;
             }
           }
index fd4f1779f582dc9e0d139c9ad1a60fec51fc7796..bde56cba8bc7d8a7fd57bf3fe6022fc824f4d094 100644 (file)
@@ -26,7 +26,7 @@ import com.intellij.openapi.roots.ModuleRootEvent;
 import com.intellij.openapi.roots.ModuleRootListener;
 import com.intellij.openapi.roots.ModuleSourceOrderEntry;
 import com.intellij.openapi.roots.OrderEntry;
-import com.intellij.openapi.roots.ui.configuration.projectRoot.ModuleStructureConfigurable;
+import com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable;
 import com.intellij.openapi.roots.ui.util.CellAppearance;
 import com.intellij.openapi.roots.ui.util.OrderEntryCellAppearanceUtils;
 import com.intellij.openapi.ui.MasterDetailsComponent;
@@ -39,8 +39,8 @@ import com.intellij.ui.PopupHandler;
 import com.intellij.ui.SimpleColoredComponent;
 import com.intellij.ui.SimpleTextAttributes;
 import com.intellij.ui.components.JBScrollPane;
-import com.intellij.util.PathUtil;
 import com.intellij.ui.treeStructure.Tree;
+import com.intellij.util.PathUtil;
 import com.intellij.util.messages.MessageBusConnection;
 import com.intellij.util.ui.UIUtil;
 import com.intellij.util.ui.tree.TreeUtil;
@@ -269,13 +269,12 @@ public class AnalyzeDependenciesComponent extends MasterDetailsComponent {
       if (module == null) {
         return;
       }
-      ModuleStructureConfigurable c = ModuleStructureConfigurable.getInstance(module.getProject());
       final ModuleDependenciesAnalyzer.OrderPathElement element = e.getData(ORDER_PATH_ELEMENT_KEY);
       if (element != null && element instanceof ModuleDependenciesAnalyzer.OrderEntryPathElement) {
         final ModuleDependenciesAnalyzer.OrderEntryPathElement o = (ModuleDependenciesAnalyzer.OrderEntryPathElement)element;
         final OrderEntry entry = o.entry();
         final Module m = entry.getOwnerModule();
-        c.selectOrderEntry(m, entry);
+        ProjectStructureConfigurable.getInstance(module.getProject()).selectOrderEntry(m, entry);
       }
     }
   }
index 763d6df14404c3add65838630ca0b045e4f0d98d..c174ee0587f1ba538ebf6def5da6ed06cf6b67c9 100644 (file)
@@ -20,7 +20,7 @@ import com.intellij.openapi.module.Module;
 import com.intellij.openapi.roots.LibraryOrderEntry;
 import com.intellij.openapi.roots.ModifiableRootModel;
 import com.intellij.openapi.roots.libraries.Library;
-import com.intellij.openapi.roots.ui.configuration.projectRoot.ModuleStructureConfigurable;
+import com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable;
 import com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext;
 
 import javax.swing.*;
@@ -29,15 +29,15 @@ import javax.swing.*;
  * @author nik
  */
 public class AddExistingCustomLibraryAction extends CustomLibraryActionBase {
-  private Library myLibrary;
+  private final Library myLibrary;
 
   public AddExistingCustomLibraryAction(Library library,
                                         Icon icon,
                                         CustomLibraryCreator creator,
                                         StructureConfigurableContext context,
-                                        ModuleStructureConfigurable moduleStructureConfigurable,
+                                        ProjectStructureConfigurable projectStructureConfigurable,
                                         Module module) {
-    super(library.getName(), null, icon, context, moduleStructureConfigurable, creator, module);
+    super(library.getName(), null, icon, context, projectStructureConfigurable, creator, module);
     myLibrary = library;
   }
 
@@ -48,6 +48,6 @@ public class AddExistingCustomLibraryAction extends CustomLibraryActionBase {
       return;
     }
     final LibraryOrderEntry orderEntry = rootModel.addLibraryEntry(myLibrary);
-    myModuleStructureConfigurable.selectOrderEntry(myModule, orderEntry);
+    myProjectStructureConfigurable.selectOrderEntry(myModule, orderEntry);
   }
 }
index bb492146eab03138099033259774d13208f2d4e8..f1e61d3ed7d26a2fdacb702028dce0e7e62dd117 100644 (file)
@@ -29,12 +29,14 @@ import com.intellij.openapi.roots.libraries.Library;
 import com.intellij.openapi.roots.libraries.LibraryKind;
 import com.intellij.openapi.roots.libraries.LibraryTable;
 import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar;
+import com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable;
 import com.intellij.openapi.roots.ui.configuration.libraryEditor.CreateNewLibraryDialog;
 import com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor;
 import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer;
 import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainerFactory;
 import com.intellij.openapi.roots.ui.configuration.projectRoot.ModuleStructureConfigurable;
 import com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext;
+import com.intellij.ui.treeStructure.Tree;
 import org.jetbrains.annotations.NotNull;
 
 import javax.swing.*;
@@ -46,13 +48,14 @@ import java.util.*;
 public class CreateCustomLibraryAction extends CustomLibraryActionBase {
   private CreateCustomLibraryAction(final String name, CustomLibraryCreator creator,
                                    StructureConfigurableContext context,
-                                   ModuleStructureConfigurable moduleStructureConfigurable, Module module) {
-    super(name, null, creator.getIcon(), context, moduleStructureConfigurable, creator, module);
+                                   ProjectStructureConfigurable projectStructureConfigurable, Module module) {
+    super(name, null, creator.getIcon(), context, projectStructureConfigurable, creator, module);
   }
 
   @Override
   public void actionPerformed(AnActionEvent e) {
-    final NewLibraryConfiguration libraryConfiguration = myCreator.getDescription().createNewLibrary(myModuleStructureConfigurable.getTree(),
+    final Tree parentComponent = ModuleStructureConfigurable.getInstance(myContext.getProject()).getTree();
+    final NewLibraryConfiguration libraryConfiguration = myCreator.getDescription().createNewLibrary(parentComponent,
                                                                                                      null);
     if (libraryConfiguration == null) {
       return;
@@ -64,7 +67,7 @@ public class CreateCustomLibraryAction extends CustomLibraryActionBase {
     LibraryTablesRegistrar registrar = LibraryTablesRegistrar.getInstance();
     final Project project = myContext.getProject();
     final List<LibraryTable> tables = Arrays.asList(registrar.getLibraryTable(project), registrar.getLibraryTable());
-    final CreateNewLibraryDialog dialog = new CreateNewLibraryDialog(myModuleStructureConfigurable.getTree(), myContext, libraryEditor, tables, 0);
+    final CreateNewLibraryDialog dialog = new CreateNewLibraryDialog(parentComponent, myContext, libraryEditor, tables, 0);
     dialog.show();
     if (dialog.isOK()) {
       final Library library = dialog.createLibrary();
@@ -73,7 +76,7 @@ public class CreateCustomLibraryAction extends CustomLibraryActionBase {
         return;
       }
       final LibraryOrderEntry orderEntry = rootModel.addLibraryEntry(library);
-      myModuleStructureConfigurable.selectOrderEntry(myModule, orderEntry);
+      myProjectStructureConfigurable.selectOrderEntry(myModule, orderEntry);
     }
   }
 
@@ -81,6 +84,7 @@ public class CreateCustomLibraryAction extends CustomLibraryActionBase {
     final Module module = moduleStructureConfigurable.getSelectedModule();
     if (module == null) return Collections.emptyList();
 
+    final ProjectStructureConfigurable projectStructureConfigurable = ProjectStructureConfigurable.getInstance(module.getProject());
     final List<AnAction> actions = new ArrayList<AnAction>();
     final LibrariesContainer container = LibrariesContainerFactory.createContainer(context);
     for (CustomLibraryCreator creator : CustomLibraryCreator.EP_NAME.getExtensions()) {
@@ -98,15 +102,15 @@ public class CreateCustomLibraryAction extends CustomLibraryActionBase {
       final Predicate<Library> notAddedLibrariesCondition = LibraryEditingUtil.getNotAddedLibrariesCondition(context.getModulesConfigurator().getRootModel(module));
       final Collection<Library> librariesToAdd = Collections2.filter(libraries, Predicates.and(suitablePredicate, notAddedLibrariesCondition));
       if (librariesToAdd.isEmpty()) {
-        actions.add(new CreateCustomLibraryAction(creator.getDisplayName(), creator, context, moduleStructureConfigurable, module));
+        actions.add(new CreateCustomLibraryAction(creator.getDisplayName(), creator, context, projectStructureConfigurable, module));
       }
       else {
         final DefaultActionGroup group = new DefaultActionGroup(creator.getDisplayName(), true);
         group.getTemplatePresentation().setIcon(creator.getIcon());
-        group.add(new CreateCustomLibraryAction("New...", creator, context, moduleStructureConfigurable, module));
+        group.add(new CreateCustomLibraryAction("New...", creator, context, projectStructureConfigurable, module));
         for (Library library : librariesToAdd) {
           Icon icon = LibraryPresentationManager.getInstance().getNamedLibraryIcon(library, context);
-          group.add(new AddExistingCustomLibraryAction(library, icon, creator, context, moduleStructureConfigurable, module));
+          group.add(new AddExistingCustomLibraryAction(library, icon, creator, context, projectStructureConfigurable, module));
         }
         actions.add(group);
       }
index 32f4b3f17b73239e4acaf139e5ee768aab832af5..16058bb70f68290e45ae8973af200d760af064bf 100644 (file)
@@ -21,9 +21,9 @@ import com.intellij.openapi.roots.LibraryOrderEntry;
 import com.intellij.openapi.roots.ModifiableRootModel;
 import com.intellij.openapi.roots.OrderEntry;
 import com.intellij.openapi.roots.libraries.Library;
+import com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable;
 import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer;
 import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainerFactory;
-import com.intellij.openapi.roots.ui.configuration.projectRoot.ModuleStructureConfigurable;
 import com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext;
 import com.intellij.openapi.ui.Messages;
 import org.jetbrains.annotations.NotNull;
@@ -38,14 +38,14 @@ import java.util.List;
 public abstract class CustomLibraryActionBase extends DumbAwareAction {
   protected final CustomLibraryCreator myCreator;
   protected final StructureConfigurableContext myContext;
-  protected final ModuleStructureConfigurable myModuleStructureConfigurable;
-  protected Module myModule;
+  protected final ProjectStructureConfigurable myProjectStructureConfigurable;
+  protected final Module myModule;
 
   protected CustomLibraryActionBase(String text, String description, Icon icon, StructureConfigurableContext context,
-                                    ModuleStructureConfigurable moduleStructureConfigurable, CustomLibraryCreator creator, Module module) {
+                                    ProjectStructureConfigurable projectStructureConfigurable, CustomLibraryCreator creator, Module module) {
     super(text, description, icon);
     myContext = context;
-    myModuleStructureConfigurable = moduleStructureConfigurable;
+    myProjectStructureConfigurable = projectStructureConfigurable;
     myCreator = creator;
     myModule = module;
   }
index aa645ed865fb50baa711a53a0c5aba0ef837730f..3584e55b996aa8f021691e02115fe80db3bef203 100644 (file)
@@ -130,7 +130,7 @@ public class ModuleConfigurable extends ProjectStructureElementConfigurable<Modu
     //do nothing
   }
 
-  ModuleEditor getModuleEditor() {
+  public ModuleEditor getModuleEditor() {
     return myConfigurator.getModuleEditor(myModule);
   }
 
index 2b03bc9e73774791a966ba60cfbec211553aa191..17a90b1d4328ae92774f7018947adf3a48247f0b 100644 (file)
@@ -30,7 +30,10 @@ import com.intellij.ide.util.projectWizard.ProjectWizardUtil;
 import com.intellij.openapi.actionSystem.*;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.components.ServiceManager;
-import com.intellij.openapi.module.*;
+import com.intellij.openapi.module.ModifiableModuleModel;
+import com.intellij.openapi.module.Module;
+import com.intellij.openapi.module.ModuleManager;
+import com.intellij.openapi.module.ModuleType;
 import com.intellij.openapi.options.ConfigurationException;
 import com.intellij.openapi.project.DumbAware;
 import com.intellij.openapi.project.Project;
@@ -40,17 +43,14 @@ import com.intellij.openapi.roots.impl.ClonableOrderEntry;
 import com.intellij.openapi.roots.impl.ProjectRootManagerImpl;
 import com.intellij.openapi.roots.impl.RootModelImpl;
 import com.intellij.openapi.roots.libraries.Library;
-import com.intellij.openapi.roots.ui.configuration.ClasspathEditor;
 import com.intellij.openapi.roots.ui.configuration.ModuleEditor;
 import com.intellij.openapi.roots.ui.configuration.ModulesConfigurator;
-import com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable;
 import com.intellij.openapi.roots.ui.configuration.libraries.CreateCustomLibraryAction;
 import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.LibraryProjectStructureElement;
 import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ModuleProjectStructureElement;
 import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureDaemonAnalyzer;
 import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElement;
 import com.intellij.openapi.ui.DialogWrapper;
-import com.intellij.openapi.ui.MasterDetailsComponent;
 import com.intellij.openapi.ui.Messages;
 import com.intellij.openapi.ui.NamedConfigurable;
 import com.intellij.openapi.util.Comparing;
@@ -392,25 +392,6 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple
     return myProject;
   }
 
-  public void selectOrderEntry(@NotNull final Module module, @Nullable final OrderEntry orderEntry) {
-    ProjectStructureConfigurable.getInstance(myProject).select(module.getName(), null, true).doWhenDone(new Runnable() {
-      public void run() {
-        final MyNode node = findModuleNode(module);
-        if (node != null) {
-          ModuleConfigurable moduleConfigurable = (ModuleConfigurable)node.getConfigurable();
-          ModuleEditor moduleEditor = moduleConfigurable.getModuleEditor();
-          moduleEditor.setSelectedTabName(ClasspathEditor.NAME);
-          if (orderEntry != null) {
-            ModuleConfigurationEditor editor = moduleEditor.getEditor(ClasspathEditor.NAME);
-            if (editor instanceof ClasspathEditor) {
-              ((ClasspathEditor)editor).selectOrderEntry(orderEntry);
-            }
-          }
-        }
-      }
-    });
-  }
-
   public Module[] getModules() {
     if (myContext.myModulesConfigurator != null) {
       final ModifiableModuleModel model = myContext.myModulesConfigurator.getModuleModel();
index 7ad2ec53aef6320067f5c0aa7041acce20af86ef..ce8f23ebf82114df92d25875df8fd15e8fe40846 100644 (file)
@@ -5,7 +5,7 @@ import com.intellij.openapi.roots.ModuleRootModel;
 import com.intellij.openapi.roots.OrderEntry;
 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 com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable;
 import com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext;
 import org.jetbrains.annotations.NotNull;
 
@@ -65,7 +65,7 @@ public class UsageInModuleClasspath extends ProjectStructureElementUsage {
     else {
       entry = null;
     }
-    ModuleStructureConfigurable.getInstance(myContext.getProject()).selectOrderEntry(myModule, entry);
+    ProjectStructureConfigurable.getInstance(myContext.getProject()).selectOrderEntry(myModule, entry);
   }
 
   @Override
index bcb38b085eb86c8d047f229a9a8f41a65aea4422..627c900d446104cb8a2b7195d7f51e22c5dbe61f 100644 (file)
@@ -26,7 +26,6 @@ import com.intellij.codeInsight.lookup.LookupManager;
 import com.intellij.ide.BrowserUtil;
 import com.intellij.ide.DataManager;
 import com.intellij.ide.IdeEventQueue;
-import com.intellij.ide.projectView.impl.nodes.NamedLibraryElement;
 import com.intellij.ide.util.PropertiesComponent;
 import com.intellij.ide.util.gotoByName.ChooseByNameBase;
 import com.intellij.lang.Language;
@@ -848,7 +847,7 @@ public class DocumentationManager {
         final VirtualFile virtualFile = containingFile.getVirtualFile();
         final OrderEntry libraryEntry = LibraryUtil.findLibraryEntry(virtualFile, myProject);
         if (libraryEntry != null) {
-          ProjectSettingsService.getInstance(myProject).openProjectLibrarySettings(new NamedLibraryElement(libraryEntry.getOwnerModule(), libraryEntry));
+          ProjectSettingsService.getInstance(myProject).openLibraryOrSdkSettings(libraryEntry);
         }
       }
     } else if (url.startsWith(PSI_ELEMENT_PROTOCOL)) {
index 4c43979af990d35201b641eff47a360d9a0b90de..715b25c6aa0b9e68bfe183251512bb82ac3812d5 100644 (file)
@@ -26,6 +26,7 @@ import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.patterns.ElementPattern;
 import com.intellij.util.containers.MultiMap;
 import com.intellij.util.indexing.FileContent;
+import com.intellij.util.indexing.FileContentImpl;
 import org.jetbrains.annotations.NotNull;
 
 import java.io.File;
@@ -90,7 +91,7 @@ public class FrameworkDetectionProcessor {
 
     myProgressIndicator.setText2(file.getPresentableUrl());
     try {
-      FileContent fileContent = new FileContent(file, file.contentsToByteArray(false));
+      FileContent fileContent = new FileContentImpl(file, file.contentsToByteArray(false));
       for (FrameworkDetectorData detector : myDetectorsByFileType.get(fileType)) {
         if (detector.myFilePattern.accepts(fileContent)) {
           detector.mySuitableFiles.add(file);
index 1e40d20d03340bc1c36609898086303617d42f52..1958ae98acb4924a47aad31e395a302498302442 100644 (file)
@@ -50,10 +50,6 @@ public class NamedLibraryElementNode extends ProjectViewNode<NamedLibraryElement
     super(project, value, viewSettings);
   }
 
-  public NamedLibraryElementNode(final Project project, final Object value, final ViewSettings viewSettings) {
-    this(project, (NamedLibraryElement)value, viewSettings);
-  }
-
   @NotNull
   public Collection<AbstractTreeNode> getChildren() {
     final List<AbstractTreeNode> children = new ArrayList<AbstractTreeNode>();
@@ -107,22 +103,24 @@ public class NamedLibraryElementNode extends ProjectViewNode<NamedLibraryElement
       final JdkOrderEntry jdkOrderEntry = (JdkOrderEntry)orderEntry;
       final Sdk projectJdk = jdkOrderEntry.getJdk();
       if (projectJdk != null) { //jdk not specified
-        presentation.setLocationString(FileUtil.toSystemDependentName(projectJdk.getHomePath()));
+        final String path = projectJdk.getHomePath();
+        if (path != null) {
+          presentation.setLocationString(FileUtil.toSystemDependentName(path));
+        }
       }
+      presentation.setTooltip(IdeBundle.message("node.projectview.jdk"));
+    }
+    else {
+      presentation.setTooltip(StringUtil.capitalize(IdeBundle.message("node.projectview.library", ((LibraryOrderEntry)orderEntry).getLibraryLevel())));
     }
-  }
-
-  protected String getToolTip() {
-    OrderEntry orderEntry = getValue().getOrderEntry();
-    return orderEntry instanceof JdkOrderEntry ? IdeBundle.message("node.projectview.jdk") : StringUtil.capitalize(IdeBundle.message("node.projectview.library", ((LibraryOrderEntry)orderEntry).getLibraryLevel()));
   }
 
   public void navigate(final boolean requestFocus) {
-    ProjectSettingsService.getInstance(myProject).openProjectLibrarySettings(getValue());
+    ProjectSettingsService.getInstance(myProject).openLibraryOrSdkSettings(getValue().getOrderEntry());
   }
 
   public boolean canNavigate() {
-    return ProjectSettingsService.getInstance(myProject).canOpenProjectLibrarySettings(getValue());
+    return ProjectSettingsService.getInstance(myProject).canOpenLibraryOrSdkSettings(getValue().getOrderEntry());
   }
 
   @Override
index 13303738430401b1268fec95b315ce63c0c156ce..d94f47bd5fb4b8b60d2152b4da60c78cf59e68df 100644 (file)
@@ -28,8 +28,10 @@ import com.intellij.openapi.module.Module;
 import com.intellij.openapi.module.ModuleUtil;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.project.ProjectUtil;
+import com.intellij.openapi.roots.OrderEntry;
 import com.intellij.openapi.roots.ProjectFileIndex;
 import com.intellij.openapi.roots.ProjectRootManager;
+import com.intellij.openapi.roots.libraries.LibraryUtil;
 import com.intellij.openapi.roots.ui.configuration.ProjectSettingsService;
 import com.intellij.openapi.util.Comparing;
 import com.intellij.openapi.util.Iconable;
@@ -218,7 +220,10 @@ public class PsiDirectoryNode extends BasePsiNode<PsiDirectory> implements Navig
         service.openModuleSettings(module);
       }
       else if (ProjectRootsUtil.isLibraryRoot(file, project)) {
-        service.openModuleLibrarySettings(module);
+        final OrderEntry orderEntry = LibraryUtil.findLibraryEntry(file, module.getProject());
+        if (orderEntry != null) {
+          service.openLibraryOrSdkSettings(orderEntry);
+        }
       }
       else {
         service.openContentEntriesSettings(module);
index 45cbf3bc1037cf6b93809675005e81dfd4c016a3..c89bcab3a4a5470aa581a10598e6d2c5cb3e41fa 100644 (file)
@@ -19,13 +19,18 @@ package com.intellij.ide.projectView.impl.nodes;
 import com.intellij.ide.highlighter.ArchiveFileType;
 import com.intellij.ide.projectView.PresentationData;
 import com.intellij.ide.projectView.ViewSettings;
+import com.intellij.ide.projectView.impl.ProjectRootsUtil;
 import com.intellij.ide.util.treeView.AbstractTreeNode;
 import com.intellij.openapi.fileTypes.StdFileTypes;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.project.ProjectUtil;
+import com.intellij.openapi.roots.OrderEntry;
+import com.intellij.openapi.roots.libraries.LibraryUtil;
+import com.intellij.openapi.roots.ui.configuration.ProjectSettingsService;
 import com.intellij.openapi.util.Iconable;
 import com.intellij.openapi.vfs.JarFileSystem;
 import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.pom.NavigatableWithText;
 import com.intellij.psi.PsiDirectory;
 import com.intellij.psi.PsiFile;
 import com.intellij.psi.PsiManager;
@@ -36,20 +41,18 @@ import org.jetbrains.annotations.Nullable;
 import java.util.ArrayList;
 import java.util.Collection;
 
-public class PsiFileNode extends BasePsiNode<PsiFile>{
+public class PsiFileNode extends BasePsiNode<PsiFile> implements NavigatableWithText {
 
   public PsiFileNode(Project project, PsiFile value, ViewSettings viewSettings) {
     super(project, value, viewSettings);
   }
 
   public Collection<AbstractTreeNode> getChildrenImpl() {
-    if (isArchive()) {
-      VirtualFile jarRoot = JarFileSystem.getInstance().getJarRootForLocalFile(getVirtualFile());
-      if (jarRoot != null) {
-        PsiDirectory psiDirectory = PsiManager.getInstance(getProject()).findDirectory(jarRoot);
-        if (psiDirectory != null) {
-          return ProjectViewDirectoryHelper.getInstance(getProject()).getDirectoryChildren(psiDirectory, getSettings(), true);
-        }
+    VirtualFile jarRoot = getJarRoot();
+    if (jarRoot != null) {
+      PsiDirectory psiDirectory = PsiManager.getInstance(getProject()).findDirectory(jarRoot);
+      if (psiDirectory != null) {
+        return ProjectViewDirectoryHelper.getInstance(getProject()).getDirectoryChildren(psiDirectory, getSettings(), true);
       }
     }
 
@@ -72,6 +75,52 @@ public class PsiFileNode extends BasePsiNode<PsiFile>{
     return value != null ? value.getVirtualFile() : null;
   }
 
+  @Override
+  public boolean canNavigate() {
+    return isNavigatableLibraryRoot() || super.canNavigate();
+  }
+
+  private boolean isNavigatableLibraryRoot() {
+    VirtualFile jarRoot = getJarRoot();
+    final Project project = getProject();
+    if (jarRoot != null && ProjectRootsUtil.isLibraryRoot(jarRoot, project)) {
+      final OrderEntry orderEntry = LibraryUtil.findLibraryEntry(jarRoot, project);
+      return orderEntry != null && ProjectSettingsService.getInstance(project).canOpenLibraryOrSdkSettings(orderEntry);
+    }
+    return false;
+  }
+
+  @Nullable
+  private VirtualFile getJarRoot() {
+    final VirtualFile file = getVirtualFile();
+    if (file == null || !file.isValid() || !(file.getFileType() instanceof ArchiveFileType)) {
+      return null;
+    }
+    return JarFileSystem.getInstance().getJarRootForLocalFile(file);
+  }
+
+  @Override
+  public void navigate(boolean requestFocus) {
+    VirtualFile jarRoot = getJarRoot();
+    final Project project = getProject();
+    if (jarRoot != null && ProjectRootsUtil.isLibraryRoot(jarRoot, project)) {
+      final OrderEntry orderEntry = LibraryUtil.findLibraryEntry(jarRoot, project);
+      if (orderEntry != null) {
+        ProjectSettingsService.getInstance(project).openLibraryOrSdkSettings(orderEntry);
+        return;
+      }
+    }
+    super.navigate(requestFocus);
+  }
+
+  @Override
+  public String getNavigateActionText(boolean focusEditor) {
+    if (isNavigatableLibraryRoot()) {
+      return "Open Library Settings";
+    }
+    return null;
+  }
+
   public int getWeight() {
     return 20;
   }
index 80d00c99ba9b1f3903606c192385e9e004e9be3b..37f0f751214bac118d82d52dea36b3917f2abbbb 100644 (file)
@@ -15,7 +15,6 @@
  */
 package com.intellij.openapi.roots.libraries;
 
-import com.intellij.ide.projectView.impl.nodes.NamedLibraryElement;
 import com.intellij.openapi.module.Module;
 import com.intellij.openapi.roots.LibraryOrderEntry;
 import com.intellij.openapi.roots.ModuleRootManager;
@@ -29,14 +28,14 @@ import org.jetbrains.annotations.NotNull;
  */
 public class LibraryNavigatable implements Navigatable {
   private final Module module;
-  private NamedLibraryElement element;
+  private OrderEntry element;
 
   public LibraryNavigatable(@NotNull Library library, @NotNull Module module) {
     this.module = module;
     for (OrderEntry entry : ModuleRootManager.getInstance(module).getOrderEntries()) {
       if (entry instanceof LibraryOrderEntry) {
         if (((LibraryOrderEntry)entry).getLibrary() == library) {
-          element = new NamedLibraryElement(module, entry);
+          element = entry;
         }
       }
     }
@@ -44,7 +43,7 @@ public class LibraryNavigatable implements Navigatable {
 
   @Override
   public void navigate(boolean requestFocus) {
-    ProjectSettingsService.getInstance(module.getProject()).openProjectLibrarySettings(element);
+    ProjectSettingsService.getInstance(module.getProject()).openLibraryOrSdkSettings(element);
   }
 
   @Override
index 08621d9bb3e01fd2aae5477977ac90b498f7e0fe..03297f5e58a06e842c8e4d5bce598644910aebf4 100644 (file)
@@ -17,7 +17,6 @@
 package com.intellij.openapi.roots.ui.configuration;
 
 import com.intellij.ide.projectView.impl.ModuleGroup;
-import com.intellij.ide.projectView.impl.nodes.NamedLibraryElement;
 import com.intellij.openapi.components.ServiceManager;
 import com.intellij.openapi.module.Module;
 import com.intellij.openapi.options.Configurable;
@@ -29,7 +28,6 @@ import com.intellij.openapi.roots.OrderEntry;
 import com.intellij.openapi.roots.impl.libraries.LibraryEx;
 import com.intellij.openapi.roots.libraries.Library;
 import com.intellij.openapi.roots.libraries.LibraryType;
-import com.intellij.openapi.roots.libraries.ui.LibraryRootsComponentDescriptor;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
@@ -72,22 +70,20 @@ public class ProjectSettingsService {
     return false;
   }
 
-  public void openProjectLibrarySettings(final NamedLibraryElement value) {
-    Configurable additionalSettingsConfigurable = getLibrarySettingsConfigurable(value);
+  public void openLibraryOrSdkSettings(final @NotNull OrderEntry orderEntry) {
+    Configurable additionalSettingsConfigurable = getLibrarySettingsConfigurable(orderEntry);
     if (additionalSettingsConfigurable != null) {
-      LibraryOrderEntry entry = (LibraryOrderEntry) value.getOrderEntry();
-      ShowSettingsUtil.getInstance()
-        .showSettingsDialog(entry.getOwnerModule().getProject(), additionalSettingsConfigurable.getDisplayName());
+      ShowSettingsUtil.getInstance().showSettingsDialog(orderEntry.getOwnerModule().getProject(),
+                                                        additionalSettingsConfigurable.getDisplayName());
     }
   }
 
-  public boolean canOpenProjectLibrarySettings(final NamedLibraryElement value) {
-    return getLibrarySettingsConfigurable(value) != null;
+  public boolean canOpenLibraryOrSdkSettings(final OrderEntry orderEntry) {
+    return getLibrarySettingsConfigurable(orderEntry) != null;
   }
 
   @Nullable
-  private static Configurable getLibrarySettingsConfigurable(NamedLibraryElement value) {
-    OrderEntry orderEntry = value.getOrderEntry();
+  private static Configurable getLibrarySettingsConfigurable(OrderEntry orderEntry) {
     if (!(orderEntry instanceof LibraryOrderEntry)) return null;
     LibraryOrderEntry libOrderEntry = (LibraryOrderEntry)orderEntry;
     Library lib = libOrderEntry.getLibrary();
index e4239fc0e3fc8526e887fd22d5457f51fa5b3434..14a04b93b02d1a3498a3a6adca302d3e51fc9f31 100644 (file)
@@ -30,6 +30,7 @@ import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.util.indexing.FileBasedIndex;
 import com.intellij.util.indexing.FileContent;
+import com.intellij.util.indexing.FileContentImpl;
 import gnu.trove.TIntArrayList;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -110,7 +111,7 @@ public class StubTree {
     }
 
     try {
-      final FileContent fc = new FileContent(vFile, vFile.contentsToByteArray());
+      final FileContent fc = new FileContentImpl(vFile, vFile.contentsToByteArray());
       fc.putUserData(FileBasedIndex.PROJECT, project);
       final StubElement element = StubUpdatingIndex.buildStubTree(fc);
       if (element instanceof PsiFileStub) {
index 66820d9ebe49b6689956687760bcd30b0bea45f7..f5824b2ac8679b62a337bbb8fe25630445833c68 100644 (file)
@@ -149,7 +149,7 @@ public class StubUpdatingIndex extends CustomImplementationFileBasedIndexExtensi
         final BinaryFileStubBuilder builder = BinaryFileStubBuilders.INSTANCE.forFileType(fileType);
         assert builder != null;
 
-        data = builder.buildStubTree(inputData.getFile(), inputData.getContent(), inputData.getProject());
+        data = builder.buildStubTree(inputData.getFile(), inputData.getContent(), ((FileContentImpl)inputData).getProject());
       }
       else {
         final LanguageFileType filetype = (LanguageFileType)fileType;
index ced6e0cc5290369866c2a516dc6d20ec3e9e9c11..904b310d9d26dac6a4635992fb91d74f62d9c9f6 100644 (file)
@@ -1196,7 +1196,7 @@ public class FileBasedIndex implements ApplicationComponent {
               return;
             }
 
-            final FileContent newFc = new FileContent(vFile, contentText, vFile.getCharset());
+            final FileContentImpl newFc = new FileContentImpl(vFile, contentText, vFile.getCharset());
 
             if (dominantContentFile != null) {
               dominantContentFile.putUserData(PsiFileImpl.BUILDING_STUB, true);
@@ -1341,7 +1341,7 @@ public class FileBasedIndex implements ApplicationComponent {
   public void indexFileContent(@Nullable Project project, com.intellij.ide.caches.FileContent content) {
     myChangedFilesCollector.ensureAllInvalidateTasksCompleted();
     final VirtualFile file = content.getVirtualFile();
-    FileContent fc = null;
+    FileContentImpl fc = null;
 
     PsiFile psiFile = null;
 
@@ -1355,7 +1355,7 @@ public class FileBasedIndex implements ApplicationComponent {
           catch (IOException e) {
             currentBytes = ArrayUtil.EMPTY_BYTE_ARRAY;
           }
-          fc = new FileContent(file, currentBytes);
+          fc = new FileContentImpl(file, currentBytes);
 
           psiFile = content.getUserData(PSI_FILE);
           if (psiFile != null) {
@@ -1524,7 +1524,7 @@ public class FileBasedIndex implements ApplicationComponent {
             if (getInputFilter(indexId).acceptInput(file)) {
               try {
                 if (fileContent == null) {
-                  fileContent = new FileContent(file);
+                  fileContent = new FileContentImpl(file);
                 }
                 updateSingleIndex(indexId, file, fileContent);
               }
@@ -1814,7 +1814,7 @@ public class FileBasedIndex implements ApplicationComponent {
                 oldStuff = false;
                 try {
                   if (fileContent == null) {
-                    fileContent = new FileContent(file);
+                    fileContent = new FileContentImpl(file);
                   }
                   updateSingleIndex(indexId, file, fileContent);
                 }
index 7748e785a69871b81a32880e5afb3be146e5a7ab..71214a6b60e2ec8555666e278b01a4c0196e2a0e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2011 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 package com.intellij.util.indexing;
 
-import com.intellij.lang.Language;
-import com.intellij.openapi.fileEditor.impl.LoadTextUtil;
 import com.intellij.openapi.fileTypes.FileType;
-import com.intellij.openapi.fileTypes.FileTypeManager;
-import com.intellij.openapi.fileTypes.LanguageFileType;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.project.ProjectManager;
-import com.intellij.openapi.util.Key;
-import com.intellij.openapi.util.UserDataHolderBase;
+import com.intellij.openapi.util.UserDataHolder;
 import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.psi.LanguageSubstitutors;
 import com.intellij.psi.PsiFile;
-import com.intellij.psi.PsiFileFactory;
 import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.TestOnly;
-
-import java.io.UnsupportedEncodingException;
-import java.nio.charset.Charset;
 
 /**
  * @author Eugene Zhuravlev
  *         Date: Mar 28, 2008
  */
-public final class FileContent extends UserDataHolderBase {
-  private final VirtualFile myFile;
-  private final String fileName;
-  private final FileType myFileType;
-  private final Charset myCharset;
-  private byte[] myContent;
-  private CharSequence myContentAsText;
-
-  public Project getProject() {
-    return getUserData(FileBasedIndex.PROJECT);
-  }
-
-  private final Key<PsiFile> CACHED_PSI = Key.create("cached psi from content");
-
-  /**
-   * @return psiFile associated with the content. If the file was not set on FileContentCreation, it will be created on the spot
-   */
-  public PsiFile getPsiFile() {
-    PsiFile psi = getUserData(FileBasedIndex.PSI_FILE);
-
-    if (psi == null) {
-      psi = getUserData(CACHED_PSI);
-    }
-
-    if (psi == null) {
-      Project project = getProject();
-      if (project == null) {
-        project = ProjectManager.getInstance().getDefaultProject();
-      }
-      final Language language = ((LanguageFileType)getFileTypeWithoutSubstitution()).getLanguage();
-      final Language substitutedLanguage = LanguageSubstitutors.INSTANCE.substituteLanguage(language, getFile(), project);
-      psi = PsiFileFactory.getInstance(project).createFileFromText(getFileName(), substitutedLanguage, getContentAsText(), false, false, true);
-
-      psi.putUserData(FileBasedIndex.VIRTUAL_FILE, getFile());
-      putUserData(CACHED_PSI, psi);
-    }
-    return psi;
-  }
-
-  public static class IllegalDataException extends RuntimeException {
-    public IllegalDataException(final String message) {
-      super(message);
-    }
-  }
-
-  public FileContent(@NotNull final VirtualFile file, @NotNull final CharSequence contentAsText, final Charset charset) {
-    this(file, contentAsText, null, charset);
-  }
-
-  public FileContent(@NotNull final VirtualFile file, @NotNull final byte[] content) {
-    this(file, null, content, LoadTextUtil.detectCharsetAndSetBOM(file, content));
-  }
-
-  public FileContent(@NotNull final VirtualFile file) {
-    this(file, null, null, null);
-  }
-
-  @TestOnly
-  public FileContent(byte[] content) {
-    this(null, null, content, null);
-  }
-
-  private FileContent(VirtualFile file, CharSequence contentAsText, byte[] content, Charset charset) {
-    myFile = file;
-    myContentAsText = contentAsText;
-    myContent = content;
-    myCharset = charset;
-    myFileType = file == null ? null : FileTypeManager.getInstance().getFileTypeByFile(file);
-    // remember name explicitly because the file could be renamed afterwards
-    fileName = file == null ? null : file.getName();
-  }
-
-  private FileType substituteFileType(VirtualFile file, FileType fileType) {
-    Project project = getProject();
-    return SubstitutedFileType.substituteFileType(file, fileType, project);
-  }
-
-  public FileType getSubstitutedFileType() {
-    return substituteFileType(myFile, myFileType);
-  }
-
-  public FileType getFileTypeWithoutSubstitution() {
-    return myFileType;
-  }
-
-  public FileType getFileType() {
-    return getSubstitutedFileType();
-  }
-
-  public VirtualFile getFile() {
-    return myFile;
-  }
+public interface FileContent extends UserDataHolder {
+  @NotNull
+  FileType getFileType();
 
-  public String getFileName() {
-    return fileName;
-  }
+  VirtualFile getFile();
 
-  public Charset getCharset() {
-    return myCharset;
-  }
+  String getFileName();
 
-  public byte[] getContent() {
-    if (myContent == null) {
-      if (myContentAsText != null) {
-        try {
-          myContent = myCharset != null ? myContentAsText.toString().getBytes(myCharset.name()) : myContentAsText.toString().getBytes();
-        }
-        catch (UnsupportedEncodingException e) {
-          throw new RuntimeException(e);
-        }
-      }
-    }
-    return myContent;
-  }
+  byte[] getContent();
 
-  public CharSequence getContentAsText() {
-    if (myFileType.isBinary()) {
-      throw new IllegalDataException("Cannot obtain text for binary file type : " + myFileType.getDescription());
-    }
-    if (myContentAsText == null) {
-      if (myContent != null) {
-        myContentAsText = LoadTextUtil.getTextByBinaryPresentation(myContent, myCharset);
-      }
-    }
-    return myContentAsText;
-  }
+  CharSequence getContentAsText();
 
-  @Override
-  public String toString() {
-    return fileName;
-  }
+  @NotNull
+  PsiFile getPsiFile();
 }
diff --git a/platform/lang-impl/src/com/intellij/util/indexing/FileContentImpl.java b/platform/lang-impl/src/com/intellij/util/indexing/FileContentImpl.java
new file mode 100644 (file)
index 0000000..0e15c43
--- /dev/null
@@ -0,0 +1,181 @@
+/*
+ * Copyright 2000-2011 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.util.indexing;
+
+import com.intellij.lang.Language;
+import com.intellij.openapi.fileEditor.impl.LoadTextUtil;
+import com.intellij.openapi.fileTypes.FileType;
+import com.intellij.openapi.fileTypes.FileTypeManager;
+import com.intellij.openapi.fileTypes.LanguageFileType;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.project.ProjectManager;
+import com.intellij.openapi.util.Key;
+import com.intellij.openapi.util.UserDataHolderBase;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.psi.LanguageSubstitutors;
+import com.intellij.psi.PsiFile;
+import com.intellij.psi.PsiFileFactory;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.TestOnly;
+
+import java.io.UnsupportedEncodingException;
+import java.nio.charset.Charset;
+
+/**
+ * @author nik
+ */
+public class FileContentImpl extends UserDataHolderBase implements FileContent {
+  private final VirtualFile myFile;
+  private final String fileName;
+  private final FileType myFileType;
+  private final Charset myCharset;
+  private byte[] myContent;
+  private CharSequence myContentAsText;
+
+  public Project getProject() {
+    return getUserData(FileBasedIndex.PROJECT);
+  }
+
+  private final Key<PsiFile> CACHED_PSI = Key.create("cached psi from content");
+
+  /**
+   * @return psiFile associated with the content. If the file was not set on FileContentCreation, it will be created on the spot
+   */
+  @NotNull
+  @Override
+  public PsiFile getPsiFile() {
+    PsiFile psi = getUserData(FileBasedIndex.PSI_FILE);
+
+    if (psi == null) {
+      psi = getUserData(CACHED_PSI);
+    }
+
+    if (psi == null) {
+      Project project = getProject();
+      if (project == null) {
+        project = ProjectManager.getInstance().getDefaultProject();
+      }
+      final Language language = ((LanguageFileType)getFileTypeWithoutSubstitution()).getLanguage();
+      final Language substitutedLanguage = LanguageSubstitutors.INSTANCE.substituteLanguage(language, getFile(), project);
+      psi = PsiFileFactory.getInstance(project).createFileFromText(getFileName(), substitutedLanguage, getContentAsText(), false, false, true);
+
+      psi.putUserData(FileBasedIndex.VIRTUAL_FILE, getFile());
+      putUserData(CACHED_PSI, psi);
+    }
+    return psi;
+  }
+
+  public static class IllegalDataException extends RuntimeException {
+    public IllegalDataException(final String message) {
+      super(message);
+    }
+  }
+
+  public FileContentImpl(@NotNull final VirtualFile file, @NotNull final CharSequence contentAsText, final Charset charset) {
+    this(file, contentAsText, null, charset);
+  }
+
+  public FileContentImpl(@NotNull final VirtualFile file, @NotNull final byte[] content) {
+    this(file, null, content, LoadTextUtil.detectCharsetAndSetBOM(file, content));
+  }
+
+  public FileContentImpl(@NotNull final VirtualFile file) {
+    this(file, null, null, null);
+  }
+
+  @TestOnly
+  public FileContentImpl(byte[] content) {
+    this(null, null, content, null);
+  }
+
+  private FileContentImpl(VirtualFile file, CharSequence contentAsText, byte[] content, Charset charset) {
+    myFile = file;
+    myContentAsText = contentAsText;
+    myContent = content;
+    myCharset = charset;
+    myFileType = file == null ? null : FileTypeManager.getInstance().getFileTypeByFile(file);
+    // remember name explicitly because the file could be renamed afterwards
+    fileName = file == null ? null : file.getName();
+  }
+
+  @NotNull
+  private FileType substituteFileType(VirtualFile file, FileType fileType) {
+    Project project = getProject();
+    return SubstitutedFileType.substituteFileType(file, fileType, project);
+  }
+
+  @NotNull
+  public FileType getSubstitutedFileType() {
+    return substituteFileType(myFile, myFileType);
+  }
+
+  public FileType getFileTypeWithoutSubstitution() {
+    return myFileType;
+  }
+
+  @NotNull
+  @Override
+  public FileType getFileType() {
+    return getSubstitutedFileType();
+  }
+
+  @Override
+  public VirtualFile getFile() {
+    return myFile;
+  }
+
+  @Override
+  public String getFileName() {
+    return fileName;
+  }
+
+  public Charset getCharset() {
+    return myCharset;
+  }
+
+  @Override
+  public byte[] getContent() {
+    if (myContent == null) {
+      if (myContentAsText != null) {
+        try {
+          myContent = myCharset != null ? myContentAsText.toString().getBytes(myCharset.name()) : myContentAsText.toString().getBytes();
+        }
+        catch (UnsupportedEncodingException e) {
+          throw new RuntimeException(e);
+        }
+      }
+    }
+    return myContent;
+  }
+
+  @Override
+  public CharSequence getContentAsText() {
+    if (myFileType.isBinary()) {
+      throw new IllegalDataException("Cannot obtain text for binary file type : " + myFileType.getDescription());
+    }
+    if (myContentAsText == null) {
+      if (myContent != null) {
+        myContentAsText = LoadTextUtil.getTextByBinaryPresentation(myContent, myCharset);
+      }
+    }
+    return myContentAsText;
+  }
+
+  @Override
+  public String toString() {
+    return fileName;
+  }
+}
index 8e9cc82dc8f973f62c715ebafb763b78b9cbfd67..aec35fb9cfd679389d740036b705a00a78d97faa 100644 (file)
@@ -38,7 +38,7 @@ public class SubstitutedFileType extends LanguageFileType{
     this.fileType = substitutionFileType;
   }
 
-
+  @NotNull
   public static FileType substituteFileType(VirtualFile file, @NotNull FileType fileType, Project project) {
     if (project == null) {
       return fileType;
index 385b1ed3a826dc23f49e0109cb6fa1eed7322724..b481e4423d6b242e868babb208ed1d75c32cef44 100644 (file)
@@ -82,6 +82,7 @@ public class IdeErrorsDialog extends DialogWrapper implements MessagePoolListene
 
   private ClearFatalsAction myClearAction = new ClearFatalsAction();
   private BlameAction myBlameAction = new BlameAction();
+  @Nullable
   private AnalyzeAction myAnalyzeAction;
   private boolean myMute;
 
@@ -121,6 +122,7 @@ public class IdeErrorsDialog extends DialogWrapper implements MessagePoolListene
     SwingUtilities.invokeLater(new Runnable() {
       public void run() {
         rebuildHeaders();
+        updateControls();
       }
     });
   }
@@ -218,7 +220,10 @@ public class IdeErrorsDialog extends DialogWrapper implements MessagePoolListene
       myDetailsTabForm.setCommentsAreaVisible(false);
     }
     else {
-      myAnalyzeAction = new AnalyzeAction(ActionManager.getInstance().getAction("AnalyzeStacktraceOnError"));
+      final AnAction analyzePlatformAction = ActionManager.getInstance().getAction("AnalyzeStacktraceOnError");
+      if (analyzePlatformAction != null) {
+        myAnalyzeAction = new AnalyzeAction(analyzePlatformAction);
+      }
       myDetailsTabForm = new DetailsTabForm(myAnalyzeAction);
       myDetailsTabForm.setCommentsAreaVisible(true);
       myDetailsTabForm.addCommentsListener(commentsListener);
@@ -459,8 +464,14 @@ public class IdeErrorsDialog extends DialogWrapper implements MessagePoolListene
       final Throwable throwable = message.getThrowable();
       ErrorReportSubmitter submitter = getSubmitter(throwable);
       if (submitter == null) {
+        PluginId pluginId = findPluginId(throwable);
+        IdeaPluginDescriptor plugin = PluginManager.getPlugin(pluginId);
+        if (plugin == null) {
+          // unknown plugin
+          myForeignPluginWarningLabel.setVisible(false);
+          return;
+        }
         myForeignPluginWarningLabel.setVisible(true);
-        final IdeaPluginDescriptor plugin = PluginManager.getPlugin(findPluginId(throwable));
         String vendor = plugin.getVendor();
         String contactInfo = plugin.getVendorUrl();
         if (StringUtil.isEmpty(contactInfo)) {
@@ -574,7 +585,6 @@ public class IdeErrorsDialog extends DialogWrapper implements MessagePoolListene
     for (final ArrayList<AbstractMessage> abstractMessages : hash2Messages.values()) {
       myMergedMessages.add(abstractMessages);
     }
-    updateControls();
   }
 
   private void markAllAsRead() {
index de794b6dcb7e5f71b4cb21c22b26f249dc67b087..fcaedf7c4c08887505a51212d926393959be4f2a 100644 (file)
@@ -3,6 +3,7 @@ package com.intellij.diagnostic.errordialog;
 import com.intellij.diagnostic.DiagnosticBundle;
 import com.intellij.ui.IdeBorderFactory;
 import com.intellij.util.ui.UIUtil;
+import org.jetbrains.annotations.Nullable;
 
 import javax.swing.*;
 
@@ -16,7 +17,7 @@ public class DetailsTabForm {
   private JPanel myDetailsHolder;
   private JButton myAnalyzeStacktraceButton;
 
-  public DetailsTabForm(Action analyzeAction) {
+  public DetailsTabForm(@Nullable Action analyzeAction) {
     myCommentsArea.setTitle(DiagnosticBundle.message("error.dialog.comment.prompt"));
     myDetailsPane.setBackground(UIUtil.getTextFieldBackground());
     myDetailsHolder.setBorder(IdeBorderFactory.createBorder());
index 4e0b7de7648674dbf62900fdecefb8a0e876f3d5..2eb67dc9c348a7ea3eda1ea70d3238bddcbaa1a0 100644 (file)
@@ -224,11 +224,11 @@ action.CloseProject.text=Close Pro_ject
 action.CloseProject.description=Close current project
 action.ShowSettings.text=Se_ttings
 action.ShowSettings.description=Configure application settings
-action.ShowProjectStructureSettings.text=Pro_ject Structure
+action.ShowProjectStructureSettings.text=Pro_ject Structure...
 action.ShowProjectStructureSettings.description=Configure project structure
-action.TemplateProjectProperties.text=Templ_ate Settings
+action.TemplateProjectProperties.text=Templ_ate Settings...
 action.TemplateProjectProperties.description=Configure template settings for all new projects
-action.TemplateProjectStructure.text=Te_mplate Project Structure
+action.TemplateProjectStructure.text=Te_mplate Project Structure...
 action.TemplateProjectStructure.description=Configure template structure for all new projects
 action.SaveAll.text=_Save All
 action.SaveAll.description=Save all files and settings
@@ -324,15 +324,15 @@ action.ViewToolButtons.text=_Tool Buttons
 action.ViewToolButtons.description=Show/hide tool window buttons
 action.ViewNavigationBar.text=Na_vigation Bar
 action.ViewNavigationBar.description=Show/hide the navigation bar
-action.FileStructurePopup.text=_File Structure Popup
+action.FileStructurePopup.text=_File Structure
 action.FileStructurePopup.description=Popup structure of the current file for quick navigation
 action.ShowFilePath.text=File _Path
 action.ShowFilePath.description=Popup path of the current file for opening in external file manager
 action.SelectIn.text=Se_lect In...
 action.SelectIn.description=Select the current class or method in any view
-action.QuickJavaDoc.text=Quick _Documentation Lookup
+action.QuickJavaDoc.text=Quick _Documentation
 action.QuickJavaDoc.description=Show a popup window with documentation for the symbol at caret
-action.QuickImplementations.text=Quick Definition Loo_kup
+action.QuickImplementations.text=Quic_k Definition
 action.QuickImplementations.description=Show a popup window with the symbol (and its implementations) content
 action.ParameterInfo.text=_Parameter Info
 action.ParameterInfo.description=Show parameters of the method call at caret
@@ -340,7 +340,7 @@ action.EditorContextInfo.text=_Context Info
 action.EditorContextInfo.description=Show the current method or class declaration when it is not visible
 action.ShowErrorDescription.text=E_rror Description
 action.ShowErrorDescription.description=Show description of error or warning at caret
-action.ProjectViewChangeView.text=Change View
+action.ProjectViewChangeView.text=Change View...
 action.ProjectViewChangeView.description=Choose Project, Sourcepath or Classpath tree in the Project View window
 action.EditSource.text=_Jump to Source
 action.EditSource.description=Open editor for the selected item and give focus to it
@@ -407,6 +407,8 @@ action.GotoNextError.text=_Next Highlighted Error
 action.GotoNextError.description=Navigate to the next highlighted error in the active editor
 action.GotoPreviousError.text=_Previous Highlighted Error
 action.GotoPreviousError.description=Navigate to the previous highlighted error in the active editor
+action.GotoRelated.text=_Related File...
+action.GotoRelated.description=Navigate to one of the related or linked files
 action.MethodDown.text=N_ext Method
 action.MethodDown.description=Navigate to the next method in the active editor
 action.MethodUp.text=Prev_ious Method
@@ -1189,9 +1191,9 @@ action.Diff.IgnoreWhitespace.text=Toggle Diff Ignore Whitespace
 action.ShelvedChanges.Restore.text=Restore Applied Shelved Change
 action.Graph.Current.Node.Dependencies.Filter.text=Show selected nodes with dependencies
 group.VcsToobarActions.text=VCS Actions
-action.StartupWizard.text=Configure Plugins
+action.StartupWizard.text=Configure Plugins...
 action.StartupWizard.description=Run a wizard for selecting the set of enabled plugins
-action.PopupHector.text=Popup Per File Highlighting Settings
+action.PopupHector.text=Per File Highlighting Settings...
 action.PopupHector.description=Show panel to configure highlighting mode for the current file
 group.EditorTabPopupMenu.text=Editor Tab Popup Menu
 group.MainMenu.text=Main menu
index 6cf4e89c900b40330b8187f5935d21229f16c279..29b0ba311aeb252b02c121490ab18748667c5f4f 100644 (file)
@@ -6,7 +6,7 @@
 
 
     <p>Use <span class="shortcut">&shortcut:QuickImplementations;</span>
-      (<span class="control">View | Quick Definition Lookup</span>),
+      (<span class="control">View | Quick Definition</span>),
       to quickly review definition or content of the symbol at caret, without the need to open it
       in a new editor tab.</p>
       <p class="image"><img src="images/ctrl_shift_i.gif"></p>
@@ -14,4 +14,4 @@
 
 
 </body>
-</html>
\ No newline at end of file
+</html>
index 739e6003a5420016f0e58af2e4023ced465245d1..9d40131bad123ef9a5949d38e07c5edf97b4705c 100644 (file)
@@ -6,7 +6,7 @@
 
 
     <p>You can quickly navigate in the currently edited file with <span class="shortcut">&shortcut:FileStructurePopup;</span>
-      (<span class="control">View | File Structure Popup</span>).</p>
+      (<span class="control">View | File Structure</span>).</p>
       <p>It shows the list of members of the current class. Select an element you want to navigate to and press the
       <span class="shortcut">Enter</span> key or the <span class="shortcut">&shortcut:EditSource;</span> key.</p>
       <p>To easily locate an item in the list, just start typing its name.</p>
index a1437f522b8e90d506bde7a53b3ee97a2f7a6ac1..ee3e2c7b6479f4be4a192cdadb8658df4f319b90 100644 (file)
@@ -6,7 +6,7 @@
 
 
     <p>You can quickly view the image referenced at caret by using the
-      <span class="">Quick Definition Lookup</span>
+      <span class="">Quick Definition</span>
       (<span class="shortcut">&shortcut:QuickImplementations;</span>). The underlying image will be opened in a popup instead of a separate editor tab.</p>
       <p class="image"><img src="images/image_lookup.gif"></p>
 
index c7fd10a4728027e66e64c22fb27f7ed2740dbdce..5a54891f2bf008ff9299b1061fdc3ebb1d6acbb5 100644 (file)
@@ -5,7 +5,7 @@
 <body>
     <p>
         To quickly see the documentation for the class or method used at the editor's caret, press <span class="shortcut">&shortcut:QuickJavaDoc;</span>
-        (<span class="control">View | Quick Documentation Lookup</span>).</p>
+        (<span class="control">View | Quick Documentation</span>).</p>
     <p class="image">
         <img src="images/quick_javadoc.gif"></p>
 </body>
index 60ee82f9ca347c55c63e5c4090689c87bc56a898..5ba036c0501092fa102fb5cfe9a4abde1e0cb8b3 100644 (file)
@@ -6,7 +6,7 @@
 
 
     <p>The shortcuts such as <span class="shortcut">&shortcut:QuickJavaDoc;</span>
-      (<span class="control">View | Quick Documentation Lookup</span>),
+      (<span class="control">View | Quick Documentation</span>),
       <span class="shortcut">&shortcut:ParameterInfo;</span> (<span class="control">View | Parameter Info</span>),
       <span class="shortcut">&shortcut:GotoDeclaration;</span> (<span class="control">Go To | Declaration</span>)
       and others can be used not only in the editor but in the code completion popup list as well.</p>
index 87474960e2ce1025532ff1c8cd9d312db0cdc352..e6bee2d60653da023491b2cf1f6aeb1e3a8dc2ae 100644 (file)
     </group>
 
     <!-- View -->
-    <action id="ViewNavigationBar" class="com.intellij.ide.actions.ViewNavigationBarAction">
-      <add-to-group group-id="ViewMenu" relative-to-action="ViewStatusBar" anchor="after"/>
-    </action>
-
-    <action id="ViewImportPopups" class="com.intellij.openapi.editor.actions.ToggleShowImportPopupsAction">
-      <add-to-group group-id="ViewMenu" relative-to-action="EditorToggleShowLineNumbers" anchor="after"/>
-    </action>
+    <group id="QuickActions">
+      <action id="QuickImplementations" class="com.intellij.codeInsight.hint.actions.ShowImplementationsAction"/>
+      <action id="QuickJavaDoc" class="com.intellij.codeInsight.documentation.actions.ShowQuickDocInfoAction"/>
 
-    <action id="ShowUsagesSettings" class="com.intellij.find.actions.ShowUsagesAction$ShowSettings"/>
+      <add-to-group group-id="ViewMenu" anchor="first"/>
+    </group>
 
     <group id="CodeEditorBaseGroup">
       <group id="CodeEditorViewGroup">
         <action id="SelectIn" class="com.intellij.ide.actions.SelectInAction"/>
         <action id="FileStructurePopup" class="com.intellij.ide.actions.ViewStructureAction"/>
         <action id="ShowFilePath" class="com.intellij.ide.actions.ShowFilePathAction"/>
-        <action id="PopupHector" class="com.intellij.codeInsight.daemon.impl.PopupHectorAction"/>
-      </group>
-      <separator/>
-
-      <group id="ProjectViewGroup">
-        <action id="ProjectViewChangeView" class="com.intellij.ide.projectView.actions.ChangeProjectViewAction"/>
       </group>
       <separator/>
 
       <add-to-group group-id="ViewMenu" relative-to-action="QuickActions" anchor="after"/>
     </group>
 
+    <action id="ViewNavigationBar" class="com.intellij.ide.actions.ViewNavigationBarAction">
+      <add-to-group group-id="ViewMenu" relative-to-action="ViewStatusBar" anchor="after"/>
+    </action>
+
+    <action id="ViewImportPopups" class="com.intellij.openapi.editor.actions.ToggleShowImportPopupsAction">
+      <add-to-group group-id="ViewMenu" relative-to-action="EditorToggleShowLineNumbers" anchor="after"/>
+    </action>
+
+    <action id="ShowUsagesSettings" class="com.intellij.find.actions.ShowUsagesAction$ShowSettings"/>
+
+    <group id="ProjectViewGroup">
+      <action id="ProjectViewChangeView" class="com.intellij.ide.projectView.actions.ChangeProjectViewAction"/>
+      <action id="PopupHector" class="com.intellij.codeInsight.daemon.impl.PopupHectorAction"/>
+      <add-to-group group-id="ViewMenu" relative-to-action="QuickChangeScheme" anchor="after"/>
+    </group>
+
     <group id="FoldingGroup" popup="true">
       <action id="ExpandRegion" class="com.intellij.codeInsight.folding.impl.actions.ExpandRegionAction"/>
       <action id="CollapseRegion" class="com.intellij.codeInsight.folding.impl.actions.CollapseRegionAction"/>
       <add-to-group group-id="ViewMenu" relative-to-action="UIToggleActions" anchor="before"/>
     </group>
 
-    <group id="QuickActions">
-      <action id="QuickImplementations" class="com.intellij.codeInsight.hint.actions.ShowImplementationsAction"/>
-      <action id="QuickJavaDoc" class="com.intellij.codeInsight.documentation.actions.ShowQuickDocInfoAction"/>
-
-      <add-to-group group-id="ViewMenu" anchor="first"/>
-    </group>
-
     <action id="RecentChanges" class="com.intellij.history.integration.ui.actions.RecentChangesAction">
       <keyboard-shortcut first-keystroke="alt shift C" keymap="$default"/>
       <add-to-group group-id="ViewRecentActions" anchor="last"/>
       <action id="MethodHierarchy" class="com.intellij.ide.hierarchy.actions.BrowseMethodHierarchyAction"/>
       <action id="CallHierarchy" class="com.intellij.ide.hierarchy.actions.BrowseCallHierarchyAction"/>
       <separator/>
-      <add-to-group group-id="ViewMenu" relative-to-action="UIToggleActions" anchor="before"/>
+      <add-to-group group-id="ViewMenu" relative-to-action="CodeEditorBaseGroup" anchor="after"/>
     </group>
 
     <!-- Go To -->
       <action id="GotoTypeDeclaration" class="com.intellij.codeInsight.navigation.actions.GotoTypeDeclarationAction"/>
       <action id="GotoSuperMethod" class="com.intellij.codeInsight.navigation.actions.GotoSuperAction"/>
       <action id="GotoTest" class="com.intellij.testIntegration.GotoTestOrCodeAction"/>
-      <action id="GotoRelated" class="com.intellij.ide.actions.GotoRelatedFileAction" text="_Related File"/>
+      <action id="GotoRelated" class="com.intellij.ide.actions.GotoRelatedFileAction"/>
       <separator/>
 
       <add-to-group group-id="GoToMenu" anchor="before" relative-to-action="GoToErrorGroup"/>
index 7fb3f56e48b9625c8ac03fecb1079dc10e37b121..56f663d82b44850e71da1cb4e04769f317e45054 100644 (file)
         <action id="QuickChangeScheme" class="com.intellij.ide.actions.QuickChangeSchemesAction"/>
         <group id="UIToggleActions">
           <separator/>
-          <action id="ViewToolBar" class="com.intellij.ide.actions.ViewToolbarAction"/>
-          <action id="ViewStatusBar" class="com.intellij.ide.actions.ViewStatusBarAction"/>
-          <action id="ViewToolButtons" class="com.intellij.ide.actions.ViewToolWindowButtonsAction"/>
           <reference ref="EditorToggleShowWhitespaces"/>
           <reference ref="EditorToggleShowLineNumbers"/>
           <reference ref="EditorToggleShowIndentLines"/>
           <reference ref="EditorToggleUseSoftWraps"/>
+          <separator/>
+          <action id="ViewToolBar" class="com.intellij.ide.actions.ViewToolbarAction"/>
+          <action id="ViewToolButtons" class="com.intellij.ide.actions.ViewToolWindowButtonsAction"/>
+          <action id="ViewStatusBar" class="com.intellij.ide.actions.ViewStatusBarAction"/>
         </group>
       </group>
 
index c3aec8259417f58a4f76ab64aa4faf4e54313d1e..1385088c2761fe69bdfcb16198a4c1c791ee38bb 100644 (file)
@@ -43,7 +43,7 @@ public abstract class UpdateOrStatusOptionsDialog extends OptionsDialog {
       myMainPanel = new JPanel(new BorderLayout());
       final Configurable configurable = confs.keySet().iterator().next();
       addComponent(confs.get(configurable), configurable, BorderLayout.CENTER);
-      myMainPanel.add(Box.createHorizontalGlue());
+      myMainPanel.add(Box.createVerticalStrut(10), BorderLayout.SOUTH);
     }
     else {
       myMainPanel = new JTabbedPane();
index 5ec11214fa582c269cc3d720fe0665ab112ae407..1d259e7f7fbb29758c406e77d264261fd0a5fbed 100644 (file)
@@ -312,18 +312,21 @@ public class GitUntrackedFilesHolder implements Disposable, BulkFileListener {
   }
 
   private void asyncRefreshFiles(final Set<VirtualFile> filesCreated) {
-    ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
-      public void run() {
-        Set<VirtualFile> filesToRefresh = new HashSet<VirtualFile>();
-        for (VirtualFile file : filesCreated) {
-          if (belongsToThisRepository(file) && !myChangeListManager.isIgnoredFile(file)) {
-            filesToRefresh.add(file);
-          }
-        }
-        rescanFiles(filesToRefresh);
-        myDirtyScopeManager.filesDirty(filesToRefresh, null); // make ChangeListManager capture new info
+    final Set<VirtualFile> filesToRefresh = new HashSet<VirtualFile>();
+    for (VirtualFile file : filesCreated) {
+      if (belongsToThisRepository(file) && !myChangeListManager.isIgnoredFile(file)) {
+        filesToRefresh.add(file);
       }
-    });
+    }
+
+    if (!filesToRefresh.isEmpty()) {
+      ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
+        public void run() {
+          rescanFiles(filesToRefresh);
+          myDirtyScopeManager.filesDirty(filesToRefresh, null); // make ChangeListManager capture new info
+        }
+      });
+    }
   }
 
   private boolean belongsToThisRepository(VirtualFile file) {
index 92ac91aee149eb4f2738d3f6d405557ca33931d7..4653b04f499b619a0c5fe702d6b6de331d9062e4 100644 (file)
@@ -9,13 +9,16 @@
   <depends>org.intellij.groovy</depends>
 
   <extensions defaultExtensionNs="com.intellij">
+    <errorHandler implementation="com.intellij.diagnostic.ITNReporter"/>
     <projectImportProvider implementation="org.jetbrains.plugins.gradle.importing.wizard.GradleProjectImportProvider"/>
     <projectImportBuilder implementation="org.jetbrains.plugins.gradle.importing.wizard.GradleProjectImportBuilder"/>
     <projectConfigurable instance="org.jetbrains.plugins.gradle.config.GradleConfigurable"/>
     <library.presentationProvider implementation="org.jetbrains.plugins.gradle.config.GradleLibraryPresentationProvider" order="last"/>
+    <java.elementFinder implementation="org.jetbrains.plugins.gradle.config.GradleClassFinder"/>
     <projectService serviceInterface="org.jetbrains.plugins.gradle.config.GradleSettings"
                     serviceImplementation="org.jetbrains.plugins.gradle.config.GradleSettings"/>
-    <java.elementFinder implementation="org.jetbrains.plugins.gradle.config.GradleClassFinder"/>
+    <projectService serviceInterface="org.jetbrains.plugins.gradle.remote.GradleApiFacadeManager"
+                    serviceImplementation="org.jetbrains.plugins.gradle.remote.GradleApiFacadeManager"/>
   </extensions>
   
   <extensions defaultExtensionNs="org.intellij.groovy">
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/GradleContentRoot.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/GradleContentRoot.java
new file mode 100644 (file)
index 0000000..9a99ec4
--- /dev/null
@@ -0,0 +1,24 @@
+package org.jetbrains.plugins.gradle.importing.model;
+
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Collection;
+
+/**
+ * Implementations of this interface are expected to be thread-safe.
+ * 
+ * @author Denis Zhdanov
+ * @since 8/9/11 6:39 PM
+ */
+public interface GradleContentRoot {
+
+  @NotNull
+  String getRootPath();
+
+  /**
+   * @param type      target dir type
+   * @return          directories of the target type configured for the current content root
+   */
+  @NotNull
+  Collection<String> getPaths(@NotNull SourceType type);
+}
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/GradleDependency.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/GradleDependency.java
new file mode 100644 (file)
index 0000000..86a142e
--- /dev/null
@@ -0,0 +1,20 @@
+package org.jetbrains.plugins.gradle.importing.model;
+
+import com.intellij.openapi.roots.DependencyScope;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Implementations of this interface are not obliged to be thread-safe.
+ * 
+ * @author Denis Zhdanov
+ * @since 8/10/11 6:31 PM
+ */
+public interface GradleDependency {
+  
+  boolean isExported();
+
+  @NotNull
+  DependencyScope getScope();
+  
+  void invite(@NotNull GradleDependencyVisitor visitor);
+}
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/GradleDependencyVisitor.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/GradleDependencyVisitor.java
new file mode 100644 (file)
index 0000000..662d80f
--- /dev/null
@@ -0,0 +1,12 @@
+package org.jetbrains.plugins.gradle.importing.model;
+
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author Denis Zhdanov
+ * @since 8/10/11 6:31 PM
+ */
+public interface GradleDependencyVisitor {
+  void visit(@NotNull GradleModuleDependency dependency);
+  void visit(@NotNull GradleLibraryDependency dependency);
+}
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/GradleLibraryDependency.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/GradleLibraryDependency.java
new file mode 100644 (file)
index 0000000..6152842
--- /dev/null
@@ -0,0 +1,25 @@
+package org.jetbrains.plugins.gradle.importing.model;
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Implementations of this interface are not obliged to be thread-safe.
+ * 
+ * @author Denis Zhdanov
+ * @since 8/10/11 6:32 PM
+ */
+public interface GradleLibraryDependency extends GradleDependency {
+
+  @NotNull
+  String getName();
+  
+  /**
+   * Allows to ask for the target path configured for the current library dependency.
+   * 
+   * @param type  target path type
+   * @return      path to the target path configured for the current library dependency
+   */
+  @Nullable
+  String getPath(@NotNull LibraryPathType type);
+}
index a3a67bd2906dd1f781952c746f397b97d072f373..ece63f073df0f0b30b654bb75753a255ba9d272c 100644 (file)
@@ -1,5 +1,10 @@
 package org.jetbrains.plugins.gradle.importing.model;
 
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.Collection;
+
 /**
  * Defines IntelliJ module view to the application configured via gradle.
  * <p/>
@@ -9,4 +14,26 @@ package org.jetbrains.plugins.gradle.importing.model;
  * @since 8/8/11 12:10 PM
  */
 public interface GradleModule {
+  
+  @NotNull
+  String getName();
+  
+  @NotNull
+  Collection<? extends GradleContentRoot> getContentRoots();
+
+  boolean isInheritProjectCompileOutputPath();
+
+  /**
+   * Allows to get file system path of the compile output of the source of the target type.
+   * 
+   * @param type  target source type
+   * @return      file system path to use for compile output for the target source type;
+   *              {@link GradleProject#getCompileOutputPath() project compile output path} should be used if current module
+   *              doesn't provide specific compile output path
+   */
+  @Nullable
+  String getCompileOutputPath(@NotNull SourceType type);
+
+  @NotNull
+  Collection<GradleDependency> getDependencies();
 }
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/GradleModuleDependency.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/GradleModuleDependency.java
new file mode 100644 (file)
index 0000000..ca15ad5
--- /dev/null
@@ -0,0 +1,13 @@
+package org.jetbrains.plugins.gradle.importing.model;
+
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author Denis Zhdanov
+ * @since 8/10/11 6:32 PM
+ */
+public interface GradleModuleDependency extends GradleDependency {
+
+  @NotNull
+  GradleModule getModule();
+}
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/GradleModuleImpl.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/GradleModuleImpl.java
deleted file mode 100644 (file)
index 2535ad2..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.jetbrains.plugins.gradle.importing.model;
-
-import java.io.Serializable;
-
-/**
- * @author Denis Zhdanov
- * @since 8/8/11 12:11 PM
- */
-public class GradleModuleImpl implements GradleModule, Serializable {
-  
-   // TODO den implement
-}
index 3bef2cdb1a3ac48c827fecf8e4b5c004af8a6657..17414c353ba6c106f62f7f82c70602dce19960bd 100644 (file)
@@ -15,6 +15,12 @@ import java.util.Set;
  */
 public interface GradleProject {
 
+  @NotNull
+  String getName();
+
+  @NotNull
+  String getCompileOutputPath();
+  
   @NotNull
   String getJdkName();
   
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/LibraryPathType.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/LibraryPathType.java
new file mode 100644 (file)
index 0000000..b90a3d9
--- /dev/null
@@ -0,0 +1,8 @@
+package org.jetbrains.plugins.gradle.importing.model;
+
+/**
+ * @author Denis Zhdanov
+ * @since 8/10/11 6:37 PM
+ */
+public enum LibraryPathType {
+  BINARY, SOURCE, JAVADOC}
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/SourceType.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/SourceType.java
new file mode 100644 (file)
index 0000000..ceef116
--- /dev/null
@@ -0,0 +1,11 @@
+package org.jetbrains.plugins.gradle.importing.model;
+
+/**
+ * Enumerates module source types.
+ * 
+ * @author Denis Zhdanov
+ * @since 8/10/11 5:21 PM
+ */
+public enum SourceType {
+  SOURCE, TEST, EXCLUDED
+}
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/impl/AbstractGradleDependency.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/impl/AbstractGradleDependency.java
new file mode 100644 (file)
index 0000000..58f6a0d
--- /dev/null
@@ -0,0 +1,43 @@
+package org.jetbrains.plugins.gradle.importing.model.impl;
+
+import com.intellij.openapi.roots.DependencyScope;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.plugins.gradle.importing.model.GradleDependency;
+
+import java.io.Serializable;
+
+/**
+ * @author Denis Zhdanov
+ * @since 8/10/11 6:41 PM
+ */
+public abstract class AbstractGradleDependency implements GradleDependency, Serializable {
+
+  private static final long serialVersionUID = 1L;
+  
+  private DependencyScope myScope = DependencyScope.COMPILE;
+  private boolean myExported;
+  
+  @NotNull
+  @Override
+  public DependencyScope getScope() {
+    return myScope;
+  }
+
+  public void setScope(DependencyScope scope) {
+    myScope = scope;
+  }
+
+  @Override
+  public boolean isExported() {
+    return myExported;
+  }
+
+  public void setExported(boolean exported) {
+    myExported = exported;
+  }
+
+  @Override
+  public String toString() {
+    return "scope: " + getScope() + ", exported: " + isExported();
+  }
+}
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/impl/GradleContentRootImpl.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/impl/GradleContentRootImpl.java
new file mode 100644 (file)
index 0000000..4d8c5ea
--- /dev/null
@@ -0,0 +1,63 @@
+package org.jetbrains.plugins.gradle.importing.model.impl;
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.plugins.gradle.importing.model.GradleContentRoot;
+import org.jetbrains.plugins.gradle.importing.model.SourceType;
+
+import java.io.File;
+import java.io.Serializable;
+import java.util.*;
+
+/**
+ * @author Denis Zhdanov
+ * @since 8/9/11 6:25 PM
+ */
+public class GradleContentRootImpl implements Serializable, GradleContentRoot {
+
+  private static final long serialVersionUID = 1L;
+  
+  private final Map<SourceType, Collection<String>> myData  = new EnumMap<SourceType, Collection<String>>(SourceType.class);
+  private final Map<SourceType, Collection<String>> myViews = new EnumMap<SourceType, Collection<String>>(SourceType.class);
+  
+  private final String myRootPath;
+
+  /**
+   * Creates new <code>GradleContentRootImpl</code> object.
+   * 
+   * @param rootPath  path to the root directory
+   */
+  public GradleContentRootImpl(@NotNull String rootPath) {
+    myRootPath = new File(rootPath).getAbsolutePath();
+    for (SourceType type : SourceType.values()) {
+      Set<String> data = new HashSet<String>();
+      myData.put(type, data);
+      myViews.put(type, Collections.unmodifiableCollection(data));
+    }
+  }
+
+  @NotNull
+  @Override
+  public Collection<String> getPaths(@NotNull SourceType type) {
+    return myViews.get(type);
+  }
+
+  public void storePath(@NotNull SourceType type, @NotNull String path) {
+    myData.get(type).add(new File(path).getAbsolutePath());
+  }
+  
+  @NotNull
+  @Override
+  public String getRootPath() {
+    return myRootPath;
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder buffer = new StringBuilder();
+    for (Map.Entry<SourceType, Collection<String>> entry : myData.entrySet()) {
+      buffer.append(entry.getKey().toString().toLowerCase()).append(": ").append(entry.getValue()).append("; ");
+    }
+    buffer.setLength(buffer.length() - 2);
+    return buffer.toString();
+  }
+}
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/impl/GradleLibraryDependencyImpl.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/impl/GradleLibraryDependencyImpl.java
new file mode 100644 (file)
index 0000000..210acbb
--- /dev/null
@@ -0,0 +1,55 @@
+package org.jetbrains.plugins.gradle.importing.model.impl;
+
+import com.intellij.util.containers.HashMap;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.gradle.importing.model.GradleDependencyVisitor;
+import org.jetbrains.plugins.gradle.importing.model.GradleLibraryDependency;
+import org.jetbrains.plugins.gradle.importing.model.LibraryPathType;
+
+import java.io.File;
+import java.io.Serializable;
+import java.util.Map;
+
+/**
+ * @author Denis Zhdanov
+ * @since 8/10/11 6:46 PM
+ */
+public class GradleLibraryDependencyImpl extends AbstractGradleDependency implements GradleLibraryDependency, Serializable {
+
+  private static final long serialVersionUID = 1L;
+
+  private final Map<LibraryPathType, String> myPaths = new HashMap<LibraryPathType, String>();
+  
+  private final String myName;
+
+  public GradleLibraryDependencyImpl(@NotNull String name) {
+    myName = name;
+  }
+
+  @NotNull
+  @Override
+  public String getName() {
+    return myName;
+  }
+
+  @Nullable
+  @Override
+  public String getPath(@NotNull LibraryPathType type) {
+    return myPaths.get(type);
+  }
+  
+  public void addPath(@NotNull LibraryPathType type, @NotNull String path) {
+    myPaths.put(type, new File(path).getAbsolutePath());
+  }
+
+  @Override
+  public void invite(@NotNull GradleDependencyVisitor visitor) {
+    visitor.visit(this); 
+  }
+
+  @Override
+  public String toString() {
+    return super.toString() + ", library: " + getName();
+  }
+}
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/impl/GradleModuleDependencyImpl.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/impl/GradleModuleDependencyImpl.java
new file mode 100644 (file)
index 0000000..f802d0e
--- /dev/null
@@ -0,0 +1,39 @@
+package org.jetbrains.plugins.gradle.importing.model.impl;
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.plugins.gradle.importing.model.GradleDependencyVisitor;
+import org.jetbrains.plugins.gradle.importing.model.GradleModule;
+import org.jetbrains.plugins.gradle.importing.model.GradleModuleDependency;
+
+import java.io.Serializable;
+
+/**
+ * @author Denis Zhdanov
+ * @since 8/10/11 6:40 PM
+ */
+public class GradleModuleDependencyImpl extends AbstractGradleDependency implements GradleModuleDependency, Serializable {
+
+  private static final long serialVersionUID = 1L;
+  
+  private final GradleModule myModule;
+
+  public GradleModuleDependencyImpl(@NotNull GradleModule module) {
+    myModule = module;
+  }
+
+  @NotNull
+  @Override
+  public GradleModule getModule() {
+    return myModule;
+  }
+
+  @Override
+  public void invite(@NotNull GradleDependencyVisitor visitor) {
+    visitor.visit(this); 
+  }
+
+  @Override
+  public String toString() {
+    return super.toString() + ", dependency module: " + getModule();
+  }
+}
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/impl/GradleModuleImpl.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/impl/GradleModuleImpl.java
new file mode 100644 (file)
index 0000000..232699d
--- /dev/null
@@ -0,0 +1,92 @@
+package org.jetbrains.plugins.gradle.importing.model.impl;
+
+import com.intellij.util.containers.HashMap;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.gradle.importing.model.GradleContentRoot;
+import org.jetbrains.plugins.gradle.importing.model.GradleDependency;
+import org.jetbrains.plugins.gradle.importing.model.GradleModule;
+import org.jetbrains.plugins.gradle.importing.model.SourceType;
+
+import java.io.File;
+import java.io.Serializable;
+import java.util.*;
+
+/**
+ * @author Denis Zhdanov
+ * @since 8/8/11 12:11 PM
+ */
+public class GradleModuleImpl implements GradleModule, Serializable {
+
+  private static final long serialVersionUID = 1L;
+
+  private final List<GradleContentRoot>      myContentRoots       = new ArrayList<GradleContentRoot>();
+  private final Map<SourceType, String>      myCompileOutputPaths = new HashMap<SourceType, String>();
+  private final Set<GradleDependency>        myDependencies       = new HashSet<GradleDependency>();
+  private final Collection<GradleDependency> myDependenciesView   = Collections.unmodifiableCollection(myDependencies);
+  
+  private boolean myInheritProjectCompileOutputPath = true;
+  
+  private final String myName;
+
+  public GradleModuleImpl(@NotNull String name) {
+    myName = name;
+  }
+
+  @NotNull
+  @Override
+  public String getName() {
+    return myName;
+  }
+
+  @NotNull
+  @Override
+  public Collection<GradleContentRoot> getContentRoots() {
+    return myContentRoots;
+  }
+
+  public void addContentRoot(@NotNull GradleContentRoot contentRoot) {
+    myContentRoots.add(contentRoot);
+  }
+
+  @Override
+  public boolean isInheritProjectCompileOutputPath() {
+    return myInheritProjectCompileOutputPath;
+  }
+
+  public void setInheritProjectCompileOutputPath(boolean inheritProjectCompileOutputPath) {
+    myInheritProjectCompileOutputPath = inheritProjectCompileOutputPath;
+  }
+
+  @Nullable
+  @Override
+  public String getCompileOutputPath(@NotNull SourceType type) {
+    return myCompileOutputPaths.get(type);
+  }
+
+  public void setCompileOutputPath(@NotNull SourceType type, @Nullable String path) {
+    if (path == null) {
+      myCompileOutputPaths.remove(type);
+      return;
+    }
+    myCompileOutputPaths.put(type, new File(path).getAbsolutePath());
+  }
+
+  @NotNull
+  @Override
+  public Collection<GradleDependency> getDependencies() {
+    return myDependenciesView;
+  }
+
+  public void addDependency(@NotNull GradleDependency dependency) {
+    myDependencies.add(dependency);
+  }
+
+  @Override
+  public String toString() {
+    return String.format(
+      "module '%s'. Content roots: %s; inherit compile output path: %b",
+      getName(), getContentRoots(), isInheritProjectCompileOutputPath()
+    );
+  }
+}
similarity index 57%
rename from plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/GradleProjectImpl.java
rename to plugins/gradle/src/org/jetbrains/plugins/gradle/importing/model/impl/GradleProjectImpl.java
index cac370ab1144709fdfd53c7136c6cc23195a2ecb..2538fc48bb0e225de6533d908e0de95e79f3979e 100644 (file)
@@ -1,9 +1,12 @@
-package org.jetbrains.plugins.gradle.importing.model;
+package org.jetbrains.plugins.gradle.importing.model.impl;
 
 import com.intellij.pom.java.LanguageLevel;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.gradle.importing.model.GradleModule;
+import org.jetbrains.plugins.gradle.importing.model.GradleProject;
 
+import java.io.File;
 import java.io.Serializable;
 import java.util.HashSet;
 import java.util.Set;
@@ -17,22 +20,48 @@ import java.util.Set;
 public class GradleProjectImpl implements Serializable, GradleProject {
 
   private static final long serialVersionUID = 1L;
+  
   private static final LanguageLevel DEFAULT_LANGUAGE_LEVEL = LanguageLevel.JDK_1_6;
   private static final String        DEFAULT_JDK            = "1.6";
 
   private final Set<GradleModuleImpl> myModules = new HashSet<GradleModuleImpl>();
 
+  private final String myCompileOutputPath;
+  
+  private String        myName          = "unnamed";
   private String        myJdk           = DEFAULT_JDK;
   private LanguageLevel myLanguageLevel = DEFAULT_LANGUAGE_LEVEL;
-  
+
+  public GradleProjectImpl(@NotNull String compileOutputPath) {
+    myCompileOutputPath = new File(compileOutputPath).getAbsolutePath();
+  }
+
+  @NotNull
+  @Override
+  public String getName() {
+    return myName;
+  }
+
+  public void setName(@NotNull String name) {
+    myName = name;
+  }
+
+  @NotNull
+  @Override
+  public String getCompileOutputPath() {
+    return myCompileOutputPath;
+  }
+
   @NotNull
   @Override
   public String getJdkName() {
     return myJdk;
   }
 
-  public void setJdk(@NotNull String jdk) {
-    myJdk = jdk;
+  public void setJdk(@Nullable String jdk) {
+    if (jdk != null) {
+      myJdk = jdk;
+    }
   }
 
   @NotNull
@@ -57,4 +86,10 @@ public class GradleProjectImpl implements Serializable, GradleProject {
   public Set<? extends GradleModule> getModules() {
     return myModules;
   }
+
+  @Override
+  public String toString() {
+    return String.format("project '%s'. Jdk: '%s', language level: '%s', modules: %s",
+                         getName(), getJdkName(), getLanguageLevel(), getModules());
+  }
 }
index 67c31cbb67e018d29bd1c9360791b07c63ca97a8..bc10da87ac3e16e9c1695061fa954b5e383e6fd3 100644 (file)
@@ -10,6 +10,7 @@ import com.intellij.openapi.progress.ProgressIndicator;
 import com.intellij.openapi.progress.ProgressManager;
 import com.intellij.openapi.progress.Task;
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.project.ProjectManager;
 import com.intellij.openapi.roots.ui.configuration.ModulesProvider;
 import com.intellij.packaging.artifacts.ModifiableArtifactModel;
 import com.intellij.projectImport.ProjectImportBuilder;
@@ -17,7 +18,7 @@ import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.plugins.gradle.importing.model.GradleProject;
 import org.jetbrains.plugins.gradle.remote.GradleApiFacadeManager;
-import org.jetbrains.plugins.gradle.remote.api.GradleProjectResolver;
+import org.jetbrains.plugins.gradle.remote.GradleProjectResolver;
 import org.jetbrains.plugins.gradle.util.GradleBundle;
 import org.jetbrains.plugins.gradle.util.GradleIcons;
 import org.jetbrains.plugins.gradle.util.GradleLog;
@@ -134,10 +135,12 @@ public class GradleProjectImportBuilder extends ProjectImportBuilder<GradleProje
       throw new ConfigurationException(GradleBundle.message("gradle.import.text.error.directory.instead.file"));
     }
     try {
-      ProgressManager.getInstance().run(new Task.Modal(null, GradleBundle.message("gradle.import.progress.text"), true) {
+      // TODO den derive target project for 'import module from gradle'.
+      Project project = ProjectManager.getInstance().getDefaultProject();
+      ProgressManager.getInstance().run(new Task.Modal(project, GradleBundle.message("gradle.import.progress.text"), true) {
         @Override
         public void run(@NotNull ProgressIndicator indicator) {
-          GradleApiFacadeManager manager = ServiceManager.getService(GradleApiFacadeManager.class);
+          GradleApiFacadeManager manager = ServiceManager.getService(getProject(), GradleApiFacadeManager.class);
           try {
             GradleProjectResolver resolver = manager.getFacade().getResolver();
             myGradleProject = resolver.resolveProjectInfo(myProjectFile.getAbsolutePath());
similarity index 96%
rename from plugins/gradle/src/org/jetbrains/plugins/gradle/remote/api/GradleApiFacade.java
rename to plugins/gradle/src/org/jetbrains/plugins/gradle/remote/GradleApiFacade.java
index cdf8334d9d8bf86d2dad546e9c8b4cd16329e124..3699fd64f53e84319f937cf2705735a5d98efcb7 100644 (file)
@@ -1,4 +1,4 @@
-package org.jetbrains.plugins.gradle.remote.api;
+package org.jetbrains.plugins.gradle.remote;
 
 import org.jetbrains.annotations.NotNull;
 
index 9dec3e3e33553ca78e7f49deecaba98ed84bc35c..7b896c53b71ff495709907b7aa0e4bcfc1d5015f 100644 (file)
@@ -29,8 +29,6 @@ import com.intellij.util.SystemProperties;
 import com.intellij.util.containers.ContainerUtil;
 import gnu.trove.THashSet;
 import org.jetbrains.annotations.NotNull;
-import org.jetbrains.plugins.gradle.remote.api.GradleApiFacade;
-import org.jetbrains.plugins.gradle.remote.api.RemoteGradleProcessSettings;
 import org.jetbrains.plugins.gradle.remote.impl.GradleApiFacadeImpl;
 import org.jetbrains.plugins.gradle.util.GradleBundle;
 import org.jetbrains.plugins.gradle.util.GradleLibraryManager;
@@ -124,7 +122,8 @@ public class GradleApiFacadeManager {
         params.setMainClass(MAIN_CLASS_NAME);
         
         params.getVMParametersList().addParametersString("-Djava.awt.headless=true -Xmx512m");
-        //params.getVMParametersList().addParametersString("-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5009");
+        // TODO den comment
+        params.getVMParametersList().addParametersString("-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5009");
         return params;
       }
 
similarity index 96%
rename from plugins/gradle/src/org/jetbrains/plugins/gradle/remote/api/GradleProjectResolver.java
rename to plugins/gradle/src/org/jetbrains/plugins/gradle/remote/GradleProjectResolver.java
index 4548b245ac95d4e0969b2340621fc3c19ae80c98..bc34e487f7f35cd90a733ca46fa63b4c84b3bbad 100644 (file)
@@ -1,4 +1,4 @@
-package org.jetbrains.plugins.gradle.remote.api;
+package org.jetbrains.plugins.gradle.remote;
 
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.plugins.gradle.importing.model.GradleProject;
similarity index 89%
rename from plugins/gradle/src/org/jetbrains/plugins/gradle/remote/api/RemoteGradleService.java
rename to plugins/gradle/src/org/jetbrains/plugins/gradle/remote/RemoteGradleService.java
index 0a8024857a66c73fdc2096d11afdd4010977b3af..f81a5b8ce77a8b85e7302d55e8e6efeef7324268 100644 (file)
@@ -1,4 +1,4 @@
-package org.jetbrains.plugins.gradle.remote.api;
+package org.jetbrains.plugins.gradle.remote;
 
 import org.jetbrains.annotations.NotNull;
 
index 0f36a6334868b311797781253706e4c471d9a3d2..580c4fc4ca9f9dd1b58e2fa21229e2fbcc7c5a42 100644 (file)
@@ -3,10 +3,10 @@ package org.jetbrains.plugins.gradle.remote.impl;
 import com.intellij.execution.rmi.RemoteServer;
 import com.intellij.util.containers.ConcurrentHashMap;
 import org.jetbrains.annotations.NotNull;
-import org.jetbrains.plugins.gradle.remote.api.GradleApiFacade;
-import org.jetbrains.plugins.gradle.remote.api.GradleProjectResolver;
-import org.jetbrains.plugins.gradle.remote.api.RemoteGradleProcessSettings;
-import org.jetbrains.plugins.gradle.remote.api.RemoteGradleService;
+import org.jetbrains.plugins.gradle.remote.GradleApiFacade;
+import org.jetbrains.plugins.gradle.remote.GradleProjectResolver;
+import org.jetbrains.plugins.gradle.remote.RemoteGradleProcessSettings;
+import org.jetbrains.plugins.gradle.remote.RemoteGradleService;
 
 import java.rmi.Remote;
 import java.rmi.RemoteException;
index f2953845d909e1cf2782a6ba1bf82be5a6ab0360..9fbba75f3f1d2a4a5c9b9026676b21d309926c47 100644 (file)
@@ -1,20 +1,27 @@
 package org.jetbrains.plugins.gradle.remote.impl;
 
 import com.intellij.execution.rmi.RemoteObject;
+import com.intellij.openapi.roots.DependencyScope;
+import com.intellij.util.containers.HashMap;
 import org.gradle.tooling.GradleConnector;
 import org.gradle.tooling.ProjectConnection;
-import org.gradle.tooling.model.idea.OfflineIdeaProject;
+import org.gradle.tooling.model.DomainObjectSet;
+import org.gradle.tooling.model.idea.*;
 import org.jetbrains.annotations.NotNull;
-import org.jetbrains.plugins.gradle.importing.model.GradleProject;
-import org.jetbrains.plugins.gradle.importing.model.GradleProjectImpl;
-import org.jetbrains.plugins.gradle.remote.api.GradleProjectResolver;
-import org.jetbrains.plugins.gradle.remote.api.RemoteGradleProcessSettings;
-import org.jetbrains.plugins.gradle.remote.api.RemoteGradleService;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.gradle.importing.model.*;
+import org.jetbrains.plugins.gradle.importing.model.impl.*;
+import org.jetbrains.plugins.gradle.remote.GradleProjectResolver;
+import org.jetbrains.plugins.gradle.remote.RemoteGradleProcessSettings;
+import org.jetbrains.plugins.gradle.remote.RemoteGradleService;
 import org.jetbrains.plugins.gradle.util.GradleBundle;
 import org.jetbrains.plugins.gradle.util.GradleLog;
 
 import java.io.File;
 import java.rmi.RemoteException;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.TimeUnit;
@@ -44,13 +51,219 @@ public class GradleProjectResolverImpl extends RemoteObject implements GradlePro
   private GradleProject doResolve(@NotNull String projectPath) {
     ProjectConnection connection = getConnection(projectPath);
     OfflineIdeaProject project = connection.getModel(OfflineIdeaProject.class);
-    GradleProjectImpl result = new GradleProjectImpl();
+    GradleProjectImpl result = populateProject(project, projectPath);
+    populateModules(project, result);
+    return result;
+  }
+
+  private static GradleProjectImpl populateProject(@NotNull IdeaProject project, @NotNull String projectPath) {
+    // TODO den retrieve the value from the gradle api as soon as it's ready
+    GradleProjectImpl result = new GradleProjectImpl(new File(projectPath).getParentFile().getAbsolutePath() + "/out");
+    result.setName(project.getName());
     result.setJdk(project.getJdkName());
     result.setLanguageLevel(project.getLanguageLevel().getLevel());
-    // TODO den build modules here
     return result;
   }
 
+  private static void populateModules(@NotNull IdeaProject gradleProject, @NotNull GradleProjectImpl intellijProject)
+    throws IllegalStateException
+  {
+    DomainObjectSet<? extends IdeaModule> gradleModules = gradleProject.getModules();
+    if (gradleModules == null || gradleModules.isEmpty()) {
+      throw new IllegalStateException("No modules found for the target project: " + gradleProject);
+    }
+    Map<String, GradleModule> modules = new HashMap<String, GradleModule>();
+    for (IdeaModule gradleModule : gradleModules) {
+      if (gradleModule == null) {
+        continue;
+      }
+      GradleModuleImpl module = populateModule(gradleModule, intellijProject);
+      String moduleName = module.getName();
+      GradleModule previouslyParsedModule = modules.get(moduleName);
+      if (modules.containsKey(moduleName)) {
+        throw new IllegalStateException(
+          String.format("Modules with duplicate name (%s) detected: '%s' and '%s'", moduleName, module, previouslyParsedModule)
+        );
+      }
+      modules.put(moduleName, module);
+      intellijProject.addModule(module);
+    }
+  }
+
+  @NotNull
+  private static GradleModuleImpl populateModule(@NotNull IdeaModule gradleModule, @NotNull GradleProject intellijProject)
+    throws IllegalStateException
+  {
+    String name = gradleModule.getName();
+    if (name == null) {
+      throw new IllegalStateException("Module with undefined name detected: " + gradleModule);
+    } 
+    GradleModuleImpl result = new GradleModuleImpl(name);
+    populateContentRoots(gradleModule, result);
+    populateCompileOutputSettings(gradleModule.getCompilerOutput(), result);
+    populateDependencies(gradleModule, result, intellijProject);
+    return result;
+  }
+
+  private static void populateContentRoots(@NotNull IdeaModule gradleModule, @NotNull GradleModuleImpl intellijModule) {
+    DomainObjectSet<? extends IdeaContentRoot> contentRoots = gradleModule.getContentRoots();
+    if (contentRoots == null) {
+      return;
+    }
+    for (IdeaContentRoot gradleContentRoot : contentRoots) {
+      if (gradleContentRoot == null) {
+        continue;
+      }
+      File rootDirectory = gradleContentRoot.getRootDirectory();
+      if (rootDirectory == null) {
+        continue;
+      }
+      GradleContentRootImpl intellijContentRoot = new GradleContentRootImpl(rootDirectory.getAbsolutePath());
+      populateContentRoot(intellijContentRoot, SourceType.SOURCE, gradleContentRoot.getSourceDirectories());
+      populateContentRoot(intellijContentRoot, SourceType.TEST, gradleContentRoot.getTestDirectories());
+      Set<File> excluded = gradleContentRoot.getExcludeDirectories();
+      if (excluded != null) {
+        for (File file : excluded) {
+          intellijContentRoot.storePath(SourceType.EXCLUDED, file.getAbsolutePath());
+        }
+      }
+      intellijModule.addContentRoot(intellijContentRoot);
+    }
+  }
+  
+  private static void populateContentRoot(@NotNull GradleContentRootImpl contentRoot, SourceType type,
+                                          @Nullable Iterable<? extends IdeaSourceDirectory> dirs) {
+    if (dirs == null) {
+      return;
+    }
+    for (IdeaSourceDirectory dir : dirs) {
+      contentRoot.storePath(type, dir.getDirectory().getAbsolutePath());
+    }
+  }
+  
+  private static void populateCompileOutputSettings(@Nullable IdeaCompilerOutput gradleSettings,
+                                                    @NotNull GradleModuleImpl intellijModule) {
+    if (gradleSettings == null) {
+      return;
+    }
+    intellijModule.setInheritProjectCompileOutputPath(gradleSettings.getInheritOutputDirs());
+
+    File sourceCompileOutputPath = gradleSettings.getOutputDir();
+    if (sourceCompileOutputPath != null) {
+      intellijModule.setCompileOutputPath(SourceType.SOURCE, sourceCompileOutputPath.getAbsolutePath());
+    }
+
+    File testCompileOutputPath = gradleSettings.getTestOutputDir();
+    if (testCompileOutputPath != null) {
+      intellijModule.setCompileOutputPath(SourceType.TEST, testCompileOutputPath.getAbsolutePath());
+    }
+  }
+
+  private static void populateDependencies(@NotNull IdeaModule gradleModule, @NotNull GradleModuleImpl intellijModule, 
+                                           @NotNull GradleProject intellijProject)
+  {
+    DomainObjectSet<? extends IdeaDependency> dependencies = gradleModule.getDependencies();
+    if (dependencies == null) {
+      return;
+    }
+    for (IdeaDependency dependency : dependencies) {
+      if (dependency == null) {
+        continue;
+      }
+      AbstractGradleDependency intellijDependency = null;
+      if (dependency instanceof IdeaModuleDependency) {
+        intellijDependency = buildDependency((IdeaModuleDependency)dependency, intellijProject);
+      }
+      else if (dependency instanceof IdeaSingleEntryLibraryDependency) {
+        intellijDependency = buildDependency((IdeaSingleEntryLibraryDependency)dependency);
+      }
+
+      if (intellijDependency == null) {
+        continue;
+      }
+      
+      intellijDependency.setExported(dependency.getExported());
+      DependencyScope scope = parseScope(dependency.getScope());
+      if (scope != null) {
+        intellijDependency.setScope(scope);
+      }
+      intellijModule.addDependency(intellijDependency);
+    }
+  }
+
+  private static AbstractGradleDependency buildDependency(@NotNull IdeaModuleDependency dependency, @NotNull GradleProject intellijProject)
+    throws IllegalStateException
+  {
+    IdeaModule module = dependency.getDependencyModule();
+    if (module == null) {
+      throw new IllegalStateException(
+        String.format("Can't parse gradle module dependency '%s'. Reason: referenced module is null", dependency)
+      );
+    }
+
+    String moduleName = module.getName();
+    if (moduleName == null) {
+      throw new IllegalStateException(String.format(
+        "Can't parse gradle module dependency '%s'. Reason: referenced module name is undefined (module: '%s') ", dependency, module
+      ));
+    }
+    
+    Set<String> registeredModuleNames = new HashSet<String>();
+    for (GradleModule gradleModule : intellijProject.getModules()) {
+      registeredModuleNames.add(gradleModule.getName());
+      if (gradleModule.getName().equals(moduleName)) {
+        return new GradleModuleDependencyImpl(gradleModule);
+      }
+    }
+    throw new IllegalStateException(String.format(
+      "Can't parse gradle module dependency '%s'. Reason: no module with such name (%s) is found. Registered modules: %s",
+      dependency, moduleName, registeredModuleNames
+    ));
+  }
+
+  private static AbstractGradleDependency buildDependency(@NotNull IdeaSingleEntryLibraryDependency dependency)
+    throws IllegalStateException
+  {
+    File binaryPath = dependency.getFile();
+    if (binaryPath == null) {
+      throw new IllegalStateException(String.format(
+        "Can't parse external library dependency '%s'. Reason: it doesn't specify path to the binaries", dependency
+      ));
+    }
+    
+    // TODO den use library name from gradle api when it's ready
+    GradleLibraryDependencyImpl result = new GradleLibraryDependencyImpl(binaryPath.getName());
+    result.addPath(LibraryPathType.BINARY, binaryPath.getAbsolutePath());
+
+    File sourcePath = dependency.getSource();
+    if (sourcePath != null) {
+      result.addPath(LibraryPathType.SOURCE, sourcePath.getAbsolutePath());
+    }
+
+    File javadocPath = dependency.getJavadoc();
+    if (javadocPath != null) {
+      result.addPath(LibraryPathType.JAVADOC, javadocPath.getAbsolutePath());
+    }
+    return result;
+  }
+
+  @Nullable
+  private static DependencyScope parseScope(@Nullable IdeaDependencyScope scope) {
+    if (scope == null) {
+      return null;
+    }
+    String scopeAsString = scope.getScope();
+    if (scopeAsString == null) {
+      return null;
+    }
+    for (DependencyScope dependencyScope : DependencyScope.values()) {
+      if (scopeAsString.equalsIgnoreCase(dependencyScope.toString())) {
+        return dependencyScope;
+      }
+    }
+    return null;
+  }
+  
   /**
    * Allows to retrieve gradle api connection to use for the given project.
    * 
index 653df2813948258971c243073dc8b74eea52a379..9959c5a70328c4b3b9ae3c6197b6aee49bd4ec29 100644 (file)
@@ -1,6 +1,6 @@
 package com.intellij.lang.properties.xml;
 
-import com.intellij.util.indexing.FileContent;
+import com.intellij.util.indexing.FileContentImpl;
 import junit.framework.TestCase;
 
 import java.util.Map;
@@ -12,7 +12,7 @@ import java.util.Map;
 public class XmlPropertiesIndexTest extends TestCase {
 
   public void testIndex() throws Exception {
-    Map<XmlPropertiesIndex.Key, String> map = new XmlPropertiesIndex().map(new FileContent(("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+    Map<XmlPropertiesIndex.Key, String> map = new XmlPropertiesIndex().map(new FileContentImpl(("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                                                                                             "<!DOCTYPE properties SYSTEM \"http://java.sun.com/dtd/properties.dtd\">\n" +
                                                                                             "<properties>\n" +
                                                                                             "<comment>Hi</comment>\n" +
@@ -27,7 +27,7 @@ public class XmlPropertiesIndexTest extends TestCase {
   }
 
   public void testSystemId() throws Exception {
-    Map<XmlPropertiesIndex.Key, String> map = new XmlPropertiesIndex().map(new FileContent(("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+    Map<XmlPropertiesIndex.Key, String> map = new XmlPropertiesIndex().map(new FileContentImpl(("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                                                                                             "<!DOCTYPE properties SYSTEM \"unknown\">\n" +
                                                                                             "<properties>\n" +
                                                                                             "<comment>Hi</comment>\n" +
index 669a8d191854f9986147d6ea28d941da8bdd8475..87add5bb72fa30a9f62d78c2bbbce78d9da73385 100644 (file)
@@ -288,7 +288,7 @@ position.highlighter.stripe.tooltip=Execution line
 hotswap.dialog.title.with.session=Reload Changed Classes for {0}
 hotswap.dialog.title=Reload Changed Classes
 hotswap.dialog.run.prompt=Some classes have been changed. Reload changed classes now?
-hotswap.dialog.hang.warning=JVM is currently suspended.\nClasses reloading with active third-party JVM agents may cause the JVM to hang.
+hotswap.dialog.hang.warning=JVM is currently suspended.\nReloading classes with active third-party JVM agents may cause the JVM to hang.
 hotswap.dialog.hang.question=Would you like to reload changed classes anyway?
 evaluate.statement.dialog.title=Code Fragment Evaluation
 label.evaluation.dialog.statements=Statements to &evaluate:
index 38d166ac198c3dd45c4372f42746917ac9e4a5c9..fbf98ba62fe04c84d5ecd5661de09d42e85088ce 100644 (file)
     <consoleFilterProvider implementation="com.intellij.execution.filters.DefaultConsoleFiltersProvider"/>
 
 
-    <selectInTarget implementation="com.intellij.ide.impl.ProjectSettingsSelectInTarget"/>
+    <selectInTarget implementation="com.intellij.ide.impl.ProjectStructureSelectInTarget"/>
 
     <OrderRootTypeUI key="JAVADOC"
                      implementationClass="com.intellij.openapi.roots.ui.configuration.libraryEditor.JavadocOrderRootTypeUIFactory"/>