Fixed - bug 273244: [Theming] Link foreground color cannot be modified using theme variants
https://bugs.eclipse.org/bugs/show_bug.cgi?id=273244
diff --git a/bundles/org.eclipse.rap.rwt.q07/js/org/eclipse/swt/LinkUtil.js b/bundles/org.eclipse.rap.rwt.q07/js/org/eclipse/swt/LinkUtil.js
index b858d8e..fbe4c9b 100644
--- a/bundles/org.eclipse.rap.rwt.q07/js/org/eclipse/swt/LinkUtil.js
+++ b/bundles/org.eclipse.rap.rwt.q07/js/org/eclipse/swt/LinkUtil.js
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2008 Innoopract Informationssysteme GmbH.
+ * Copyright (c) 2002, 2009 Innoopract Informationssysteme GmbH.
* 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
@@ -50,6 +50,30 @@
}
}
},
+
+ addState : function( widget, state ) {
+ if( widget ) {
+ if( state.substr( 0, 8 ) == "variant_" ) {
+ widget.addState( state );
+ var children = widget.getChildren();
+ for( var i = 0; i < children.length; i++ ) {
+ children[ i ].addState( state );
+ }
+ }
+ }
+ },
+
+ removeState : function( widget, state ) {
+ if( widget ) {
+ if( state.substr( 0, 8 ) == "variant_" ) {
+ widget.removeState( state );
+ var children = widget.getChildren();
+ for( var i = 0; i < children.length; i++ ) {
+ children[ i ].removeState( state );
+ }
+ }
+ }
+ },
setSelectionListener : function( widget, value ) {
widget.setUserData( "widgetSelectedListener", value );
diff --git a/bundles/org.eclipse.rap.rwt.q07/src/org/eclipse/swt/internal/widgets/linkkit/LinkLCA.java b/bundles/org.eclipse.rap.rwt.q07/src/org/eclipse/swt/internal/widgets/linkkit/LinkLCA.java
index 5eab067..a8429a7 100644
--- a/bundles/org.eclipse.rap.rwt.q07/src/org/eclipse/swt/internal/widgets/linkkit/LinkLCA.java
+++ b/bundles/org.eclipse.rap.rwt.q07/src/org/eclipse/swt/internal/widgets/linkkit/LinkLCA.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2008 Innoopract Informationssysteme GmbH.
+ * Copyright (c) 2002, 2009 Innoopract Informationssysteme GmbH.
* 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
@@ -36,12 +36,16 @@
private static final String JS_FUNC_INIT = JS_LINK_UTIL + ".init";
private static final String JS_FUNC_ADD_LINK = JS_LINK_UTIL + ".addLink";
private static final String JS_FUNC_ADD_TEXT = JS_LINK_UTIL + ".addText";
+ private static final String JS_FUNC_ADD_STATE = JS_LINK_UTIL + ".addState";
+ private static final String JS_FUNC_REMOVE_STATE
+ = JS_LINK_UTIL + ".removeState";
private static final String JS_FUNC_CLEAR = JS_LINK_UTIL + ".clear";
private static final String JS_FUNC_DESTROY = JS_LINK_UTIL + ".destroy";
private static final String JS_FUNC_SET_SELECTION_LISTENER
= JS_LINK_UTIL + ".setSelectionListener";
private static final String PROP_TEXT = "text";
+ private static final String PROP_VARIANT = "variant";
static final String PROP_SEL_LISTENER = "selectionListener";
public void preserveValues( final Widget widget ) {
@@ -75,7 +79,7 @@
ControlLCAUtil.writeChanges( link );
writeSelectionListener( link );
writeText( link );
- WidgetLCAUtil.writeCustomVariant( link );
+ writeCustomVariant( link );
}
public void renderDispose( final Widget widget ) throws IOException {
@@ -189,4 +193,23 @@
}
}
}
+
+ private static void writeCustomVariant( final Link link )
+ throws IOException
+ {
+ IWidgetAdapter adapter = WidgetUtil.getAdapter( link );
+ String oldValue = ( String )adapter.getPreserved( PROP_VARIANT );
+ String newValue = WidgetUtil.getVariant( link );
+ if( WidgetLCAUtil.hasChanged( link, PROP_VARIANT, newValue, null ) ) {
+ JSWriter writer = JSWriter.getWriterFor( link );
+ Object[] args = new Object[] { link, "variant_" + oldValue };
+ if( oldValue != null ) {
+ writer.callStatic( JS_FUNC_REMOVE_STATE, args );
+ }
+ if( newValue != null ) {
+ args = new Object[] { link, "variant_" + newValue };
+ writer.callStatic( JS_FUNC_ADD_STATE, args );
+ }
+ }
+ }
}