1.1 --- a/visualweb.complib/src/org/netbeans/modules/visualweb/complib/ComplibServiceProvider.java Sun Apr 22 05:08:19 2007 +0000
1.2 +++ b/visualweb.complib/src/org/netbeans/modules/visualweb/complib/ComplibServiceProvider.java Sun Apr 22 18:15:02 2007 +0000
1.3 @@ -650,7 +650,7 @@
1.4 }
1.5
1.6 /**
1.7 - * Remove existing the legacy Library Refs and Library Defs to an embedded
1.8 + * Remove existing legacy Library Refs and Library Defs to an embedded
1.9 * complib for a particular project.
1.10 *
1.11 * TODO This is a hack b/c there isn't a NB API to get all of the project's
1.12 @@ -666,16 +666,23 @@
1.13 ExtensionComplib projectComplib) throws IOException {
1.14
1.15 /*
1.16 + * FIXME This code does not work because of complicated problems related
1.17 + * to changes in the way Lib Defs and Refs were mapped to NB APIs in
1.18 + * JsfProjectUtils. I think, it would be time consuming to really fix
1.19 + * this so the workaround is to remove old Lib Refs manually via Project
1.20 + * Properties.
1.21 + */
1.22 +
1.23 + /*
1.24 * In VWP 5.5.x or shortfin, there was only a single Lib Def with a
1.25 * "design-time" volume but two separate Lib Refs. However, the API has
1.26 * changed so I don't know if this code will remove both of the exiting
1.27 * Lib Refs.
1.28 */
1.29 - // TODO Test that this works.
1.30 String projectName = project.getProjectDirectory().getName();
1.31 String libName = IdeUtil.removeWhiteSpace(projectName + "_"
1.32 + projectComplib.getDirectoryBaseName());
1.33 - if (removeLibraryDefAndRef(project, libName)) {
1.34 + if (removeLibraryDefAndRef(project, libName, projectComplib)) {
1.35 return;
1.36 }
1.37
1.38 @@ -685,11 +692,11 @@
1.39 */
1.40 libName = IdeUtil.removeWhiteSpace(projectName + " Design-time "
1.41 + projectComplib.getTitle());
1.42 - removeLibraryDefAndRef(project, libName);
1.43 + removeLibraryDefAndRef(project, libName, projectComplib);
1.44
1.45 libName = IdeUtil.removeWhiteSpace(projectName + " Runtime "
1.46 + projectComplib.getTitle());
1.47 - removeLibraryDefAndRef(project, libName);
1.48 + removeLibraryDefAndRef(project, libName, projectComplib);
1.49 }
1.50
1.51 /**
1.52 @@ -697,21 +704,28 @@
1.53 *
1.54 * @param project
1.55 * @param libName
1.56 + * Lib Def name
1.57 + * @param complib
1.58 + * the complib that corresponds to the Lib Def
1.59 * @return
1.60 * @throws IOException
1.61 */
1.62 - private boolean removeLibraryDefAndRef(Project project, String libName)
1.63 - throws IOException {
1.64 + private boolean removeLibraryDefAndRef(Project project, String libName,
1.65 + ExtensionComplib complib) throws IOException {
1.66 boolean found = false;
1.67
1.68 Library libDef = LibraryManager.getDefault().getLibrary(libName);
1.69 if (libDef == null) {
1.70 /*
1.71 * There is no NB API to remove just a Lib Ref so we create a dummy
1.72 - * Lib Def to check if there is a Lib Ref that points to it.
1.73 + * Lib Def to check if there is a Lib Ref that points to it. As of
1.74 + * 2007-04-22, we also need to have a classpath specified or else
1.75 + * JsfProjectUtils.hasLibraryReference(project, libDef) does not
1.76 + * work.
1.77 */
1.78 + List<URL> rtPath = fileListToUrlList(complib.getRuntimePath());
1.79 libDef = JsfProjectUtils.createComponentLibrary(libName, null,
1.80 - null, null, null, null, null);
1.81 + null, rtPath, null, null, null);
1.82 }
1.83
1.84 // Remove an existing Lib Ref