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

Bug 274904

Summary: [api] support deletion of multiple interaction elements
Product: z_Archived Reporter: Shawn Minto <shawn.minto>
Component: MylynAssignee: Shawn Minto <shawn.minto>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: steffen.pingel
Version: unspecified   
Target Milestone: 3.2   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
patch
none
mylyn/context/zip
none
additional improvments none

Description Shawn Minto CLA 2009-05-04 17:53:45 EDT
This can be a very slow operation that locks the workbench UI especially with a large context.  Using a deleteElements method that can be called once could eliminate this as there would only be 1 notification of a deletion instead of multiple.
Comment 1 Shawn Minto CLA 2009-05-04 18:36:00 EDT
Created attachment 134337 [details]
patch

Here is a patch that takes in a list of elements for deletion instead of deleting one-by-one.  This improves the performance since it only triggers 1 refresh (of many objects) instead of many different refreshes.  Steffen, let me know what you think.
Comment 2 Shawn Minto CLA 2009-05-04 18:36:02 EDT
Created attachment 134338 [details]
mylyn/context/zip
Comment 3 Shawn Minto CLA 2009-05-04 18:41:13 EDT
Created attachment 134340 [details]
additional improvments

This patch tries to be smart about the deletion events that are received to determine if it is cheaper to refresh all or just refresh the changes.  This patch doesn't increase the performance as much as the first patch and it may not be worth applying.  The only part that may be worth it is the TypeHistoryManager.
Comment 4 Steffen Pingel CLA 2009-05-06 03:32:01 EDT
First patch looks good to me, minor nits:
- rename taskscape to context :)
- InteractionContextManager.deleteElements() should thrown an exception in case of a null elements and only check once if elements.size() ==0

Let's look over the second patch together. I can't say how much this will improve performance. It would be really great if we could come up with performance tests to verify this.
Comment 5 Shawn Minto CLA 2009-05-06 11:02:42 EDT
(In reply to comment #4)
> First patch looks good to me, minor nits:
> - rename taskscape to context :)
> - InteractionContextManager.deleteElements() should thrown an exception in case
> of a null elements and only check once if elements.size() ==0

I will fix these nits and commit the patch.  I forgot that I can change names now without patch size problems ;)

> Let's look over the second patch together. I can't say how much this will
> improve performance. It would be really great if we could come up with
> performance tests to verify this.

I agree that we need to review this and I don't know if there is enough benefit to maintain these cases or not since the real problem is related to refresh of the viewers and it would be better not to mask that problem until we determine how it can be fixed.
Comment 6 Shawn Minto CLA 2009-05-06 12:31:47 EDT
I have applied the first patch after fixing the nits that you pointed out.  We now throw an IllegalArgumentException if a null list of elements is passed in.  When should we assert vs throw an exception? Lets decide if we want the second patch before we close this bug.  
Comment 7 Steffen Pingel CLA 2009-05-06 13:41:51 EDT
Yes, please always use Assert from o.e.core.runtime.
Comment 8 Steffen Pingel CLA 2009-05-06 13:43:22 EDT
Just noticed that the patch removes //$NON-NLS-1$ comments. These should be left in the code.
Comment 9 Shawn Minto CLA 2009-05-06 14:18:04 EDT
I updated to use Assert instead.  As for the //$NON-NLS-1$ comments,  I didn't remove any and I don't see any warnings for the classes that I patched.  Does the patch wizard ignore these for some reason?
Comment 10 Shawn Minto CLA 2009-05-06 14:20:32 EDT
I see what you mean, the second patch seems to have them removed.  Interesting as I remember them being there in my local workspace.  I will make sure to watch out for this.
Comment 11 Steffen Pingel CLA 2009-05-08 16:41:29 EDT
Thanks Shawn. I have moved the second patch to bug 275512. We can discuss addtional performance improvements on that bug.