KickJava   Java API By Example, From Geeks To Geeks.

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


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.IMemoryBlockRetrieval;
17 import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
18 import org.eclipse.debug.internal.ui.viewers.provisional.AsynchronousContentAdapter;
19 import org.eclipse.debug.ui.IDebugUIConstants;
20
21 public class MemoryRetrievalContentAdapter extends AsynchronousContentAdapter{
22
23     protected Object JavaDoc[] getChildren(Object JavaDoc parent, IPresentationContext context) throws CoreException {
24         String JavaDoc id = context.getId();
25         if (id.equals(IDebugUIConstants.ID_MEMORY_VIEW))
26         {
27             if (parent instanceof IMemoryBlockRetrieval)
28             {
29                 return DebugPlugin.getDefault().getMemoryBlockManager().getMemoryBlocks((IMemoryBlockRetrieval)parent);
30             }
31         }
32         return EMPTY;
33     }
34
35     protected boolean hasChildren(Object JavaDoc element, IPresentationContext context) throws CoreException {
36         String JavaDoc id = context.getId();
37         if (id.equals(IDebugUIConstants.ID_MEMORY_VIEW))
38         {
39             if (element instanceof IMemoryBlockRetrieval)
40             {
41                 if (((IMemoryBlockRetrieval)element).supportsStorageRetrieval())
42                     return DebugPlugin.getDefault().getMemoryBlockManager().getMemoryBlocks((IMemoryBlockRetrieval)element).length > 0;
43             }
44         }
45         return false;
46     }
47
48     protected boolean supportsPartId(String JavaDoc id) {
49         return id.equals(IDebugUIConstants.ID_MEMORY_VIEW);
50     }
51
52 }
53
Popular Tags