~vil/pydev/upstream

« back to all changes in this revision

Viewing changes to org.python.pydev.debug/src/org/python/pydev/debug/ui/actions/PythonBreakpointPropertiesRulerAction.java

  • Committer: Vladimír Lapáček
  • Date: 2006-08-30 18:38:44 UTC
  • Revision ID: vladimir.lapacek@gmail.com-20060830183844-f4d82c1239a7770a
Initial import of upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package org.python.pydev.debug.ui.actions;
 
2
 
 
3
import java.util.Map;
 
4
 
 
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;
 
23
 
 
24
public class PythonBreakpointPropertiesRulerAction extends
 
25
                AbstractBreakpointRulerAction implements IAction {
 
26
 
 
27
        public PythonBreakpointPropertiesRulerAction(ITextEditor editor, IVerticalRulerInfo rulerInfo) {
 
28
                setInfo(rulerInfo);
 
29
                setTextEditor(editor);
 
30
                setText("Breakpoint &Properties..."); 
 
31
        }
 
32
 
 
33
        /**
 
34
         * @throws CoreException 
 
35
         * @see Action#run()
 
36
         */
 
37
        public void run() {
 
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) {
 
43
                                        }
 
44
                                        public ISelection getSelection() {
 
45
                                                return new StructuredSelection(getBreakpoint());
 
46
                                        }
 
47
                                        public void removeSelectionChangedListener(ISelectionChangedListener listener) {
 
48
                                        }
 
49
                                        public void setSelection(ISelection selection) {
 
50
                                        }
 
51
                                });
 
52
                        action.run();   
 
53
                        
 
54
                        /*
 
55
                        Map map = null;
 
56
                        try {
 
57
                                map = breakPoint.getMarker().getAttributes();
 
58
                        } catch (CoreException e) {
 
59
                                PydevDebugPlugin.log(IStatus.ERROR, e.getLocalizedMessage(), e);
 
60
                        }
 
61
                        
 
62
                        IEditorInput editorInput= getTextEditor().getEditorInput();             
 
63
                        final IResource resource = (IResource)editorInput.getAdapter(IResource.class);
 
64
                        
 
65
                        if (resource == null) {
 
66
                                PydevDebugPlugin.log(IStatus.ERROR, "Could not find resource to create marker on", null);
 
67
                                return;
 
68
                        }
 
69
                                
 
70
                        
 
71
                        try {
 
72
                                if (map != null) {
 
73
                                        //resource.deleteMarkers(breakPoint.getMarker().getType(), false, 0);
 
74
                                        IMarker marker = breakPoint.getMarker();
 
75
                                        marker.delete();
 
76
                                        
 
77
                                        marker= resource.createMarker(PyBreakpoint.PY_CONDITIONAL_BREAK_MARKER);
 
78
                                        marker.setAttributes(map);
 
79
                                        breakPoint.setMarker(marker);
 
80
                                        
 
81
                                        IBreakpointManager breakpointManager= DebugPlugin.getDefault().getBreakpointManager();
 
82
                                        breakpointManager.addBreakpoint(breakPoint);
 
83
                                }
 
84
                        } catch (CoreException e) {
 
85
                                PydevDebugPlugin.log(IStatus.ERROR, e.getLocalizedMessage(), e);
 
86
                        }*/
 
87
                }
 
88
        }
 
89
        
 
90
        public void update() {
 
91
                setBreakpoint(determineBreakpoint());
 
92
                if (getBreakpoint() == null || !(getBreakpoint() instanceof PyBreakpoint)) {
 
93
                        setBreakpoint(null);
 
94
                        setEnabled(false);
 
95
                        return;
 
96
                }
 
97
                setEnabled(true);
 
98
                
 
99
//              IBreakpointManager breakpointManager= DebugPlugin.getDefault().getBreakpointManager();
 
100
//              breakpointManager.fireBreakpointChanged(getBreakpoint());
 
101
        }
 
102
 
 
103
}