KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ant > internal > ui > editor > actions > EnableDisableBreakpointRulerAction


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.ant.internal.ui.editor.actions;
12
13 import org.eclipse.ant.internal.ui.AntUIPlugin;
14 import org.eclipse.core.runtime.CoreException;
15 import org.eclipse.jface.dialogs.ErrorDialog;
16 import org.eclipse.jface.text.source.IVerticalRulerInfo;
17 import org.eclipse.ui.texteditor.ITextEditor;
18
19 public class EnableDisableBreakpointRulerAction extends AbstractBreakpointRulerAction {
20     
21     /**
22      * Creates the action to enable/disable breakpoints
23      */

24     public EnableDisableBreakpointRulerAction(ITextEditor editor, IVerticalRulerInfo info) {
25         setInfo(info);
26         setTextEditor(editor);
27         setText(AntEditorActionMessages.getString("EnableDisableBreakpointRulerAction.0")); //$NON-NLS-1$
28
}
29
30     /* (non-Javadoc)
31      * @see org.eclipse.jface.action.IAction#run()
32      */

33     public void run() {
34         if (getBreakpoint() != null) {
35             try {
36                 getBreakpoint().setEnabled(!getBreakpoint().isEnabled());
37             } catch (CoreException e) {
38                 ErrorDialog.openError(getTextEditor().getEditorSite().getShell(), AntEditorActionMessages.getString("EnableDisableBreakpointRulerAction.1"), AntEditorActionMessages.getString("EnableDisableBreakpointRulerAction.2"), e.getStatus()); //$NON-NLS-1$ //$NON-NLS-2$
39
}
40         }
41     }
42     
43     /* (non-Javadoc)
44      * @see org.eclipse.ui.texteditor.IUpdate#update()
45      */

46     public void update() {
47         setBreakpoint(determineBreakpoint());
48         if (getBreakpoint() == null) {
49             setEnabled(false);
50             return;
51         }
52         setEnabled(true);
53         try {
54             boolean enabled= getBreakpoint().isEnabled();
55             setText(enabled ? AntEditorActionMessages.getString("EnableDisableBreakpointRulerAction.3"): AntEditorActionMessages.getString("EnableDisableBreakpointRulerAction.4")); //$NON-NLS-1$ //$NON-NLS-2$
56
} catch (CoreException ce) {
57             AntUIPlugin.log(ce);
58         }
59     }
60 }
61
Popular Tags