Bug 125000 - [Perspectives] Custom Perspectives Can't Be Deployed With RCP
Summary: [Perspectives] Custom Perspectives Can't Be Deployed With RCP
Status: ASSIGNED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P5 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Platform UI Triaged CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2006-01-24 08:52 EST by Jacob Robertson CLA
Modified: 2012-08-23 08:03 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jacob Robertson CLA 2006-01-24 08:52:46 EST
If I have a graphic designer use Eclipse's "Save Perspective As..." Dialog, we can create our precise custom perspectives with all the right views etc.  However, there is no mechanism to take that "Preference" as it is saved in the workspace, and deploy that new perspective with a plugin for our RCP.  I have muddled with some workarounds, using internal APIs, but so far everything I've tried won't actually restore the customization, just the original copied perspective.  In any case, the workarounds I'm persuing are just that - and I believe someone who is intimate with this code should be able to quite easily expose this.

Let me summarize what I've been trying.  To get a customized perspective to deploy, I do this.

1) Save a customized perspective
2) Close the workbench (to get it to persist)
3) Go to the preferences file, and copy that xml
4) paste that xml into my own preferences file that is loaded in a plugin
5) Create a preferences extension in that plugin, to a custom PerspectiveFactory with the id of that extension mapping to the preference Id I pasted in step 4

When the PerspectiveFactory is called, it tries to load the preference in a number of ways that I gleaned from looking at PerspectiveDescriptor, Perspective, PerspectiveRegistry, and PerspectiveExtensionReader.  However, as mentioned above, none of this works.

Obviously there is code already in place to do the perspective loading for me, but what is missing is the ability to load my own "Memento" (from a preferences.ini or really I should be able to provide that Memento from wherever I want to keep it), and get the perspective to load up correctly without me writing a bunch of custom code.

The approach I described above is pretty reasonable, as it requires only a few steps.  What is missing is a PerspectiveFactory that actually works.
Comment 1 Nick Edgar CLA 2006-02-07 11:48:45 EST
Is it possible to take your designer's recommendations and modify the actual code for the perspective to correspond?

If not, try the following as a workaround:
- modify the perspective
- Save it under the same name (this is important so the saved preference gets the id of the original perspective, instead of a constructed id based on the new name)
- export prefs
- edit the prefs file

- it will have an entry:
/instance/org.eclipse.ui.workbench/perspectives=(list of customized perspectives)
For example, if I save a custom version of the Java perspective, it looks like:
/instance/org.eclipse.ui.workbench/perspectives=org.eclipse.jdt.ui.JavaPerspective

- it will also have an entry for each customized perspective of the form:
/instance/org.eclipse.ui.workbench/<persp-id>_persp=<XML definition>
For example, the entry for the customized Java perspective looks like:
/instance/org.eclipse.ui.workbench/org.eclipse.jdt.ui.JavaPerspective_persp=<?xml...

- copy these two (or more) entries to a new file, removing the "/instance/" prefixes, e.g.:
org.eclipse.ui.workbench/perspectives=org.eclipse.jdt.ui.JavaPerspective
org.eclipse.ui.workbench/org.eclipse.jdt.ui.JavaPerspective_persp=<?xml...

- add this file to the plugin containing your product extension, and use it to override the preference defaults using the approach described here:
http://wiki.eclipse.org/index.php/RCP_FAQ#customPrefs

- run your app, being sure to specify eclipse.product=<product id> in the config.ini file, or on the command line via -product <product id>
Comment 2 Nick Edgar CLA 2006-03-15 11:46:57 EST
Reassigning bugs in component areas that are changing ownership.