KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > viewers > update > DebugTargetEventHandler


1 /*******************************************************************************
2  * Copyright (c) 2005, 2006 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.viewers.update;
12
13 import org.eclipse.debug.core.DebugEvent;
14 import org.eclipse.debug.core.DebugPlugin;
15 import org.eclipse.debug.core.model.IDebugTarget;
16 import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
17 import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta;
18 import org.eclipse.debug.internal.ui.viewers.provisional.AbstractModelProxy;
19
20
21 /**
22  * @since 3.2
23  */

24 public class DebugTargetEventHandler extends DebugEventHandler {
25
26     /**
27      * Constructs an event handler for a debug target on the given viewer.
28      *
29      * @param viewer
30      */

31     public DebugTargetEventHandler(AbstractModelProxy proxy) {
32         super(proxy);
33     }
34
35     /* (non-Javadoc)
36      * @see org.eclipse.debug.internal.ui.viewers.update.DebugEventHandler#handlesEvent(org.eclipse.debug.core.DebugEvent)
37      */

38     protected boolean handlesEvent(DebugEvent event) {
39         return event.getSource() instanceof IDebugTarget;
40     }
41
42     protected void handleChange(DebugEvent event) {
43         int flags = IModelDelta.STATE;
44         if (event.getDetail() == DebugEvent.CONTENT) {
45             flags = flags | IModelDelta.CONTENT;
46         }
47         fireDelta((IDebugTarget) event.getSource(), flags);
48     }
49
50     protected void handleCreate(DebugEvent event) {
51         fireDelta((IDebugTarget) event.getSource(), IModelDelta.EXPAND);
52     }
53
54     protected void handleResume(DebugEvent event) {
55         fireDelta((IDebugTarget) event.getSource(), IModelDelta.CONTENT | IModelDelta.STATE | IModelDelta.SELECT);
56     }
57
58     protected void handleSuspend(DebugEvent event) {
59         fireDelta((IDebugTarget) event.getSource(), IModelDelta.CONTENT | IModelDelta.STATE);
60     }
61
62     protected void handleTerminate(DebugEvent event) {
63         fireDelta((IDebugTarget) event.getSource(), IModelDelta.CONTENT | IModelDelta.STATE | IModelDelta.UNINSTALL);
64     }
65
66     private void fireDelta(IDebugTarget target, int flags) {
67         ModelDelta root = new ModelDelta(DebugPlugin.getDefault().getLaunchManager(), IModelDelta.NO_CHANGE);
68         ModelDelta delta = root.addNode(target.getLaunch(), IModelDelta.NO_CHANGE);
69         delta.addNode(target, flags);
70         fireDelta(root);
71     }
72     
73 }
74
Popular Tags