Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Furnadjiev2016-09-20 11:53:46 +0000
committerGerrit Code Review @ Eclipse.org2016-09-22 11:03:59 +0000
commita294f8cb416a54c66503658eb1e105bb55929f6f (patch)
treebf6abceae84e9a57f54446a0f9afb9ab6a66d995 /bundles
parent71253fe690d4daaf4057541ab9b0b4bc2649ed65 (diff)
downloadorg.eclipse.rap-a294f8cb416a54c66503658eb1e105bb55929f6f.tar.gz
org.eclipse.rap-a294f8cb416a54c66503658eb1e105bb55929f6f.tar.xz
org.eclipse.rap-a294f8cb416a54c66503658eb1e105bb55929f6f.zip
Don't use public SWT API when synchronizing common Control properties
Common Control properties (visible, enabled...) are preserved on demand (when SWT public API setters are used). It's possible to change one of these properties with scripting and apply them in ControlOperationHandler. In this case, the old value should not be preserved as it's not changed on the server. Add common Control properties setters to ControlAdapter. Use these setters to apply the client value instead of using the public SWT API. Adjust some tests accordingly. 494881: [Control] Changing visibility state using client scripting fails https://bugs.eclipse.org/bugs/show_bug.cgi?id=494881 Change-Id: I8767132ab5beaca4541af1d32feb1811773232a6
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.rap.rwt/src/org/eclipse/rap/rwt/internal/lifecycle/ControlLCAUtil.java7
-rw-r--r--bundles/org.eclipse.rap.rwt/src/org/eclipse/rap/rwt/internal/protocol/ControlOperationHandler.java13
-rw-r--r--bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/IControlAdapter.java12
-rw-r--r--bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Control.java96
4 files changed, 85 insertions, 43 deletions
diff --git a/bundles/org.eclipse.rap.rwt/src/org/eclipse/rap/rwt/internal/lifecycle/ControlLCAUtil.java b/bundles/org.eclipse.rap.rwt/src/org/eclipse/rap/rwt/internal/lifecycle/ControlLCAUtil.java
index 89e340a896..eb23d94853 100644
--- a/bundles/org.eclipse.rap.rwt/src/org/eclipse/rap/rwt/internal/lifecycle/ControlLCAUtil.java
+++ b/bundles/org.eclipse.rap.rwt/src/org/eclipse/rap/rwt/internal/lifecycle/ControlLCAUtil.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2015 Innoopract Informationssysteme GmbH and others.
+ * Copyright (c) 2002, 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
@@ -20,7 +20,6 @@ import static org.eclipse.swt.internal.widgets.ControlUtil.getControlAdapter;
import org.eclipse.rap.rwt.internal.util.ActiveKeysUtil;
import org.eclipse.swt.SWT;
import org.eclipse.swt.internal.widgets.ControlRemoteAdapter;
-import org.eclipse.swt.internal.widgets.ControlUtil;
import org.eclipse.swt.internal.widgets.IControlAdapter;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
@@ -87,7 +86,7 @@ public class ControlLCAUtil {
private static void resetTabIndices( Composite composite ) {
for( Control control : composite.getChildren() ) {
- ControlUtil.getControlAdapter( control ).setTabIndex( -1 );
+ getControlAdapter( control ).setTabIndex( -1 );
if( control instanceof Composite ) {
resetTabIndices( ( Composite )control );
}
@@ -97,7 +96,7 @@ public class ControlLCAUtil {
private static int computeTabIndices( Composite composite, int startIndex ) {
int result = startIndex;
for( Control control : composite.getTabList() ) {
- ControlUtil.getControlAdapter( control ).setTabIndex( result );
+ getControlAdapter( control ).setTabIndex( result );
// for Links, leave a range out to be assigned to hrefs on the client
result += control instanceof Link ? 300 : 1;
if( control instanceof Composite ) {
diff --git a/bundles/org.eclipse.rap.rwt/src/org/eclipse/rap/rwt/internal/protocol/ControlOperationHandler.java b/bundles/org.eclipse.rap.rwt/src/org/eclipse/rap/rwt/internal/protocol/ControlOperationHandler.java
index 362264b77d..b2962285cb 100644
--- a/bundles/org.eclipse.rap.rwt/src/org/eclipse/rap/rwt/internal/protocol/ControlOperationHandler.java
+++ b/bundles/org.eclipse.rap.rwt/src/org/eclipse/rap/rwt/internal/protocol/ControlOperationHandler.java
@@ -30,6 +30,7 @@ import static org.eclipse.rap.rwt.internal.protocol.ClientMessageConst.EVENT_PAR
import static org.eclipse.rap.rwt.internal.protocol.ClientMessageConst.EVENT_TRAVERSE;
import static org.eclipse.rap.rwt.internal.protocol.ProtocolUtil.wasEventSent;
import static org.eclipse.swt.internal.events.EventLCAUtil.translateButton;
+import static org.eclipse.swt.internal.widgets.ControlUtil.getControlAdapter;
import org.eclipse.rap.json.JsonArray;
import org.eclipse.rap.json.JsonObject;
@@ -111,7 +112,7 @@ public abstract class ControlOperationHandler<T extends Control> extends WidgetO
arrayValue.get( 1 ).asInt(),
arrayValue.get( 2 ).asInt() );
}
- control.setForeground( foreground );
+ getControlAdapter( control ).setForeground( foreground );
}
}
@@ -131,7 +132,7 @@ public abstract class ControlOperationHandler<T extends Control> extends WidgetO
arrayValue.get( 1 ).asInt(),
arrayValue.get( 2 ).asInt() );
}
- control.setBackground( background );
+ getControlAdapter( control ).setBackground( background );
}
}
@@ -143,7 +144,7 @@ public abstract class ControlOperationHandler<T extends Control> extends WidgetO
public void handleSetVisibility( T control, JsonObject properties ) {
JsonValue value = properties.get( PROP_VISIBILITY );
if( value != null ) {
- control.setVisible( value.asBoolean() );
+ getControlAdapter( control ).setVisible( value.asBoolean() );
}
}
@@ -155,7 +156,7 @@ public abstract class ControlOperationHandler<T extends Control> extends WidgetO
public void handleSetEnabled( T control, JsonObject properties ) {
JsonValue value = properties.get( PROP_ENABLED );
if( value != null ) {
- control.setEnabled( value.asBoolean() );
+ getControlAdapter( control ).setEnabled( value.asBoolean() );
}
}
@@ -168,7 +169,7 @@ public abstract class ControlOperationHandler<T extends Control> extends WidgetO
JsonValue value = properties.get( PROP_TOOL_TIP );
if( value != null ) {
String toolTipText = value.isNull() ? null : value.asString();
- control.setToolTipText( toolTipText );
+ getControlAdapter( control ).setToolTipText( toolTipText );
}
}
@@ -184,7 +185,7 @@ public abstract class ControlOperationHandler<T extends Control> extends WidgetO
if( !value.isNull() ) {
cursor = new Cursor( control.getDisplay(), translateCursor( value.asString() ) );
}
- control.setCursor( cursor );
+ getControlAdapter( control ).setCursor( cursor );
}
}
diff --git a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/IControlAdapter.java b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/IControlAdapter.java
index 253430f0c7..bac6ad0e3a 100644
--- a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/IControlAdapter.java
+++ b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/IControlAdapter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2015 Innoopract Informationssysteme GmbH and others.
+ * Copyright (c) 2002, 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
@@ -12,6 +12,7 @@
package org.eclipse.swt.internal.widgets;
import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Rectangle;
@@ -37,4 +38,11 @@ public interface IControlAdapter {
Rectangle getBounds();
-} \ No newline at end of file
+ void setForeground( Color color );
+ void setBackground( Color color );
+ void setVisible( boolean visible );
+ void setEnabled( boolean enabled );
+ void setToolTipText( String toolTipText );
+ void setCursor( Cursor cursor );
+
+}
diff --git a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Control.java
index 5f9fca4438..f712e75336 100644
--- a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Control.java
@@ -138,6 +138,36 @@ public abstract class Control extends Widget implements Drawable {
return bounds;
}
+ @Override
+ public void setForeground( Color color ) {
+ foreground = color;
+ }
+
+ @Override
+ public void setBackground( Color color ) {
+ background = color;
+ }
+
+ @Override
+ public void setVisible( boolean visible ) {
+ internalSetVisible( visible );
+ }
+
+ @Override
+ public void setEnabled( boolean enabled ) {
+ internalSetEnabled( enabled );
+ }
+
+ @Override
+ public void setToolTipText( String toolTipText ) {
+ Control.this.toolTipText = toolTipText;
+ }
+
+ @Override
+ public void setCursor( Cursor cursor ) {
+ Control.this.cursor = cursor;
+ }
+
}
private transient IControlAdapter controlAdapter;
@@ -296,6 +326,13 @@ public abstract class Control extends Widget implements Drawable {
public void setVisible( boolean visible ) {
checkWidget();
if( hasState( HIDDEN ) != !visible ) {
+ preserveState( HIDDEN );
+ internalSetVisible( visible );
+ }
+ }
+
+ private void internalSetVisible( boolean visible ) {
+ if( hasState( HIDDEN ) != !visible ) {
if( visible ) {
notifyListeners( SWT.Show, null );
}
@@ -378,26 +415,35 @@ public abstract class Control extends Widget implements Drawable {
*/
public void setEnabled( boolean enabled ) {
checkWidget();
- /*
- * Feature in Windows. If the receiver has focus, disabling
- * the receiver causes no window to have focus. The fix is
- * to assign focus to the first ancestor window that takes
- * focus. If no window will take focus, set focus to the
- * desktop.
- */
- Control control = null;
- boolean fixFocus = false;
- if( !enabled ) {
- control = display.getFocusControl();
- fixFocus = isFocusAncestor( control );
- }
- if( enabled ) {
- removeState( DISABLED );
- } else {
- addState( DISABLED );
+ if( hasState( DISABLED ) != !enabled ) {
+ preserveState( DISABLED );
+ internalSetEnabled( enabled );
}
- if( fixFocus ) {
- fixFocus( control );
+ }
+
+ private void internalSetEnabled( boolean enabled ) {
+ if( hasState( DISABLED ) != !enabled ) {
+ /*
+ * Feature in Windows. If the receiver has focus, disabling
+ * the receiver causes no window to have focus. The fix is
+ * to assign focus to the first ancestor window that takes
+ * focus. If no window will take focus, set focus to the
+ * desktop.
+ */
+ Control control = null;
+ boolean fixFocus = false;
+ if( !enabled ) {
+ control = display.getFocusControl();
+ fixFocus = isFocusAncestor( control );
+ }
+ if( enabled ) {
+ removeState( DISABLED );
+ } else {
+ addState( DISABLED );
+ }
+ if( fixFocus ) {
+ fixFocus( control );
+ }
}
}
@@ -2673,18 +2719,6 @@ public abstract class Control extends Widget implements Drawable {
oldDecorations.fixDecorations( newDecorations, this );
}
- @Override
- void addState( int flag ) {
- preserveState( flag );
- super.addState( flag );
- }
-
- @Override
- void removeState( int flag ) {
- preserveState( flag );
- super.removeState( flag );
- }
-
private void preserveState( int flag ) {
if( ( flag & DISABLED ) != 0 ) {
getRemoteAdapter().preserveEnabled( !hasState( DISABLED ) );

Back to the top