Bug 465666: Fix bread crumb background in dark theme
Change-Id: Ic0ada8e3fc648be24cb9a111a40a12d9f902c61b
Also-by: Fabio Zadrozny <fabiofz@gmail.com>
Signed-off-by: Fabio Zadrozny <fabiofz@gmail.com>
Signed-off-by: Matthias Becker <ma.becker@sap.com>
diff --git a/org.eclipse.jdt.ui/css/e4-dark_jdt_syntaxhighlighting.css b/org.eclipse.jdt.ui/css/e4-dark_jdt_syntaxhighlighting.css
index 3dde4ba..fcc8d9d 100644
--- a/org.eclipse.jdt.ui/css/e4-dark_jdt_syntaxhighlighting.css
+++ b/org.eclipse.jdt.ui/css/e4-dark_jdt_syntaxhighlighting.css
@@ -112,4 +112,24 @@
background-color:#515658;
color:#eeeeee;
swt-titlebar-color: #cccccc;
+}
+
+#BreadcrumbComposite,
+#BreadcrumbItemComposite,
+#BreadcrumbItemDetailComposite,
+#BreadcrumbItemDetailTextComposite,
+#BreadcrumbItemDetailImageComposite,
+#BreadcrumbItemDetailTextLabel,
+#BreadcrumbItemDetailImageLabel,
+#BreadcrumbItemDropDownToolBar
+{
+ /*
+ * Bug 465666
+ *
+ * Note: as we can't change the arrow to black, we configure
+ * the background with the lighter color used for the background
+ * of toolbars and make the foreground color brighter too.
+ */
+ background-color:#515658;
+ color: white;
}
\ No newline at end of file
diff --git a/org.eclipse.jdt.ui/css/e4-light_jdt_syntaxhighlighting.css b/org.eclipse.jdt.ui/css/e4-light_jdt_syntaxhighlighting.css
new file mode 100644
index 0000000..a647ba4
--- /dev/null
+++ b/org.eclipse.jdt.ui/css/e4-light_jdt_syntaxhighlighting.css
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2018 SAP SE 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
+ *******************************************************************************/
+
+#BreadcrumbComposite,
+#BreadcrumbItemComposite,
+#BreadcrumbItemDetailComposite,
+#BreadcrumbItemDetailTextComposite,
+#BreadcrumbItemDetailImageComposite,
+#BreadcrumbItemDetailTextLabel,
+#BreadcrumbItemDetailImageLabel,
+#BreadcrumbItemDropDownToolBar
+{
+ background-color:COLOR-WIDGET-LIGHT-SHADOW;;
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.ui/plugin.xml b/org.eclipse.jdt.ui/plugin.xml
index f17b90a..c0185dd 100644
--- a/org.eclipse.jdt.ui/plugin.xml
+++ b/org.eclipse.jdt.ui/plugin.xml
@@ -6812,6 +6812,12 @@
refid="org.eclipse.e4.ui.css.theme.e4_dark">
</themeid>
</stylesheet>
+ <stylesheet
+ uri="css/e4-light_jdt_syntaxhighlighting.css">
+ <themeid
+ refid="org.eclipse.e4.ui.css.theme.e4_default">
+ </themeid>
+ </stylesheet>
</extension>
<extension
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/breadcrumb/BreadcrumbItem.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/breadcrumb/BreadcrumbItem.java
index ad9b119..a28c688 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/breadcrumb/BreadcrumbItem.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/breadcrumb/BreadcrumbItem.java
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Fabio Zadrozny - Bug 465666
*******************************************************************************/
package org.eclipse.jdt.internal.ui.javaeditor.breadcrumb;
@@ -73,6 +74,8 @@
fDetailsBlock= new BreadcrumbItemDetails(this, fContainer);
fExpandBlock= new BreadcrumbItemDropDown(this, fContainer);
+
+ fContainer.setData("org.eclipse.e4.ui.css.id", "BreadcrumbItemComposite"); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/breadcrumb/BreadcrumbItemDetails.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/breadcrumb/BreadcrumbItemDetails.java
index 4f6c055..e9462c3 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/breadcrumb/BreadcrumbItemDetails.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/breadcrumb/BreadcrumbItemDetails.java
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Fabio Zadrozny - Bug 465666
*******************************************************************************/
package org.eclipse.jdt.internal.ui.javaeditor.breadcrumb;
@@ -25,13 +26,11 @@
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.events.TraverseEvent;
import org.eclipse.swt.events.TraverseListener;
-import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
@@ -126,6 +125,12 @@
});
fDetailComposite.setTabList(new Control[] { fTextComposite });
+
+ fDetailComposite.setData("org.eclipse.e4.ui.css.id", "BreadcrumbItemDetailComposite"); //$NON-NLS-1$ //$NON-NLS-2$
+ fTextComposite.setData("org.eclipse.e4.ui.css.id", "BreadcrumbItemDetailTextComposite"); //$NON-NLS-1$ //$NON-NLS-2$
+ fImageComposite.setData("org.eclipse.e4.ui.css.id", "BreadcrumbItemDetailImageComposite"); //$NON-NLS-1$ //$NON-NLS-2$
+ fElementImage.setData("org.eclipse.e4.ui.css.id", "BreadcrumbItemDetailImageLabel"); //$NON-NLS-1$ //$NON-NLS-2$
+ fElementText.setData("org.eclipse.e4.ui.css.id", "BreadcrumbItemDetailTextLabel"); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
@@ -221,7 +226,6 @@
fImageComposite.setFocus();
}
}
- updateSelection();
}
/**
@@ -253,7 +257,6 @@
if (!fSelected)
fHasFocus= false;
- updateSelection();
}
public void setFocus(boolean enabled) {
@@ -268,39 +271,6 @@
fImageComposite.setFocus();
}
}
- updateSelection();
- }
-
- private void updateSelection() {
- Color background;
- Color foreground;
-
- if (fSelected && fHasFocus) {
- background= Display.getDefault().getSystemColor(SWT.COLOR_LIST_SELECTION);
- foreground= Display.getDefault().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT);
- } else {
- foreground= null;
- background= null;
- }
-
- if (isTextVisible()) {
- fTextComposite.setBackground(background);
- fElementText.setBackground(background);
- fElementText.setForeground(foreground);
-
- fImageComposite.setBackground(null);
- fElementImage.setBackground(null);
- } else {
- fImageComposite.setBackground(background);
- fElementImage.setBackground(background);
-
- fTextComposite.setBackground(null);
- fElementText.setBackground(null);
- fElementText.setForeground(null);
- }
-
- fTextComposite.redraw();
- fImageComposite.redraw();
}
/**
@@ -406,7 +376,6 @@
public void focusGained(FocusEvent e) {
if (!fHasFocus) {
fHasFocus= true;
- updateSelection();
}
}
@@ -414,7 +383,6 @@
public void focusLost(FocusEvent e) {
if (fHasFocus) {
fHasFocus= false;
- updateSelection();
}
}
});
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/breadcrumb/BreadcrumbItemDropDown.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/breadcrumb/BreadcrumbItemDropDown.java
index 814827a..dfab74e 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/breadcrumb/BreadcrumbItemDropDown.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/breadcrumb/BreadcrumbItemDropDown.java
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Fabio Zadrozny - Bug 465666
*******************************************************************************/
package org.eclipse.jdt.internal.ui.javaeditor.breadcrumb;
@@ -104,19 +105,19 @@
@Override
protected void drawCompositeImage(int width, int height) {
Display display= fParentComposite.getDisplay();
-
+
ImageDataProvider imageProvider= zoom -> {
Image image= new Image(display, ARROW_SIZE, ARROW_SIZE * 2);
-
+
GC gc= new GC(image, fLTR ? SWT.LEFT_TO_RIGHT : SWT.RIGHT_TO_LEFT);
gc.setAntialias(SWT.ON);
-
+
Color triangleColor= createColor(SWT.COLOR_LIST_FOREGROUND, SWT.COLOR_LIST_BACKGROUND, 20, display);
gc.setBackground(triangleColor);
gc.fillPolygon(new int[] { 0, 0, ARROW_SIZE, ARROW_SIZE, 0, ARROW_SIZE * 2 });
gc.dispose();
triangleColor.dispose();
-
+
ImageData imageData= image.getImageData(zoom);
image.dispose();
int zoomedArrowSize= ARROW_SIZE * zoom / 100;
@@ -152,7 +153,7 @@
private static final int DROP_DOWN_MIN_WIDTH= 250;
private static final int DROP_DOWN_MAX_WIDTH= 500;
-
+
private static final int DROP_DOWN_DEFAULT_MIN_HEIGHT= 200;
private static final int DROP_DOWN_DEFAULT_MAX_HEIGHT= 300;
@@ -211,6 +212,7 @@
}
});
}
+ fToolBar.setData("org.eclipse.e4.ui.css.id", "BreadcrumbItemDropDownToolBar"); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
@@ -306,7 +308,7 @@
fDropDownViewer.setInput(input);
setShellBounds(fShell);
-
+
fShell.addControlListener(new ControlAdapter() {
/*
* @see org.eclipse.swt.events.ControlAdapter#controlResized(org.eclipse.swt.events.ControlEvent)
@@ -315,7 +317,7 @@
public void controlResized(ControlEvent e) {
if (isResizingProgrammatically)
return;
-
+
Point size= fShell.getSize();
getDialogSettings().put(DIALOG_HEIGHT, size.y);
}
@@ -653,7 +655,7 @@
settings= javaSettings.addNewSection(DIALOG_SETTINGS);
return settings;
}
-
+
private int getMaxHeight() {
try {
return getDialogSettings().getInt(DIALOG_HEIGHT);
@@ -661,7 +663,7 @@
return DROP_DOWN_DEFAULT_MAX_HEIGHT;
}
}
-
+
/**
* Calculates a useful size for the given shell.
*
@@ -748,7 +750,7 @@
int currentHeight= size.y;
int maxHeight= getMaxHeight();
-
+
if (currentHeight >= maxHeight && currentWidth >= DROP_DOWN_MAX_WIDTH)
return;
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/breadcrumb/BreadcrumbViewer.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/breadcrumb/BreadcrumbViewer.java
index 558668e..a1603dc 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/breadcrumb/BreadcrumbViewer.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/breadcrumb/BreadcrumbViewer.java
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Fabio Zadrozny - Bug 465666
*******************************************************************************/
package org.eclipse.jdt.internal.ui.javaeditor.breadcrumb;
@@ -21,15 +22,11 @@
import org.eclipse.swt.events.MenuDetectListener;
import org.eclipse.swt.events.TraverseEvent;
import org.eclipse.swt.events.TraverseListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.GC;
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.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
@@ -51,8 +48,6 @@
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.ViewerCell;
-import org.eclipse.ui.forms.FormColors;
-
/**
* A breadcrumb viewer shows a the parent chain of its input element in a list. Each breadcrumb item
@@ -108,22 +103,7 @@
}
});
fContainer.setBackgroundMode(SWT.INHERIT_DEFAULT);
-
- fContainer.addListener(SWT.Resize, new Listener() {
- @Override
- public void handleEvent(Event event) {
- int height= fContainer.getClientArea().height;
-
- if (fGradientBackground == null || fGradientBackground.getBounds().height != height) {
- Image image= height == 0 ? null : createGradientImage(height, event.display);
- fContainer.setBackgroundImage(image);
-
- if (fGradientBackground != null)
- fGradientBackground.dispose();
- fGradientBackground= image;
- }
- }
- });
+ fContainer.setData("org.eclipse.e4.ui.css.id", "BreadcrumbComposite"); //$NON-NLS-1$ //$NON-NLS-2$
hookControl(fContainer);
@@ -744,71 +724,6 @@
fContainer.setRedraw(false);
}
- /**
- * The image to use for the breadcrumb background as specified in
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=221477
- *
- * @param height the height of the image to create
- * @param display the current display
- * @return the image for the breadcrumb background
- */
- private Image createGradientImage(int height, Display display) {
- int width= 50;
-
- Image result= new Image(display, width, height);
-
- GC gc= new GC(result);
-
- Color colorC= createColor(SWT.COLOR_WIDGET_BACKGROUND, SWT.COLOR_LIST_BACKGROUND, 35, display);
- Color colorD= createColor(SWT.COLOR_WIDGET_BACKGROUND, SWT.COLOR_LIST_BACKGROUND, 45, display);
- Color colorE= createColor(SWT.COLOR_WIDGET_BACKGROUND, SWT.COLOR_LIST_BACKGROUND, 80, display);
- Color colorF= createColor(SWT.COLOR_WIDGET_BACKGROUND, SWT.COLOR_LIST_BACKGROUND, 70, display);
- Color colorG= createColor(SWT.COLOR_WIDGET_BACKGROUND, SWT.COLOR_WHITE, 45, display);
- Color colorH= createColor(SWT.COLOR_WIDGET_NORMAL_SHADOW, SWT.COLOR_LIST_BACKGROUND, 35, display);
-
- try {
- drawLine(width, 0, colorC, gc);
- drawLine(width, 1, colorC, gc);
-
- gc.setForeground(colorD);
- gc.setBackground(colorE);
- gc.fillGradientRectangle(0, 2, width, 2 + 8, true);
-
- gc.setBackground(colorE);
- gc.fillRectangle(0, 2 + 9, width, height - 4);
-
- drawLine(width, height - 3, colorF, gc);
- drawLine(width, height - 2, colorG, gc);
- drawLine(width, height - 1, colorH, gc);
-
- } finally {
- gc.dispose();
-
- colorC.dispose();
- colorD.dispose();
- colorE.dispose();
- colorF.dispose();
- colorG.dispose();
- colorH.dispose();
- }
-
- return result;
- }
-
- private void drawLine(int width, int position, Color color, GC gc) {
- gc.setForeground(color);
- gc.drawLine(0, position, width, position);
- }
-
- private Color createColor(int color1, int color2, int ratio, Display display) {
- RGB rgb1= display.getSystemColor(color1).getRGB();
- RGB rgb2= display.getSystemColor(color2).getRGB();
-
- RGB blend= FormColors.blend(rgb2, rgb1, ratio);
-
- return new Color(display, blend);
- }
-
/*
* @see org.eclipse.jface.viewers.StructuredViewer#handleDispose(org.eclipse.swt.events.DisposeEvent)
* @since 3.6.1