Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: e89f52fa22265dbd9b5681eaae8cd4bfc458c640 (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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/*****************************************************************
 * Copyright (c) 2010, 2011 Texas Instruments and others
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Patrick Chuong (Texas Instruments) - Pin and Clone Supports (331781)
 *     Patrick Chuong (Texas Instruments) - Add support for icon overlay in the debug view (Bug 334566)
 *****************************************************************/
package org.eclipse.cdt.debug.ui; 

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IWorkbenchPart;

/**
 * Debug element that wants to enable pin capability should be adaptable to this interface.
 * <br><br>
 * When the user presses the 'Pin' action in a view that supports debug context pinning, the 
 * DebugEventFilterService calls the <code>pin</code> method with the selected debug context.
 * If more than one debug context is selected, the <code>pin</code> method is called multiple times.
 * The <code>pin</code> method should return a handle for the pinned debug context and when
 * there is a debug context change event generated by the debug context manager, 
 * <code>isPinnedTo</code> will be call by the DebugEventFilterService to determine whether the
 * debug context in question is pinned to the handle returned by the <code>pin</code> method.
 * 
 *  @since 7.1
 */
public interface IPinProvider {
	/**
	 * Pin element color descriptor.
	 */
	public interface IPinElementColorDescriptor {
		/**
		 * Default number of color count.
		 */
		final int DEFAULT_COLOR_COUNT = 3; 
		
		/**
		 * An undefined color
		 */
		int UNDEFINED = -1;
		
		/**
		 * Green color (Default)
		 */
		int GREEN = 0;
		
		/**
		 * Red color
		 */
		int RED = 1;
		
		/**
		 * Blue color
		 */
		int BLUE = 2;
		
		/**
		 * Returns the overlay pin color. The overlay pin will be used to decorate the debug view for an element that
		 * is pinned to a view.
		 * 
		 * @return one of the overlay colors
		 */
		int getOverlayColor();
		
		/**
		 * Returns the toolbar pin action image description to use when the view is pinned, can be <code>null</code>. 
		 * If <code>null</code>, then the default image description will be used.
		 *  
		 * @return the icon descriptor
		 */
		ImageDescriptor getToolbarIconDescriptor();
	}
	
	/**
	 * Pin element handler interface. 
	 */
	public interface IPinElementHandle {
		/**
		 * Returns the debug context for this handle.
		 * 
		 * @return the debug context
		 */
		Object getDebugContext();
		
		/**
		 * Returns the label that will be used in the pinned view's description.
		 *  
		 * @return the handle label
		 */
		String getLabel();
		
		/**
		 * Returns color descriptor for this element.
		 * 
		 * @return the color descriptor, can be <code>null</code>
		 */
		IPinElementColorDescriptor getPinElementColorDescriptor();
	}
	
	/**
	 * A callback interface that can be used by an IPinProvider to indicate 
	 * that the model has changed for a pinned view and that the view must be
	 * refreshed.
	 *
	 * @noimplement This interface is not intended to be implemented by clients.
	 */
	public interface IPinModelListener {
		static final int RESUMED = 0;	
		static final int EXITED = 1;
		
		/**
		 * Model changed handler that will cause the view to update.
		 * 
		 * @param eventType one of the event type.  
		 */
		void modelChanged(int eventType);
	}

	/**
	 * Returns whether the debug context is pinnable.
	 * 
	 * @param part the workbench part
	 * @param debugContext the debug context in question
	 * @return true if the debug context is pinnable
	 */
	boolean isPinnable(IWorkbenchPart part, Object debugContext);
	
	/**
	 * Pin the debug context and returns a handle for the pinned debug context.
	 * 
	 * @param part the workbench part
	 * @param debugContext the debug context to pin to
	 * @return a handle for the pinned debug context
	 */

	IPinElementHandle pin(IWorkbenchPart part, Object debugContext, IPinModelListener listener);
	
	/**
	 * Unpin the debug context for the given pin handle.
	 *  
	 * @param part the workbench part
	 * @param handle the handle for the pinned debug context
	 */
	void unpin(IWorkbenchPart part, IPinElementHandle handle);
	
	
	/**
	 * Returns true if the debug context belongs to the handle. If returning true,
	 * then the debug context change event will be delegated to the view. 
	 * 
	 * @param debugContext the debug context in question
	 * @param handle an existing pinned debug context handle
	 * @return true to delegate debug context change event to the view
	 */
	boolean isPinnedTo(Object debugContext, IPinElementHandle handle);
}

Back to the top