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 40604 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jdt/internal/junit/ui/IJUnitPreferencesConstants.java (+9 lines)
Lines 38-41 Link Here
38
	 */				
38
	 */				
39
	public static final String PREF_INACTIVE_FILTERS_LIST = JUnitPlugin.PLUGIN_ID + ".inactive_filters"; //$NON-NLS-1$	
39
	public static final String PREF_INACTIVE_FILTERS_LIST = JUnitPlugin.PLUGIN_ID + ".inactive_filters"; //$NON-NLS-1$	
40
40
41
	/**
42
	 * OK color for the progress bar.
43
	 */	
44
	public static final String PREF_COLOR_OK= JUnitPlugin.PLUGIN_ID + ".ok_color"; //$NON-NLS-1$	
45
46
	/**
47
	 * Failure color for the progress bar.
48
	 */	
49
	public static final String PREF_COLOR_FAILURE= JUnitPlugin.PLUGIN_ID + ".failure_color"; //$NON-NLS-1$	
41
}
50
}
(-)src/org/eclipse/jdt/internal/junit/ui/JUnitMessages.properties (+4 lines)
Lines 167-169 Link Here
167
ExpandAllAction.tooltip=Expand All Nodes
167
ExpandAllAction.tooltip=Expand All Nodes
168
JUnitAddLibraryProposal.info=Add the JUnit library to the project\'s build class path
168
JUnitAddLibraryProposal.info=Add the JUnit library to the project\'s build class path
169
JUnitAddLibraryProposal.label=Add JUnit libraries
169
JUnitAddLibraryProposal.label=Add JUnit libraries
170
JUnitPreferencePage.color.group.label=Colors
171
JUnitPreferencePage.ok.color=OK &status:
172
JUnitPreferencePage.failure.color=Fail&ure status:
173
JUnitPreferencePage.color.note=Note: Color settings are not applied to already open JUnit views
(-)src/org/eclipse/jdt/internal/junit/ui/JUnitPreferencePage.java (-1 / +63 lines)
Lines 21-26 Link Here
21
import org.eclipse.jdt.core.IType;
21
import org.eclipse.jdt.core.IType;
22
import org.eclipse.jdt.core.JavaModelException;
22
import org.eclipse.jdt.core.JavaModelException;
23
import org.eclipse.jdt.core.search.SearchEngine;
23
import org.eclipse.jdt.core.search.SearchEngine;
24
25
import org.eclipse.jdt.internal.junit.util.ColorEditor;
24
import org.eclipse.jdt.internal.junit.util.ExceptionHandler;
26
import org.eclipse.jdt.internal.junit.util.ExceptionHandler;
25
import org.eclipse.jdt.internal.junit.util.SWTUtil;
27
import org.eclipse.jdt.internal.junit.util.SWTUtil;
26
import org.eclipse.jdt.ui.IJavaElementSearchConstants;
28
import org.eclipse.jdt.ui.IJavaElementSearchConstants;
Lines 31-36 Link Here
31
import org.eclipse.jface.dialogs.IDialogConstants;
33
import org.eclipse.jface.dialogs.IDialogConstants;
32
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
34
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
33
import org.eclipse.jface.preference.IPreferenceStore;
35
import org.eclipse.jface.preference.IPreferenceStore;
36
import org.eclipse.jface.preference.PreferenceConverter;
34
import org.eclipse.jface.preference.PreferencePage;
37
import org.eclipse.jface.preference.PreferencePage;
35
import org.eclipse.jface.viewers.CheckStateChangedEvent;
38
import org.eclipse.jface.viewers.CheckStateChangedEvent;
36
import org.eclipse.jface.viewers.CheckboxTableViewer;
39
import org.eclipse.jface.viewers.CheckboxTableViewer;
Lines 55-66 Link Here
55
import org.eclipse.swt.events.KeyAdapter;
58
import org.eclipse.swt.events.KeyAdapter;
56
import org.eclipse.swt.events.KeyEvent;
59
import org.eclipse.swt.events.KeyEvent;
57
import org.eclipse.swt.graphics.Image;
60
import org.eclipse.swt.graphics.Image;
61
import org.eclipse.swt.graphics.RGB;
58
import org.eclipse.swt.layout.GridData;
62
import org.eclipse.swt.layout.GridData;
59
import org.eclipse.swt.layout.GridLayout;
63
import org.eclipse.swt.layout.GridLayout;
60
import org.eclipse.swt.widgets.Button;
64
import org.eclipse.swt.widgets.Button;
61
import org.eclipse.swt.widgets.Composite;
65
import org.eclipse.swt.widgets.Composite;
62
import org.eclipse.swt.widgets.Control;
66
import org.eclipse.swt.widgets.Control;
63
import org.eclipse.swt.widgets.Event;
67
import org.eclipse.swt.widgets.Event;
68
import org.eclipse.swt.widgets.Group;
64
import org.eclipse.swt.widgets.Label;
69
import org.eclipse.swt.widgets.Label;
65
import org.eclipse.swt.widgets.Listener;
70
import org.eclipse.swt.widgets.Listener;
66
import org.eclipse.swt.widgets.Shell;
71
import org.eclipse.swt.widgets.Shell;
Lines 93-98 Link Here
93
		"junit.framework.Assert", //$NON-NLS-1$
98
		"junit.framework.Assert", //$NON-NLS-1$
94
		"java.lang.reflect.Method.invoke" //$NON-NLS-1$
99
		"java.lang.reflect.Method.invoke" //$NON-NLS-1$
95
	};
100
	};
101
	
102
	private static final RGB DEFAULT_OK_COLOR= new RGB(63, 127, 63);
103
	private static final RGB DEFAULT_FAILURE_COLOR= new RGB(223, 63, 63);
96
104
97
	// Step filter widgets
105
	// Step filter widgets
98
	private CheckboxTableViewer fFilterViewer;
106
	private CheckboxTableViewer fFilterViewer;
Lines 115-120 Link Here
115
	private Label fTableLabel;
123
	private Label fTableLabel;
116
124
117
	private StackFilterContentProvider fStackFilterContentProvider;
125
	private StackFilterContentProvider fStackFilterContentProvider;
126
	private ColorEditor fOkColorButton;
127
	private ColorEditor fFailureColorButton;
118
128
119
	/**
129
	/**
120
	 * Model object that represents a single entry in the filter table.
130
	 * Model object that represents a single entry in the filter table.
Lines 329-340 Link Here
329
		data.verticalAlignment= GridData.FILL;
339
		data.verticalAlignment= GridData.FILL;
330
		data.horizontalAlignment= GridData.FILL;
340
		data.horizontalAlignment= GridData.FILL;
331
		composite.setLayoutData(data);
341
		composite.setLayoutData(data);
332
342
		
343
		createColorPickers(composite);
333
		createStackFilterPreferences(composite);
344
		createStackFilterPreferences(composite);
334
		Dialog.applyDialogFont(composite);
345
		Dialog.applyDialogFont(composite);
335
		return composite;
346
		return composite;
336
	}
347
	}
337
348
349
	private void createColorPickers(Composite composite) {
350
		Group colorPickerComposite= new Group(composite, SWT.NONE);
351
		colorPickerComposite.setText(JUnitMessages.getString("JUnitPreferencePage.color.group.label")); //$NON-NLS-1$
352
		colorPickerComposite.setLayoutData(new GridData());
353
		GridLayout gl= new GridLayout();
354
		gl.numColumns= 2;
355
		colorPickerComposite.setLayout(gl);
356
		
357
		Label okLabel= new Label(colorPickerComposite, SWT.NONE);
358
		okLabel.setText(JUnitMessages.getString("JUnitPreferencePage.ok.color")); //$NON-NLS-1$
359
		okLabel.setLayoutData(new GridData());
360
		
361
		fOkColorButton= new ColorEditor(colorPickerComposite);
362
		fOkColorButton.setColorValue(getOKColor());
363
		fOkColorButton.getButton().setLayoutData(new GridData());
364
		
365
		Label failureLabel= new Label(colorPickerComposite, SWT.NONE);
366
		failureLabel.setText(JUnitMessages.getString("JUnitPreferencePage.failure.color")); //$NON-NLS-1$
367
		failureLabel.setLayoutData(new GridData());
368
		
369
		fFailureColorButton= new ColorEditor(colorPickerComposite);
370
		fFailureColorButton.setColorValue(getFailureColor());
371
		fFailureColorButton.getButton().setLayoutData(new GridData());
372
		
373
		Label noteLabel= new Label(colorPickerComposite, SWT.NONE);
374
		noteLabel.setText(JUnitMessages.getString("JUnitPreferencePage.color.note")); //$NON-NLS-1$
375
		GridData gd= new GridData();
376
		gd.horizontalSpan= 2;
377
		noteLabel.setLayoutData(gd);
378
	}
379
338
	/**
380
	/**
339
	 * Create a group to contain the step filter related widgetry
381
	 * Create a group to contain the step filter related widgetry
340
	 */
382
	 */
Lines 732-737 Link Here
732
		IPreferenceStore store= getPreferenceStore();
774
		IPreferenceStore store= getPreferenceStore();
733
		store.setValue(IJUnitPreferencesConstants.SHOW_ON_ERROR_ONLY, fShowOnErrorCheck.getSelection());
775
		store.setValue(IJUnitPreferencesConstants.SHOW_ON_ERROR_ONLY, fShowOnErrorCheck.getSelection());
734
		fStackFilterContentProvider.saveFilters();
776
		fStackFilterContentProvider.saveFilters();
777
		PreferenceConverter.setValue(store, IJUnitPreferencesConstants.PREF_COLOR_OK, fOkColorButton.getColorValue());
778
		PreferenceConverter.setValue(store, IJUnitPreferencesConstants.PREF_COLOR_FAILURE, fFailureColorButton.getColorValue());
735
		return true;
779
		return true;
736
	}
780
	}
737
781
Lines 742-747 Link Here
742
786
743
	private void setDefaultValues() {
787
	private void setDefaultValues() {
744
		fStackFilterContentProvider.setDefaults();
788
		fStackFilterContentProvider.setDefaults();
789
		fOkColorButton.setColorValue(DEFAULT_OK_COLOR);
790
		fFailureColorButton.setColorValue(DEFAULT_FAILURE_COLOR);
745
	}
791
	}
746
792
747
	/**
793
	/**
Lines 814-819 Link Here
814
	public static boolean getShowOnErrorOnly() {
860
	public static boolean getShowOnErrorOnly() {
815
		IPreferenceStore store= JUnitPlugin.getDefault().getPreferenceStore();
861
		IPreferenceStore store= JUnitPlugin.getDefault().getPreferenceStore();
816
		return store.getBoolean(IJUnitPreferencesConstants.SHOW_ON_ERROR_ONLY);
862
		return store.getBoolean(IJUnitPreferencesConstants.SHOW_ON_ERROR_ONLY);
863
	}
864
865
	public static RGB getOKColor() {
866
		IPreferenceStore store= JUnitPlugin.getDefault().getPreferenceStore();
867
		RGB color= PreferenceConverter.getColor(store, IJUnitPreferencesConstants.PREF_COLOR_OK);
868
		if (color.equals(PreferenceConverter.COLOR_DEFAULT_DEFAULT))
869
			return DEFAULT_OK_COLOR;
870
		return color;
871
	}
872
873
	public static RGB getFailureColor() {
874
		IPreferenceStore store= JUnitPlugin.getDefault().getPreferenceStore();
875
		RGB color= PreferenceConverter.getColor(store, IJUnitPreferencesConstants.PREF_COLOR_FAILURE);
876
		if (color.equals(PreferenceConverter.COLOR_DEFAULT_DEFAULT))
877
			return DEFAULT_FAILURE_COLOR;
878
		return color;
817
	}
879
	}
818
	
880
	
819
	/**
881
	/**
(-)src/org/eclipse/jdt/internal/junit/ui/JUnitProgressBar.java (-2 / +2 lines)
Lines 52-59 Link Here
52
			}
52
			}
53
		});
53
		});
54
		Display display= parent.getDisplay();
54
		Display display= parent.getDisplay();
55
		fFailureColor= new Color(display, 223, 63, 63);
55
		fFailureColor= new Color(display, JUnitPreferencePage.getFailureColor());
56
		fOKColor= new Color(display, 63, 127, 63);
56
		fOKColor= new Color(display, JUnitPreferencePage.getOKColor());
57
	}
57
	}
58
58
59
	public void setMaximum(int max) {
59
	public void setMaximum(int max) {
(-)src/org/eclipse/jdt/internal/junit/util/ColorEditor.java (+123 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2003 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/cpl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.junit.util;
12
13
import org.eclipse.swt.SWT;
14
import org.eclipse.swt.events.DisposeEvent;
15
import org.eclipse.swt.events.DisposeListener;
16
import org.eclipse.swt.events.SelectionAdapter;
17
import org.eclipse.swt.events.SelectionEvent;
18
import org.eclipse.swt.graphics.Color;
19
import org.eclipse.swt.graphics.Font;
20
import org.eclipse.swt.graphics.GC;
21
import org.eclipse.swt.graphics.Image;
22
import org.eclipse.swt.graphics.Point;
23
import org.eclipse.swt.graphics.RGB;
24
import org.eclipse.swt.widgets.Button;
25
import org.eclipse.swt.widgets.ColorDialog;
26
import org.eclipse.swt.widgets.Composite;
27
import org.eclipse.swt.widgets.Control;
28
import org.eclipse.swt.widgets.Display;
29
30
import org.eclipse.jface.resource.JFaceResources;
31
32
/**
33
 * A "button" of a certain color determined by the color picker.
34
 * (copied from jdt ui)
35
 */
36
public class ColorEditor {
37
	
38
	private Point fExtent;
39
	private Image fImage;
40
	private RGB fColorValue;
41
	private Color fColor;
42
	private Button fButton;
43
	
44
	public ColorEditor(Composite parent) {
45
		
46
		fButton= new Button(parent, SWT.PUSH);
47
		fExtent= computeImageSize(parent);
48
		fImage= new Image(parent.getDisplay(), fExtent.x, fExtent.y);
49
		
50
		GC gc= new GC(fImage);
51
		gc.setBackground(fButton.getBackground());
52
		gc.fillRectangle(0, 0, fExtent.x, fExtent.y);
53
		gc.dispose();
54
		
55
		fButton.setImage(fImage);
56
		fButton.addSelectionListener(new SelectionAdapter() {
57
			public void widgetSelected(SelectionEvent event) {
58
				ColorDialog colorDialog= new ColorDialog(fButton.getShell());
59
				colorDialog.setRGB(fColorValue);
60
				RGB newColor = colorDialog.open();
61
				if (newColor != null) {
62
					fColorValue= newColor;
63
					updateColorImage();
64
				}
65
			}
66
		});
67
		
68
		fButton.addDisposeListener(new DisposeListener() {
69
			public void widgetDisposed(DisposeEvent event) {
70
				if (fImage != null)  {
71
					fImage.dispose();
72
					fImage= null;
73
				}
74
				if (fColor != null) {
75
					fColor.dispose();
76
					fColor= null;
77
				}
78
			}
79
		});
80
	}
81
	
82
	public RGB getColorValue() {
83
		return fColorValue;
84
	}
85
	
86
	public void setColorValue(RGB rgb) {
87
		fColorValue= rgb;
88
		updateColorImage();
89
	}
90
	
91
	public Button getButton() {
92
		return fButton;
93
	}
94
	
95
	protected void updateColorImage() {
96
		
97
		Display display= fButton.getDisplay();
98
		
99
		GC gc= new GC(fImage);
100
		gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
101
		gc.drawRectangle(0, 2, fExtent.x - 1, fExtent.y - 4);
102
		
103
		if (fColor != null)
104
			fColor.dispose();
105
			
106
		fColor= new Color(display, fColorValue);
107
		gc.setBackground(fColor);
108
		gc.fillRectangle(1, 3, fExtent.x - 2, fExtent.y - 5);
109
		gc.dispose();
110
		
111
		fButton.setImage(fImage);
112
	}
113
	
114
	protected Point computeImageSize(Control window) {
115
		GC gc= new GC(window);
116
		Font f= JFaceResources.getFontRegistry().get(JFaceResources.DEFAULT_FONT);
117
		gc.setFont(f);
118
		int height= gc.getFontMetrics().getHeight();
119
		gc.dispose();
120
		Point p= new Point(height * 3 - 6, height);
121
		return p;
122
	}
123
}

Return to bug 40604