Lines 1-5
Link Here
|
1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2008, 2011 Wind River Systems and others. |
2 |
* Copyright (c) 2008, 2012 Wind River Systems and others. |
3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
Lines 29-34
import org.eclipse.core.expressions.Expression;
Link Here
|
29 |
import org.eclipse.core.expressions.ExpressionConverter; |
29 |
import org.eclipse.core.expressions.ExpressionConverter; |
30 |
import org.eclipse.core.expressions.ExpressionTagNames; |
30 |
import org.eclipse.core.expressions.ExpressionTagNames; |
31 |
import org.eclipse.core.expressions.IEvaluationContext; |
31 |
import org.eclipse.core.expressions.IEvaluationContext; |
|
|
32 |
import org.eclipse.core.resources.IMarker; |
32 |
import org.eclipse.core.runtime.CoreException; |
33 |
import org.eclipse.core.runtime.CoreException; |
33 |
import org.eclipse.core.runtime.IAdaptable; |
34 |
import org.eclipse.core.runtime.IAdaptable; |
34 |
import org.eclipse.core.runtime.IAdapterManager; |
35 |
import org.eclipse.core.runtime.IAdapterManager; |
Lines 38-43
import org.eclipse.core.runtime.IStatus;
Link Here
|
38 |
import org.eclipse.core.runtime.ListenerList; |
39 |
import org.eclipse.core.runtime.ListenerList; |
39 |
import org.eclipse.core.runtime.Platform; |
40 |
import org.eclipse.core.runtime.Platform; |
40 |
import org.eclipse.core.runtime.Status; |
41 |
import org.eclipse.core.runtime.Status; |
|
|
42 |
import org.eclipse.core.runtime.preferences.IEclipsePreferences; |
43 |
import org.eclipse.core.runtime.preferences.InstanceScope; |
44 |
import org.eclipse.debug.core.DebugPlugin; |
45 |
import org.eclipse.debug.core.model.IBreakpoint; |
41 |
import org.eclipse.debug.internal.core.IConfigurationElementConstants; |
46 |
import org.eclipse.debug.internal.core.IConfigurationElementConstants; |
42 |
import org.eclipse.debug.internal.ui.DebugUIPlugin; |
47 |
import org.eclipse.debug.internal.ui.DebugUIPlugin; |
43 |
import org.eclipse.debug.ui.DebugUITools; |
48 |
import org.eclipse.debug.ui.DebugUITools; |
Lines 45-55
import org.eclipse.debug.ui.IDebugUIConstants;
Link Here
|
45 |
import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget; |
50 |
import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget; |
46 |
import org.eclipse.debug.ui.actions.IToggleBreakpointsTargetExtension; |
51 |
import org.eclipse.debug.ui.actions.IToggleBreakpointsTargetExtension; |
47 |
import org.eclipse.debug.ui.actions.IToggleBreakpointsTargetFactory; |
52 |
import org.eclipse.debug.ui.actions.IToggleBreakpointsTargetFactory; |
|
|
53 |
import org.eclipse.jface.text.BadLocationException; |
54 |
import org.eclipse.jface.text.IDocument; |
55 |
import org.eclipse.jface.text.Position; |
56 |
import org.eclipse.jface.text.source.IAnnotationModel; |
57 |
import org.eclipse.jface.text.source.IVerticalRulerInfo; |
48 |
import org.eclipse.jface.viewers.ISelection; |
58 |
import org.eclipse.jface.viewers.ISelection; |
49 |
import org.eclipse.jface.viewers.IStructuredSelection; |
59 |
import org.eclipse.jface.viewers.IStructuredSelection; |
50 |
import org.eclipse.jface.viewers.StructuredSelection; |
60 |
import org.eclipse.jface.viewers.StructuredSelection; |
|
|
61 |
import org.eclipse.ui.IEditorInput; |
51 |
import org.eclipse.ui.IEditorPart; |
62 |
import org.eclipse.ui.IEditorPart; |
52 |
import org.eclipse.ui.IWorkbenchPart; |
63 |
import org.eclipse.ui.IWorkbenchPart; |
|
|
64 |
import org.eclipse.ui.texteditor.IDocumentProvider; |
65 |
import org.eclipse.ui.texteditor.ITextEditor; |
66 |
import org.eclipse.ui.texteditor.SimpleMarkerAnnotation; |
53 |
|
67 |
|
54 |
/** |
68 |
/** |
55 |
* Organizes the toggle breakpoints target factories contributed through the |
69 |
* Organizes the toggle breakpoints target factories contributed through the |
Lines 82-88
public class ToggleBreakpointsTargetManager {
Link Here
|
82 |
|
96 |
|
83 |
/** |
97 |
/** |
84 |
* Acts as a proxy between the toggle breakpoints target manager and the factories |
98 |
* Acts as a proxy between the toggle breakpoints target manager and the factories |
85 |
* contributed to the extension point. Only loads information from the plug-in xml |
99 |
* contributed to the extension point. Only loads information from the plug-in XML |
86 |
* and only instantiates the specified factory if required (lazy loading). |
100 |
* and only instantiates the specified factory if required (lazy loading). |
87 |
*/ |
101 |
*/ |
88 |
private static class ToggleTargetFactory implements IToggleBreakpointsTargetFactory { |
102 |
private static class ToggleTargetFactory implements IToggleBreakpointsTargetFactory { |
Lines 635-641
public class ToggleBreakpointsTargetManager {
Link Here
|
635 |
buffer.append(entry.getValue()); |
649 |
buffer.append(entry.getValue()); |
636 |
buffer.append('|'); |
650 |
buffer.append('|'); |
637 |
} |
651 |
} |
638 |
DebugUIPlugin.getDefault().getPluginPreferences().setValue(PREF_TARGETS, buffer.toString()); |
652 |
IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(DebugUIPlugin.getUniqueIdentifier()); |
|
|
653 |
if(prefs != null) { |
654 |
prefs.put(PREF_TARGETS, buffer.toString()); |
655 |
} |
639 |
} |
656 |
} |
640 |
|
657 |
|
641 |
/** |
658 |
/** |
Lines 645-651
public class ToggleBreakpointsTargetManager {
Link Here
|
645 |
*/ |
662 |
*/ |
646 |
private void loadPreferredTargets() { |
663 |
private void loadPreferredTargets() { |
647 |
fPreferredTargets = new HashMap(); |
664 |
fPreferredTargets = new HashMap(); |
648 |
String preferenceValue = DebugUIPlugin.getDefault().getPluginPreferences().getString(PREF_TARGETS); |
665 |
String preferenceValue = Platform.getPreferencesService().getString( |
|
|
666 |
DebugUIPlugin.getUniqueIdentifier(), |
667 |
PREF_TARGETS, |
668 |
null, |
669 |
null); |
670 |
if(preferenceValue == null) { |
671 |
return; |
672 |
} |
649 |
StringTokenizer entryTokenizer = new StringTokenizer(preferenceValue,"|"); //$NON-NLS-1$ |
673 |
StringTokenizer entryTokenizer = new StringTokenizer(preferenceValue,"|"); //$NON-NLS-1$ |
650 |
while (entryTokenizer.hasMoreTokens()){ |
674 |
while (entryTokenizer.hasMoreTokens()){ |
651 |
String token = entryTokenizer.nextToken(); |
675 |
String token = entryTokenizer.nextToken(); |
Lines 744-747
public class ToggleBreakpointsTargetManager {
Link Here
|
744 |
} |
768 |
} |
745 |
} |
769 |
} |
746 |
|
770 |
|
|
|
771 |
/** |
772 |
* Attempts to resolve the {@link IBreakpoint} from the {@link IMarker} at the current location in the editor on the vertical ruler. |
773 |
* <br><br> |
774 |
* Returns <code>null</code> if the breakpoint cannot be resolved. |
775 |
* @param editor the backing editor |
776 |
* @param info the current {@link IVerticalRulerInfo} |
777 |
* @return the {@link IBreakpoint} backing the marker on the ruler or <code>null</code> |
778 |
* @since 3.8 |
779 |
*/ |
780 |
public static IBreakpoint getBeakpointFromEditor(ITextEditor editor, IVerticalRulerInfo info) { |
781 |
IDocumentProvider provider = editor.getDocumentProvider(); |
782 |
if(provider == null) { |
783 |
return null; |
784 |
} |
785 |
IEditorInput input = editor.getEditorInput(); |
786 |
IAnnotationModel annotationModel = provider.getAnnotationModel(input); |
787 |
if (annotationModel != null) { |
788 |
IDocument document = provider.getDocument(input); |
789 |
Iterator iterator = annotationModel.getAnnotationIterator(); |
790 |
while (iterator.hasNext()) { |
791 |
Object object = iterator.next(); |
792 |
if (object instanceof SimpleMarkerAnnotation) { |
793 |
SimpleMarkerAnnotation markerAnnotation = (SimpleMarkerAnnotation) object; |
794 |
IMarker marker = markerAnnotation.getMarker(); |
795 |
try { |
796 |
if (marker.isSubtypeOf(IBreakpoint.BREAKPOINT_MARKER)) { |
797 |
Position position = annotationModel.getPosition(markerAnnotation); |
798 |
int line = document.getLineOfOffset(position.getOffset()); |
799 |
if (line == info.getLineOfLastMouseButtonActivity()) { |
800 |
IBreakpoint breakpoint = DebugPlugin.getDefault().getBreakpointManager().getBreakpoint(marker); |
801 |
if (breakpoint != null) { |
802 |
return breakpoint; |
803 |
} |
804 |
} |
805 |
} |
806 |
} catch (CoreException e) { |
807 |
} catch (BadLocationException e) { |
808 |
} |
809 |
} |
810 |
} |
811 |
} |
812 |
return null; |
813 |
} |
747 |
} |
814 |
} |