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

Bug 339130

Summary: Unable to save perspective
Product: [Eclipse Project] Platform Reporter: DJ Houghton <dj.houghton>
Component: UIAssignee: Dean Roberts <dean.t.roberts>
Status: VERIFIED FIXED QA Contact: Remy Suen <remy.suen>
Severity: major    
Priority: P3 CC: daniel_megert, dean.t.roberts, pwebster, remy.suen
Version: 4.1   
Target Milestone: 4.2 M3   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on: 353328, 355099, 355101, 355228, 356634    
Bug Blocks: 356307    
Attachments:
Description Flags
Initial patch to add the necessary ModelService API
none
Patch for save perspective implementation
none
Add save perspective as to tool item menu
none
Fix problem with 2nd and subsequent saves of same name being lost none

Description DJ Houghton CLA 2011-03-07 14:00:33 EST
eclipse.buildId=I20110304-1022

Paul mentioned that Eric is already aware of this issue but I tried to find a bug report about it but couldn't.

I can customize my perspective but there is no way to save it. This is extremely frustrating because every once in a while when I start up my perspective is reset to the default layout.
Comment 1 Remy Suen CLA 2011-03-08 13:59:55 EST
(In reply to comment #0)
> This is
> extremely frustrating because every once in a while when I start up my
> perspective is reset to the default layout.

Sorry DJ, layout loss is likely caused by the fallout from bug 338444.
Comment 2 Eric Moffatt CLA 2011-04-21 14:17:27 EDT
Created attachment 193869 [details]
Initial patch to add the necessary ModelService API


This is just the API that allows creating a clone of an element's structure into a 'snippet' and generating an instance of the cloned snippet.

This will be used in the implementation of the Perspective SaveAs / Reset functionality.
Comment 3 Eric Moffatt CLA 2011-04-21 14:18:11 EDT
Committed in >20110421. Applied the patch.
Comment 4 Dani Megert CLA 2011-07-28 10:33:29 EDT
> dean_roberts@ca.ibm.com  Depends on 		35328

I don't see how this depends on 35328.
Comment 5 Dean Roberts CLA 2011-08-29 11:30:58 EDT
Created attachment 202338 [details]
Patch for save perspective implementation

This patch will implement save perspective as and revert perspective for both perspectives saved with their own name, and perspectives saved "on top" of predefined perspectives.

This patch requires the fix to the model from bug 355228.

Also, until bug 355099 is fixed, you need to start Eclipse with the -deltaRestore false program arguments for saved perspectives to be persistant across Eclipse invocations
Comment 6 Dean Roberts CLA 2011-09-02 10:45:59 EDT
Created attachment 202680 [details]
Add save perspective as to tool item menu

Add the Save perspective as item to the perspecitve switcher tool item.  This patch is incremental and should be applied after the 1st batch on this defect (attachment 202338 [details])
Comment 7 Dean Roberts CLA 2011-09-02 10:49:06 EDT
Resaving a customized perspective with the same name loses the new customizations.  This is happening because the new cloned snippet, with the same ID is simply being added to the cloned snippets list.

A change to the model has been requested in bug 355101.  When this model change is released, we can fix this behaviour.
Comment 8 Eric Moffatt CLA 2011-09-02 11:17:35 EDT
Committed in >20110902.

80942baad79d11120f604a6a3c179513d8effc30

Good work !

I'll make the necessary model mods and we can re-check the 'save over' behavior...
Comment 9 Dean Roberts CLA 2011-09-02 15:56:57 EDT
Reopening so I can add the patch that allows saving a customization over top of an existing customization.
Comment 10 Dean Roberts CLA 2011-09-02 16:01:44 EDT
Created attachment 202696 [details]
Fix problem with 2nd and subsequent saves of same name being lost
Comment 11 Eric Moffatt CLA 2011-09-15 12:52:48 EDT
M2 is done...
Comment 12 Dean Roberts CLA 2011-09-15 13:47:19 EDT
Just to be clear.  In the build I20110915-0200, the candidate for M2, Save Perspective As functionality is released and working EXCEPT for the inability to save the same perspective more than once with the same name.
Comment 13 Remy Suen CLA 2011-09-15 14:19:04 EDT
Opened bug 357853 for saved perspectives not working properly when multiple workbench windows are used.

(In reply to comment #12)
> In the build I20110915-0200, the candidate for M2, Save
> Perspective As functionality is released and working EXCEPT for the inability
> to save the same perspective more than once with the same name.

Do we need a new bug for this or will this be addressed as a part of this bug?
Comment 14 Remy Suen CLA 2011-09-20 09:28:20 EDT
(In reply to comment #10)
> Created attachment 202696 [details]
> Fix problem with 2nd and subsequent saves of same name being lost

Dean, what is the change to removeSnippet(*) meant to accomplish?
Comment 15 Dean Roberts CLA 2011-09-20 10:35:39 EDT
It is just a cleaner coding pattern to do the remove, and would leverage any performance improvements that may exist or be implemented in find() at a later date.

It also matches the pattern added, by the patch, to ModelServiceImpl ... so it improves code consistency.
Comment 16 Remy Suen CLA 2011-09-20 11:57:02 EDT
(In reply to comment #10)
> Created attachment 202696 [details]
> Fix problem with 2nd and subsequent saves of same name being lost

Pushed to R4_development, thanks Dean!
http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?h=R4_development&id=3f4f91b76e12039dfc898b47f51ff70dd62437cb

Marking this bug as fixed. We will use new bugs for future problems that are encountered.
Comment 17 Dani Megert CLA 2011-09-29 02:37:42 EDT
Did someone verify that this bug is really fixed in an official 4.2 build?

While doing a check on our common bundles I found out that the change to WorkbenchActionBuilder in attachment 202338 [details]  is not in the 4.2 builds because 4.2 consumes ui.ide from 3.8 and the fix for WorkbenchActionBuilder was not cherry-picked to R3_developement.

I've fixed that now (Commit c49ba5f8d40b9373cf74e716a93c5a236589577b).
Comment 18 Dani Megert CLA 2011-09-29 02:48:19 EDT
> I've fixed that now (Commit c49ba5f8d40b9373cf74e716a93c5a236589577b).
Sorry, correct hash is: Commit 0cc54d8295551fce26a14076eaa95b774a955bd8

I also fixed the copyright date in both branches.
Comment 19 Remy Suen CLA 2011-09-29 06:46:51 EDT
(In reply to comment #17)
> While doing a check on our common bundles I found out that the change to
> WorkbenchActionBuilder in attachment 202338 [details]  is not in the 4.2 builds because
> 4.2 consumes ui.ide from 3.8 and the fix for WorkbenchActionBuilder was not
> cherry-picked to R3_developement.

Good catch, Dani! When attachment 202338 [details] was delivered in 	80942baad79d11120f604a6a3c179513d8effc30, it did include changes in the org.eclipse.ui.bundle.
http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?h=R4_development&id=80942baad79d11120f604a6a3c179513d8effc30

However, I am seeing the 'Window > Save Perspective As...' option on I20110923-1625, so perhaps that code change wasn't even necessary? Dean (or Eric), could you comment on this?
Comment 20 Dani Megert CLA 2011-09-29 06:53:07 EDT
> Good catch, Dani! When attachment 202338 [details] [diff] was delivered in    
> 80942baad79d11120f604a6a3c179513d8effc30, it did include changes in the
> org.eclipse.ui.bundle.

org.eclipse.ui.ide that is ;-).
Comment 21 Dean Roberts CLA 2011-09-29 07:26:23 EDT
The change in WorkbenchActionBuilder is a clean up of code that was converting Actions over to IContributionItems.

This conversion was work that was started before I joined the team, I forget by whomm.  As I was essentailly re adding the save and reset perspective actions it seemd more correct to add them in the new IContributionItem way.

So the actual save and reset perspective code is in and working in 4.2 ... but, without the WorkbenchActionBuilder change, it is being invoked as an Action and not an IContributionItem.
Comment 22 Dean Roberts CLA 2011-10-26 11:27:32 EDT
Verified on I20111025-2000