Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Furnadjiev2014-01-30 10:58:42 +0000
committerIvan Furnadjiev2014-02-03 13:31:58 +0000
commita42cd142074c173deeb0db2587decb7d87a65757 (patch)
treedbf49adc6c79e63a8ebbcdfac51d64ea8183417c /bundles
parent23dd22dee2da88a1a31f551fe571ee2f4a5a490c (diff)
downloadorg.eclipse.rap-a42cd142074c173deeb0db2587decb7d87a65757.tar.gz
org.eclipse.rap-a42cd142074c173deeb0db2587decb7d87a65757.tar.xz
org.eclipse.rap-a42cd142074c173deeb0db2587decb7d87a65757.zip
Always use adapter method to set the text sent by the client
The adapter method is now responsible for setting the text only. Selection is set in TextLCA after the text. 424118: [Text] Cursor reset to first character when typing fast https://bugs.eclipse.org/bugs/show_bug.cgi?id=424118 Change-Id: I6ce0f31ad3ed7d275eb05103fb9ea9dfa0a24592
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/ITextAdapter.java10
-rw-r--r--bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Text.java25
-rw-r--r--bundles/org.eclipse.rap.rwt/widgetkits/org/eclipse/swt/internal/widgets/textkit/TextLCAUtil.java14
3 files changed, 30 insertions, 19 deletions
diff --git a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/ITextAdapter.java b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/ITextAdapter.java
index f5e32b6c74..1b9b0f4e68 100644
--- a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/ITextAdapter.java
+++ b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/ITextAdapter.java
@@ -1,19 +1,19 @@
/*******************************************************************************
- * Copyright (c) 2008 Innoopract Informationssysteme GmbH.
+ * Copyright (c) 2008, 2014 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Innoopract Informationssysteme GmbH - initial API and implementation
+ * Innoopract Informationssysteme GmbH - initial API and implementation
+ * EclipseSource - ongoing development
******************************************************************************/
package org.eclipse.swt.internal.widgets;
-import org.eclipse.swt.graphics.Point;
-
public interface ITextAdapter {
- void setText( String text, Point selection );
+ void setText( String text );
+
}
diff --git a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Text.java
index 1a61e7c1d5..bd9cd2a3fe 100644
--- a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Text.java
+++ b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Text.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2013 Innoopract Informationssysteme GmbH.
+ * Copyright (c) 2002, 2014 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
@@ -162,8 +162,11 @@ public class Text extends Scrollable {
if( ITextAdapter.class.equals( adapter ) ) {
if( textAdapter == null ) {
textAdapter = new ITextAdapter() {
- public void setText( String text, Point selection ) {
- Text.this.setText( text, selection );
+ public void setText( String text ) {
+ if( internalSetText( text ) ) {
+ adjustSelection();
+ notifyListeners( SWT.Modify, new Event() );
+ }
}
};
}
@@ -1094,15 +1097,21 @@ public class Text extends Scrollable {
return result;
}
- private void setText( String text, Point selection ) {
+ private boolean internalSetText( String text ) {
String verifiedText = verifyText( text, 0, this.text.length() );
if( verifiedText != null ) {
- this.text = verifiedText;
- if( selection != null ) {
- setSelection( selection.x, selection.y );
+ if( verifiedText.length() > textLimit ) {
+ this.text = verifiedText.substring( 0, textLimit );
+ } else {
+ this.text = verifiedText;
}
- notifyListeners( SWT.Modify, new Event() );
}
+ return verifiedText != null;
+ }
+
+ private void adjustSelection() {
+ selection.x = Math.min( selection.x, text.length() );
+ selection.y = Math.min( selection.y, text.length() );
}
///////////////////////////////////////
diff --git a/bundles/org.eclipse.rap.rwt/widgetkits/org/eclipse/swt/internal/widgets/textkit/TextLCAUtil.java b/bundles/org.eclipse.rap.rwt/widgetkits/org/eclipse/swt/internal/widgets/textkit/TextLCAUtil.java
index e6b462b6ed..5306b545e4 100644
--- a/bundles/org.eclipse.rap.rwt/widgetkits/org/eclipse/swt/internal/widgets/textkit/TextLCAUtil.java
+++ b/bundles/org.eclipse.rap.rwt/widgetkits/org/eclipse/swt/internal/widgets/textkit/TextLCAUtil.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2013 Innoopract Informationssysteme GmbH and others.
+ * Copyright (c) 2002, 2014 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
@@ -126,20 +126,18 @@ final class TextLCAUtil {
// fire a VerifyEvent whose fields (text and doit) need to be evaluated
// before actually setting the new value
ProcessActionRunner.add( new Runnable() {
-
public void run() {
- text.getAdapter( ITextAdapter.class ).setText( txt, selection );
- // since text is set in process action, preserved values have to be
- // replaced
WidgetAdapter adapter = WidgetUtil.getAdapter( text );
+ getTextAdapter( text ).setText( txt );
adapter.preserve( PROP_TEXT, txt );
if( selection != null ) {
+ text.setSelection( selection );
adapter.preserve( PROP_SELECTION, selection );
}
}
} );
} else {
- text.setText( txt );
+ getTextAdapter( text ).setText( txt );
if( selection != null ) {
text.setSelection( selection );
}
@@ -204,4 +202,8 @@ final class TextLCAUtil {
return isListening( text, SWT.Modify ) || isListening( text, SWT.Verify );
}
+ private static ITextAdapter getTextAdapter( Text text ) {
+ return text.getAdapter( ITextAdapter.class );
+ }
+
}

Back to the top