KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > debug > ui > actions > JavaBreakpointPropertiesRulerAction


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.jdt.internal.debug.ui.actions;
12
13
14 import org.eclipse.debug.core.model.IBreakpoint;
15 import org.eclipse.debug.ui.actions.RulerBreakpointAction;
16 import org.eclipse.jdt.debug.core.IJavaBreakpoint;
17 import org.eclipse.jface.text.source.IVerticalRulerInfo;
18 import org.eclipse.jface.viewers.ISelection;
19 import org.eclipse.jface.viewers.ISelectionChangedListener;
20 import org.eclipse.jface.viewers.ISelectionProvider;
21 import org.eclipse.jface.viewers.StructuredSelection;
22 import org.eclipse.ui.dialogs.PropertyDialogAction;
23 import org.eclipse.ui.texteditor.ITextEditor;
24 import org.eclipse.ui.texteditor.IUpdate;
25
26
27 /**
28  * Presents the standard properties dialog to configure
29  * the attibutes of a Java Breakpoint from the ruler popup menu of a
30  * text editor.
31  */

32 public class JavaBreakpointPropertiesRulerAction extends RulerBreakpointAction implements IUpdate {
33     
34     private IBreakpoint fBreakpoint;
35
36     /**
37      * Creates the action to enable/disable breakpoints
38      */

39     public JavaBreakpointPropertiesRulerAction(ITextEditor editor, IVerticalRulerInfo info) {
40         super(editor, info);
41         setText(ActionMessages.JavaBreakpointPropertiesRulerAction_Breakpoint__Properties_1);
42     }
43     /**
44      * @see Action#run()
45      */

46     public void run() {
47         if (getBreakpoint() != null) {
48             PropertyDialogAction action=
49                 new PropertyDialogAction(getEditor().getEditorSite(), new ISelectionProvider() {
50                     public void addSelectionChangedListener(ISelectionChangedListener listener) {
51                     }
52                     public ISelection getSelection() {
53                         return new StructuredSelection(getBreakpoint());
54                     }
55                     public void removeSelectionChangedListener(ISelectionChangedListener listener) {
56                     }
57                     public void setSelection(ISelection selection) {
58                     }
59                 });
60             action.run();
61         }
62     }
63     
64     /**
65      * @see IUpdate#update()
66      */

67     public void update() {
68         fBreakpoint = null;
69         IBreakpoint breakpoint = getBreakpoint();
70         if (breakpoint != null && (breakpoint instanceof IJavaBreakpoint)) {
71             fBreakpoint = breakpoint;
72         }
73         setEnabled(fBreakpoint != null);
74     }
75 }
76
Popular Tags