From 09dbc79f9ab26483254034d17fe9fdcc01ba88fb Mon Sep 17 00:00:00 2001 From: Alexey Pegov Date: Wed, 21 Oct 2009 17:47:41 +0400 Subject: [PATCH] absolute paths for external resources -> relative paths + dispose library editors fixes --- .../ui/configuration/libraryEditor/LibraryTableEditor.java | 8 +++++++- .../openapi/components/impl/ModulePathMacroManager.java | 10 +--------- .../openapi/components/impl/ProjectPathMacroManager.java | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryTableEditor.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryTableEditor.java index 4078ff173e..2e12307d4b 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryTableEditor.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryTableEditor.java @@ -263,7 +263,8 @@ public class LibraryTableEditor implements Disposable { } private void removeLibrary(Library library) { - myLibraryToEditorMap.remove(library); + final LibraryEditor libraryEditor = myLibraryToEditorMap.remove(library); + if (libraryEditor != null) Disposer.dispose(libraryEditor); myTableModifiableModel.removeLibrary(library); if (myProject != null){ ModuleStructureConfigurable.getInstance(myProject).fireItemsChangeListener(library); @@ -278,6 +279,7 @@ public class LibraryTableEditor implements Disposable { public void run() { for (LibraryEditor libraryEditor : myLibraryToEditorMap.values()) { libraryEditor.commit(); + Disposer.dispose(libraryEditor); } myTableModifiableModel.commit(); } @@ -287,6 +289,10 @@ public class LibraryTableEditor implements Disposable { } public void cancelChanges() { + for (LibraryEditor libraryEditor : new ArrayList(myLibraryToEditorMap.values())) { + Disposer.dispose(libraryEditor); + } + myLibraryToEditorMap.clear(); } diff --git a/platform/lang-impl/src/com/intellij/openapi/components/impl/ModulePathMacroManager.java b/platform/lang-impl/src/com/intellij/openapi/components/impl/ModulePathMacroManager.java index 190edb0a76..a79c0645fe 100644 --- a/platform/lang-impl/src/com/intellij/openapi/components/impl/ModulePathMacroManager.java +++ b/platform/lang-impl/src/com/intellij/openapi/components/impl/ModulePathMacroManager.java @@ -50,9 +50,8 @@ public class ModulePathMacroManager extends BasePathMacroManager /*ProjectPathMa public ReplacePathToMacroMap getReplacePathMap() { ReplacePathToMacroMap result = new ReplacePathToMacroMap(); - getModuleHomeReplacements(result, false); result.putAll(super.getReplacePathMap()); - getModuleHomeReplacements(result, true); // TODO: change to false and remove previous call to this method to save ABSOLUTE paths + getModuleHomeReplacements(result, true); return result; } @@ -85,19 +84,12 @@ public class ModulePathMacroManager extends BasePathMacroManager /*ProjectPathMa // [dsl]: Q? //if(!f.exists()) return; - final VirtualFile baseDir = myModule.getProject().getBaseDir(); - final String projectParent = baseDir != null && baseDir.getParent() != null ? PathMacroMap.quotePath(baseDir.getParent().getPath()): null; - String macro = "$" + PathMacrosImpl.MODULE_DIR_MACRO_NAME + "$"; boolean check = false; while (f != null) { @NonNls String path = PathMacroMap.quotePath(f.getAbsolutePath()); String s = macro; - if (projectParent != null && path.equals(projectParent)) { - break; // never step out of the project dir - } - if (StringUtil.endsWithChar(path, '/')) s += "/"; if (path.equals("/")) break; diff --git a/platform/platform-impl/src/com/intellij/openapi/components/impl/ProjectPathMacroManager.java b/platform/platform-impl/src/com/intellij/openapi/components/impl/ProjectPathMacroManager.java index 202d640133..225de01201 100644 --- a/platform/platform-impl/src/com/intellij/openapi/components/impl/ProjectPathMacroManager.java +++ b/platform/platform-impl/src/com/intellij/openapi/components/impl/ProjectPathMacroManager.java @@ -44,7 +44,7 @@ public class ProjectPathMacroManager extends BasePathMacroManager { public ReplacePathToMacroMap getReplacePathMap() { ReplacePathToMacroMap result = new ReplacePathToMacroMap(); result.putAll(super.getReplacePathMap()); - getProjectHomeReplacements(result, false); + getProjectHomeReplacements(result, true); return result; } -- 2.11.4.GIT