Bug 141906 - don't suppress classpath entities at their original locations
Summary: don't suppress classpath entities at their original locations
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 major with 1 vote (vote)
Target Milestone: 3.5 M7   Edit
Assignee: Markus Keller CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 141718 307219 (view as bug list)
Depends on:
Blocks: 244406
  Show dependency tree
 
Reported: 2006-05-15 18:01 EDT by Konstantin Komissarchik CLA
Modified: 2010-03-29 09:29 EDT (History)
11 users (show)

See Also:


Attachments
Fix (5.07 KB, patch)
2009-03-20 17:03 EDT, Markus Keller CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Konstantin Komissarchik CLA 2006-05-15 18:01:28 EDT
When a jar that is part of a java project is added to that project's classpath, the Package Explorer view suppresses the jar from being displayed at its original location in the file system tree. The same behavior is seen with class and source directories. While this behavior might be ok for classpath entries added manually, this behavior is bad when classpath entries are contributed automatically by a classpath container. 

WTP has a classpath container that automatically adds jars from web project's WEB-INF/lib directory to its classpath. As soon as a jar is dropped into the WEB-INF/lib directory it is picked up by the container. This makes it disappear from the original location in the Package Explorer view (drop target) leaving the users befuddled. Not only that, but once the jar has been added in order to delete the jar they have to switch to the Resource Navigator view. 

WTP has received at least half a dozen bugs reports pertaining to this behavior. Would it be possible to continue displaying resources at their original locations after they are added to the classpath?
Comment 1 Konstantin Komissarchik CLA 2006-05-15 18:05:12 EDT
*** Bug 141718 has been marked as a duplicate of this bug. ***
Comment 2 Martin Aeschlimann CLA 2006-06-10 06:52:39 EDT
jdt core decides what resources are still shown as non-Java resources
Comment 3 Philipe Mulet CLA 2008-07-09 09:31:04 EDT
What do you think Jerome ?
Comment 4 Mauro Molinari CLA 2008-07-22 12:09:28 EDT
IMHO the current behaviour is ok, but there actually is a problem with JARs in WEB-INF/lib, because they can't be removed in any easy way, without using an external file editor to phisically remove the JARs from that folder in the file system.
Comment 5 BenH CLA 2008-07-24 02:12:52 EDT
I would like to see this addressed because of the impact on WTP, as described by the reporter, which Ive personally experienced.
Comment 6 Jerome Lanneluc CLA 2008-08-13 10:33:41 EDT
This would require a new API: getNonJavaResources(int flags) where a flag would be INCLUDE_INTERNAL_JARS. Then the Package Explorer would need to use this new API.
Comment 7 Markus Keller CLA 2008-08-13 14:21:36 EDT
Hmm, in I20080812-0800, I already see a differnce between Jars inside and Jars outside of the workspace:

Jar stays in getNonJavaResources() if on classpath as:
- kind="lib" path="<absolute-OS-path>"
- kind="var" path="<VARIABLE>/<path-to-jar>"

Jar suppressed in getNonJavaResources() if on classpath as:
- kind="lib" path="<project-relative>"
- kind="lib" path="<absolute-workspace-path>"
- kind="con" path="org.eclipse.jdt.USER_LIBRARY/<user-lib-name>" (stored as absolute workspace path)

I guess WTP could work around the issue by adding the jars to their container using an absolute filesystem path, and not with a relative path inside the workspace.

That being said, I don't think we should add another preference for the user to toggle the appearance. What's the reason for suppressing the Jars from getNonJavaResources() at all? On the top level, it would look strange if the Jar would appear as a resource and also as a package fragment root (as siblings).
On the other hand, I don't think it would be a problem to *always* leave a Jar in getNonJavaResources() if its resource is not a direct child of the project (e.g the /<project>/WEB-INF/lib case).

> [..] once the jar has been added in order to
> delete the jar they have to switch to the Resource Navigator view.

In the Package Explorer, I can delete a Jar from the workspace via Edit > Delete, even if it is on the build path. I would expect this to work with the web tools container as well (at least in 3.4).
Comment 8 Konstantin Komissarchik CLA 2008-08-13 16:13:14 EDT
> I guess WTP could work around the issue by adding the jars to their container 
> using an absolute filesystem path, and not with a relative path inside the 
> workspace.

Interesting. This does work. I will go ahead and put this workaround into WTP. Could you indicate whether this behavior is considered a bug that would be fixed at some point or something that's likely to continue unchanged.

> That being said, I don't think we should add another preference for the user to 
> toggle the appearance. What's the reason for suppressing the Jars from
> getNonJavaResources() at all? On the top level, it would look strange if the 
> Jar would appear as a resource and also as a package fragment root (as 
> siblings). On the other hand, I don't think it would be a problem to *always* 
> leave a Jar in getNonJavaResources() if its resource is not a direct child of 
> the project (e.g the /<project>/WEB-INF/lib case).

I think it's possible to go a bit further than that. Even if a jar is at project root, there is still no possibility for user confusion if the jar is being added by a classpath container. The only case where confusion can happen is when a jar is at project root and is added to classpath directly.

If you do go with this approach, in the case where original entry is suppressed, you need to make sure that the possible actions on the visible entries are a union of what's possible on the classpath entry and what's possible on a regular file. To be specific, the Delete action needs to work. There may be others.

> > [..] once the jar has been added in order to delete the jar they have 
> > to switch to the Resource Navigator view.
> 
> In the Package Explorer, I can delete a Jar from the workspace via Edit > 
> Delete, even if it is on the build path. I would expect this to work with the 
> web tools container as well (at least in 3.4).

You can't do that if the original file is suppressed. The Delete action for jar classpath entries is disabled. It looks like it is disabled even for stand-alone jar entries (not sure why). For containers, enabling the Delete action would require new API in order to delegate to container implementation.
Comment 9 Markus Keller CLA 2008-08-14 10:45:20 EDT
OK, the Delete action is currently only available for Jars on the classpath that are directly inside the project, but not e.g. for Jars in WEB-INF/lib or for Jars from other projects.
Comment 10 Jerome Lanneluc CLA 2008-08-18 05:53:25 EDT
(In reply to comment #7)
> Jar stays in getNonJavaResources() if on classpath as:
> - kind="lib" path="<absolute-OS-path>"
> - kind="var" path="<VARIABLE>/<path-to-jar>"
Entered bug 244406 for these cases.
Comment 11 Jerome Lanneluc CLA 2008-08-18 05:56:54 EDT
For the problem reported in comment 0, the 'WEB-INF' directory is expanded by the Package Explorer, not by JDT/Core.

Moving to JDT/UI to remove the filtering of jars on the classpath in non-Java directories.
Comment 12 Markus Keller CLA 2008-08-18 06:30:39 EDT
OK, the plan is to show Jars as normal files (i.e. without children) at their original location, with one exception:
If the Jar is
- directly inside the project,
- directly on the classpath, and
- the "Referenced Libraries" node is not shown,
the Jar file is suppressed and only the package fragment root is shown.

I'm not yet sure what to do about the Delete action. It certainly needs to be available on the classpath entry in case the Jar is suppressed. We could also enable it for all classpath entries whose resource is inside the classpath entry's project. In the second case, it should then also work on entries in WTP's classpath container (no support from the classpath container needed).
Comment 13 Paul Klicnik CLA 2009-03-19 10:05:29 EDT
The workaround suggested to WTP to fix this problem is breaking a consuming product. In the mean time, WTP has agreed to revert that fix but we will need a proper fix from JDT as soon as possible.
Comment 14 Markus Keller CLA 2009-03-20 17:03:47 EDT
Created attachment 129501 [details]
Fix

Implements comment 12.

I didn't touch the Delete action, so it is still only available on Jars whose resource is a direct child of the project. But for the WTP case, Jars can now be deleted from the lib folder (since their resource stays visible there).
Comment 15 Markus Keller CLA 2009-03-21 10:03:17 EDT
Jerome, I'm ready to release together with bug 244406.
Comment 16 Markus Keller CLA 2009-03-23 11:18:12 EDT
Released to HEAD.
Comment 17 Dani Megert CLA 2009-04-28 08:42:36 EDT
Verified in I20090428-0100 but it also does this for source folders which get the library decoration. This is confusing. Filed bug 274023 to track this.
Comment 18 Markus Keller CLA 2010-03-29 09:29:40 EDT
*** Bug 307219 has been marked as a duplicate of this bug. ***