KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > actions > breakpoints > RulerEnableDisableBreakpointAction


1 /*******************************************************************************
2  * Copyright (c) 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.breakpoints;
12
13 import org.eclipse.core.runtime.CoreException;
14 import org.eclipse.debug.core.model.IBreakpoint;
15 import org.eclipse.debug.internal.ui.DebugUIPlugin;
16 import org.eclipse.debug.internal.ui.actions.ActionMessages;
17 import org.eclipse.debug.ui.actions.RulerBreakpointAction;
18 import org.eclipse.jface.text.source.IVerticalRulerInfo;
19 import org.eclipse.ui.texteditor.ITextEditor;
20 import org.eclipse.ui.texteditor.IUpdate;
21
22 /**
23  * @since 3.2
24  *
25  */

26 public class RulerEnableDisableBreakpointAction extends RulerBreakpointAction implements IUpdate {
27     
28     private IBreakpoint fBreakpoint;
29     
30     public RulerEnableDisableBreakpointAction(ITextEditor editor, IVerticalRulerInfo info) {
31         super(editor, info);
32     }
33
34     /* (non-Javadoc)
35      * @see org.eclipse.jface.action.Action#run()
36      */

37     public void run() {
38         if (fBreakpoint != null) {
39             try {
40                 fBreakpoint.setEnabled(!fBreakpoint.isEnabled());
41             } catch (CoreException e) {
42                 DebugUIPlugin.errorDialog(getEditor().getSite().getShell(), ActionMessages.RulerEnableDisableBreakpointAction_0, ActionMessages.RulerEnableDisableBreakpointAction_1, e.getStatus());
43             }
44         }
45     }
46
47     /* (non-Javadoc)
48      * @see org.eclipse.ui.texteditor.IUpdate#update()
49      */

50     public void update() {
51         fBreakpoint = getBreakpoint();
52         setEnabled(fBreakpoint != null);
53         if (fBreakpoint != null) {
54             try {
55                 if (fBreakpoint.isEnabled()) {
56                     setText(ActionMessages.RulerEnableDisableBreakpointAction_2);
57                 } else {
58                     setText(ActionMessages.RulerEnableDisableBreakpointAction_3);
59                 }
60             } catch (CoreException e) {
61             }
62         } else {
63             setText(ActionMessages.RulerEnableDisableBreakpointAction_2);
64         }
65     }
66
67 }
68
Popular Tags