Bug 368015 - Support for source attachment encoding at classpath entry level
Summary: Support for source attachment encoding at classpath entry level
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.8   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 3.8 M5   Edit
Assignee: Deepak Azad CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 361356
Blocks:
  Show dependency tree
 
Reported: 2012-01-06 05:34 EST by Jay Arthanareeswaran CLA
Modified: 2012-01-23 09:54 EST (History)
3 users (show)

See Also:


Attachments
screenshot of new design - 1 (74.68 KB, image/png)
2012-01-18 10:56 EST, Deepak Azad CLA
no flags Details
screenshot of new design - 2 (75.55 KB, image/png)
2012-01-18 10:56 EST, Deepak Azad CLA
no flags Details
fix (25.79 KB, patch)
2012-01-19 04:55 EST, Deepak Azad CLA
no flags Details | Diff
screenshot of new design - 1 (71.42 KB, text/plain)
2012-01-19 07:02 EST, Deepak Azad CLA
no flags Details
screenshot of new design - 1 (71.42 KB, image/png)
2012-01-19 07:04 EST, Deepak Azad CLA
no flags Details
additional fix - work in progress (13.99 KB, patch)
2012-01-20 15:45 EST, Deepak Azad CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jay Arthanareeswaran CLA 2012-01-06 05:34:55 EST
Refer to bug #361356.

We have to be able to specify encoding for classpath entries, which can be used for source attachments. The encoding will be stored on the classpath using an extra classpath attribute. For more details, look at bug 361356.
Comment 1 Jay Arthanareeswaran CLA 2012-01-17 03:39:53 EST
Any chance of this going for M5? As Dani mentioned here (bug 361356, comment #14), this also sort of blocks bug 361356.
Comment 2 Dani Megert CLA 2012-01-17 05:25:11 EST
Deepak, please also review/verify the Core part.
Comment 3 Deepak Azad CLA 2012-01-18 10:56:37 EST
Created attachment 209686 [details]
screenshot of new design - 1

I am almost done with the UI (testing things now) and just need a quick feedback on the layout of various controls in the UI. Dani, what do you think?
Comment 4 Deepak Azad CLA 2012-01-18 10:56:59 EST
Created attachment 209687 [details]
screenshot of new design - 2
Comment 5 Deepak Azad CLA 2012-01-19 04:55:38 EST
Created attachment 209731 [details]
fix

The patch should be good to go. 

The UI allows specifying the encoding for source attachments which are not in workspace or the corresponding classpath entry is of type IClasspathEntry.CPE_VARIABLE.
Comment 6 Deepak Azad CLA 2012-01-19 07:02:39 EST
Created attachment 209737 [details]
screenshot of new design - 1

Updated screenshot.
Comment 7 Deepak Azad CLA 2012-01-19 07:04:57 EST
Created attachment 209738 [details]
screenshot of new design - 1

Something went wrong the last time.
Comment 8 Dani Megert CLA 2012-01-19 10:54:13 EST
Looks good overall. Tested the known paths. Two things I noticed:
- The encoding field is empty for the rt.jar's source. Should be the OS 
  encoding.

- When editing the rt.jar's source I'd expect that src.jar is selected and I can
  hit 'Open' in the dialog.
Comment 9 Dani Megert CLA 2012-01-19 11:00:25 EST
Ah, and please update the doc.
Comment 10 Deepak Azad CLA 2012-01-19 13:22:44 EST
(In reply to comment #8)
> Looks good overall. Tested the known paths. Two things I noticed:
> - The encoding field is empty for the rt.jar's source. Should be the OS 
>   encoding.
Will it always be 'OS encoding'? If yes, should the combo control for encoding be disabled in this case?

I guess the same behavior should apply to jars from plug-in container or any other container for that matter, no?

> - When editing the rt.jar's source I'd expect that src.jar is selected and I
> can
>   hit 'Open' in the dialog.
This is old behavior :-) Should not be difficult to fix though.
Comment 11 Dani Megert CLA 2012-01-19 16:15:28 EST
(In reply to comment #10)
> (In reply to comment #8)
> > Looks good overall. Tested the known paths. Two things I noticed:
> > - The encoding field is empty for the rt.jar's source. Should be the OS 
> >   encoding.
> Will it always be 'OS encoding'? 
What else do you expect?

> If yes, should the combo control for encoding
> be disabled in this case?

??? Not really, right? The key is to allow to change this. But the default should be shown.
Comment 12 Deepak Azad CLA 2012-01-20 02:11:26 EST
(In reply to comment #11)
> > Will it always be 'OS encoding'? 
> What else do you expect?
I guess you want that in case the user has not specified the encoding for a jar we show the default encoding just like the encoding for a resource.

() Inherited from container (zzzz)
() Other [_____]
 
Also a bit more work is required to support jars in the JRE container, for example see org.eclipse.jdt.internal.launching.JREContainerInitializer.requestClasspathContainerUpdate(IPath, IJavaProject, IClasspathContainer)

I don't know yet if anything would be required for PDE container.
Comment 13 Deepak Azad CLA 2012-01-20 03:04:00 EST
> Also a bit more work is required to support jars in the JRE container, for
> example see
I am trying to create a patch for JDT/Debug, let's see how that goes.
Comment 14 Jay Arthanareeswaran CLA 2012-01-20 03:23:09 EST
(In reply to comment #12)
org.eclipse.jdt.internal.launching.JREContainerInitializer.requestClasspathContainerUpdate(IPath,
> IJavaProject, IClasspathContainer)
> 
> I don't know yet if anything would be required for PDE container.

PDE container seems to be alright. But user libraries are having a bit of problem in keeping the encoding value entered.
Comment 15 Dani Megert CLA 2012-01-20 04:10:07 EST
(In reply to comment #12)
> (In reply to comment #11)
> > > Will it always be 'OS encoding'? 
> > What else do you expect?
> I guess you want that in case the user has not specified the encoding for a jar
> we show the default encoding just like the encoding for a resource.
> 
> () Inherited from container (zzzz)
> () Other [_____]
> 

Nope, just set default into your existing widget (but don't persist it).
Comment 16 Deepak Azad CLA 2012-01-20 04:19:56 EST
(In reply to comment #13)
> > Also a bit more work is required to support jars in the JRE container, for
> > example see
> I am trying to create a patch for JDT/Debug, let's see how that goes.

This is quite a bit of work. Hence, I have filed bug 369188 and for now will disable in the UI encoding editing for container classpath entries.
Comment 17 Deepak Azad CLA 2012-01-20 15:45:09 EST
Created attachment 209856 [details]
additional fix - work in progress

> disable in the UI encoding editing for container classpath entries.

I am almost there.
- Editing is disabled for JRE container
- Editing is enabled for User Library container
- Problems with user libraries as mentioned in comment 14 are fixed.

Essentially I now check if a classpath container supports editing of encoding. Hence, when JRE container (or any other container) begins to support it, things should just work seamlessly. Currently only User Library container supports it.

TODOs:
- Show used encoding value when the user has not specified it
- Enable encoding editing via 'Attach Source' action
- Testing
Comment 18 Deepak Azad CLA 2012-01-21 07:47:52 EST
Everything should work nicely with this pushed commit - e7c4b9c222d5aea7f6613838bdb5851672306793

Note: There is one new API - org.eclipse.jdt.ui.wizards.BuildPathDialogAccess.configureSourceAttachment(Shell, IClasspathEntry, boolean)

(In reply to comment #8)
> - When editing the rt.jar's source I'd expect that src.jar is selected and I
> can hit 'Open' in the dialog.
Initially the source can be an external file or folder, and then the user can click either external file or folder buttons. Trying to implement the above leads to too much complexity for too little gain. Hence I have left things as is.

(In reply to comment #9)
> Ah, and please update the doc.
I will work on this now.
Comment 20 Markus Keller CLA 2012-01-22 17:53:37 EST
The UI needs some more polish:
- Browse button misses ...
- The sub-options should be indented, see "Javadoc Location" properties page.
- Only show the Encoding label and combo if editing the encoding is supported. Don't show disabled controls that can never be enabled in a given instance of the dialog.
Comment 21 Deepak Azad CLA 2012-01-23 07:04:32 EST
(In reply to comment #20)
> The UI needs some more polish:
> - Browse button misses ...
> - The sub-options should be indented, see "Javadoc Location" properties page.
Fixed in master - 84637a701752506c342f3d2dc0ba5b2d72564795

> - Only show the Encoding label and combo if editing the encoding is supported.
> Don't show disabled controls that can never be enabled in a given instance of
> the dialog.
Dani had wanted to show the default encoding in disabled state for rt.jar. Hence, I have left this as is for now. We can discuss this in our call tomorrow.
Comment 22 Markus Keller CLA 2012-01-23 08:46:18 EST
> Dani had wanted to show the default encoding in disabled state for rt.jar.

OK, that makes sense. However, I currently only see the encoding if the rt.jar already has a source attachment. It should also be shown if no source attachment is set. Same problem if the encoding is editable: The combo only comes up with a value if there was already a source attachment initially.
Comment 23 Dani Megert CLA 2012-01-23 09:15:06 EST
(In reply to comment #22)

Reopening.
Comment 24 Deepak Azad CLA 2012-01-23 09:54:20 EST
(In reply to comment #22)
> OK, that makes sense. However, I currently only see the encoding if the rt.jar
> already has a source attachment. It should also be shown if no source
> attachment is set. Same problem if the encoding is editable: The combo only
> comes up with a value if there was already a source attachment initially.

Fixed in master - b73f6b19b673f8d2286e79ea6d7166cfaa8770f7.