KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > elements > adapters > DebugTargetContentAdapter


1 /*******************************************************************************
2  * Copyright (c) 2005, 2006 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
12 package org.eclipse.debug.internal.ui.elements.adapters;
13
14 import org.eclipse.core.runtime.CoreException;
15 import org.eclipse.debug.core.DebugPlugin;
16 import org.eclipse.debug.core.model.IDebugTarget;
17 import org.eclipse.debug.core.model.IMemoryBlockRetrieval;
18 import org.eclipse.debug.internal.ui.viewers.provisional.AsynchronousContentAdapter;
19 import org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext;
20 import org.eclipse.debug.ui.IDebugUIConstants;
21
22 public class DebugTargetContentAdapter extends AsynchronousContentAdapter {
23
24
25     /*
26      * (non-Javadoc)
27      * @see org.eclipse.debug.internal.ui.viewers.provisional.AsynchronousContentAdapter#getChildren(java.lang.Object, org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext)
28      */

29     protected Object JavaDoc[] getChildren(Object JavaDoc parent, IPresentationContext context) throws CoreException {
30         String JavaDoc id = context.getPart().getSite().getId();
31         if (id.equals(IDebugUIConstants.ID_DEBUG_VIEW))
32             return ((IDebugTarget) parent).getThreads();
33         else if (id.equals(IDebugUIConstants.ID_MEMORY_VIEW))
34         {
35             if (parent instanceof IMemoryBlockRetrieval)
36             {
37                 return DebugPlugin.getDefault().getMemoryBlockManager().getMemoryBlocks((IMemoryBlockRetrieval)parent);
38             }
39         }
40         return EMPTY;
41     }
42
43     /*
44      * (non-Javadoc)
45      * @see org.eclipse.debug.internal.ui.viewers.provisional.AsynchronousContentAdapter#hasChildren(java.lang.Object, org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext)
46      */

47     protected boolean hasChildren(Object JavaDoc element, IPresentationContext context) throws CoreException {
48         String JavaDoc id = context.getPart().getSite().getId();
49         if (id.equals(IDebugUIConstants.ID_DEBUG_VIEW))
50             return ((IDebugTarget)element).hasThreads();
51         if (id.equals(IDebugUIConstants.ID_MEMORY_VIEW))
52         {
53             if (element instanceof IMemoryBlockRetrieval)
54             {
55                 if (((IMemoryBlockRetrieval)element).supportsStorageRetrieval())
56                     return DebugPlugin.getDefault().getMemoryBlockManager().getMemoryBlocks((IMemoryBlockRetrieval)element).length > 0;
57             }
58         }
59         return false;
60     }
61
62
63     /*
64      * (non-Javadoc)
65      * @see org.eclipse.debug.internal.ui.viewers.provisional.AsynchronousContentAdapter#supportsPartId(java.lang.String)
66      */

67     protected boolean supportsPartId(String JavaDoc id) {
68         return IDebugUIConstants.ID_DEBUG_VIEW.equals(id) || IDebugUIConstants.ID_MEMORY_VIEW.equals(id);
69     }
70
71 }
72
Popular Tags