KickJava   Java API By Example, From Geeks To Geeks.

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


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.internal.ui.viewers.model.provisional.IPresentationContext;
15 import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate;
16 import org.eclipse.debug.ui.IDebugUIConstants;
17
18 /**
19  * This content provider is required in order to have selection maintained properly
20  * when swtiching between session. The problem is, when swtich debug session, the memory view reset the input
21  * to the viewer.
22  *
23  * After the input is set, viewer's doInitialRestore is called. At this time, the elemtns
24  * are not mapped in the viewer yet, as a result, the selection cannot be maintained.
25  *
26  * The viewer tries to restore selection again after elements are added to the view. This is done
27  * in the HasChildrenJob. However, this job will not get scheduled unless the element provides a content
28  * provider adapter. As a result, the job is never scheduled and the selection cannot be maintained.
29  *
30  */

31 public class MemoryBlockContentProvider extends ElementContentProvider {
32
33     protected int getChildCount(Object JavaDoc element, IPresentationContext context,
34             IViewerUpdate monitor) throws CoreException {
35         return 0;
36     }
37
38     protected Object JavaDoc[] getChildren(Object JavaDoc parent, int index, int length,
39             IPresentationContext context, IViewerUpdate monitor)
40             throws CoreException {
41         return EMPTY;
42     }
43
44     protected boolean supportsContextId(String JavaDoc id) {
45         if (id.equals(IDebugUIConstants.ID_MEMORY_VIEW))
46             return true;
47         return false;
48     }
49
50 }
51
Popular Tags