Skip to content

Commit

Permalink
Plug-In Image browser does not highlight the current page in dark theme
Browse files Browse the repository at this point in the history
Temporary fix to disable the styling for current page (Hyperlink widget)
and setting white color to it (only if current theme is Dark Theme ).

Fixes #822
  • Loading branch information
lathapatil committed Nov 15, 2023
1 parent f169a74 commit 3337ee3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ui/org.eclipse.pde.ui/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ Require-Bundle:
org.eclipse.team.ui;bundle-version="[3.10.200,4.0.0)",
org.eclipse.help;bundle-version="[3.10.200,4.0.0)",
org.eclipse.equinox.bidi;bundle-version="[1.4.300,2.0.0)",
org.eclipse.equinox.security;bundle-version="[1.4.100,2.0.0)"
org.eclipse.equinox.security;bundle-version="[1.4.100,2.0.0)",
org.eclipse.e4.ui.css.swt.theme;bundle-version="0.14.200"
Import-Package: aQute.bnd.build.model;version="[4.2.0,5.0.0)",
aQute.bnd.header;version="[2.5.0,3.0.0)",
aQute.bnd.help;version="2.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* Christian Pontesegger - initial API and implementation
* IBM Corporation - ongoing enhancements
* Alena Laskavaia - Bug 481613 pagination controls
* Latha Patil - Issue 822 Current page in pagination control is not highlighted in Dark Theme
*******************************************************************************/

package org.eclipse.pde.internal.ui.views.imagebrowser;
Expand All @@ -27,6 +28,8 @@
import org.eclipse.core.commands.NotEnabledException;
import org.eclipse.core.commands.NotHandledException;
import org.eclipse.core.commands.common.NotDefinedException;
import org.eclipse.e4.ui.css.swt.theme.ITheme;
import org.eclipse.e4.ui.css.swt.theme.IThemeEngine;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.RowLayoutFactory;
Expand Down Expand Up @@ -87,10 +90,12 @@
* Provides the PDE Image browser view which displays all icons and images from plug-ins. The plug-ins
* can be loaded from the target platform, the workspace or the current install.
*/
@SuppressWarnings("restriction")
public class ImageBrowserView extends ViewPart implements IImageTarget {

private static final String COMMAND_SAVE_TO_WORKSPACE = "org.eclipse.pde.ui.imagebrowser.saveToWorkspace"; //$NON-NLS-1$
protected final static String VIEW_ID = "org.eclipse.pde.ui.ImageBrowserView"; //$NON-NLS-1$
private static final String DISABLE_CSS = "org.eclipse.e4.ui.css.disabled"; //$NON-NLS-1$

private final UpdateUI mUIJob = new UpdateUI();

Expand Down Expand Up @@ -123,6 +128,7 @@ public class ImageBrowserView extends ViewPart implements IImageTarget {
private ImageElement imageElement;

private Action saveAction;
private boolean isDarkTheme = false;

public ImageBrowserView() {
// create default filters
Expand All @@ -144,6 +150,7 @@ public ImageBrowserView() {
mFilters.add(enabledIcons);
textPatternFilter = new StringFilter("*"); //$NON-NLS-1$
mFilters.add(textPatternFilter);
isDarkTheme = isDarkThemeApplied();
}

@Override
Expand Down Expand Up @@ -364,6 +371,16 @@ public void linkActivated(HyperlinkEvent e) {
scanImages();
}
});
} else {
// Remove Cursor for current page
pageLink.setCursor(null);
// FIXME :#1168 Issue (Current page is not highlighted in
// Dark theme) - This is the temporary fix provided . Actual
// fix has to be done in CSS styling.
if (isDarkTheme) {
pageLink.setData(DISABLE_CSS, Boolean.TRUE);
pageLink.setForeground(getDisplay().getSystemColor(SWT.COLOR_TRANSPARENT));
}
}

}
Expand Down Expand Up @@ -589,4 +606,13 @@ public void widgetDefaultSelected(SelectionEvent e) {

}
}

private boolean isDarkThemeApplied() {
IThemeEngine themeEngine = PlatformUI.getWorkbench().getService(IThemeEngine.class);
if (themeEngine != null) {
ITheme activeTheme = themeEngine.getActiveTheme();
return (activeTheme != null && activeTheme.getLabel() != null && activeTheme.getLabel().equals("Dark")); //$NON-NLS-1$
}
return false;
}
}

0 comments on commit 3337ee3

Please sign in to comment.