KickJava   Java API By Example, From Geeks To Geeks.

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


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
12 package org.eclipse.debug.internal.ui.viewers.update;
13
14 import org.eclipse.debug.core.DebugEvent;
15 import org.eclipse.debug.core.DebugPlugin;
16 import org.eclipse.debug.core.model.IExpression;
17 import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
18 import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxy;
19 import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta;
20 import org.eclipse.debug.internal.ui.viewers.provisional.AbstractModelProxy;
21
22 /**
23  * Event handler for an expression.
24  *
25  * @since 3.2
26  *
27  */

28 public class ExpressionEventHandler extends DebugEventHandler {
29
30     public ExpressionEventHandler(AbstractModelProxy proxy) {
31         super(proxy);
32     }
33
34     protected boolean handlesEvent(DebugEvent event) {
35         return event.getKind() == DebugEvent.CHANGE;
36     }
37
38     protected void handleChange(DebugEvent event) {
39         ModelDelta delta = new ModelDelta(DebugPlugin.getDefault().getExpressionManager(), IModelDelta.NO_CHANGE);
40         IExpression expression = null;
41         if (event.getSource() instanceof IExpression) {
42             expression = (IExpression) event.getSource();
43         } else {
44             IModelProxy modelProxy = getModelProxy();
45             if (modelProxy instanceof DefaultExpressionModelProxy) {
46                 DefaultExpressionModelProxy proxy = (DefaultExpressionModelProxy) modelProxy;
47                 expression = proxy.getExpression();
48             }
49         }
50         if (expression != null) {
51             int flags = IModelDelta.NO_CHANGE;
52             if ((event.getDetail() & DebugEvent.STATE) != 0) {
53                 flags = flags | IModelDelta.STATE;
54             }
55             if ((event.getDetail() & DebugEvent.CONTENT) != 0) {
56                 flags = flags | IModelDelta.CONTENT;
57             }
58             delta.addNode(expression, flags);
59             fireDelta(delta);
60         }
61     }
62
63     protected void refreshRoot(DebugEvent event) {
64         ModelDelta delta = new ModelDelta(DebugPlugin.getDefault().getExpressionManager(), IModelDelta.CONTENT);
65         fireDelta(delta);
66     }
67     
68 }
69
Popular Tags