1
/*******************************************************************************
2
* Copyright (c) 2007 ARM 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
9
* ARM - Initial API and implementation
10
*******************************************************************************/
11
package org.eclipse.cdt.debug.internal.ui.views.modules;
13
import org.eclipse.cdt.core.model.ICElement;
14
import org.eclipse.cdt.debug.core.CDIDebugModel;
15
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
16
import org.eclipse.cdt.debug.core.model.ICModule;
17
import org.eclipse.cdt.debug.core.model.ICStackFrame;
18
import org.eclipse.cdt.debug.core.model.ICThread;
19
import org.eclipse.cdt.debug.core.model.IModuleRetrieval;
20
import org.eclipse.core.runtime.CoreException;
21
import org.eclipse.core.runtime.IAdaptable;
22
import org.eclipse.debug.internal.ui.model.elements.ElementMementoProvider;
23
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
24
import org.eclipse.ui.IMemento;
27
* org.eclipse.cdt.debug.internal.ui.views.modules.ModuleMementoProvider:
28
* //TODO Add description.
30
public class ModuleMementoProvider extends ElementMementoProvider {
35
private static final String ELEMENT_NAME = "ELEMENT_NAME"; //$NON-NLS-1$
38
* @see org.eclipse.debug.internal.ui.model.elements.ElementMementoProvider#encodeElement(java.lang.Object, org.eclipse.ui.IMemento, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext)
40
protected boolean encodeElement( Object element, IMemento memento, IPresentationContext context ) throws CoreException {
41
if ( element instanceof ICDebugTarget || element instanceof ICThread || element instanceof ICStackFrame ) {
42
IModuleRetrieval mr = (IModuleRetrieval)((IAdaptable)element).getAdapter( IModuleRetrieval.class );
44
memento.putString( ELEMENT_NAME, mr.toString() );
48
memento.putString( ELEMENT_NAME, CDIDebugModel.getPluginIdentifier() );
51
else if ( element instanceof ICModule ) {
52
memento.putString( ELEMENT_NAME, ((ICModule)element).getName() );
54
else if ( element instanceof ICElement ) {
55
memento.putString( ELEMENT_NAME, ((ICElement)element).getElementName() );
64
* @see org.eclipse.debug.internal.ui.model.elements.ElementMementoProvider#isEqual(java.lang.Object, org.eclipse.ui.IMemento, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext)
66
protected boolean isEqual( Object element, IMemento memento, IPresentationContext context ) throws CoreException {
67
String mementoName = memento.getString( ELEMENT_NAME );
68
if ( mementoName != null ) {
69
String elementName = null;
70
if ( element instanceof ICDebugTarget || element instanceof ICThread || element instanceof ICStackFrame ) {
71
IModuleRetrieval mr = (IModuleRetrieval)((IAdaptable)element).getAdapter( IModuleRetrieval.class );
72
elementName = ( mr != null ) ? mr.toString() : CDIDebugModel.getPluginIdentifier();
74
else if ( element instanceof ICModule ) {
75
elementName = ((ICModule)element).getName();
77
else if ( element instanceof ICElement ) {
78
elementName = ((ICElement)element).getElementName();
80
if ( elementName != null ) {
81
return elementName.equals( mementoName );