1
package org.python.pydev.debug.ui.actions;
5
import org.eclipse.core.resources.IMarker;
6
import org.eclipse.core.resources.IResource;
7
import org.eclipse.core.runtime.CoreException;
8
import org.eclipse.core.runtime.IStatus;
9
import org.eclipse.debug.core.DebugPlugin;
10
import org.eclipse.debug.core.IBreakpointManager;
11
import org.eclipse.debug.core.model.IBreakpoint;
12
import org.eclipse.jface.action.IAction;
13
import org.eclipse.jface.text.source.IVerticalRulerInfo;
14
import org.eclipse.jface.viewers.ISelection;
15
import org.eclipse.jface.viewers.ISelectionChangedListener;
16
import org.eclipse.jface.viewers.ISelectionProvider;
17
import org.eclipse.jface.viewers.StructuredSelection;
18
import org.eclipse.ui.IEditorInput;
19
import org.eclipse.ui.dialogs.PropertyDialogAction;
20
import org.eclipse.ui.texteditor.ITextEditor;
21
import org.python.pydev.debug.core.PydevDebugPlugin;
22
import org.python.pydev.debug.model.PyBreakpoint;
24
public class PythonBreakpointPropertiesRulerAction extends
25
AbstractBreakpointRulerAction implements IAction {
27
public PythonBreakpointPropertiesRulerAction(ITextEditor editor, IVerticalRulerInfo rulerInfo) {
29
setTextEditor(editor);
30
setText("Breakpoint &Properties...");
34
* @throws CoreException
38
IBreakpoint breakPoint = getBreakpoint();
39
if (breakPoint != null) {
40
PropertyDialogAction action=
41
new PropertyDialogAction(getTextEditor().getEditorSite().getShell(), new ISelectionProvider() {
42
public void addSelectionChangedListener(ISelectionChangedListener listener) {
44
public ISelection getSelection() {
45
return new StructuredSelection(getBreakpoint());
47
public void removeSelectionChangedListener(ISelectionChangedListener listener) {
49
public void setSelection(ISelection selection) {
57
map = breakPoint.getMarker().getAttributes();
58
} catch (CoreException e) {
59
PydevDebugPlugin.log(IStatus.ERROR, e.getLocalizedMessage(), e);
62
IEditorInput editorInput= getTextEditor().getEditorInput();
63
final IResource resource = (IResource)editorInput.getAdapter(IResource.class);
65
if (resource == null) {
66
PydevDebugPlugin.log(IStatus.ERROR, "Could not find resource to create marker on", null);
73
//resource.deleteMarkers(breakPoint.getMarker().getType(), false, 0);
74
IMarker marker = breakPoint.getMarker();
77
marker= resource.createMarker(PyBreakpoint.PY_CONDITIONAL_BREAK_MARKER);
78
marker.setAttributes(map);
79
breakPoint.setMarker(marker);
81
IBreakpointManager breakpointManager= DebugPlugin.getDefault().getBreakpointManager();
82
breakpointManager.addBreakpoint(breakPoint);
84
} catch (CoreException e) {
85
PydevDebugPlugin.log(IStatus.ERROR, e.getLocalizedMessage(), e);
90
public void update() {
91
setBreakpoint(determineBreakpoint());
92
if (getBreakpoint() == null || !(getBreakpoint() instanceof PyBreakpoint)) {
99
// IBreakpointManager breakpointManager= DebugPlugin.getDefault().getBreakpointManager();
100
// breakpointManager.fireBreakpointChanged(getBreakpoint());