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
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;
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;
28
public class ModuleContentProvider extends ElementContentProvider {
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)
33
protected int getChildCount( Object element, IPresentationContext context, IViewerUpdate monitor ) throws CoreException {
34
return getAllChildren( element, context ).length;
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)
40
protected Object[] getChildren( Object parent, int index, int length, IPresentationContext context, IViewerUpdate monitor ) throws CoreException {
41
return getElements( getAllChildren( parent, context ), index, length );
45
* @see org.eclipse.debug.internal.ui.model.elements.ElementContentProvider#supportsContextId(java.lang.String)
47
protected boolean supportsContextId( String id ) {
48
return IDebugUIConstants.ID_MODULE_VIEW.equals( id );
51
protected Object[] getAllChildren( Object parent, IPresentationContext context ) throws CoreException {
52
if ( parent instanceof IModuleRetrieval ) {
53
return ((IModuleRetrieval)parent).getModules();
55
else if ( parent instanceof ICThread || parent instanceof ICStackFrame ) {
56
IModuleRetrieval mr = (IModuleRetrieval)((IAdaptable)parent).getAdapter( IModuleRetrieval.class );
58
return mr.getModules();
61
else if ( parent instanceof ICModule ) {
62
IBinary binary = (IBinary)((ICModule)parent).getAdapter( IBinary.class );
63
if ( binary != null ) {
65
return binary.getChildren();
67
catch( CModelException e ) {
71
else if ( parent instanceof IParent ) {
73
return ((IParent)parent).getChildren();
75
catch( CModelException e ) {