Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.rap.rwt/src/org/eclipse/rap/rwt/internal/theme/ThemeUtil.java12
-rw-r--r--bundles/org.eclipse.rap.rwt/widgetkits/org/eclipse/swt/internal/widgets/controlkit/ControlThemeAdapterImpl.java10
-rw-r--r--tests/org.eclipse.rap.rwt.test/src/org/eclipse/rap/rwt/internal/theme/ControlThemeAdapter_Test.java33
3 files changed, 37 insertions, 18 deletions
diff --git a/bundles/org.eclipse.rap.rwt/src/org/eclipse/rap/rwt/internal/theme/ThemeUtil.java b/bundles/org.eclipse.rap.rwt/src/org/eclipse/rap/rwt/internal/theme/ThemeUtil.java
index b5c0465b51..1cc9933cc1 100644
--- a/bundles/org.eclipse.rap.rwt/src/org/eclipse/rap/rwt/internal/theme/ThemeUtil.java
+++ b/bundles/org.eclipse.rap.rwt/src/org/eclipse/rap/rwt/internal/theme/ThemeUtil.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2015 Innoopract Informationssysteme GmbH and others.
+ * Copyright (c) 2007, 2016 Innoopract Informationssysteme GmbH 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
@@ -123,16 +123,16 @@ public final class ThemeUtil {
// Methods for accessing themed values
public static CssValue getCssValue( String cssElement,
- String cssProperty,
- SimpleSelector selector )
+ String cssProperty,
+ SimpleSelector selector )
{
return getCssValue( cssElement, cssProperty, selector, null );
}
public static CssValue getCssValue( String cssElement,
- String cssProperty,
- ValueSelector selector,
- Widget widget )
+ String cssProperty,
+ ValueSelector selector,
+ Widget widget )
{
return getCssValue( getCurrentThemeId(), cssElement, cssProperty, selector, widget );
}
diff --git a/bundles/org.eclipse.rap.rwt/widgetkits/org/eclipse/swt/internal/widgets/controlkit/ControlThemeAdapterImpl.java b/bundles/org.eclipse.rap.rwt/widgetkits/org/eclipse/swt/internal/widgets/controlkit/ControlThemeAdapterImpl.java
index 0bdbf4a955..49b0f606b3 100644
--- a/bundles/org.eclipse.rap.rwt/widgetkits/org/eclipse/swt/internal/widgets/controlkit/ControlThemeAdapterImpl.java
+++ b/bundles/org.eclipse.rap.rwt/widgetkits/org/eclipse/swt/internal/widgets/controlkit/ControlThemeAdapterImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2015 Innoopract Informationssysteme GmbH and others.
+ * Copyright (c) 2007, 2016 Innoopract Informationssysteme GmbH 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
@@ -13,12 +13,14 @@ package org.eclipse.swt.internal.widgets.controlkit;
import org.eclipse.rap.rwt.internal.theme.ThemeAdapter;
import org.eclipse.rap.rwt.internal.theme.WidgetMatcher;
+import org.eclipse.rap.rwt.internal.theme.WidgetMatcher.Constraint;
import org.eclipse.rap.rwt.theme.BoxDimensions;
import org.eclipse.rap.rwt.theme.ControlThemeAdapter;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Widget;
public class ControlThemeAdapterImpl extends ThemeAdapter implements ControlThemeAdapter {
@@ -26,6 +28,12 @@ public class ControlThemeAdapterImpl extends ThemeAdapter implements ControlThem
@Override
protected void configureMatcher( WidgetMatcher matcher ) {
matcher.addStyle( "BORDER", SWT.BORDER );
+ matcher.addState( "disabled", new Constraint() {
+ @Override
+ public boolean matches( Widget widget ) {
+ return !( ( Control )widget ).getEnabled();
+ }
+ });
}
@Override
diff --git a/tests/org.eclipse.rap.rwt.test/src/org/eclipse/rap/rwt/internal/theme/ControlThemeAdapter_Test.java b/tests/org.eclipse.rap.rwt.test/src/org/eclipse/rap/rwt/internal/theme/ControlThemeAdapter_Test.java
index 971a9a7db9..76296c0c0f 100644
--- a/tests/org.eclipse.rap.rwt.test/src/org/eclipse/rap/rwt/internal/theme/ControlThemeAdapter_Test.java
+++ b/tests/org.eclipse.rap.rwt.test/src/org/eclipse/rap/rwt/internal/theme/ControlThemeAdapter_Test.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2015 Innoopract Informationssysteme GmbH and others.
+ * Copyright (c) 2008, 2016 Innoopract Informationssysteme GmbH 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
@@ -21,6 +21,7 @@ import org.eclipse.rap.rwt.theme.BoxDimensions;
import org.eclipse.rap.rwt.theme.ControlThemeAdapter;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.internal.widgets.controlkit.ControlThemeAdapterImpl;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
@@ -36,6 +37,8 @@ public class ControlThemeAdapter_Test {
private Display display;
private Shell shell;
+ private Label control;
+ private ControlThemeAdapter themeAdapter;
@Before
public void setUp() {
@@ -43,6 +46,8 @@ public class ControlThemeAdapter_Test {
Fixture.fakeNewRequest();
display = new Display();
shell = new Shell( display );
+ control = new Label( shell, SWT.BORDER );
+ themeAdapter = getControlThemeAdapter( control );
}
@After
@@ -52,22 +57,28 @@ public class ControlThemeAdapter_Test {
@Test
public void testValues() {
- Label label = new Label( shell, SWT.BORDER );
- ControlThemeAdapter cta = getControlThemeAdapter( label );
- assertEquals( new BoxDimensions( 1, 1, 1, 1 ), cta.getBorder( label ) );
- assertEquals( new Color( display, 74, 74, 74 ), cta.getForeground( label ) );
- assertEquals( new Color( display, 255, 255, 255 ), cta.getBackground( label ) );
+ assertEquals( new BoxDimensions( 1, 1, 1, 1 ), themeAdapter.getBorder( control ) );
+ assertEquals( new Color( display, 74, 74, 74 ), themeAdapter.getForeground( control ) );
+ assertEquals( new Color( display, 255, 255, 255 ), themeAdapter.getBackground( control ) );
}
@Test
public void testForegroundWhenDisabled() {
- Label label = new Label( shell, SWT.BORDER );
- label.setEnabled( false );
- ControlThemeAdapter cta = getControlThemeAdapter( label );
+ control.setEnabled( false );
- // even though the label is grayed out, getForeground() shows the original color in SWT
- assertEquals( new Color( display, 74, 74, 74 ), cta.getForeground( label ) );
+ assertEquals( new Color( display, 207, 207, 207 ), themeAdapter.getForeground( control ) );
+ }
+
+ @Test
+ public void testFontWhenDisabled() throws IOException {
+ String css = "Label:disabled { font: bold 16px Arial }";
+ ThemeTestUtil.registerTheme( "custom", css, null );
+ ThemeTestUtil.setCurrentThemeId( "custom" );
+ control.setEnabled( false );
+
+ Font expected = new Font( display, "Arial", 16, SWT.BOLD);
+ assertEquals( expected, control.getFont() );
}
@Test

Back to the top