Skip to content

Commit 7894286

Browse files
committed
Fix disabled wizard buttons appearing enabled in dark theme
In the dark theme, the CSS sets a foreground color on all Button elements, which overrides the native OS disabled button rendering. This causes disabled buttons (like 'Finish') to look identical to enabled ones. Fix this by setting a 'disabled' CSS class on wizard buttons when they are disabled. The dark theme CSS now includes a Button.disabled rule with a dimmed foreground color. A reskin is triggered on state change so the CSS engine re-applies styles without needing the global dynamic CSS pseudo-class support (which is disabled for performance).
1 parent a7e91a0 commit 7894286

File tree

6 files changed

+85
-5
lines changed

6 files changed

+85
-5
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<?eclipse version="3.4"?>
3+
<plugin>
4+
5+
<extension
6+
id="product"
7+
point="org.eclipse.core.runtime.products">
8+
<product
9+
name="e"
10+
application="org.eclipse.ui.ide.workbench">
11+
<property
12+
name="appName"
13+
value="e">
14+
</property>
15+
</product>
16+
</extension>
17+
18+
</plugin>

bundles/org.eclipse.jface/src/org/eclipse/jface/wizard/WizardDialog.java

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,7 @@ private void restoreEnableState(Control control, Map<String,Object> saveState, S
973973
if (control != null) {
974974
Boolean b = (Boolean) saveState.get(key);
975975
if (b != null) {
976-
control.setEnabled(b.booleanValue());
976+
setButtonEnabled(control, b.booleanValue());
977977
}
978978
}
979979
}
@@ -1066,10 +1066,25 @@ public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable
10661066
private void saveEnableStateAndSet(Control control, Map<String, Object> saveState, String key, boolean enabled) {
10671067
if (control != null) {
10681068
saveState.put(key, control.getEnabled() ? Boolean.TRUE : Boolean.FALSE);
1069-
control.setEnabled(enabled);
1069+
setButtonEnabled(control, enabled);
10701070
}
10711071
}
10721072

1073+
/**
1074+
* Sets the enabled state of a button and updates the CSS class name so that
1075+
* the dark theme can style disabled buttons differently. The CSS class
1076+
* "disabled" is set when the button is disabled, and cleared when enabled.
1077+
* This triggers a reskin so that the CSS engine re-applies styles.
1078+
*
1079+
* @param control the button control
1080+
* @param enabled whether the button should be enabled
1081+
*/
1082+
private static void setButtonEnabled(Control control, boolean enabled) {
1083+
control.setEnabled(enabled);
1084+
control.setData("org.eclipse.e4.ui.css.CssClassName", enabled ? null : "disabled"); //$NON-NLS-1$ //$NON-NLS-2$
1085+
control.reskin(SWT.NONE);
1086+
}
1087+
10731088
/**
10741089
* Captures and returns the enabled/disabled state of the wizard dialog's
10751090
* buttons and the tree of controls for the currently showing page. All
@@ -1332,13 +1347,13 @@ public void updateButtons() {
13321347
boolean canFinish = wizard.canFinish();
13331348
if (backButton != null) {
13341349
boolean backEnabled = currentPage != null && currentPage.getPreviousPage() != null;
1335-
backButton.setEnabled(backEnabled);
1350+
setButtonEnabled(backButton, backEnabled);
13361351
}
13371352
if (nextButton != null) {
13381353
canFlipToNextPage = currentPage != null && currentPage.canFlipToNextPage();
1339-
nextButton.setEnabled(canFlipToNextPage);
1354+
setButtonEnabled(nextButton, canFlipToNextPage);
13401355
}
1341-
finishButton.setEnabled(canFinish);
1356+
setButtonEnabled(finishButton, canFinish);
13421357
// finish is default unless it is disabled and next is enabled
13431358
if (canFlipToNextPage && !canFinish) {
13441359
getShell().setDefaultButton(nextButton);

bundles/org.eclipse.ui.themes/css/dark/e4-dark_globalstyle.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ Group > StyledText {
4545
color:'#org-eclipse-ui-workbench-DARK_FOREGROUND';
4646
}
4747

48+
/* Disabled buttons should appear dimmed to distinguish them from enabled buttons */
49+
Button.disabled {
50+
color: #777777;
51+
}
52+
4853
/* ############################## Toolbar ############################## */
4954
/* Ensure that the labels in the tabfolder gets updated
5055
See Bug 552780

product/.project

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>product</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
</buildSpec>
9+
<natures>
10+
</natures>
11+
</projectDescription>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
eclipse.preferences.version=1
2+
encoding/<project>=UTF-8

product/eclipse.product

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<?pde version="3.5"?>
3+
4+
<product name="e" uid="eclipse" id="org.eclipse.e4.ui.workbench3.product" application="org.eclipse.ui.ide.workbench" version="1.0.0.qualifier" type="mixed" includeLaunchers="true" autoIncludeRequirements="true">
5+
6+
<configIni use="default">
7+
</configIni>
8+
9+
<launcherArgs>
10+
<vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts
11+
</vmArgsMac>
12+
</launcherArgs>
13+
14+
<plugins>
15+
</plugins>
16+
17+
<features>
18+
<feature id="org.eclipse.sdk" installMode="root"/>
19+
</features>
20+
21+
<configurations>
22+
<plugin id="org.eclipse.core.runtime" autoStart="true" startLevel="4" />
23+
<plugin id="org.eclipse.equinox.common" autoStart="true" startLevel="2" />
24+
<plugin id="org.eclipse.equinox.event" autoStart="true" startLevel="2" />
25+
<plugin id="org.apache.felix.scr" autoStart="true" startLevel="2" />
26+
<plugin id="org.eclipse.equinox.simpleconfigurator" autoStart="true" startLevel="1" />
27+
</configurations>
28+
29+
</product>

0 commit comments

Comments
 (0)