Bug 364455 - [Databinding] StringIndexOutOfBoundsException , Databinding & FormattedText
Summary: [Databinding] StringIndexOutOfBoundsException , Databinding & FormattedText
Status: REOPENED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.7.1   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal with 8 votes (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-22 06:47 EST by Christophe Bouhier CLA
Modified: 2020-08-22 06:36 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christophe Bouhier CLA 2011-11-22 06:47:33 EST
The following code throws the exception when editing the value in the text field. 

FormattedText quickFormatedText = new FormattedText(expansionDurationComposite,
				SWT.BORDER | SWT.RIGHT);
NumberFormatter numberFormatter = new NumberFormatter("###,##0");
numberFormatter.setDecimalSeparatorAlwaysShown(false);
quickFormatedText.setFormatter(numberFormatter);
Text txtQuick = quickFormatedText.getControl();


Reproducable: Always

Exception:

java.lang.StringIndexOutOfBoundsException: String index out of range: -1
	at java.lang.String.substring(String.java:1937)
	at java.lang.String.substring(String.java:1904)
	at org.eclipse.jface.internal.databinding.swt.SWTVetoableValueDecorator$1.handleEvent(SWTVetoableValueDecorator.java:38)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4121)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1453)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1476)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1461)
	at org.eclipse.swt.widgets.Text.verifyText(Text.java:2219)
	at org.eclipse.swt.widgets.Text.shouldChangeTextInRange_replacementString(Text.java:2109)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5721)
	at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
	at org.eclipse.swt.widgets.Widget.callSuper(Widget.java:220)
	at org.eclipse.swt.widgets.Widget.doCommandBySelector(Widget.java:674)
	at org.eclipse.swt.widgets.Control.doCommandBySelector(Control.java:1048)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5556)
	at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
Comment 1 Christophe Bouhier CLA 2011-11-22 06:51:09 EST
Note: 

the Text control is bound with JFace Databinding. 

Control observable: 

IObservableValue quickDurationObservable = SWTObservables.observeDelayedValue(400, SWTObservables.observeText(
				this.txtQuick, SWT.Modify));


Property: (EMF and featurePath). 

IEMFValueProperty quickDurationProperty = EMFEditProperties
				.value(editingService.getEditingDomain(),
						FeaturePath
								.fromList(								NetxstudioPackage.Literals.SERVER_SETTINGS__EXPANSION_DURATION_SETTINGS,
										GenericsPackage.Literals.EXPANSION_DURATION_SETTING__QUICK_DURATION,
										GenericsPackage.Literals.EXPANSION_DURATION_VALUE__VALUE));
Comment 2 Nicole Behlen CLA 2014-10-30 06:30:50 EDT
We have a similar problem on Luna Release (4.4.0)

org.eclipse.swt.win32.win32.x86.source_3.103.0.v20140605-2012.jar
org.eclipse.jface.databinding.source_1.6.200.v20140528-1422.jar

java.lang.StringIndexOutOfBoundsException: String index out of range: -1
	at java.lang.String.substring(Unknown Source)
	at org.eclipse.jface.internal.databinding.swt.SWTVetoableValueDecorator$1.handleEvent(SWTVetoableValueDecorator.java:38)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4353)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1085)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1070)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:782)
	at org.eclipse.swt.custom.StyledText.modifyContent(StyledText.java:7236)
	at org.eclipse.swt.custom.StyledText.sendKeyEvent(StyledText.java:8111)
	at org.eclipse.swt.custom.StyledText.doBackspace(StyledText.java:2285)
	at org.eclipse.swt.custom.StyledText.invokeAction(StyledText.java:7058)
	at org.eclipse.swt.custom.StyledText.handleKey(StyledText.java:5959)
	at org.eclipse.swt.custom.StyledText.handleKeyDown(StyledText.java:5986)
	at org.eclipse.swt.custom.StyledText$7.handleEvent(StyledText.java:5663)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4353)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1085)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1070)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1112)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1108)
	at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1529)
	at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:4722)
	at org.eclipse.swt.widgets.Canvas.WM_CHAR(Canvas.java:343)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4610)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:339)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5023)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2549)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3759)
	at org.eclipse.jface.window.Window.runEventLoop(Window.java:832)
	at org.eclipse.jface.window.Window.open(Window.java:808)

Is there a workaround for?
Comment 3 Conrad Groth CLA 2015-12-28 05:55:32 EST
(In reply to Christophe Bouhier from comment #0)
> FormattedText quickFormatedText = new FormattedText(expansionDurationComposite,
> 				SWT.BORDER | SWT.RIGHT);
> NumberFormatter numberFormatter = new NumberFormatter("###,##0");
> numberFormatter.setDecimalSeparatorAlwaysShown(false);
> quickFormatedText.setFormatter(numberFormatter);
> Text txtQuick = quickFormatedText.getControl();

The classes FormattedText and NumberFormatter are part of the nebula project.

> org.eclipse.swt.widgets.Text.shouldChangeTextInRange_replacementString(Text.java:2109)
> 	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5721)
> 	at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
> 	at org.eclipse.swt.widgets.Widget.callSuper(Widget.java:220)

The method shouldChangeTextInRange_replacementString is MAC-specific, so it's very hard for me to analyse that bug on windows. I think, it should be marked as SWT bug.
Comment 4 Conrad Groth CLA 2015-12-28 06:15:38 EST
(In reply to Nicole Behlen from comment #2)
> We have a similar problem on Luna Release (4.4.0)
> 
> org.eclipse.swt.win32.win32.x86.source_3.103.0.v20140605-2012.jar
> org.eclipse.jface.databinding.source_1.6.200.v20140528-1422.jar
> 
> java.lang.StringIndexOutOfBoundsException: String index out of range: -1
> 	at java.lang.String.substring(Unknown Source)
> 	at
> org.eclipse.jface.internal.databinding.swt.SWTVetoableValueDecorator$1.
> handleEvent(SWTVetoableValueDecorator.java:38)
> 	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
> 	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4353)
> 	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061)
> 	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1085)
> 	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1070)
> 	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:782)
> 	at org.eclipse.swt.custom.StyledText.modifyContent(StyledText.java:7236)
> 	at org.eclipse.swt.custom.StyledText.sendKeyEvent(StyledText.java:8111)
> 	at org.eclipse.swt.custom.StyledText.doBackspace(StyledText.java:2285)
> 	at org.eclipse.swt.custom.StyledText.invokeAction(StyledText.java:7058)
> 	at org.eclipse.swt.custom.StyledText.handleKey(StyledText.java:5959)
> 	at org.eclipse.swt.custom.StyledText.handleKeyDown(StyledText.java:5986)
> 	at org.eclipse.swt.custom.StyledText$7.handleEvent(StyledText.java:5663)
> 	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
> 	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4353)
> 	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061)
> 	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1085)
> 	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1070)
> 	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1112)
> 	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1108)
> 	at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1529)
> 	at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:4722)
> 	at org.eclipse.swt.widgets.Canvas.WM_CHAR(Canvas.java:343)
> 	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4610)
> 	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:339)
> 	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5023)
> 	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
> 	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2549)
> 	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3759)
> 	at org.eclipse.jface.window.Window.runEventLoop(Window.java:832)
> 	at org.eclipse.jface.window.Window.open(Window.java:808)
> 
> Is there a workaround for?

I couldn't reproduce that with SWT 3.105.0.v20151209-1900 (neither by deleting a single character with backspace nor by deleting the whole text with backspace).
Comment 5 Lars Vogel CLA 2016-01-05 04:36:13 EST
Moving to SWT for investigation, sounds like this only happens on Mac.
Comment 6 Eclipse Genie CLA 2020-08-19 05:45:43 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 7 Lars Vogel CLA 2020-08-19 06:41:52 EDT
Jens, can you please check this one?
Comment 8 Jens Lideström CLA 2020-08-22 06:36:06 EDT
(In reply to Lars Vogel from comment #7)
> Jens, can you please check this one?

I think you need a Mac to test this one, which I don't have access to.

I won't have time to dive into it any more unfortunately.