added handling bundled django and django in gae (PY-1296, PY-1854) pycharm/96.1191
authorDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Thu, 16 Sep 2010 11:50:46 +0000 (15:50 +0400)
committerDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Thu, 16 Sep 2010 15:13:09 +0000 (19:13 +0400)
platform/lang-impl/src/com/intellij/openapi/roots/impl/OrderEntryUtil.java

index 73f67ad712c223586f70d7d3a51ab39da1aef3c9..f1eb679aeacb3a31d9db6bd63af66e244902e8bd 100644 (file)
@@ -45,6 +45,29 @@ public class OrderEntryUtil {
     return null;
   }
 
+  @Nullable
+  public static LibraryOrderEntry findLibraryOrderEntry(@NotNull ModuleRootModel model, @NotNull String libraryName) {
+    for (OrderEntry orderEntry : model.getOrderEntries()) {
+      if (orderEntry instanceof LibraryOrderEntry) {
+        final String libName = ((LibraryOrderEntry)orderEntry).getLibraryName();
+        if (libraryName.equals(libName)) {
+          return (LibraryOrderEntry)orderEntry;
+        }
+      }
+    }
+    return null;
+  }
+
+  public static void detachModuleLibrary(@NotNull ModifiableRootModel model, @Nullable OrderEntry entry) {
+    if (entry == null) {
+      model.dispose();
+    }
+    else {
+      model.removeOrderEntry(entry);
+      model.commit();
+    }
+  }
+
   @Nullable
   public static ModuleOrderEntry findModuleOrderEntry(@NotNull ModuleRootModel model, @Nullable Module module) {
     if (module == null) return null;
@@ -73,7 +96,8 @@ public class OrderEntryUtil {
     if (orderEntry1 instanceof JdkOrderEntry && orderEntry2 instanceof JdkOrderEntry) {
       final JdkOrderEntry jdkOrderEntry1 = (JdkOrderEntry)orderEntry1;
       final JdkOrderEntry jdkOrderEntry2 = (JdkOrderEntry)orderEntry2;
-      return Comparing.equal(jdkOrderEntry1.getJdk(), jdkOrderEntry2.getJdk()) && Comparing.strEqual(jdkOrderEntry1.getJdkName(), jdkOrderEntry2.getJdkName());
+      return Comparing.equal(jdkOrderEntry1.getJdk(), jdkOrderEntry2.getJdk()) &&
+             Comparing.strEqual(jdkOrderEntry1.getJdkName(), jdkOrderEntry2.getJdkName());
     }
     if (orderEntry1 instanceof LibraryOrderEntry && orderEntry2 instanceof LibraryOrderEntry) {
       final LibraryOrderEntry jdkOrderEntry1 = (LibraryOrderEntry)orderEntry1;
@@ -123,7 +147,7 @@ public class OrderEntryUtil {
     if (libraryOrderEntry.isModuleLevel()) {
       final Library jarLibrary = rootModel.getModuleLibraryTable().createLibrary();
       final Library.ModifiableModel libraryModel = jarLibrary.getModifiableModel();
-      for(OrderRootType orderRootType: OrderRootType.getAllTypes()) {
+      for (OrderRootType orderRootType : OrderRootType.getAllTypes()) {
         VirtualFile[] files = library.getFiles(orderRootType);
         for (VirtualFile jarFile : files) {
           libraryModel.addRoot(jarFile, orderRootType);