This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 177531

Summary: Edit button for wrapped JAR src & javadoc is initially disabled
Product: apisupport Reporter: Jesse Glick <jglick>
Component: ProjectAssignee: Martin Kozeny <mkozeny>
Status: RESOLVED FIXED    
Severity: normal CC: nigjo_iqn, tkellerer, tzezula
Priority: P4    
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:
Bug Depends on:    
Bug Blocks: 171125    

Description Jesse Glick 2009-11-24 09:15:55 UTC
See https://netbeans.org/bugzilla/show_bug.cgi?id=171125#c4 for description.
Comment 1 Jesse Glick 2010-05-04 20:33:39 UTC
ClassPathSupport.getSourceProperty => null since property = "release/modules/ext/whatever.jar", not matching the reference pattern, so Item.canEdit => false.

The following makes the Edit button be enabled, but setting a source association then has no effect:

diff --git a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/customizer/SingleModuleProperties.java b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/customizer/SingleModuleProperties.java
--- a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/customizer/SingleModuleProperties.java
+++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/customizer/SingleModuleProperties.java
@@ -779,7 +779,11 @@
         for (String s : cpExt) {
             sb.append(s);
         }
-        return getClassPathSupport().itemsIterator(sb.toString(), CPEXT);
+        List<Item> items = getClassPathSupport().itemsList(sb.toString(), CPEXT);
+        for (Item item : items) {
+            item.setReference("${file.reference." + item.getReference() + "}");
+        }
+        return items.iterator();
     }
 
     DefaultListModel getWrappedJarsListModel() {

I'm afraid I hardly understand what any of this code does and it is likely any changes would result in regressions. Perhaps it would be better to stop using ClassPathUiSupport and just write a simple data model from scratch; apisupport's storage of JARs is not much like that of other Ant-based projects.

Workaround is to make source/Javadoc associations when adding the JAR; if already added, delete and readd.
Comment 2 Jesse Glick 2011-11-16 01:12:09 UTC
*** Bug 205051 has been marked as a duplicate of this bug. ***
Comment 3 Jesse Glick 2011-11-16 16:55:18 UTC
Does not matter as much in 7.1 since you do not really need this UI any more; independent of project type, you are offered the opportunity to associate source or Javadoc with a JAR at the point where you actually need it (e.g. code completion in the editor). Possibly the special association system should simply be removed altogether, to simplify code in apisupport.
Comment 4 aldobrucale 2011-11-25 09:05:15 UTC
I had not noticed the "Attach javadoc..." link. I think that the "Edit" button should be preserved, in case one has set the wrong directory.

I still can't find how to attach the sources.
Comment 5 Jesse Glick 2011-11-30 13:43:53 UTC
(In reply to comment #4)
> I think that the "Edit" button
> should be preserved, in case one has set the wrong directory.

Probably needs to be addressed more generically in source attacher in java.j2seplatform, though I am not sure what the UI should be - maybe some dialog listing previously attached source and Javadoc locations with a Remove button.

> I still can't find how to attach the sources.

Whenever you get a generated source skeleton - Ctrl-B, Ctrl-O, etc. on a class in the library - there will be a button at the top of the editor to attach real sources.
Comment 6 aldobrucale 2011-12-01 14:21:13 UTC
Thank you, I've just seen it. The "Attach sources" button on the far right of the editor window is not very noticeable, expecially on 16:9 displays... And it doesn't seem to work in nb 7.1 RC1, I'll file separate issues about this.
Comment 7 Martin Kozeny 2014-01-06 12:58:31 UTC
Using Jesse's solution: https://hg.netbeans.org/core-main/rev/248186aaf91f, probably there is no other. Connected to https://netbeans.org/bugzilla/show_bug.cgi?id=240022.