Bug 112958 - [Perspectives] Access to perspective descriptor when creating initial layout
Summary: [Perspectives] Access to perspective descriptor when creating initial layout
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.2   Edit
Hardware: All All
: P3 enhancement with 1 vote (vote)
Target Milestone: 3.2 M4   Edit
Assignee: Nick Edgar CLA
QA Contact:
URL:
Whiteboard:
Keywords: api
Depends on:
Blocks:
 
Reported: 2005-10-18 12:44 EDT by Brandon Brockway CLA
Modified: 2005-12-13 13:49 EST (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 Brandon Brockway CLA 2005-10-18 12:44:57 EDT
Required if you desire to reuse an IPerspectiveFactory, (e.g. when creating
dynamic perspectives). The same IPerspectiveFactory class may be used to
generate perspectives based on some criteria (user identity etc.). The
IPerspectiveFactory may read the definition of the perspective from a dynamic
store (database, XML stream) etc. and needs some way of differentiating one call
to creatInitialLayout() from another. Granting access to the the descriptor of
the perspective it's laying out would give it a unique identifier (perpsective
ID) that can be used as a key to perform a lookup to obtain the information
required to generate the perspective.

As a suggestion the public method in the org.eclipse.ui.internal.PageLayout
class called getDescriptor() could be promoted to the IPageLayout interface.
Comment 1 Kim Horne CLA 2005-10-18 13:52:48 EDT
You could simply have your IPerspectiveFactory implement IExecutableExtension.  From the data provided 
to this methods interfaces you could look up any useful info stored in the perspective descriptor or 
elsewhere within the workbench. 

I would be inclined to mark this as WONTFIX.
Comment 2 Nick Edgar CLA 2005-10-18 14:31:10 EDT
I actually don't think it's unreasonable to let the factory know the id of the
perspective, and use that to look up information.

I'm -strongly- against giving semantics to the id itself, e.g. encoding
parameters or other info in the id proper.

Implementing IExecutableExtension in your perspective factory would work.  You
can get the id using configElement.getAttribute("id").

As of 3.1, you can also use IExecutableExtensionFactory.  In the perspective
extension, instead of referring the class implementing IPerspectiveFactory
directly, provide a class implementing IExecutableExtensionFactory.  This can
also implement IExecutableExtension to obtain data from the configuration element.
For an example, see how the progress view is declared in org.eclipse.ui.ide's
plugin.xml.  It refers to org.eclipse.ui.ExtensionFactory passing "progressView"
as the data.
Comment 3 Brandon Brockway CLA 2005-10-18 15:54:16 EDT
IExecutableExtension works well except when cloning an existing perspective. If
you use the IPerspectiveRegistry.clone() method than the new perspective gets
the IConfigurationElement of the original perspective, thus the same ID, etc. If
I cast the IPageLayout instance to a PageLayout than I can get the
IPerspectiveDescriptor with the correct information, including the ID and label
passed to the clone method (e.g. ((PageLayout)layout).getDescriptor().getId(); )
Comment 4 Nick Edgar CLA 2005-11-29 21:08:23 EST
Fixed as suggested in builds >= N20051130.
Comment 5 Nick Edgar CLA 2005-12-13 13:49:41 EST
Verified in I20051213-0010.

Added an API test for it: IPageLayoutTest.testGetDescriptor()