KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > actions > ReevaluateWatchExpressionAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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.actions;
12
13
14 import java.util.Iterator JavaDoc;
15
16 import org.eclipse.debug.core.model.IDebugElement;
17 import org.eclipse.debug.core.model.IWatchExpression;
18 import org.eclipse.jface.action.IAction;
19 import org.eclipse.jface.viewers.ISelection;
20
21 /**
22  * Ask to re-evaluate one or more watch expressions in the context of the
23  * currently selected thread.
24  */

25 public class ReevaluateWatchExpressionAction extends WatchExpressionAction {
26
27     /**
28      * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
29      */

30     public void run(IAction action) {
31         IDebugElement context = getContext();
32         for (Iterator JavaDoc iter= getCurrentSelection().iterator(); iter.hasNext();) {
33             IWatchExpression expression= (IWatchExpression) iter.next();
34             expression.setExpressionContext(context);
35             if (!expression.isEnabled()) {
36                 // Force a reevaluation
37
expression.evaluate();
38             }
39         }
40     }
41     
42     /**
43      * @see IActionDelegate#selectionChanged(IAction, ISelection)
44      */

45     public void selectionChanged(IAction action, ISelection selection) {
46         IDebugElement debugElement = getContext();
47         if (debugElement == null) {
48             action.setEnabled(false);
49         } else {
50             action.setEnabled(true);
51         }
52     }
53
54 }
55
Popular Tags