KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.eclipse.debug.core.DebugPlugin;
15 import org.eclipse.debug.core.model.IWatchExpression;
16 import org.eclipse.debug.internal.ui.DebugUIPlugin;
17 import org.eclipse.jface.action.IAction;
18 import org.eclipse.jface.viewers.ISelection;
19 import org.eclipse.jface.window.Window;
20 import org.eclipse.ui.IViewActionDelegate;
21 import org.eclipse.ui.IViewPart;
22
23 /**
24  * Open a watch expression dialog and add the created watch expression to the
25  * expression view.
26  */

27 public class AddWatchExpressionAction extends WatchExpressionAction implements IViewActionDelegate {
28
29     /**
30      * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
31      */

32     public void init(IViewPart view) {
33     }
34
35     /**
36      * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
37      */

38     public void run(IAction action) {
39         // create a watch expression
40
IWatchExpression watchExpression= DebugPlugin.getDefault().getExpressionManager().newWatchExpression(""); //$NON-NLS-1$
41
// open the watch expression dialog
42
if (new WatchExpressionDialog(DebugUIPlugin.getShell(), watchExpression, false).open() == Window.OK) {
43             // if OK is selected, add the expression to the expression view and try to evaluate the expression.
44
DebugPlugin.getDefault().getExpressionManager().addExpression(watchExpression);
45             watchExpression.setExpressionContext(getContext());
46         }
47     }
48
49     /**
50      * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
51      */

52     public void selectionChanged(IAction action, ISelection selection) {
53     }
54
55 }
56
Popular Tags