Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » SWT Text
SWT Text [message #652545] Fri, 04 February 2011 13:51 Go to next message
Edin Edin is currently offline Edin EdinFriend
Messages: 101
Registered: January 2010
Senior Member
Hello,

i have a SWT.MULTIPLE, SWT:WRAP, SWT.V_SCROLL Text with huge String Widget, which i want to be searched for a substring.
The search is done with indexof. Now i want to select the found string, to present it to the user. I tried with text.setselection with start index and endindex, but nothing seems to happens. i can only select the whole text with sellectall method. Onther thing i would like to do is to move scrollbar of the text to the position where the substring is found, any idea how to realise this? Is actually Text widget useful for such tasks, or is there some other widgets for searching on Strings better?

Thnx

Edit:

setting focus on Text before i call the setselection method makes the selection be visible, however, the positon is wrong. the indexof method returns i.e. 230, but setting the selection of the text to 230, 230+lenghtofstring doesnt select the the searched string: its about 10 charakters later on in the mainstring. problem of moving the textfield scrolls is still there.
any hints?

[Updated on: Fri, 04 February 2011 14:12]

Report message to a moderator

Re: SWT Text [message #652590 is a reply to message #652545] Fri, 04 February 2011 16:14 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi,
to visualize the selection you have to focus the Text widget. For example:
------
text.setSelection( 5, 10 );
text.setFocus();
------
Currently, it's not possible to scroll the Text widget programmatically,
because Text#setTopIndex method is not implemented in RAP. See bug:
316265: [Text] getTopIndex() and setTopIndex() are not implemented
https://bugs.eclipse.org/bugs/show_bug.cgi?id=316265
If I remember correctly, you can achieve what you want with the
read-only prototype of StyledText from the sendbox
(org.eclipse.rap/sandbox/org.eclipse.rwt.widgets.styledtext) . There is a
demo in the sandbox too
(org.eclipse.rap/sandbox/org.eclipse.rwt.widgets.styledtext. demo).
HTH,
Ivan

On 2/4/2011 3:51 PM, ededagic wrote:
> Hello,
>
> i have a SWT.MULTIPLE, SWT:WRAP, SWT.V_SCROLL Text with huge String
> Widget, which i want to be searched for a substring.
> The search is done with indexof. Now i want to select the found
> string, to present it to the user. I tried with text.setselection with
> start index and endindex, but nothing seems to happens. i can only
> select the whole text with sellectall method. Onther thing i would
> like to do is to move scrollbar of the text to the position where the
> substring is found, any idea how to realise this? Is actually Text
> widget useful for such tasks, or is there some other widgets for
> searching on Strings better?
>
> Thnx
Re: SWT Text [message #652831 is a reply to message #652590] Mon, 07 February 2011 09:22 Go to previous messageGo to next message
Edin Edin is currently offline Edin EdinFriend
Messages: 101
Registered: January 2010
Senior Member
Hi, Ivan

Thx for your reply.
Can you tell me which method to use to let styledText instace to scroll. i Make a new StyleRange each time i found a new occurance of the searching string. It marks then the found string wenn i use styledTexxt.setRange, but nothing happens with scroll bar.There is also no settopindex method there.
At the moment, If there are more than one place where the string is found, all of the occurances remains. Should i remove them shomehow before i search for new occurance of the string. Because for me it looks better the old search results stay inside.

Thnx, Edin
Re: SWT Text [message #652857 is a reply to message #652831] Mon, 07 February 2011 11:20 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi Edin,
I think that setSelection select a range of text and scroll to make it
visible. Use the demo bundle, set "huge" text and play with it -
selection, range and other functionality.
HTH,
Ivan

On 2/7/2011 11:22 AM, ededagic wrote:
> Hi, Ivan
>
> Thx for your reply.
> Can you tell me which method to use to let styledText instace to
> scroll. i Make a new StyleRange each time i found a new occurance of
> the searching string. It marks then the found string wenn i use
> styledTexxt.setRange, but nothing happens with scroll bar.There is
> also no settopindex method there.
> At the moment, If there are more than one place where the string is
> found, all of the occurances remains. Should i remove them shomehow
> before i search for new occurance of the string. Because for me it
> looks better the old search results stay inside.
>
> Thnx, Edin
Re: SWT Text [message #730273 is a reply to message #652857] Wed, 28 September 2011 03:48 Go to previous message
Andre  is currently offline Andre Friend
Messages: 1
Registered: September 2011
Junior Member
Hi... I spent about 4 hours of my life trying to do that... This line solved my problem!

=> textArea.setTopIndex(textArea.getLineCount());
Previous Topic:HTTP PUT, GET, POST
Next Topic:multiple JAAS call-backs for RAP login
Goto Forum:
  


Current Time: Wed Apr 24 16:54:34 GMT 2024

Powered by FUDForum. Page generated in 0.03288 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top