use of org.python.pydev.debug.model.PyBreakpoint in project Pydev by fabioz.
the class PyBreakpointRulerAction method addBreakpointMarker.
public static void addBreakpointMarker(IDocument document, int lineNumber, ITextEditor textEditor, final String type) {
try {
if (lineNumber < 0) {
return;
}
// just to validate it
try {
document.getLineInformation(lineNumber - 1);
} catch (Exception e) {
// ignore
return;
}
final IResource resource = PyMarkerUIUtils.getResourceForTextEditor(textEditor);
// The map containing the marker attributes
final Map<String, Object> map = new HashMap<String, Object>();
// if not null, we're dealing with an external file.
final IEditorInput externalFileEditorInput = getExternalFileEditorInput(textEditor);
// TODO: that happens when we're trying to set a breakpoint in a file that's within a zip file.
if (externalFileEditorInput == null && resource instanceof IWorkspaceRoot) {
return;
}
map.put(IMarker.MESSAGE, PYDEV_BREAKPOINT);
map.put(IMarker.LINE_NUMBER, lineNumber);
map.put(IBreakpoint.ENABLED, true);
map.put(IBreakpoint.ID, PyDebugModelPresentation.PY_DEBUG_MODEL_ID);
map.put(PyBreakpoint.PY_BREAK_TYPE, type);
if (externalFileEditorInput != null) {
File file = EditorInputUtils.getFile(externalFileEditorInput);
if (file != null) {
map.put(PyBreakpoint.PY_BREAK_EXTERNAL_PATH_ID, FileUtils.getFileAbsolutePath(file));
}
}
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
IMarker marker;
if (type.equals(PyBreakpoint.PY_BREAK_TYPE_DJANGO)) {
marker = resource.createMarker(PyBreakpoint.DJANGO_BREAK_MARKER);
} else {
if (!type.equals(PyBreakpoint.PY_BREAK_TYPE_PYTHON)) {
Log.log("Error. Expected :" + PyBreakpoint.PY_BREAK_TYPE_PYTHON + " or " + PyBreakpoint.PY_BREAK_TYPE_DJANGO + ". Found: " + type + " (considered as python break type).");
}
marker = resource.createMarker(PyBreakpoint.PY_BREAK_MARKER);
}
marker.setAttributes(map);
PyBreakpoint br = new PyBreakpoint();
br.setMarker(marker);
IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager();
breakpointManager.addBreakpoint(br);
}
};
resource.getWorkspace().run(runnable, null);
} catch (Exception e) {
Log.log(e);
}
}
use of org.python.pydev.debug.model.PyBreakpoint in project Pydev by fabioz.
the class PythonBreakpointPage method createLabels.
/**
* Creates the labels displayed for the breakpoint.
* @param parent
*/
protected void createLabels(Composite parent) {
PyBreakpoint breakpoint = (PyBreakpoint) getElement();
Composite labelComposite = createComposite(parent, 2);
String typeName = breakpoint.getFile();
if (typeName != null) {
// $NON-NLS-1$
createLabel(labelComposite, "File");
createLabel(labelComposite, typeName);
}
createTypeSpecificLabels(labelComposite);
}
use of org.python.pydev.debug.model.PyBreakpoint in project Pydev by fabioz.
the class PythonBreakpointPage method doStore.
/**
* Stores the values configured in this page. This method
* should be called from within a workspace runnable to
* reduce the number of resource deltas.
*/
protected void doStore() throws CoreException {
PyBreakpoint breakpoint = getBreakpoint();
storeEnabled(breakpoint);
if (fConditionEditor != null) {
boolean enableCondition = fEnableConditionButton.getSelection();
String condition = fConditionEditor.getCondition();
if (breakpoint.isConditionEnabled() != enableCondition) {
breakpoint.setConditionEnabled(enableCondition);
}
if (!condition.equals(breakpoint.getCondition())) {
breakpoint.setCondition(condition);
}
}
}
use of org.python.pydev.debug.model.PyBreakpoint in project Pydev by fabioz.
the class PythonBreakpointPage method createConditionEditor.
/**
* Creates the controls that allow the user to specify the breakpoint's
* condition
* @param parent the composite in which the condition editor should be created
* @throws CoreException if an exception occurs accessing the breakpoint
*/
private void createConditionEditor(Composite parent) throws CoreException {
PyBreakpoint breakpoint = getBreakpoint();
String label = null;
ICommandManager commandManager = PlatformUI.getWorkbench().getCommandSupport().getCommandManager();
// $NON-NLS-1$
ICommand command = commandManager.getCommand("org.eclipse.ui.edit.text.contentAssist.proposals");
if (command != null) {
List keyBindings = command.getKeySequenceBindings();
if (keyBindings != null && keyBindings.size() > 0) {
IKeySequenceBinding binding = (IKeySequenceBinding) keyBindings.get(0);
// $NON-NLS-1$
label = StringUtils.format("E&nable Condition %s", binding.getKeySequence().format());
}
}
if (label == null) {
// $NON-NLS-1$
label = "E&nable Condition (code assist not available)";
}
Composite conditionComposite = new Group(parent, SWT.NONE);
conditionComposite.setFont(parent.getFont());
conditionComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
conditionComposite.setLayout(new GridLayout());
fEnableConditionButton = createCheckButton(conditionComposite, label);
fEnableConditionButton.setSelection(breakpoint.isConditionEnabled());
fEnableConditionButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
setConditionEnabled(fEnableConditionButton.getSelection());
}
});
fConditionEditor = new BreakpointConditionEditor(conditionComposite, this);
// fSuspendWhenLabel= createLabel(conditionComposite, "Suspend when:");
// fConditionIsTrue= createRadioButton(conditionComposite, "condition is \'tr&ue\'");
// fConditionIsTrue= createLabel(conditionComposite, "condition is \'tr&ue\'");
// fConditionHasChanged= createRadioButton(conditionComposite, "value of condition ch&anges");
// if (breakpoint.isConditionSuspendOnTrue()) {
// fConditionIsTrue.setSelection(true);
// } else {
// fConditionHasChanged.setSelection(true);
// }
setConditionEnabled(fEnableConditionButton.getSelection());
}
use of org.python.pydev.debug.model.PyBreakpoint in project Pydev by fabioz.
the class PythonBreakpointPage method createTypeSpecificLabels.
/**
* Allows subclasses to add type specific labels to the common Java
* breakpoint page.
* @param parent
*/
protected void createTypeSpecificLabels(Composite parent) {
// Line number
PyBreakpoint breakpoint = getBreakpoint();
StringBuffer lineNumber = new StringBuffer(4);
try {
int lNumber = breakpoint.getLineNumber();
if (lNumber > 0) {
lineNumber.append(lNumber);
}
} catch (CoreException ce) {
PydevDebugPlugin.log(IStatus.ERROR, ce.getLocalizedMessage(), ce);
}
if (lineNumber.length() > 0) {
createLabel(parent, "&Line Number:");
createLabel(parent, lineNumber.toString());
}
// Member
/*
try {
IMember member = BreakpointUtils.getMember(breakpoint);
if (member == null) {
return;
}
String label = PropertyPageMessages.JavaLineBreakpointPage_3; //$NON-NLS-1$
String memberName = fJavaLabelProvider.getText(member);
if (breakpoint instanceof IJavaMethodBreakpoint) {
label = PropertyPageMessages.JavaLineBreakpointPage_4; //$NON-NLS-1$
} else if (breakpoint instanceof IJavaWatchpoint) {
label = PropertyPageMessages.JavaLineBreakpointPage_5; //$NON-NLS-1$
}
createLabel(parent, label);
createLabel(parent, memberName);
} catch (CoreException exception) {
PydevDebugPlugin.log(IStatus.ERROR,e.getLocalizedMessage(),exception);
}*/
}
Aggregations