Fix java declaration view rhbz#1305107

This commit is contained in:
Mat Booth 2016-02-09 11:14:08 +00:00
parent 4c47d08d5a
commit dc64e86b25
2 changed files with 152 additions and 2 deletions

145
eclipse-bug-477487.patch Normal file
View File

@ -0,0 +1,145 @@
diff --git a/eclipse.platform.ui/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/themes/RGBVisibleContrastColorFactory.java b/eclipse.platform.ui/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/themes/RGBVisibleContrastColorFactory.java
new file mode 100644
index 0000000..67b33c7
--- /dev/null
+++ b/eclipse.platform.ui/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/themes/RGBVisibleContrastColorFactory.java
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2011 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.internal.themes;
+
+import java.util.Hashtable;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExecutableExtension;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.ui.themes.ColorUtil;
+import org.eclipse.ui.themes.IColorFactory;
+
+/**
+ * A <code>IColorFactory</code> that may be used to select a color with a higher
+ * contrast. The input colors are specified as per method number two in
+ * {@link org.eclipse.core.runtime.IExecutableExtension}.
+ * <p>
+ * Example usage:
+ *
+ * <pre>
+ * &lt;colorDefinition
+ * label="Declaration view background"
+ * id="org.eclipse.jdt.ui.DeclarationView.backgroundColor"&gt;
+ * &lt;colorFactory
+ * plugin="org.eclipse.ui"
+ * class="org.eclipse.ui.internal.themes.RGBContrastFactory"&gt;
+ * &lt;parameter name="foreground" value="0,0,0" /&gt;
+ * &lt;parameter name="background" value="COLOR_INFO_BACKGROUND" /&gt;
+ * &lt;parameter name="alternativeBackground" value="COLOR_LIST_BACKGROUND" /&gt;
+ * &lt;/colorFactory&gt;
+ * &lt;/colorDefinition&gt;
+ * </pre>
+ *
+ * <p>
+ * Returns <em>background</em> if <em>foreground</em> is visibly distinct from
+ * <em>background</em>. Otherwise, returns <em>alternativeBackground</em> if
+ * that color has more difference in brightness to the foreground. If both
+ * colors are bad, returns <em>background</em>. The color values may be
+ * specified as RGB triples or as SWT constants.
+ *
+ * @see org.eclipse.swt.SWT
+ * @since 3.107.100
+ */
+// This class is used by org.eclipse.jdt.ui/plugin.xml to fix
+// https://bugs.eclipse.org/477487
+public class RGBVisibleContrastColorFactory implements IColorFactory, IExecutableExtension {
+ private String fg, bg, altBg;
+
+ @Override
+ public RGB createColor() {
+ RGB cfg, cbg, cbgAlt;
+
+ if (fg != null) {
+ cfg = ColorUtil.getColorValue(fg);
+ } else {
+ cfg = new RGB(0, 0, 0);
+ }
+ if (bg != null) {
+ cbg = ColorUtil.getColorValue(bg);
+ } else {
+ cbg = new RGB(255, 255, 255);
+ }
+ if (altBg != null) {
+ cbgAlt = ColorUtil.getColorValue(altBg);
+ } else {
+ cbgAlt = new RGB(255, 255, 255);
+ }
+
+ float bfg = cfg.getHSB()[2];
+ float bbg = cbg.getHSB()[2];
+ float bbgAlt = cbgAlt.getHSB()[2];
+
+ if (Math.abs(bbg - bfg) < 0.5f && Math.abs(bbgAlt - bfg) > Math.abs(bbg - bfg)) {
+ return cbgAlt;
+ }
+ return cbg;
+ }
+
+ /**
+ * This executable extension requires parameters to be explicitly declared
+ * via the second method described in the <code>IExecutableExtension</code>
+ * documentation. This class expects that there will be three parameters,
+ * <code>foreground</code>, <code>background</code> and
+ * <code>alternativeBackground</code>. These values may either be RGB
+ * triples or SWT constants.
+ */
+ @Override
+ public void setInitializationData(IConfigurationElement config, String propertyName, Object data)
+ throws CoreException {
+ if (data instanceof Hashtable) {
+ @SuppressWarnings("unchecked")
+ Hashtable<String, String> table = (Hashtable<String, String>) data;
+ fg = table.get("foreground"); //$NON-NLS-1$
+ bg = table.get("background"); //$NON-NLS-1$
+ altBg = table.get("alternativeBackground"); //$NON-NLS-1$
+ }
+ }
+}
diff --git a/eclipse.jdt.ui/org.eclipse.jdt.ui/plugin.xml b/org.eclipse.jdt.ui/plugin.xml
index e266d1a..f4b51ed 100644
--- a/eclipse.jdt.ui/org.eclipse.jdt.ui/plugin.xml
+++ b/eclipse.jdt.ui/org.eclipse.jdt.ui/plugin.xml
@@ -1065,8 +1065,23 @@
<colorDefinition
label="%DeclarationViewBackgroundColor.label"
categoryId="org.eclipse.jdt.ui.presentation"
- value="COLOR_INFO_BACKGROUND"
id="org.eclipse.jdt.ui.DeclarationView.backgroundColor">
+ <colorFactory
+ plugin="org.eclipse.ui"
+ class="org.eclipse.ui.internal.themes.RGBVisibleContrastColorFactory">
+ <parameter
+ name="foreground"
+ value="0,0,0">
+ </parameter>
+ <parameter
+ name="background"
+ value="COLOR_INFO_BACKGROUND">
+ </parameter>
+ <parameter
+ name="alternativeBackground"
+ value="COLOR_LIST_BACKGROUND">
+ </parameter>
+ </colorFactory>
<description>
%DeclarationViewBackgroundColor.description
</description>
--
cgit v0.11.2-4-g4a35

View File

@ -49,7 +49,7 @@ Epoch: 1
Summary: An open, extensible IDE
Name: eclipse
Version: %{eclipse_version}
Release: 10%{?dist}
Release: 11%{?dist}
License: EPL
URL: http://www.eclipse.org/
@ -148,6 +148,7 @@ Patch32: eclipse-bug-479998.patch
Patch33: eclipse-bug-483096.patch
Patch34: eclipse-bug-484696.patch
Patch35: eclipse-bug-484729.patch
Patch36: eclipse-bug-477487.patch
BuildRequires: rsync
BuildRequires: make, gcc
@ -408,6 +409,7 @@ pushd eclipse.platform.swt
%patch35 -p1
popd
%patch30 -p1
%patch36 -p1
# Resolving the target platform requires too many changes, so don't use it
%pom_xpath_remove "pom:configuration/pom:target" eclipse-platform-parent
@ -571,7 +573,7 @@ for f in `find eclipse.platform.team/bundles/org.eclipse.core.net/fragments -nam
echo -e "Eclipse-BundleShape: dir\n\n" >> $f;
done
%if 0%{?rhel} < 7
%if 0%{?rhel} == 6
# No GTK3 on EL 6
sed -i '/machine_gtk3/d' eclipse.platform.swt.binaries/bundles/org.eclipse.swt.gtk.linux.%{eclipse_arch}/pom.xml
%endif
@ -1132,6 +1134,9 @@ fi
%{_libdir}/%{pkg_name}/plugins/org.eclipse.osgi.compatibility.state_*
%changelog
* Mon Feb 08 2016 Mat Booth <mat.booth@redhat.com> - 1:4.5.1-11
- Fix java declaration view rhbz#1305107
* Wed Feb 03 2016 Mat Booth <mat.booth@redhat.com> - 1:4.5.1-10
- Fix symlinks for new lucene
- Use %%global instead of %%define and other macro improvements