Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Parsing, retrieving and displaying via custom tags
Parsing, retrieving and displaying via custom tags [message #463214] Mon, 31 October 2005 07:53
Alex Chan is currently offline Alex Chan
Messages: 16
Registered: July 2009
Junior Member
Hi all. I'm attempting to apply text formatting to text that has been
retrieved from my database. Prior to this, the text has been saved to the
database with appended custom tags. What I would actually like to achieve
is:

1. Retrieve string from database: <b>BO</b>OK<b>IE</b>
2. Remove tag <b> and </b>
3. Apply Bold formatting to "BO" and "IE". I would like to bold the text
in between these tags "<b>...</b>"
4. Display the formatted version of the actual text "BOOKIE" in my RCP
application.

So, far I have been successful in retrieving the string and removing the
tags. However, my problem would be recognizing which portion of the string
to apply BOLD via index.

My formatting function as follows:

for(int a = 0; a < condition.length(); a++){
styleRange = new StyleRange(a, 1, null, null, SWT.NORMAL);
styleRange.start = ? //How to find the start index
styleRange.length = ? //How to find the length
styleRange.fontStyle ^= SWT.BOLD;
panel.getTxtCondition().setStyleRange(styleRange);
}

A case to point, I know for a fact that in order to bold "BO" I have,

styleRange.start = 0;
styleRange.length = 2;

With this, I can bold "BO". But this is given that I already know
firsthand the position of "BO" in the word "BOOKIE". As compared to
<b>BO</b>OK<b>IE</b> where the position of "BO" would be

styleRange.start = 3;
styleRange.length = 2;

So, after removing the tags, the index are already shifted. Anyone got any
idea or suggestions for a workaround on this? Thanks alot for reading!!!

Cheers
Previous Topic:CTabItem change foreground when tab was selected
Next Topic:Home for SWT JFreeChart
Goto Forum:
  


Current Time: Tue Sep 30 12:01:54 GMT 2014

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

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