KickJava   Java API By Example, From Geeks To Geeks.

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


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