Bug 546790 - [9][build path] synchronize data on different tabs of Java Build Path
Summary: [9][build path] synchronize data on different tabs of Java Build Path
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.12   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 4.12 RC1   Edit
Assignee: Stephan Herrmann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 546352
Blocks: 547772
  Show dependency tree
 
Reported: 2019-04-27 08:58 EDT by Stephan Herrmann CLA
Modified: 2019-05-30 02:48 EDT (History)
2 users (show)

See Also:
noopur_gupta: review+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stephan Herrmann CLA 2019-04-27 08:58:05 EDT
With extracting the modularity configuration into its own tab via bug 546352, data entered on one tab can affect validity of data entered on another tab. Specifically when changing the "module" attribute of any classpath entry, the Module Dependencies tab will have to react, or may even want to veto. Conversely, due to patch-module, some entries may change their module-ness, to be reflected in the Project & Libraries tabs.

At an upper level, property pages already suggest to Apply changes before switching to another property page.

Different tabs *within* Java Build Path have no such protocol, but share data via BuildPathBlock#fClassPathList, so that some changes done on one page are immediately available in the other.

Still, while changes have not been Applied, additional coordination is necessary.

I believe, that BuildPathsBlock.buildPathDialogFieldChanged() should be a suitable location for coordinating between different tabs, but we should check in detail how exactly this coordination should happen.
Comment 1 Stephan Herrmann CLA 2019-04-27 09:20:40 EDT
Also introducing a protocol BuildPathsBlock.pageSelected(BuildPathBasePage) would allow things like showing a page-specific status (e.g., on Module Dependencies we could spell out an Info "This project is not modular, module dependencies are not applicable".)  See also BuildPathsBlock.tabChanged().
Comment 2 Stephan Herrmann CLA 2019-05-04 17:59:45 EDT
(In reply to Stephan Herrmann from comment #0)
> At an upper level, property pages already suggest to Apply changes before
> switching to another property page.

In this regard the new UI is already clean: by directly operating on the list of CPListElements shared among tabs, changes made on tab Module Dependencies already trigger the question (Apply / Discard / Apply Later) when trying to select another property page.
Comment 3 Noopur Gupta CLA 2019-05-07 05:16:42 EDT
- Add a library (e.g. external JAR)  on Libraries tab, click Apply, go to Module Dependencies tab, the new library is not shown in the list of modules.
- Close and reopen the dialog. The added library is now shown in the list.

The same is applicable when removing the library from the Libraries tab, clicking Apply, and going to the new tab. The old library is still visible in the list and clicking on that gives the following exception in error log:

Java Model Exception: Java Model Status [C:\Eclipse\Builds\eclipse-SDK-I20190506-1800\eclipse\plugins\com.ibm.icu_63.1.0.v20181030-1705.jar is not on its project's build path]
	at org.eclipse.jdt.internal.core.JavaElement.newJavaModelException(JavaElement.java:583)
	at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:256)
	at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:596)
	at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:326)
	at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:312)
	at org.eclipse.jdt.internal.core.JavaElement.getChildren(JavaElement.java:267)
	at org.eclipse.jdt.internal.ui.wizards.buildpaths.ModuleDependenciesAdapter$DeclaredDetails.getPackages(ModuleDependenciesAdapter.java:172)
...
Comment 4 Noopur Gupta CLA 2019-05-07 05:38:26 EDT
> (In reply to Stephan Herrmann from comment #43)
> > From above we already have bug 546790.
> Something similar is done in Launch configuration tabs when making a change
> in the JRE tab and moving to Classpath/Dependencies tab without clicking
> Apply.
Comment 5 Stephan Herrmann CLA 2019-05-20 17:25:41 EDT
Thanks, Noopur, for fixing the target milestone.
That drop down is just too long for my screen :-/
Comment 6 Noopur Gupta CLA 2019-05-21 04:13:07 EDT
(In reply to Stephan Herrmann from comment #5)
> Thanks, Noopur, for fixing the target milestone.
> That drop down is just too long for my screen :-/
You can try the Bugzilla script which provides links/shortcuts for many common tasks: https://www.eclipse.org/jdt/ui/dev.php#scripts.
Comment 7 Eclipse Genie CLA 2019-05-28 17:43:49 EDT
New Gerrit change created: https://git.eclipse.org/r/142980
Comment 8 Stephan Herrmann CLA 2019-05-28 17:56:53 EDT
(In reply to Eclipse Genie from comment #7)
> New Gerrit change created: https://git.eclipse.org/r/142980

This may not be perfect, but it's the best (and last code change) I can offer for RC1.

Strategy:

Mainly rely on the shared List<CPListElement> to synchronize with other tabs. Only change here: when switching to the new tab, re-scan all modules. I was afraid this could cause a performance issue, but in my toy workspace, such scan was a matter of ~10 ms. Until we have data from huge workspaces, I hope this is good enough.
Re-scan includes clearing all cached data in ModuleDependenciesPage and ModuleDependenciesList.


Next, I noticed that a jar freshly added to the module path still doesn't show up, because for this we need an IPackageFragmentRoot, which hasn't been created yet. Current solution: raise a warning:
  Not all modules could be found. Please consider pressing Apply to synchronize.


Finally, I needed to re-scan modules also on Apply, which I achieved by letting BuildPathsBlock.doUpdateUI() unconditionally initialized ModuleDependenciesPage (not just when switching between 8- and 9+).


@Noopur, unfortunately I won't have time for follow-up during office hours tomorrow. I'm fine with any of: submit, submit only part of the change, or defer to 4.13 - I'll have to let you decide which you prefer.
Comment 10 Noopur Gupta CLA 2019-05-29 04:53:02 EDT
The current state of the patch looks good for RC1. I have released the patch.

Please open a new bug to improve on this in 4.13 e.g. to synchronize automatically instead of the warning.
Comment 11 Stephan Herrmann CLA 2019-05-29 18:29:34 EDT
(In reply to Noopur Gupta from comment #10)
> The current state of the patch looks good for RC1. I have released the patch.

Thanks!

> Please open a new bug to improve on this in 4.13 e.g. to synchronize
> automatically instead of the warning.

Sure, it's bug 547772. Suggestions welcome.
Comment 12 Noopur Gupta CLA 2019-05-30 02:48:47 EDT
Verified in I20190529-2005.