Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: e9e67db92116cda9e9d90e5d7968afa641118f0f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*******************************************************************************
 * Copyright (c) 2006, 2007 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.debug.internal.ui.model.elements;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate;
import org.eclipse.debug.ui.IDebugUIConstants;

/**
 * This content provider is required in order to have selection maintained properly
 * when swtiching between session.  The problem is, when swtich debug session, the memory view reset the input
 * to the viewer.
 *
 * After the input is set, viewer's doInitialRestore is called.  At this time, the elemtns
 * are not mapped in the viewer yet, as a result, the selection cannot be maintained.
 *
 * The viewer tries to restore selection again after elements are added to the view.  This is done
 * in the HasChildrenJob.  However, this job will not get scheduled unless the element provides a content
 * provider adapter.  As a result, the job is never scheduled and the selection cannot be maintained.
 *
 */
public class MemoryBlockContentProvider extends ElementContentProvider {

	@Override
	protected int getChildCount(Object element, IPresentationContext context,
			IViewerUpdate monitor) throws CoreException {
		return 0;
	}

	@Override
	protected Object[] getChildren(Object parent, int index, int length,
			IPresentationContext context, IViewerUpdate monitor)
			throws CoreException {
		return EMPTY;
	}

	@Override
	protected boolean supportsContextId(String id) {
		if (id.equals(IDebugUIConstants.ID_MEMORY_VIEW))
			return true;
		return false;
	}

}

Back to the top