~ubuntu-branches/debian/sid/eclipse-cdt/sid

« back to all changes in this revision

Viewing changes to debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModuleContentProvider.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2011-10-06 21:15:04 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20111006211504-8dutmljjih0zikfv
Tags: 8.0.1-1
* New upstream release.
* Split the JNI packages into a separate architecture dependent
  package and made eclipse-cdt architecture independent.
* Install JNI libraries into multiarch aware location
* Bumped Standards-Version to 3.9.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*******************************************************************************
 
2
 * Copyright (c) 2007, 2008 ARM and others.
 
3
 * All rights reserved. This program and the accompanying materials
 
4
 * are made available under the terms of the Eclipse Public License v1.0
 
5
 * which accompanies this distribution, and is available at
 
6
 * http://www.eclipse.org/legal/epl-v10.html
 
7
 *
 
8
 * Contributors:
 
9
 * ARM - Initial API and implementation
 
10
 * Wind River Systems - adapted to work with platform Modules view (bug 210558)
 
11
 *******************************************************************************/
 
12
package org.eclipse.cdt.debug.internal.ui.views.modules; 
 
13
 
 
14
import org.eclipse.cdt.core.model.CModelException;
 
15
import org.eclipse.cdt.core.model.IBinary;
 
16
import org.eclipse.cdt.core.model.IParent;
 
17
import org.eclipse.cdt.debug.core.model.ICModule;
 
18
import org.eclipse.cdt.debug.core.model.ICStackFrame;
 
19
import org.eclipse.cdt.debug.core.model.ICThread;
 
20
import org.eclipse.cdt.debug.core.model.IModuleRetrieval;
 
21
import org.eclipse.core.runtime.CoreException;
 
22
import org.eclipse.core.runtime.IAdaptable;
 
23
import org.eclipse.debug.internal.ui.model.elements.ElementContentProvider;
 
24
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
 
25
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate;
 
26
import org.eclipse.debug.ui.IDebugUIConstants;
 
27
 
 
28
public class ModuleContentProvider extends ElementContentProvider {
 
29
 
 
30
        /* (non-Javadoc)
 
31
         * @see org.eclipse.debug.internal.ui.model.elements.ElementContentProvider#getChildCount(java.lang.Object, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate)
 
32
         */
 
33
        protected int getChildCount( Object element, IPresentationContext context, IViewerUpdate monitor ) throws CoreException {
 
34
                return getAllChildren( element, context ).length;
 
35
        }
 
36
 
 
37
        /* (non-Javadoc)
 
38
         * @see org.eclipse.debug.internal.ui.model.elements.ElementContentProvider#getChildren(java.lang.Object, int, int, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate)
 
39
         */
 
40
        protected Object[] getChildren( Object parent, int index, int length, IPresentationContext context, IViewerUpdate monitor ) throws CoreException {
 
41
                return getElements( getAllChildren( parent, context ), index, length );
 
42
        }
 
43
 
 
44
        /* (non-Javadoc)
 
45
         * @see org.eclipse.debug.internal.ui.model.elements.ElementContentProvider#supportsContextId(java.lang.String)
 
46
         */
 
47
        protected boolean supportsContextId( String id ) {
 
48
                return IDebugUIConstants.ID_MODULE_VIEW.equals( id );
 
49
        }
 
50
        
 
51
        protected Object[] getAllChildren( Object parent, IPresentationContext context ) throws CoreException {                 
 
52
                if ( parent instanceof IModuleRetrieval ) {
 
53
                        return ((IModuleRetrieval)parent).getModules();
 
54
                }
 
55
                else if ( parent instanceof ICThread || parent instanceof ICStackFrame ) {
 
56
                        IModuleRetrieval mr = (IModuleRetrieval)((IAdaptable)parent).getAdapter( IModuleRetrieval.class );
 
57
                        if ( mr != null ) {
 
58
                                return mr.getModules();
 
59
                        }
 
60
                }
 
61
                else if ( parent instanceof ICModule ) {
 
62
                        IBinary binary = (IBinary)((ICModule)parent).getAdapter( IBinary.class );
 
63
                        if ( binary != null ) {
 
64
                                try {
 
65
                                        return binary.getChildren();
 
66
                                }
 
67
                                catch( CModelException e ) {
 
68
                                }
 
69
                        }
 
70
                }
 
71
                else if ( parent instanceof IParent ) {
 
72
                        try {
 
73
                                return ((IParent)parent).getChildren();
 
74
                        }
 
75
                        catch( CModelException e ) {
 
76
                        }
 
77
                }
 
78
                return EMPTY;
 
79
        }
 
80
}