KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > model > elements > DebugTargetContentProvider


1 /*******************************************************************************
2  * Copyright (c) 2006, 2007 IBM Corporation 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  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.debug.internal.ui.model.elements;
12
13 import org.eclipse.core.runtime.CoreException;
14 import org.eclipse.debug.core.DebugPlugin;
15 import org.eclipse.debug.core.model.IDebugTarget;
16 import org.eclipse.debug.core.model.IMemoryBlockRetrieval;
17 import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
18 import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate;
19 import org.eclipse.debug.ui.IDebugUIConstants;
20
21 /**
22  * @since 3.3
23  */

24 public class DebugTargetContentProvider extends ElementContentProvider {
25
26     /* (non-Javadoc)
27      * @see org.eclipse.debug.internal.ui.viewers.model.provisional.elements.ElementContentProvider#getChildCount(java.lang.Object, org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext)
28      */

29     protected int getChildCount(Object JavaDoc element, IPresentationContext context, IViewerUpdate monitor) throws CoreException {
30         String JavaDoc id = context.getId();
31         if (id.equals(IDebugUIConstants.ID_DEBUG_VIEW))
32         {
33             return ((IDebugTarget)element).getThreads().length;
34         }
35         else if (id.equals(IDebugUIConstants.ID_MEMORY_VIEW))
36         {
37             return getAllChildren(element, context, monitor).length;
38         }
39         return 0;
40     }
41
42     /* (non-Javadoc)
43      * @see org.eclipse.debug.internal.ui.viewers.model.provisional.elements.ElementContentProvider#supportsContextId(java.lang.String)
44      */

45     protected boolean supportsContextId(String JavaDoc id) {
46         return IDebugUIConstants.ID_DEBUG_VIEW.equals(id) || IDebugUIConstants.ID_MEMORY_VIEW.equals(id);
47     }
48
49     /* (non-Javadoc)
50      * @see org.eclipse.debug.internal.ui.viewers.model.provisional.elements.ElementContentProvider#getChildren(java.lang.Object, int, int, org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext)
51      */

52     protected Object JavaDoc[] getChildren(Object JavaDoc parent, int index, int length, IPresentationContext context, IViewerUpdate monitor) throws CoreException {
53         return getElements(getAllChildren(parent, context, monitor), index, length);
54     }
55
56     protected boolean hasChildren(Object JavaDoc element, IPresentationContext context, IViewerUpdate monitor) throws CoreException {
57         String JavaDoc id = context.getId();
58         if (id.equals(IDebugUIConstants.ID_DEBUG_VIEW))
59         {
60             return ((IDebugTarget)element).hasThreads();
61         }
62         else if (id.equals(IDebugUIConstants.ID_MEMORY_VIEW))
63         {
64             return getAllChildren(element, context, monitor).length > 0;
65         }
66         return false;
67     }
68
69     protected Object JavaDoc[] getAllChildren(Object JavaDoc parent, IPresentationContext context, IViewerUpdate monitor) throws CoreException {
70         String JavaDoc id = context.getId();
71         if (id.equals(IDebugUIConstants.ID_DEBUG_VIEW))
72         {
73             return ((IDebugTarget)parent).getThreads();
74         }
75         else if (id.equals(IDebugUIConstants.ID_MEMORY_VIEW))
76         {
77             if (parent instanceof IMemoryBlockRetrieval)
78             {
79                 if (((IMemoryBlockRetrieval)parent).supportsStorageRetrieval())
80                     return DebugPlugin.getDefault().getMemoryBlockManager().getMemoryBlocks((IMemoryBlockRetrieval)parent);
81             }
82         }
83         return EMPTY;
84     }
85     
86     
87 }
88
Popular Tags