KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > actions > expressions > RemoveAllExpressionsAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 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.actions.expressions;
12
13  
14 import org.eclipse.debug.core.DebugPlugin;
15 import org.eclipse.debug.core.IExpressionManager;
16 import org.eclipse.debug.core.IExpressionsListener;
17 import org.eclipse.debug.core.model.IExpression;
18 import org.eclipse.debug.internal.ui.DebugUIPlugin;
19 import org.eclipse.debug.internal.ui.actions.AbstractRemoveAllActionDelegate;
20 import org.eclipse.debug.internal.ui.actions.ActionMessages;
21 import org.eclipse.jface.action.IAction;
22 import org.eclipse.jface.dialogs.MessageDialog;
23 import org.eclipse.ui.IWorkbenchWindow;
24
25 /**
26  * Removes all expressions from the expressions view.
27  */

28 public class RemoveAllExpressionsAction extends AbstractRemoveAllActionDelegate implements IExpressionsListener {
29
30     /* (non-Javadoc)
31      * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
32      */

33     public void run(IAction action) {
34         IWorkbenchWindow window = DebugUIPlugin.getActiveWorkbenchWindow();
35         if (window != null) {
36             boolean proceed = MessageDialog.openQuestion(window.getShell(), ActionMessages.RemoveAllExpressionsAction_0, ActionMessages.RemoveAllExpressionsAction_1);
37             if (proceed) {
38                 IExpressionManager manager = DebugPlugin.getDefault().getExpressionManager();
39                 IExpression[] expressions= manager.getExpressions();
40                 manager.removeExpressions(expressions);
41             }
42         }
43     }
44     
45     /* (non-Javadoc)
46      * @see org.eclipse.debug.internal.ui.actions.selection.AbstractRemoveAllActionDelegate#isEnabled()
47      */

48     protected boolean isEnabled() {
49         return DebugPlugin.getDefault().getExpressionManager().hasExpressions();
50     }
51
52     /* (non-Javadoc)
53      * @see org.eclipse.debug.internal.ui.actions.selection.AbstractRemoveAllActionDelegate#initialize()
54      */

55     protected void initialize() {
56         DebugPlugin.getDefault().getExpressionManager().addExpressionListener(this);
57     }
58
59     /* (non-Javadoc)
60      * @see org.eclipse.debug.internal.ui.actions.selection.AbstractRemoveAllActionDelegate#dispose()
61      */

62     public void dispose() {
63         DebugPlugin.getDefault().getExpressionManager().removeExpressionListener(this);
64         super.dispose();
65     }
66
67     /* (non-Javadoc)
68      * @see org.eclipse.debug.core.IExpressionsListener#expressionsAdded(org.eclipse.debug.core.model.IExpression[])
69      */

70     public void expressionsAdded(IExpression[] expressions) {
71         update();
72     }
73
74     /* (non-Javadoc)
75      * @see org.eclipse.debug.core.IExpressionsListener#expressionsRemoved(org.eclipse.debug.core.model.IExpression[])
76      */

77     public void expressionsRemoved(IExpression[] expressions) {
78         update();
79     }
80
81     /* (non-Javadoc)
82      * @see org.eclipse.debug.core.IExpressionsListener#expressionsChanged(org.eclipse.debug.core.model.IExpression[])
83      */

84     public void expressionsChanged(IExpression[] expressions) {}
85 }
86
Popular Tags