Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Corona HowTo: Customize "Project Container Explorer" view"

m (obsolete)
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
<table border='1' cellpadding='3'>
 
<tr>
 
<td>[http://www.eclipse.org/corona Eclipse Home]</td>
 
<td>[[Corona|Wiki Home]]</td>
 
<td>[[Corona Development|Development]]</td>
 
<td>[[Corona HowTo|How To...]]</td>
 
</tr>
 
</table>
 
----
 
==Expandable RepositoryDescriptors==
 
===Introduction===
 
By default Project Container Explorer view in corona without any additional work is capable of showing following objects:
 
* ProjectContextContainer
 
* ProjectContextContainerStub
 
* RepositoryDescriptor
 
* RepositoryDescriptorStub
 
  
In following structure:
 
  - ProjectContextContainer
 
  |  |
 
  |  |RepositoryDescriptor
 
  |  |
 
  |  |RepositoryDescriptorStub
 
  + ProjectContextContainerStub
 
 
Please note that RepositoryDescriptors are leafs in the displayed tree. There might be a need that some of the repository descriptors should show additional information inside PCX view. Let's take as an example "team member repository". The repository descriptor describing team members could show as it's leafs all team members defined for it.<br>
 
Please see how new tree structure could look in the example below:<br>
 
[[Image:CoronaPcxViewTeamMember.JPG]]
 
===New type of objects displayed in PCX===
 
To achieve the result shown in above example the list of objects shown in the PCX had to be enlarged to:
 
* <b>IWorkbenchAdapter</b>
 
* <b>IAdaptable (with <i>IWorkbenchAdapter</i> defined)</b>
 
* ProjectContextContainer
 
* ProjectContextContainerStub
 
* RepositoryDescriptor
 
* RepositoryDescriptorStub
 
IWorkbenchAdapter interface provides common solution for all objects displayed in the tree, it contains all required method to show a tree view structure in different forms.<br>
 
Additionally RepositoryDescriptorStub was changed and now it's also implementing the IAdaptable interface.
 
===Step 1: Implement IWorkbenchAdapter interface for TeamMember RepositoryDescriptorStub===
 
As a first step we should implement the IWorkbenchAdapter which handles the RepositoryDescriptorStub objects. Let's call that class for TeamMembers the TeamRepositoryDescriptorWorkbenchAdapter. Below you can find the example of getChildren method:
 
  public Object[] getChildren(Object o) {
 
      if (o instanceof RepositoryDescriptorStub) {
 
        RepositoryDescriptor rd = ((RepositoryDescriptorStub) o).getRepositoryDescriptor();
 
        IRepositoryAdapter adapter = Activator.getRepositoryAdapter(rd);
 
        try {
 
            adapter.open();
 
            List<Object> l = new ArrayList<Object>();
 
            Iterator it = adapter.listResourceIds().iterator();
 
            while (it.hasNext()) {
 
              l.add((String) it.next());
 
            }
 
            adapter.close();
 
            return l.toArray();
 
        } catch (Exception e) {
 
            Activator.getCoronaLogService().log(CoronaLogService.LOG_ERROR, "Failed to open team repository!", e);
 
        }
 
      }
 
      return null;
 
  }
 
Please note that it will retrieve the list of objects ids which in the "Team Member" repository are strings and they are the team member login names. Following questions might arise now:
 
* how to connect the TeamRepositoryDescriptorWorkbenchAdapter class with the "Team Member Repository Descriptor".
 
* how do we know if repository descriptor stub in getChildren method is a "Team Member Repository Descriptor".
 
===Step 2: Join RepositoryDescriptorStub with IWorkbenchAdapter===
 
As an eclipse developer you should be familiar with the idea of IAdaptable interface and IAdaptableFactory classes/concept (if not please read the [http://www.eclipsezone.com/articles/what-is-iadaptable IAdaptable article]). Special [http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.corona/plugins/org.eclipse.corona.container.project.ui/src/org/eclipse/corona/internal/container/project/ui/explorer/views/extension/WorkbenchAdapterAdaptableFactory.java?root=Technology_Project&view=markup adaptable factory class] was created for retrieving IWorkbenchAdapter adaptable for RepositoryDescriptorStub object. To use the factory use the repositoryDescriptorWorkbenchAdapter extension point like in example below:
 
  <extension
 
        point="org.eclipse.corona.container.project.ui.repositoryDescriptorWorkbenchAdapter">
 
      <repositoryDescriptorStubWorkbenchAdaptable
 
            class="org.eclipse.corona.container.project.ui.explorer.views.team.TeamRepositoryDescriptorWorkbenchAdapter"
 
            content-type="http://www.eclipse.org/corona/contentTypes/teamContent"
 
            access-type="any"
 
            name="any"
 
            uri="any"/>
 
  </extension>
 
The extension point defines which IWorkbenchAdapter object will be returned when calling RepositoryDescriptorStub.getAdapter(IWorkbenchAdapter) method, additional attributes like content-type etc provides better match for retrieving proper WorkbechAdapter. ''"any"'' string is reserved factory word which indicates that repository descriptor attribute can have any value.<br>
 
The example above adds the TeamRepositoryDescriptorWorkbenchAdapter class for all repository descriptors which have the content-type equal to "http://www.eclipse.org/corona/contentTypes/teamContent". It's also possible to restrict the range of RepositoryDescriptorStubs which have the IWorkbenchAdapter defined by setting up other attributes.
 
===Example implementation===
 
You can find exemplary implementation in package org.eclipse.corona.container.project.ui.explorer.views.team.
 
 
==PCX action extension==
 
//TODO describe pre and post pcx action calls
 
===PreAction===
 
===PostAction===
 
 
==RepositoryDescriptorStub attributes==
 
//TODO describe all the attributes based on which PCX action can be tested
 

Latest revision as of 10:58, 27 February 2008

Back to the top