Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 5534 Details for
Bug 40604
JUnit status bar colors difficult for color blind user [JUnit]
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
patch for the junit project
40604-2.patch (text/plain), 14.54 KB, created by
Adam Kiezun
on 2003-07-23 08:32:42 EDT
(
hide
)
Description:
patch for the junit project
Filename:
MIME Type:
Creator:
Adam Kiezun
Created:
2003-07-23 08:32:42 EDT
Size:
14.54 KB
patch
obsolete
>Index: src/org/eclipse/jdt/internal/junit/ui/IJUnitPreferencesConstants.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/IJUnitPreferencesConstants.java,v >retrieving revision 1.2 >diff -u -r1.2 IJUnitPreferencesConstants.java >--- src/org/eclipse/jdt/internal/junit/ui/IJUnitPreferencesConstants.java 10 Mar 2003 21:55:10 -0000 1.2 >+++ src/org/eclipse/jdt/internal/junit/ui/IJUnitPreferencesConstants.java 23 Jul 2003 12:31:13 -0000 >@@ -38,4 +38,13 @@ > */ > public static final String PREF_INACTIVE_FILTERS_LIST = JUnitPlugin.PLUGIN_ID + ".inactive_filters"; //$NON-NLS-1$ > >+ /** >+ * OK color for the progress bar. >+ */ >+ public static final String PREF_COLOR_OK= JUnitPlugin.PLUGIN_ID + ".ok_color"; //$NON-NLS-1$ >+ >+ /** >+ * Failure color for the progress bar. >+ */ >+ public static final String PREF_COLOR_FAILURE= JUnitPlugin.PLUGIN_ID + ".failure_color"; //$NON-NLS-1$ > } >Index: src/org/eclipse/jdt/internal/junit/ui/JUnitMessages.properties >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitMessages.properties,v >retrieving revision 1.31 >diff -u -r1.31 JUnitMessages.properties >--- src/org/eclipse/jdt/internal/junit/ui/JUnitMessages.properties 16 Jul 2003 09:47:15 -0000 1.31 >+++ src/org/eclipse/jdt/internal/junit/ui/JUnitMessages.properties 23 Jul 2003 12:31:13 -0000 >@@ -167,3 +167,5 @@ > ExpandAllAction.tooltip=Expand All Nodes > JUnitAddLibraryProposal.info=Add the JUnit library to the project\'s build class path > JUnitAddLibraryProposal.label=Add JUnit libraries >+JUnitPreferencePage.ok.color=OK &status color: >+JUnitPreferencePage.failure.color=Fail&ure status color: >Index: src/org/eclipse/jdt/internal/junit/ui/JUnitPreferencePage.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitPreferencePage.java,v >retrieving revision 1.13 >diff -u -r1.13 JUnitPreferencePage.java >--- src/org/eclipse/jdt/internal/junit/ui/JUnitPreferencePage.java 18 Mar 2003 19:44:43 -0000 1.13 >+++ src/org/eclipse/jdt/internal/junit/ui/JUnitPreferencePage.java 23 Jul 2003 12:31:15 -0000 >@@ -21,6 +21,8 @@ > import org.eclipse.jdt.core.IType; > import org.eclipse.jdt.core.JavaModelException; > import org.eclipse.jdt.core.search.SearchEngine; >+ >+import org.eclipse.jdt.internal.junit.util.ColorEditor; > import org.eclipse.jdt.internal.junit.util.ExceptionHandler; > import org.eclipse.jdt.internal.junit.util.SWTUtil; > import org.eclipse.jdt.ui.IJavaElementSearchConstants; >@@ -31,6 +33,7 @@ > import org.eclipse.jface.dialogs.IDialogConstants; > import org.eclipse.jface.dialogs.ProgressMonitorDialog; > import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.jface.preference.PreferenceConverter; > import org.eclipse.jface.preference.PreferencePage; > import org.eclipse.jface.viewers.CheckStateChangedEvent; > import org.eclipse.jface.viewers.CheckboxTableViewer; >@@ -55,12 +58,14 @@ > import org.eclipse.swt.events.KeyAdapter; > import org.eclipse.swt.events.KeyEvent; > import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.graphics.RGB; > import org.eclipse.swt.layout.GridData; > import org.eclipse.swt.layout.GridLayout; > import org.eclipse.swt.widgets.Button; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Control; > import org.eclipse.swt.widgets.Event; >+import org.eclipse.swt.widgets.Group; > import org.eclipse.swt.widgets.Label; > import org.eclipse.swt.widgets.Listener; > import org.eclipse.swt.widgets.Shell; >@@ -93,6 +98,9 @@ > "junit.framework.Assert", //$NON-NLS-1$ > "java.lang.reflect.Method.invoke" //$NON-NLS-1$ > }; >+ >+ private static final RGB DEFAULT_OK_COLOR= new RGB(63, 127, 63); >+ private static final RGB DEFAULT_FAILURE_COLOR= new RGB(223, 63, 63); > > // Step filter widgets > private CheckboxTableViewer fFilterViewer; >@@ -115,6 +123,8 @@ > private Label fTableLabel; > > private StackFilterContentProvider fStackFilterContentProvider; >+ private ColorEditor fOkColorButton; >+ private ColorEditor fFailureColorButton; > > /** > * Model object that represents a single entry in the filter table. >@@ -329,12 +339,39 @@ > data.verticalAlignment= GridData.FILL; > data.horizontalAlignment= GridData.FILL; > composite.setLayoutData(data); >- >+ >+ createColorPickers(composite); > createStackFilterPreferences(composite); > Dialog.applyDialogFont(composite); > return composite; > } > >+ private void createColorPickers(Composite composite) { >+ Composite colorPickerComposite= new Composite(composite, SWT.NONE); >+ colorPickerComposite.setLayoutData(new GridData()); >+ GridLayout gl= new GridLayout(); >+ gl.numColumns= 2; >+ gl.marginHeight= 0; >+ gl.marginWidth= 0; >+ colorPickerComposite.setLayout(gl); >+ >+ Label okLabel= new Label(colorPickerComposite, SWT.NONE); >+ okLabel.setText(JUnitMessages.getString("JUnitPreferencePage.ok.color")); //$NON-NLS-1$ >+ okLabel.setLayoutData(new GridData()); >+ >+ fOkColorButton= new ColorEditor(colorPickerComposite); >+ fOkColorButton.setColorValue(getOKColor()); >+ fOkColorButton.getButton().setLayoutData(new GridData()); >+ >+ Label failureLabel= new Label(colorPickerComposite, SWT.NONE); >+ failureLabel.setText(JUnitMessages.getString("JUnitPreferencePage.failure.color")); //$NON-NLS-1$ >+ failureLabel.setLayoutData(new GridData()); >+ >+ fFailureColorButton= new ColorEditor(colorPickerComposite); >+ fFailureColorButton.setColorValue(getFailureColor()); >+ fFailureColorButton.getButton().setLayoutData(new GridData()); >+ } >+ > /** > * Create a group to contain the step filter related widgetry > */ >@@ -732,6 +769,8 @@ > IPreferenceStore store= getPreferenceStore(); > store.setValue(IJUnitPreferencesConstants.SHOW_ON_ERROR_ONLY, fShowOnErrorCheck.getSelection()); > fStackFilterContentProvider.saveFilters(); >+ PreferenceConverter.setValue(store, IJUnitPreferencesConstants.PREF_COLOR_OK, fOkColorButton.getColorValue()); >+ PreferenceConverter.setValue(store, IJUnitPreferencesConstants.PREF_COLOR_FAILURE, fFailureColorButton.getColorValue()); > return true; > } > >@@ -742,6 +781,8 @@ > > private void setDefaultValues() { > fStackFilterContentProvider.setDefaults(); >+ fOkColorButton.setColorValue(DEFAULT_OK_COLOR); >+ fFailureColorButton.setColorValue(DEFAULT_FAILURE_COLOR); > } > > /** >@@ -814,6 +855,22 @@ > public static boolean getShowOnErrorOnly() { > IPreferenceStore store= JUnitPlugin.getDefault().getPreferenceStore(); > return store.getBoolean(IJUnitPreferencesConstants.SHOW_ON_ERROR_ONLY); >+ } >+ >+ public static RGB getOKColor() { >+ IPreferenceStore store= JUnitPlugin.getDefault().getPreferenceStore(); >+ RGB color= PreferenceConverter.getColor(store, IJUnitPreferencesConstants.PREF_COLOR_OK); >+ if (color.equals(PreferenceConverter.COLOR_DEFAULT_DEFAULT)) >+ return DEFAULT_OK_COLOR; >+ return color; >+ } >+ >+ public static RGB getFailureColor() { >+ IPreferenceStore store= JUnitPlugin.getDefault().getPreferenceStore(); >+ RGB color= PreferenceConverter.getColor(store, IJUnitPreferencesConstants.PREF_COLOR_FAILURE); >+ if (color.equals(PreferenceConverter.COLOR_DEFAULT_DEFAULT)) >+ return DEFAULT_FAILURE_COLOR; >+ return color; > } > > /** >Index: src/org/eclipse/jdt/internal/junit/ui/JUnitProgressBar.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitProgressBar.java,v >retrieving revision 1.5 >diff -u -r1.5 JUnitProgressBar.java >--- src/org/eclipse/jdt/internal/junit/ui/JUnitProgressBar.java 4 Jul 2003 21:17:47 -0000 1.5 >+++ src/org/eclipse/jdt/internal/junit/ui/JUnitProgressBar.java 23 Jul 2003 12:31:15 -0000 >@@ -18,11 +18,15 @@ > import org.eclipse.swt.graphics.Color; > import org.eclipse.swt.graphics.GC; > import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.graphics.RGB; > import org.eclipse.swt.graphics.Rectangle; > import org.eclipse.swt.widgets.Canvas; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Display; > >+import org.eclipse.jface.util.IPropertyChangeListener; >+import org.eclipse.jface.util.PropertyChangeEvent; >+ > /** > * A progress bar with a red/green indication for success or failure. > */ >@@ -36,6 +40,7 @@ > private Color fOKColor; > private Color fFailureColor; > private boolean fError; >+ private IPropertyChangeListener fPropertyChangeListener; > > public JUnitProgressBar(Composite parent) { > super(parent, SWT.NONE); >@@ -51,9 +56,43 @@ > paint(e); > } > }); >- Display display= parent.getDisplay(); >- fFailureColor= new Color(display, 223, 63, 63); >- fOKColor= new Color(display, 63, 127, 63); >+ fPropertyChangeListener= createPropertyChangeListener(); >+ JUnitPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(fPropertyChangeListener); >+ resetColors(); >+ } >+ >+ private IPropertyChangeListener createPropertyChangeListener() { >+ return new IPropertyChangeListener() { >+ public void propertyChange(PropertyChangeEvent event) { >+ JUnitProgressBar.this.handlePropertyChange(event); >+ } >+ }; >+ } >+ >+ private void handlePropertyChange(PropertyChangeEvent event) { >+ if (event.getProperty().equals(IJUnitPreferencesConstants.PREF_COLOR_FAILURE) || event.getProperty().equals(IJUnitPreferencesConstants.PREF_COLOR_OK)) { >+ resetColors(); >+ } >+ } >+ >+ private void resetColors() { >+ if (isDisposed()) >+ return; >+ resetOKColorFromPreferences(); >+ resetFailureColorFromPreferences(); >+ refresh(fError); >+ } >+ >+ private void resetOKColorFromPreferences() { >+ if (fOKColor != null && !fOKColor.isDisposed()) >+ fOKColor.dispose(); >+ fOKColor= new Color(getDisplay(), JUnitPreferencePage.getOKColor()); >+ } >+ >+ private void resetFailureColorFromPreferences() { >+ if (fFailureColor != null && !fFailureColor.isDisposed()) >+ fFailureColor.dispose(); >+ fFailureColor= new Color(getDisplay(), JUnitPreferencePage.getFailureColor()); > } > > public void setMaximum(int max) { >@@ -66,6 +105,7 @@ > fColorBarWidth= 0; > fMaxTickCount= 0; > redraw(); >+ resetColors(); > } > > private void paintStep(int startX, int endX) { >@@ -81,6 +121,7 @@ > super.dispose(); > fFailureColor.dispose(); > fOKColor.dispose(); >+ JUnitPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPropertyChangeListener); > } > > private void setStatusColor(GC gc) { >Index: src/org/eclipse/jdt/internal/junit/util/ColorEditor.java >=================================================================== >RCS file: src/org/eclipse/jdt/internal/junit/util/ColorEditor.java >diff -N src/org/eclipse/jdt/internal/junit/util/ColorEditor.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jdt/internal/junit/util/ColorEditor.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,123 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2003 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.junit.util; >+ >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.DisposeEvent; >+import org.eclipse.swt.events.DisposeListener; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.graphics.Color; >+import org.eclipse.swt.graphics.Font; >+import org.eclipse.swt.graphics.GC; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.graphics.RGB; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.ColorDialog; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Display; >+ >+import org.eclipse.jface.resource.JFaceResources; >+ >+/** >+ * A "button" of a certain color determined by the color picker. >+ * (copied from jdt ui) >+ */ >+public class ColorEditor { >+ >+ private Point fExtent; >+ private Image fImage; >+ private RGB fColorValue; >+ private Color fColor; >+ private Button fButton; >+ >+ public ColorEditor(Composite parent) { >+ >+ fButton= new Button(parent, SWT.PUSH); >+ fExtent= computeImageSize(parent); >+ fImage= new Image(parent.getDisplay(), fExtent.x, fExtent.y); >+ >+ GC gc= new GC(fImage); >+ gc.setBackground(fButton.getBackground()); >+ gc.fillRectangle(0, 0, fExtent.x, fExtent.y); >+ gc.dispose(); >+ >+ fButton.setImage(fImage); >+ fButton.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent event) { >+ ColorDialog colorDialog= new ColorDialog(fButton.getShell()); >+ colorDialog.setRGB(fColorValue); >+ RGB newColor = colorDialog.open(); >+ if (newColor != null) { >+ fColorValue= newColor; >+ updateColorImage(); >+ } >+ } >+ }); >+ >+ fButton.addDisposeListener(new DisposeListener() { >+ public void widgetDisposed(DisposeEvent event) { >+ if (fImage != null) { >+ fImage.dispose(); >+ fImage= null; >+ } >+ if (fColor != null) { >+ fColor.dispose(); >+ fColor= null; >+ } >+ } >+ }); >+ } >+ >+ public RGB getColorValue() { >+ return fColorValue; >+ } >+ >+ public void setColorValue(RGB rgb) { >+ fColorValue= rgb; >+ updateColorImage(); >+ } >+ >+ public Button getButton() { >+ return fButton; >+ } >+ >+ protected void updateColorImage() { >+ >+ Display display= fButton.getDisplay(); >+ >+ GC gc= new GC(fImage); >+ gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK)); >+ gc.drawRectangle(0, 2, fExtent.x - 1, fExtent.y - 4); >+ >+ if (fColor != null) >+ fColor.dispose(); >+ >+ fColor= new Color(display, fColorValue); >+ gc.setBackground(fColor); >+ gc.fillRectangle(1, 3, fExtent.x - 2, fExtent.y - 5); >+ gc.dispose(); >+ >+ fButton.setImage(fImage); >+ } >+ >+ protected Point computeImageSize(Control window) { >+ GC gc= new GC(window); >+ Font f= JFaceResources.getFontRegistry().get(JFaceResources.DEFAULT_FONT); >+ gc.setFont(f); >+ int height= gc.getFontMetrics().getHeight(); >+ gc.dispose(); >+ Point p= new Point(height * 3 - 6, height); >+ return p; >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 40604
:
5532
| 5534