Skip to main content
summaryrefslogtreecommitdiffstats
blob: fde370bb264f4ba515a94be558b8e9cf23cc52f3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package org.eclipse.debug.internal.ui;

/*
 * (c) Copyright IBM Corp. 2000, 2001.
 * All Rights Reserved.
 */
 
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IMarkerDelta;
import org.eclipse.debug.core.*;
import org.eclipse.jface.viewers.TableViewer;

/**
 * Provides the contents for a breakpoints viewer
 */
public class BreakpointsContentProvider extends BasicContentProvider implements IBreakpointListener {

	/**
	 * Creates this content provider
	 */
	public BreakpointsContentProvider() {
		DebugPlugin.getDefault().getBreakpointManager().addBreakpointListener(this);
	}

	/**
	 * Returns all the breakpoint markers in the current open workspace
	 */
	public Object[] getElements(Object parent) {
		return ((IBreakpointManager) parent).getBreakpoints();
	}
	
	/**
	 * @see IContentProvider
	 */
	public void dispose() {
		super.dispose();
		DebugPlugin.getDefault().getBreakpointManager().removeBreakpointListener(this);
	}

	/**
	 * @see IBreakpointListener
	 */
	public void breakpointAdded(final IMarker breakpoint) {
		if (breakpoint.exists()) {		
			asyncExec(new Runnable() {
				public void run() {
					if (!isDisposed()) {
						((TableViewer)fViewer).add(breakpoint);
					}
				}
			});
		}
	}

	/**
	 * @see IBreakpointListener
	 */
	public void breakpointRemoved(final IMarker breakpoint, IMarkerDelta delta) {
		asyncExec(new Runnable() {
			public void run() {
				if (!isDisposed()) {
					((TableViewer)fViewer).remove(breakpoint);
				}
			}
		});
	}

	/**
	 * @see IBreakpointListener
	 */
	public void breakpointChanged(final IMarker breakpoint, IMarkerDelta delta) {
		if (breakpoint.exists()) {
			asyncExec(new Runnable() {
				public void run() {
					if (!isDisposed()) {
						refresh(breakpoint);
					}
				}
			});
		}
	}
	
	/**
	 * @see BasicContentProvider#doHandleDebug(Event)
	 */
	protected void doHandleDebugEvent(DebugEvent event) {
		//not a registered debug event listener
	}
	
	/**
	 * @see BasicContentProvider#doGetChildren(Object)
	 */
	protected Object[] doGetChildren(Object parent) {
		//not a tree content provider
		return null;
	}
}

Back to the top