diff --git a/java.api.common/src/org/netbeans/modules/java/api/common/project/ui/customizer/EditMediator.java b/java.api.common/src/org/netbeans/modules/java/api/common/project/ui/customizer/EditMediator.java --- a/java.api.common/src/org/netbeans/modules/java/api/common/project/ui/customizer/EditMediator.java +++ b/java.api.common/src/org/netbeans/modules/java/api/common/project/ui/customizer/EditMediator.java @@ -361,14 +361,15 @@ } else if ( source == addLibrary ) { //TODO this piece needs to go somewhere else? + URL librariesFolder = null; LibraryManager manager = null; boolean empty = false; try { String path = libraryPath.getText(0, libraryPath.getLength()); if (path != null && path.length() > 0) { File fil = PropertyUtils.resolveFile(FileUtil.toFile(helper.getProjectDirectory()), path); - URL url = FileUtil.normalizeFile(fil).toURI().toURL(); - manager = LibraryManager.forLocation(url); + librariesFolder = FileUtil.normalizeFile(fil).toURI().toURL(); + manager = LibraryManager.forLocation(librariesFolder); } else { empty = true; } @@ -387,7 +388,7 @@ } Set added = LibraryChooser.showDialog(manager, - createLibraryFilter(), refHelper.getLibraryChooserImportHandler()); + createLibraryFilter(), empty ? refHelper.getLibraryChooserImportHandler() : refHelper.getLibraryChooserImportHandler(librariesFolder)); if (added != null) { Set includedLibraries = new HashSet(); int[] newSelection = ClassPathUiSupport.addLibraries(listModel, list.getSelectedIndices(), diff --git a/project.ant/apichanges.xml b/project.ant/apichanges.xml --- a/project.ant/apichanges.xml +++ b/project.ant/apichanges.xml @@ -108,6 +108,22 @@ + + + Added getLibraryChooserImportHandler method into ReferenceHelper accepting URL + + + + + +

+ A new method enables a client to specify target folder different from AntProjectHelper.getLibrariesLocation +

+
+ + +
+ Added SourceGroupModifierImplementation implementation for Ant-based projects diff --git a/project.ant/manifest.mf b/project.ant/manifest.mf --- a/project.ant/manifest.mf +++ b/project.ant/manifest.mf @@ -1,6 +1,6 @@ Manifest-Version: 1.0 OpenIDE-Module: org.netbeans.modules.project.ant/1 -OpenIDE-Module-Specification-Version: 1.40 +OpenIDE-Module-Specification-Version: 1.41 OpenIDE-Module-Layer: org/netbeans/modules/project/ant/resources/mf-layer.xml OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/project/ant/Bundle.properties OpenIDE-Module-Install: org/netbeans/modules/project/ant/AntProjectModule.class diff --git a/project.ant/src/org/netbeans/spi/project/support/ant/ReferenceHelper.java b/project.ant/src/org/netbeans/spi/project/support/ant/ReferenceHelper.java --- a/project.ant/src/org/netbeans/spi/project/support/ant/ReferenceHelper.java +++ b/project.ant/src/org/netbeans/spi/project/support/ant/ReferenceHelper.java @@ -49,6 +49,7 @@ import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; +import java.net.URL; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -62,6 +63,7 @@ import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.netbeans.api.annotations.common.NonNull; import org.netbeans.api.project.Project; import org.netbeans.api.project.ProjectManager; import org.netbeans.api.project.ProjectUtils; @@ -1554,9 +1556,9 @@ return lib; } File mainPropertiesFile = h.resolveFile(h.getLibrariesLocation()); - return ProjectLibraryProvider.copyLibrary(lib, mainPropertiesFile.toURI().toURL(), true); + return copyLibrary(lib, mainPropertiesFile.toURI().toURL()); } - + /** * Returns library import handler which imports global library to sharable * one. See {@link LibraryChooser#showDialog} for usage of this handler. @@ -1570,6 +1572,23 @@ } }; } + + /** + * Returns library import handler which imports global library to sharable + * one. See {@link LibraryChooser#showDialog} for usage of this handler. + * @param the URL of the libraries definition file to import the library into + * @return copy handler + * @since org.netbeans.modules.project.ant/1 1.41 + */ + public LibraryChooser.LibraryImportHandler getLibraryChooserImportHandler(final @NonNull URL librariesLocation) { + return new LibraryChooser.LibraryImportHandler() { + @Override + public Library importLibrary(final @NonNull Library library) throws IOException { + return copyLibrary(library, librariesLocation); + } + }; + } + /** * Tries to find a library by name in library manager associated with the project. * It is not guaranteed that any returned library is an identical object to one which passed in to {@link #createLibraryReference}. @@ -1940,5 +1959,10 @@ } } - + + private static Library copyLibrary(final @NonNull Library lib, final @NonNull URL librariesLocation) throws IOException { + Parameters.notNull("lib", lib); //NOI18N + Parameters.notNull("librariesLocation", librariesLocation); //NOI18N + return ProjectLibraryProvider.copyLibrary(lib, librariesLocation, true); + } }