Skip to content

Commit

Permalink
improve Dark Theme on Windows eclipse-platform/.github#27 (#126)
Browse files Browse the repository at this point in the history
Using CTabFolder and CTabItem, instead of TabFolder/TabItem, improves
the look when in Dark Theme; the background of the tab no longer has a
non-dark background.

This relates to multiple commits to fix:

[Windows][Dark theme] Multiple preference pages use tab widgets, that
are not dark theme aware eclipse-platform/.github#27
  • Loading branch information
betamaxbandit authored Jul 25, 2022
1 parent 5f9f486 commit e9a3635
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import java.util.Map;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
Expand All @@ -30,8 +32,6 @@
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Widget;

import org.eclipse.core.runtime.CoreException;
Expand Down Expand Up @@ -135,7 +135,7 @@ public interface IRemoveOldBinariesQuery {

private IStatusChangeListener fContext;
private Control fSWTWidget;
private TabFolder fTabFolder;
private CTabFolder fTabFolder;

private int fPageIndex;

Expand Down Expand Up @@ -226,12 +226,13 @@ public Control createControl(Composite parent) {
layout.numColumns= 1;
composite.setLayout(layout);

TabFolder folder= new TabFolder(composite, SWT.NONE);
CTabFolder folder= new CTabFolder(composite, SWT.NONE);
folder.setLayoutData(new GridData(GridData.FILL_BOTH));
folder.setFont(composite.getFont());

TabItem item;
item= new TabItem(folder, SWT.NONE);
CTabItem item;
item= new CTabItem(folder, SWT.NONE);
folder.setSelection(0);
item.setText(NewWizardMessages.BuildPathsBlock_tab_source);
item.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_PACKFRAG_ROOT));

Expand All @@ -246,14 +247,14 @@ public Control createControl(Composite parent) {
Image projectImage= PlatformUI.getWorkbench().getSharedImages().getImage(IDE.SharedImages.IMG_OBJ_PROJECT);

fProjectsPage= new ProjectsWorkbookPage(fClassPathList, fPageContainer);
item= new TabItem(folder, SWT.NONE);
item= new CTabItem(folder, SWT.NONE);
item.setText(NewWizardMessages.BuildPathsBlock_tab_projects);
item.setImage(projectImage);
item.setData(fProjectsPage);
item.setControl(fProjectsPage.getControl(folder));

fLibrariesPage= new LibrariesWorkbookPage(fClassPathList, fPageContainer);
item= new TabItem(folder, SWT.NONE);
item= new CTabItem(folder, SWT.NONE);
item.setText(NewWizardMessages.BuildPathsBlock_tab_libraries);
item.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_LIBRARY));
item.setData(fLibrariesPage);
Expand All @@ -264,14 +265,14 @@ public Control createControl(Composite parent) {
composite.addDisposeListener(new ImageDisposer(cpoImage));

ClasspathOrderingWorkbookPage ordpage= new ClasspathOrderingWorkbookPage(fClassPathList);
item= new TabItem(folder, SWT.NONE);
item= new CTabItem(folder, SWT.NONE);
item.setText(NewWizardMessages.BuildPathsBlock_tab_order);
item.setImage(cpoImage);
item.setData(ordpage);
item.setControl(ordpage.getControl(folder));

fModulesPage= new ModuleDependenciesPage(fContext, fClassPathList);
item= new TabItem(folder, SWT.NONE);
item= new CTabItem(folder, SWT.NONE);
item.setText(NewWizardMessages.BuildPathsBlock_tab_modules);
item.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_MODULE));
item.setData(fModulesPage);
Expand Down Expand Up @@ -1026,8 +1027,8 @@ private IContainer chooseContainer() {
// -------- tab switching ----------

private void tabChanged(Widget widget) {
if (widget instanceof TabItem) {
TabItem tabItem= (TabItem) widget;
if (widget instanceof CTabItem) {
CTabItem tabItem= (CTabItem) widget;
BuildPathBasePage newPage= (BuildPathBasePage) tabItem.getData();
if (fCurrPage != null) {
List<?> selection= fCurrPage.getSelection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.ibm.icu.text.MessageFormat;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
Expand All @@ -39,7 +40,6 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
Expand Down Expand Up @@ -240,7 +240,7 @@ public Control getControl(Composite parent) {

fDetailsList.setViewerComparator(new CPListElementSorter());

((TabFolder) parent).addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
((CTabFolder) parent).addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
if (e.item.getData() == this && fCurrJProject != null)
init(fCurrJProject);
}));
Expand Down

0 comments on commit e9a3635

Please sign in to comment.