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

Corona HowTo: Customize "Project Container Explorer" view

Revision as of 07:34, 1 March 2007 by Piotr.jaworowski.compuware.com (Talk | contribs) (Initial version 0.000001)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Eclipse Home Wiki Home Development How To...

Expandable RepositoryDescriptors

By default Project Container Explorer view in corona without any additional coding is capable of showing following objects:

  • ProjectContextContainer
  • ProjectContextContainerStub
  • RepositoryDescriptor
  • RepositoryDescriptorStub

In following structure:

  - ProjectContextContainer
  |  |
  |  |RepositoryDescriptor
  |  |
  |  |RepositoryDescriptorStub
  + ProjectContextContainerStub

Please note that RepositoryDescriptors are leafs of displayed tree and on other additional elements can be shown under the repository descriptor.
Some of the repository descritors could 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.
Please see how the new tree structure can look in the example below:
CoronaPcxViewTeamMember.JPG

New type of objects displayed in PCX

To achieve the result of RepositoryDescriptors with additional information the list of objects shown in the PCX was enlarged to:

  • IWorkbenchAdapter
  • IAdaptable (with IWorkbenchAdapter defined)
  • 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.
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: Connect repository descriptor stub 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 IAdaptable article). A special 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 can have any value describing the attribute.
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".

Back to the top