Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: d08e49145f7b5537de03de28939f95f13991ca9e (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*******************************************************************************
 * Copyright (c) 2004 QNX Software Systems 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:
 * QNX Software Systems - Initial API and implementation
 *******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.views.modules; 

import org.eclipse.cdt.debug.core.model.ICModule;
import org.eclipse.cdt.debug.core.model.IModuleRetrieval;
import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.debug.internal.ui.viewers.provisional.AbstractModelProxy;
import org.eclipse.debug.internal.ui.viewers.provisional.IModelDelta;
import org.eclipse.debug.internal.ui.viewers.provisional.ModelDelta;
import org.eclipse.debug.internal.ui.viewers.update.DebugEventHandler;
 
/**
 * Comment for .
 */
public class ModulesViewEventHandler extends DebugEventHandler {

	private IModuleRetrieval fModuleRetrieval;

	/** 
	 * Constructor for ModulesViewEventHandler. 
	 */
	public ModulesViewEventHandler( AbstractModelProxy proxy, IModuleRetrieval moduleRetrieval ) {
		super( proxy );
		fModuleRetrieval = moduleRetrieval;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.debug.internal.ui.viewers.update.DebugEventHandler#handlesEvent(org.eclipse.debug.core.DebugEvent)
	 */
	protected boolean handlesEvent( DebugEvent event ) {
		if ( event.getKind() == DebugEvent.CREATE || 
			 event.getKind() == DebugEvent.TERMINATE || 
			 event.getKind() == DebugEvent.CHANGE )
			return true;
		return false;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.debug.internal.ui.viewers.update.DebugEventHandler#handleChange(org.eclipse.debug.core.DebugEvent)
	 */
	protected void handleChange( DebugEvent event ) {
		if ( event.getSource() instanceof ICModule )
			fireDelta( (ICModule)event.getSource(), IModelDelta.STATE );
	}

	/* (non-Javadoc)
	 * @see org.eclipse.debug.internal.ui.viewers.update.DebugEventHandler#handleCreate(org.eclipse.debug.core.DebugEvent)
	 */
	protected void handleCreate( DebugEvent event ) {
		if ( event.getSource() instanceof IDebugTarget ) {
			refreshRoot( event );
		}
		else if ( event.getSource() instanceof ICModule ) {
			fireDelta( (ICModule)event.getSource(), IModelDelta.ADDED );
		}
	}

	/* (non-Javadoc)
	 * @see org.eclipse.debug.internal.ui.viewers.update.DebugEventHandler#handleTerminate(org.eclipse.debug.core.DebugEvent)
	 */
	protected void handleTerminate( DebugEvent event ) {
		if ( event.getSource() instanceof IDebugTarget ) {
			refreshRoot( event );
		}
		else if ( event.getSource() instanceof ICModule ) {
			fireDelta( (ICModule)event.getSource(), IModelDelta.REMOVED );
		}
	}

	private void fireDelta( ICModule module, int flags ) {
		ModelDelta root = new ModelDelta( fModuleRetrieval, IModelDelta.NO_CHANGE );
		root.addNode( module, flags );
		fireDelta( root );
	}

	/* (non-Javadoc)
	 * @see org.eclipse.debug.internal.ui.viewers.update.DebugEventHandler#dispose()
	 */
	public synchronized void dispose() {
		super.dispose();
		fModuleRetrieval = null;
	}
}

Back to the top