public class QVTODebugImages { public static final String CONDITIONAL_BPNT_ENABLED = "conditionalBreakpointEnabled"; //$NON-NLS-1$ public static final String CONDITIONAL_BPNT_DISABLED = "conditionalBreakpointDisabled"; //$NON-NLS-1$ public static final String MODEL_PARAMETER = "modelParameter"; // $NON-NLS-1$ public static final String REFERENCE = "reference"; // $NON-NLS-1$ public static final String ATTRIBUTE = "attribute"; // $NON-NLS-1$ public static final String INTERM_PROPERTY = "intermediateProperty"; // $NON-NLS-1$ public static final String THIS_VARIABLE = "thisVariable"; // $NON-NLS-1$ public static final String PREDEFINED_VARIABLE = "predefinedVariable"; // $NON-NLS-1$ public static final String LOCAL_VARIABLE = "localVariable"; // $NON-NLS-1$ public static final String COLLECTION_ELEMENT = "collectionElement"; // $NON-NLS-1$ private static ImageRegistry fgImageRegistry = QVTODebugUIPlugin.getDefault().getImageRegistry(); private QVTODebugImages() { super(); } public static Image getImage(String key) { return fgImageRegistry.get(key); } }
public void toggleLineBreakpoints(final IWorkbenchPart part, ISelection selection) throws CoreException { final QvtEditor qvtEditor = getEditor(part); if (qvtEditor == null) { return; } IFile unitFile = (IFile) qvtEditor.getEditorInput().getAdapter(IResource.class); ITextSelection textSelection = (ITextSelection) selection; int lineNumber = textSelection.getStartLine() + 1; List<ILineBreakpoint> breakpoints = QVTODebugCore.getQVTOBreakpoints(ILineBreakpoint.class); for (ILineBreakpoint next : breakpoints) { if (!unitFile.equals(next.getMarker().getResource())) { continue; } if (next.getLineNumber() == lineNumber) { try { // a breakpoint already exists at this line =>toggle again means remove DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint(next, true); } catch (CoreException e) { QVTODebugUIPlugin.log(e.getStatus()); } next.delete(); return; } } URI sourceURI = URIUtils.getResourceURI(unitFile); final QVTOBreakpoint lineBreakpoint = new QVTOBreakpoint(sourceURI, lineNumber); lineBreakpoint.register(true); Job job = new Job(DebugUIMessages.QVTOToggleBreakpointAdapter_VerifyBreakpointJob) { @Override protected IStatus run(IProgressMonitor monitor) { return new BreakpointLocationVerifier( qvtEditor, lineBreakpoint, DebugUIMessages.QVTOToggleBreakpointAdapter_CannotSetBreakpoint) .run(); } @Override public boolean belongsTo(Object family) { return QVTOBreakpoint.QVTO_BREAKPOINT_JOBFAMILY == family; } }; job.setPriority(Job.INTERACTIVE); job.setSystem(true); job.schedule(); }