Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 335275 - [call hierarchy] update history when a top level item is removed from view
Summary: [call hierarchy] update history when a top level item is removed from view
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.7 M5   Edit
Assignee: Markus Keller CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-25 00:08 EST by Deepak Azad CLA
Modified: 2011-01-28 03:09 EST (History)
3 users (show)

See Also:


Attachments
Patch (5.51 KB, patch)
2011-01-26 05:02 EST, Raksha Vasisht CLA
no flags Details | Diff
Patch 2 (5.72 KB, patch)
2011-01-26 07:06 EST, Markus Keller CLA
no flags Details | Diff
Patch on top of Patch_2 (2.52 KB, patch)
2011-01-26 07:54 EST, Raksha Vasisht CLA
no flags Details | Diff
Patch 4 (6.03 KB, patch)
2011-01-26 09:37 EST, 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 Deepak Azad CLA 2011-01-25 00:08:34 EST
---------------------------------------
package p;
class A {
	void foo(Object a) {		
		bar();
	}
	
	void bar() {
		foo(this);
	}
}
---------------------------------------

1. Empty CH view
2. Select foo in Outline view and drag to CH view => CH view looks like
    -foo
     + bar
3. Select bar in Outline view and Ctrl+drag to CH view => 
    -bar
     + foo
    -foo
     + bar
4. Remove from view (delete) bar =>
    -foo
     + bar
5. Select bar in Outline view and Ctrl+drag to CH view => Not good !
    -foo
     + bar
6. Refresh View (view toolbar button) =>
    -bar
     + foo
    -foo
     + bar
Comment 1 Deepak Azad CLA 2011-01-25 00:20:49 EST
After step 4 (remove from view), the history is not updated. While this is not entirely incorrect, you can argue that removing a top level item from the view should be reflected in the history.

At the very least, if an item is explicitly added back, it should be added back, even though it might have been removed at some point in the past.
Comment 2 Deepak Azad CLA 2011-01-25 00:32:35 EST
(In reply to comment #1)
> After step 4 (remove from view), the history is not updated. While this is not
> entirely incorrect, you can argue that removing a top level item from the view
> should be reflected in the history.

The more I think about it, I think the right solution is to update history when a top level item is removed from view. Just like adding a top level item (Ctrl+drag) updates history.
Comment 3 Dani Megert CLA 2011-01-25 02:51:36 EST
Which build ID?
Comment 4 Deepak Azad CLA 2011-01-25 03:04:49 EST
(In reply to comment #3)
> Which build ID?

I20110124-1800
Comment 5 Markus Keller CLA 2011-01-25 06:24:24 EST
> The more I think about it, I think the right solution is to update history when
> a top level item is removed from view. Just like adding a top level item
> (Ctrl+drag) updates history.

That sounds reasonable to me. Raksha, what do you think?

I guess it would also be better if the CH updated the current history element when the user adds elements to the view (rather than adding a new entry each time).
Comment 6 Deepak Azad CLA 2011-01-25 07:52:06 EST
(In reply to comment #5)
> I guess it would also be better if the CH updated the current history element
> when the user adds elements to the view (rather than adding a new entry each
> time).

I would probably prefer to add a new entry each time
- History is more detailed/accurate, and this could be useful at times.
- Does a new entry hurt in any way ? Will there be a lot of unnecessary clutter in the history ? Is it expensive to add a new entry ?
Comment 7 Markus Keller CLA 2011-01-25 08:42:12 EST
Reasons for adding new history entries:
- most accurate, zero loss of most recent state

Reasons against:
- clutters history with less relevant input updates
- increases danger of losing interesting entries

This is purely a UI decision that should be based on how we expect the feature to be used. I think the history is mostly used to look at something that's not directly related to the current input elements. Adding/removing elements is a quick operation that tweaks an existing input in order to improve the shown data. Therefore, I consider the last state of an input as superior to the states before. In contrast, the value of unrelated older inputs is on the same scale as the last state of an add/remove sequence.
Comment 8 Deepak Azad CLA 2011-01-25 09:05:00 EST
(In reply to comment #7)
> Reasons for adding new history entries:
> - most accurate, zero loss of most recent state
> 
> Reasons against:
> - clutters history with less relevant input updates
> - increases danger of losing interesting entries
> 
> This is purely a UI decision that should be based on how we expect the feature
> to be used. I think the history is mostly used to look at something that's not
> directly related to the current input elements. Adding/removing elements is a
> quick operation that tweaks an existing input in order to improve the shown
> data. Therefore, I consider the last state of an input as superior to the
> states before. In contrast, the value of unrelated older inputs is on the same
> scale as the last state of an add/remove sequence.

Updating the current history item is acceptable in case something is added, but leads to loss of data if something is removed.

e.g. what happens when there are 2 top level elements in the CH view, and one of them is removed - the history entry now shows only 1 item ?
Comment 9 Dani Megert CLA 2011-01-25 10:56:09 EST
I tend to agree with Markus. For me the history should get a new item each time I replace the current input entirely. When I modify the current input it should modify the current history entry.
Comment 10 Raksha Vasisht CLA 2011-01-26 05:02:21 EST
Created attachment 187620 [details]
Patch

(In reply to comment #7)
> Reasons for adding new history entries:
> - most accurate, zero loss of most recent state
> 
> Reasons against:
> - clutters history with less relevant input updates
> - increases danger of losing interesting entries
> 
> This is purely a UI decision that should be based on how we expect the feature
> to be used. I think the history is mostly used to look at something that's not
> directly related to the current input elements. Adding/removing elements is a
> quick operation that tweaks an existing input in order to improve the shown
> data. Therefore, I consider the last state of an input as superior to the
> states before. In contrast, the value of unrelated older inputs is on the same
> scale as the last state of an add/remove sequence.

I agree that the history should have only the latest entry and not separate entries after every addition/removal since the history shows utmost 2 entries and there's  no way to differentiate between the multiple entries if the first two elements are same and it clutters the dialog with duplicate entries.  The latest patch fixes this as well as step 5 in the example in comment #0 and updates the history after an element is  removed from view. Markus, could you pls have a look?
Comment 11 Deepak Azad CLA 2011-01-26 05:24:18 EST
(In reply to comment #10)
> Created attachment 187620 [details] [diff]
> Patch

The patch fails when
- Open CH on a method
- Remove from view (delete) the method
=> Error dialog comes up - ""Delete" did not complete normally.  Please see the log for more information."

You have to delete the history entry itself in this case. (Which I think is loss of data and something we should not do.)
Comment 12 Markus Keller CLA 2011-01-26 07:06:25 EST
Created attachment 187629 [details]
Patch 2

(In reply to comment #11)
Corner case. Fixed by not updating the history in case the last element is removed (like it was in 3.6). I also had to adapt CallHierarchyViewPart#addInputElements(IMember[]) to make sure it works fine when you add an element to the empty view again.

RemoveFromViewAction:
- in #run(), "new ArrayList(Arrays.asList(inputElements))" saves a copying op.
- #getInputElements(ISelection) -> #getSelectedElements()
Comment 13 Deepak Azad CLA 2011-01-26 07:20:40 EST
(In reply to comment #12)
> Created attachment 187629 [details] [diff]
> Patch 2
> 
> (In reply to comment #11)
> Corner case. Fixed by not updating the history in case the last element is
> removed (like it was in 3.6). 
Well, the original problem still remains - Ctrl+drag does not work after all top level items are removed from view :)

Either the history entry has to be removed, or on Ctrl+drag the dragged item(s) must be shown even though it was removed in past.
Comment 14 Raksha Vasisht CLA 2011-01-26 07:22:44 EST
(In reply to comment #12)
> Created attachment 187629 [details] [diff]
> Patch 2
> 
> (In reply to comment #11)
> Corner case. Fixed by not updating the history in case the last element is
> removed (like it was in 3.6). 

Yeah I had done the same in my fix that I almost attached...

> I also had to adapt
> CallHierarchyViewPart#addInputElements(IMember[]) to make sure it works fine
> when you add an element to the empty view again.
> 
> RemoveFromViewAction:
> - in #run(), "new ArrayList(Arrays.asList(inputElements))" saves a copying op.
> - #getInputElements(ISelection) -> #getSelectedElements()

Alright, Patch 2 looks good. Committed to HEAD. Thanks Markus!
Comment 15 Deepak Azad CLA 2011-01-26 07:25:00 EST
> Alright, Patch 2 looks good. Committed to HEAD. Thanks Markus!
No it is not, see comment 13.
Comment 16 Deepak Azad CLA 2011-01-26 07:34:08 EST
Reopening...
Comment 17 Raksha Vasisht CLA 2011-01-26 07:36:08 EST
(In reply to comment #15)
> > Alright, Patch 2 looks good. Committed to HEAD. Thanks Markus!
> No it is not, see comment 13.

Hmmm dragging the same elements doesn't work anymore! Will try to clear the history altogether when the last element is removed.. Patch coming up..
Comment 18 Raksha Vasisht CLA 2011-01-26 07:54:04 EST
Created attachment 187632 [details]
Patch on top of Patch_2

(In reply to comment #17)
> (In reply to comment #15)
> > > Alright, Patch 2 looks good. Committed to HEAD. Thanks Markus!
> > No it is not, see comment 13.
> 
> Hmmm dragging the same elements doesn't work anymore! Will try to clear the
> history altogether when the last element is removed.. Patch coming up..

Patch attached and committed to HEAD. Added changes to clear the history on removing the last element from the view.. ctrl+drag works fine afterwards on the empty view.
Comment 19 Raksha Vasisht CLA 2011-01-26 07:59:53 EST
 comment #18 Contd..

We do not delete the entry but the history is cleared when a single input is removed from the view showing the empty page. The view is still open so the input can be dragged and dropped again on the same view. Marking it resolved.. feel free to test/reopen if required.
Comment 20 Deepak Azad CLA 2011-01-26 08:20:24 EST
and now I get the same error mentioned in comment 11

> Patch attached and committed to HEAD. Added changes to clear the history on
> removing the last element from the view.. ctrl+drag works fine afterwards on
> the empty view.
Plus do you clear the entire history?
Comment 21 Raksha Vasisht CLA 2011-01-26 08:43:46 EST
(In reply to comment #20)
> and now I get the same error mentioned in comment 11
> 
I cannot reproduce that :/ I see the element being removed and an empty page shown..
Comment 22 Markus Keller CLA 2011-01-26 08:50:30 EST
I'll take care of this. The right fix is my patch 2 + some tweaks to make sure a removed input element shows up again when the user Ctrl+drags it to the view.
Comment 23 Markus Keller CLA 2011-01-26 09:37:00 EST
Created attachment 187636 [details]
Patch 4

This patch is against HEAD. It reverts comment 18 and implements comment 22.
Released to HEAD.
Comment 24 Markus Keller CLA 2011-01-26 09:37:40 EST
Deepak, please check HEAD.
Comment 25 Deepak Azad CLA 2011-01-26 10:09:44 EST
Its much better now, however a small issue remains
- Open CH on foo()
- Remove foo() => history contains 1 item 'foo()'
- Ctrl+Drag bar() to CH view => view contains 'bar()' and history contains 1 item 'foo(), bar()'. This is not consistent with 'history should have only the latest entry' policy.

This is a corner case, and should not happen too often in practice. Markus, your call if you want to fix this or not.
Comment 26 Markus Keller CLA 2011-01-26 10:31:23 EST
(In reply to comment #25)
Thanks, fixed in HEAD of CallHierarchyViewPart#addInputElements(IMember[]).
Comment 27 Deepak Azad CLA 2011-01-26 11:04:55 EST
Works nicely now.
Comment 28 Dani Megert CLA 2011-01-28 03:08:10 EST
Verified in I20110127-2034.
One scenario is a little bit unexpected, see bug 335657.
Comment 29 Dani Megert CLA 2011-01-28 03:09:17 EST
.