Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 284363 | Differences between
and this patch

Collapse All | Expand All

(-)ui/org/eclipse/debug/internal/ui/model/elements/ElementLabelProvider.java (+38 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Patrick Chuong (Texas Instruments) - added support for checkbox (Bug 286310)
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.debug.internal.ui.model.elements;
12
package org.eclipse.debug.internal.ui.model.elements;
12
13
Lines 19-24 Link Here
19
import org.eclipse.core.runtime.Status;
20
import org.eclipse.core.runtime.Status;
20
import org.eclipse.core.runtime.jobs.ISchedulingRule;
21
import org.eclipse.core.runtime.jobs.ISchedulingRule;
21
import org.eclipse.core.runtime.jobs.Job;
22
import org.eclipse.core.runtime.jobs.Job;
23
import org.eclipse.debug.internal.ui.viewers.model.provisional.ICheckUpdate;
22
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider;
24
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider;
23
import org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate;
25
import org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate;
24
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
26
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
Lines 214-219 Link Here
214
			update.setBackground(getBackground(elementPath, presentationContext, columnId), i);
216
			update.setBackground(getBackground(elementPath, presentationContext, columnId), i);
215
			update.setForeground(getForeground(elementPath, presentationContext, columnId), i);
217
			update.setForeground(getForeground(elementPath, presentationContext, columnId), i);
216
			update.setFontData(getFontData(elementPath, presentationContext, columnId), i);
218
			update.setFontData(getFontData(elementPath, presentationContext, columnId), i);
219
			if (update instanceof ICheckUpdate && 
220
			    Boolean.TRUE.equals(presentationContext.getProperty(ICheckUpdate.PROP_CHECK))) 
221
			{
222
				((ICheckUpdate) update).setChecked(
223
				    getChecked(elementPath, presentationContext), getGrayed(elementPath, presentationContext));
224
			}
217
		}
225
		}
218
	}
226
	}
219
227
Lines 270-275 Link Here
270
	 */
278
	 */
271
	protected abstract String getLabel(TreePath elementPath, IPresentationContext presentationContext, String columnId) throws CoreException;	
279
	protected abstract String getLabel(TreePath elementPath, IPresentationContext presentationContext, String columnId) throws CoreException;	
272
280
281
	/**
282
	 * Returns the checked state for the given path.
283
	 * 
284
     * @param path Path of the element to retrieve the grayed state for.
285
     * @param presentationContext Presentation context where the element is 
286
     * displayed.
287
     * @return <code>true<code> if the element check box should be checked
288
     * @throws CoreException 
289
	 * 
290
	 * @since 3.6
291
	 */
292
	public boolean getChecked(TreePath path, IPresentationContext presentationContext) throws CoreException {
293
		return false;
294
	}
295
	
296
	/**
297
	 * Returns the grayed state for the given path.
298
	 * 
299
	 * @param path Path of the element to retrieve the grayed state for.
300
     * @param presentationContext Presentation context where the element is 
301
     * displayed.
302
	 * @return <code>true<code> if the element check box should be grayed
303
	 * @throws CoreException 
304
     * 
305
     * @since 3.6
306
	 */
307
	public boolean getGrayed(TreePath path, IPresentationContext presentationContext) throws CoreException {
308
		return false;
309
	}
310
	
273
    /* (non-Javadoc)
311
    /* (non-Javadoc)
274
     * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider#update(org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate[])
312
     * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider#update(org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate[])
275
     */
313
     */
(-)ui/org/eclipse/debug/internal/ui/viewers/model/ITreeModelLabelProviderTarget.java (-1 / +1 lines)
Lines 16-22 Link Here
16
import org.eclipse.swt.graphics.RGB;
16
import org.eclipse.swt.graphics.RGB;
17
17
18
/**
18
/**
19
 * This interface must be implemented by the viewer which uses the
19
 *  This interface must be implemented by the viewer which uses the
20
 * {@link TreeModelLabelProvider} label provider.  It allows the label
20
 * {@link TreeModelLabelProvider} label provider.  It allows the label
21
 * provider to update the viewer with information retrieved from the 
21
 * provider to update the viewer with information retrieved from the 
22
 * element-based label providers.
22
 * element-based label providers.
(-)ui/org/eclipse/debug/internal/ui/viewers/model/ViewerAdapterService.java (-1 / +15 lines)
Lines 8-18 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 * 	   Wind River Systems - Pawel Piech: Bug 213244 - VariableAdapterService should also call IAdaptable.getAdapter() for adaptables that implement this method directly.
10
 * 	   Wind River Systems - Pawel Piech: Bug 213244 - VariableAdapterService should also call IAdaptable.getAdapter() for adaptables that implement this method directly.
11
 * 	   Patrick Chuong (Texas Instruments) - added support for checkbox (Bug 286310)
11
 *******************************************************************************/
12
 *******************************************************************************/
12
package org.eclipse.debug.internal.ui.viewers.model;
13
package org.eclipse.debug.internal.ui.viewers.model;
13
14
14
import org.eclipse.debug.core.DebugPlugin;
15
import org.eclipse.debug.core.DebugPlugin;
15
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentationFactory;
16
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentationFactory;
17
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementCheckReceiver;
16
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider;
18
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider;
17
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementEditor;
19
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementEditor;
18
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider;
20
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider;
Lines 133-139 Link Here
133
    public static IViewerInputProvider getInputProvider(Object element) {        
135
    public static IViewerInputProvider getInputProvider(Object element) {        
134
    	return (IViewerInputProvider)getAdapter(element, IViewerInputProvider.class);
136
    	return (IViewerInputProvider)getAdapter(element, IViewerInputProvider.class);
135
    }			
137
    }			
136
	
138
		    
139
    /**
140
     * Returns the check receiver for the given element or <code>null</code> if none.
141
     * 
142
     * @param element element to retrieve adapter for
143
     * @return check receiver or <code>null</code>
144
     *
145
     * @since 3.6
146
     */
147
    public static IElementCheckReceiver getElementCheckListener(Object element) {
148
    	return (IElementCheckReceiver)getAdapter(element, IElementCheckReceiver.class);
149
    }
150
    
137
	/**
151
	/**
138
	 * Returns an adapter of the specified type for the given object or <code>null</code>
152
	 * Returns an adapter of the specified type for the given object or <code>null</code>
139
	 * if none.
153
	 * if none.
(-)ui/org/eclipse/debug/internal/ui/viewers/model/InternalTreeModelViewer.java (-1 / +45 lines)
Lines 8-13 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Pawel Piech (Wind River) - added support for a virtual tree model viewer (Bug 242489)
10
 *     Pawel Piech (Wind River) - added support for a virtual tree model viewer (Bug 242489)
11
 *     Patrick Chuong (Texas Instruments) - added support for checkbox (Bug 286310)
11
 *******************************************************************************/
12
 *******************************************************************************/
12
package org.eclipse.debug.internal.ui.viewers.model;
13
package org.eclipse.debug.internal.ui.viewers.model;
13
14
Lines 24-32 Link Here
24
import org.eclipse.core.runtime.IProgressMonitor;
25
import org.eclipse.core.runtime.IProgressMonitor;
25
import org.eclipse.debug.internal.core.IInternalDebugCoreConstants;
26
import org.eclipse.debug.internal.core.IInternalDebugCoreConstants;
26
import org.eclipse.debug.internal.core.commands.Request;
27
import org.eclipse.debug.internal.core.commands.Request;
28
import org.eclipse.debug.internal.ui.viewers.model.provisional.ICheckUpdate;
27
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate;
29
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate;
28
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentation;
30
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentation;
29
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentationFactory;
31
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentationFactory;
32
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementCheckReceiver;
30
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider;
33
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider;
31
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementEditor;
34
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementEditor;
32
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider;
35
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider;
Lines 55-60 Link Here
55
import org.eclipse.swt.events.DisposeEvent;
58
import org.eclipse.swt.events.DisposeEvent;
56
import org.eclipse.swt.events.PaintEvent;
59
import org.eclipse.swt.events.PaintEvent;
57
import org.eclipse.swt.events.PaintListener;
60
import org.eclipse.swt.events.PaintListener;
61
import org.eclipse.swt.events.SelectionEvent;
58
import org.eclipse.swt.graphics.Color;
62
import org.eclipse.swt.graphics.Color;
59
import org.eclipse.swt.graphics.Font;
63
import org.eclipse.swt.graphics.Font;
60
import org.eclipse.swt.graphics.FontData;
64
import org.eclipse.swt.graphics.FontData;
Lines 78-84 Link Here
78
 * @since 3.3
82
 * @since 3.3
79
 */
83
 */
80
public class InternalTreeModelViewer extends TreeViewer 
84
public class InternalTreeModelViewer extends TreeViewer 
81
    implements ITreeModelViewer,  ITreeModelContentProviderTarget, ITreeModelLabelProviderTarget
85
    implements ITreeModelViewer,  ITreeModelContentProviderTarget, ITreeModelLabelProviderTarget, ITreeModelCheckProviderTarget
82
{
86
{
83
	
87
	
84
	private IPresentationContext fContext;
88
	private IPresentationContext fContext;
Lines 1015-1020 Link Here
1015
		if (fIsPopup) {
1019
		if (fIsPopup) {
1016
		    ((ITreeModelContentProvider)getContentProvider()).setSuppressModelControlDeltas(true);
1020
		    ((ITreeModelContentProvider)getContentProvider()).setSuppressModelControlDeltas(true);
1017
		}
1021
		}
1022
        if ((style & SWT.CHECK) != 0) {
1023
            context.setProperty(ICheckUpdate.PROP_CHECK, Boolean.TRUE);
1024
        }
1018
	}
1025
	}
1019
	
1026
	
1020
	/**
1027
	/**
Lines 2248-2251 Link Here
2248
    public void updateViewer(IModelDelta delta) {
2255
    public void updateViewer(IModelDelta delta) {
2249
        ((ITreeModelContentProvider)getContentProvider()).updateModel(delta);
2256
        ((ITreeModelContentProvider)getContentProvider()).updateModel(delta);
2250
    }
2257
    }
2258
2259
    /*
2260
     * (non-Javadoc)
2261
     * @see org.eclipse.debug.internal.ui.viewers.model.ITreeModelCheckProvider#setElementChecked(org.eclipse.jface.viewers.TreePath, boolean, boolean)
2262
     */
2263
	public void setElementChecked(TreePath path, boolean checked, boolean grayed) {
2264
	   	 Widget widget = findItem(path);
2265
		 
2266
		 if (widget != null && widget instanceof TreeItem && !widget.isDisposed()) {
2267
	         TreeItem item = (TreeItem)widget;
2268
	         
2269
	         item.setChecked(checked);
2270
	         item.setGrayed(grayed);
2271
		 }
2272
	}
2273
	
2274
	/*
2275
	 * (non-Javadoc)
2276
	 * @see org.eclipse.jface.viewers.StructuredViewer#handleSelect(org.eclipse.swt.events.SelectionEvent)
2277
	 */
2278
	protected void handleSelect(SelectionEvent event) {
2279
	       if (event.detail == SWT.CHECK) {
2280
	            TreeItem item = (TreeItem) event.item;
2281
	            super.handleSelect(event);
2282
2283
	            Object element = item.getData();
2284
	            if (element != null) {
2285
	            	IElementCheckReceiver listener = ViewerAdapterService.getElementCheckListener(element);
2286
	            	if (listener != null) {
2287
	            	    TreePath path = getTreePathFromItem(item);
2288
	            		listener.setChecked(getPresentationContext(), getInput(), path, item.getChecked());
2289
	            	}            	
2290
	            }
2291
	        } else {
2292
				super.handleSelect(event);
2293
			}
2294
	}
2251
}
2295
}
(-)ui/org/eclipse/debug/internal/ui/viewers/model/LabelUpdate.java (-1 / +17 lines)
Lines 8-17 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Pawel Piech (Wind River) - added support for a virtual tree model viewer (Bug 242489)
10
 *     Pawel Piech (Wind River) - added support for a virtual tree model viewer (Bug 242489)
11
 *     Patrick Chuong (Texas Instruments) - added support for checkbox (Bug 286310)
11
 *******************************************************************************/
12
 *******************************************************************************/
12
package org.eclipse.debug.internal.ui.viewers.model;
13
package org.eclipse.debug.internal.ui.viewers.model;
13
14
14
import org.eclipse.debug.internal.core.commands.Request;
15
import org.eclipse.debug.internal.core.commands.Request;
16
import org.eclipse.debug.internal.ui.viewers.model.provisional.ICheckUpdate;
15
import org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate;
17
import org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate;
16
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
18
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
17
import org.eclipse.jface.resource.ImageDescriptor;
19
import org.eclipse.jface.resource.ImageDescriptor;
Lines 22-28 Link Here
22
/**
24
/**
23
 * @since 3.3
25
 * @since 3.3
24
 */
26
 */
25
class LabelUpdate extends Request implements ILabelUpdate {
27
class LabelUpdate extends Request implements ILabelUpdate, ICheckUpdate {
26
	
28
	
27
	private TreePath fElementPath;
29
	private TreePath fElementPath;
28
	private String[] fColumnIds;
30
	private String[] fColumnIds;
Lines 36-41 Link Here
36
	private int fNumColumns; 
38
	private int fNumColumns; 
37
	private IPresentationContext fContext;
39
	private IPresentationContext fContext;
38
	private Object fViewerInput;
40
	private Object fViewerInput;
41
	private boolean fChecked;
42
	private boolean fGrayed;
39
	
43
	
40
	/**
44
	/**
41
	 * @param viewerInput input at the time the request was made
45
	 * @param viewerInput input at the time the request was made
Lines 151-156 Link Here
151
	 */
155
	 */
152
	public void update() {
156
	public void update() {
153
	    fTreeViewer.setElementData(fElementPath, fNumColumns, fLabels, fImageDescriptors, fFontDatas, fForegrounds, fBackgrounds);
157
	    fTreeViewer.setElementData(fElementPath, fNumColumns, fLabels, fImageDescriptors, fFontDatas, fForegrounds, fBackgrounds);
158
		if (fTreeViewer instanceof ITreeModelCheckProviderTarget)
159
			((ITreeModelCheckProviderTarget) fTreeViewer).setElementChecked(fElementPath, fChecked, fGrayed);
160
154
		fProvider.updateComplete(this);
161
		fProvider.updateComplete(this);
155
	}
162
	}
156
163
Lines 174-177 Link Here
174
	public Object getViewerInput() {
181
	public Object getViewerInput() {
175
		return fViewerInput;
182
		return fViewerInput;
176
	}
183
	}
184
185
	/*
186
	 * (non-Javadoc)
187
	 * @see org.eclipse.debug.internal.ui.viewers.model.provisional.ICheckable#setChecked(boolean, boolean)
188
	 */
189
	public void setChecked(boolean checked, boolean grayed) {
190
		fChecked = checked;
191
		fGrayed = grayed;
192
	}
177
}
193
}
(-)ui/org/eclipse/debug/internal/ui/viewers/model/ITreeModelCheckProviderTarget.java (+34 lines)
Added Link Here
1
/*****************************************************************
2
 * Copyright (c) 2009 Texas Instruments and others
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Patrick Chuong (Texas Instruments) - Initial API and implementation  (Bug 286310)
10
 *****************************************************************/
11
package org.eclipse.debug.internal.ui.viewers.model;
12
13
import org.eclipse.jface.viewers.TreePath;
14
15
/**
16
 *  This interface can be implemented by the viewer which uses the
17
 * {@link TreeModelLabelProvider} label provider and supports the 
18
 * {@link org.eclipse.swt.SWT.CHECK} style.  It allows the label provider to 
19
 * update the viewer with check-box information retrieved from the 
20
 * element-based label providers.
21
 * 
22
 * @since 3.6
23
 */
24
public interface ITreeModelCheckProviderTarget extends ITreeModelLabelProviderTarget {
25
    
26
    /**
27
     * Sets the element check state data.
28
     * 
29
     * @param path
30
     * @param checked
31
     * @param grayed
32
     */
33
    public void setElementChecked(TreePath path, boolean checked, boolean grayed);    
34
}
(-)ui/org/eclipse/debug/internal/ui/viewers/model/provisional/ICheckUpdate.java (+36 lines)
Added Link Here
1
/*****************************************************************
2
 * Copyright (c) 2009 Texas Instruments and others
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Patrick Chuong (Texas Instruments) - Initial API and implementation (Bug 286310)
10
 *****************************************************************/
11
package org.eclipse.debug.internal.ui.viewers.model.provisional;
12
13
/**
14
 * Label update which allows the label provide to set the checked element state.
15
 * The label provider can use the presentation context to determine whether the 
16
 * viewer is showing item check boxes. 
17
 * 
18
 * @since 3.6
19
 */
20
public interface ICheckUpdate extends ILabelUpdate {
21
22
    /**
23
     * Property of the presentation context which indicates that the viewer 
24
     * has the check box style.
25
     */
26
    public static final String PROP_CHECK = "org.eclipse.debug.ui.check";  //$NON-NLS-1$
27
    
28
    /**
29
     * Sets the check state of the tree node.
30
     * 
31
     * @param checked
32
     * @param grayed
33
     */
34
    public void setChecked(boolean checked, boolean grayed);
35
    
36
}
(-)ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IElementCheckReceiver.java (+36 lines)
Added Link Here
1
/*****************************************************************
2
 * Copyright (c) 2009 Texas Instruments and others
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Patrick Chuong (Texas Instruments) - Initial API and implementation (Bug 286310)
10
 *****************************************************************/
11
package org.eclipse.debug.internal.ui.viewers.model.provisional;
12
13
import org.eclipse.jface.viewers.TreePath;
14
15
16
/**
17
 * Receiver of checked events from a virtual viewer with check boxes.  The 
18
 * receiver is retrieved for each element through the adapter mechanism.
19
 * 
20
 * @since 3.6
21
 */
22
public interface IElementCheckReceiver {
23
24
    /**
25
     * Notifies the receiver that the given element has had its 
26
     * checked state modified in the viewer.
27
     * 
28
     * @param context Presentation context in which the element was updated.
29
     * @param viewerInput The root element of the viewer where the check
30
     * selection took place.
31
     * @param path Path of the element that had its checked state changed
32
     * @param checked The new checked state of the element
33
     */
34
    public void setChecked(IPresentationContext context, Object viewerInput, TreePath path, boolean checked);
35
36
}

Return to bug 284363