Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 461083

Summary: [target] Target definition editor prematurely allows editing of a Software Site
Product: [Eclipse Project] PDE Reporter: Peter Steinfeld <pete.steinfeld>
Component: UIAssignee: Vikas Chandra <Vikas.Chandra>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: curtis.windatt.public, dubauski_psl, Vikas.Chandra
Version: 4.2.1   
Target Milestone: 4.6 M2   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Bug Depends on:    
Bug Blocks: 482640    
Attachments:
Description Flags
Fix
none
Another fix none

Description Peter Steinfeld CLA 2015-02-27 13:56:21 EST
I created a target definition file that contains a location which is a P2 Software Site.  The initial state of my workspace is that I have a different target selected, and the target definition file exists in my workspace, but it is not open in an editor.  The P2 Software Site has categories, and the target definition file selects some of those categories.

The problem is that if open the target definition file and then quickly edit the P2 Software Site, the "Edit Software Site" dialog will incorrectly show that no categories are selected.

Here are the steps to reproduce the problem.

    1 -- Start with a workspace in which the target definition file is not open in an editor.
    2 -- Open the target definition file.  Immediately after opening the file, Eclipse creates a progress monitor that says "Resolving Target Definition".  At this point, the editor also displays the "Locations" panel where it displays the Software Site associated with the target.
    3 -- Now, before Eclipse has completed resolving the target definition, double click on the Software Site in the "Locations" panel.  At this point, Eclipse will open the "Edit Software Site" dialog, but no categories will be selected.  An error message will be displayed at the top of the panel saying "At least one item must be selected".

I presume that the easiest solution would be to block opening the "Edit Software Site" dialog until the process of resolving the target definition is complete.
Comment 1 Vikas Chandra CLA 2015-03-15 06:49:49 EDT
I have a fix for this one and I am currently testing it.
Comment 2 Vikas Chandra CLA 2015-04-27 07:23:07 EDT
There are few issues with the fix I have. Moving out of M7
Comment 3 Vikas Chandra CLA 2015-08-20 06:59:11 EDT
Created attachment 255984 [details]
Fix

Fix for this issue.  During resolve, what about enable and disable of other button?
Comment 4 Peter Steinfeld CLA 2015-08-20 11:11:53 EDT
Regarding comment 3 --
The only other button that's enabled when I first open the editor is the "Add ..." button to add a new location.

I don't know of any reason to disable this button.
Comment 5 Curtis Windatt CLA 2015-08-20 13:35:47 EDT
We should be striving to allow the user to do as much as possible while the target is resolving.  A better solution would be to have an edit dialog that doesn't blow up because it can't query a p2 repository (though the workflow isn't nearly as broken after Bug 275999 was fixed).  If we aren't going to allow editing during resolve, we should still be enabling the other buttons that don't cause problems (add, remove, update, reload).

I've -1'd this for a couple of reasons
1) It looks like it only affects button enablement.  Double clicking on the tree item would still open it.
2) Having the resolve operation set a flag in the UI piece is the wrong pattern (and also requires several syncExecs).  The UI pieces have a handle to the target and targets have isResolved().  Just need to ensure that setInput/updateButtons is being called after the resolve completes (the tree contents updates after the resolve, so it is already working in that case).
Comment 6 Vikas Chandra CLA 2015-08-21 04:59:16 EDT
Created attachment 256004 [details]
Another fix

Based on Curtis's suggestion, this is another fix.
Comment 7 Vikas Chandra CLA 2015-08-21 05:00:22 EDT
Curtis, can you please have a quick look?
Comment 8 Curtis Windatt CLA 2015-08-24 13:31:49 EDT
(In reply to Vikas Chandra from comment #7)
> Curtis, can you please have a quick look?

1 line fix is much better than the syncExecs :)

Does it prevent you from double clicking on a tree item to edit?
Comment 9 Vikas Chandra CLA 2015-08-26 11:17:15 EDT
>>Does it prevent you from double clicking on a tree item to edit?

Yes during resolve or also when resolve is canceled midway.
Comment 10 Vikas Chandra CLA 2015-08-28 05:02:12 EDT
Thanks Curtis. Removing review request as I think it is no longer needed after the feedback.

Fixed via
http://git.eclipse.org/c/pde/eclipse.pde.ui.git/commit/?id=09d55b792dd170a579d0d625ed40cf9645b828b1
Comment 11 Vikas Chandra CLA 2015-09-15 04:08:48 EDT
verified in 
Version: Neon (4.6)
Build id: I20150914-2000