Cloning Custom Perspectives [message #666197] |
Tue, 19 April 2011 12:51 |
Rob Stark Messages: 7 Registered: March 2011 |
Junior Member |
|
|
I am building a UI Framework that uses the EClipse RCP in support of standing up a new UI development team.
We're using Eclipse as we like the use of sessions(workbench)/perspectives/widgets etc. We have a need to expose in the UI a button that allows the user to "copy" a given perspective. I can easily clone a perspective using the IPerspectiveRegistry.clonPerspective() method. There are no issues when you clone a default perspecive defined in the plug-in file. You get the associated viewParts no problem.
Lets say the user clones a default perspective, adds a few views (ViewParts) to it (creating a custom perspective) and then wants to clone this custom perspective. The problem is that the added ViewParts are not included in the cloned object.
(1) Do you have any suggestions as to how I can completely clone a custom perspective? I am calling window.getActivePage().savePerspective() anytime a view is added/removed from a perspective.
I have tried a number of approaches to solve this problem. Some efforts I knew going in were a bad idea as it had me mucking with eclipse internal (workbench) objects...creating a perspectiveDescriptor, adding it to the registry etc... Currently my util method stands as folows:
<PerspectiveUtils>
public static IPerspectiveDescriptor clonePerspective( IWokbenchWindow window, String originalId, String newPerspectiveId, String name ) {
IPerspectiveRegistry perspectiveRegistry = window.getWorkbench().getPerspectiveRegistry();
IPerspectiveDescriptor descriptor = perspectiveRegistry.findPerspectiveWithId( originalId );
return perspectiveRegistry.clonePerspective( newPerspectiveId.replaceAll(" ", "_"), name, descriptor );
}
I suspect, based on reading the source code, that the RCP framework was not designed with this type of behavior in mind. For example, the PerspectiveRegistry.clonePerspective() method does not include in the clone the copying of the configElement attribute (on the PerspectiveDescriptor object). (2) Is there a reason for that?
I did notice that the cloned object maintains a reference to the originalId, which has me wondering if somehow when the new (cloned) perspective is shown (ie window.getWorkbench().showPerspective()) that the original ViewParts from the original plug-in definition perspective are loaded and not the immediate parental custom object (viewParts).
Ok - have to ask, (3) is there a reason that no setter() method is exposed for the label attribute on the PerspectiveDescriptor? (IE supporting renaming the Perspective)
Thanks for your time. Please advise if you have any ideas how to do a deep clone of a custom perspective.
Regards,
~Rob.
[Updated on: Tue, 19 April 2011 12:58] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03624 seconds