Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6604195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:07:19+00:00 2026-05-25T19:07:19+00:00

I had create a simple keywords highlighting editor, it just wrap a StyledText widget:

  • 0

I had create a simple keywords highlighting editor, it just wrap a StyledText widget:

public class SQLSegmentEditor extends Composite {

    private StyledText st;

    public SQLSegmentEditor(Composite parent) {
        super(parent, SWT.NONE);
        this.setLayout(new FillLayout());
        st = new StyledText(this, SWT.WRAP | SWT.BORDER | SWT.V_SCROLL);
        st.addLineStyleListener(new SQLSegmentLineStyleListener());
    }

}

How can I make it can be used in data-binding? I am looking for the proper way, not just one that makes it work.

I want to observer the text content of the inner StyledText.

For example : I can just add a getStyledText method to return the wrapped StyledText widget for using it in databinding. But this will take a risk. In order to keep my editor behavior correctly, I should keep the StyledText widget not visible to client code.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:07:19+00:00Added an answer on May 25, 2026 at 7:07 pm

    Although I don’t understand your argument of not exposing the wrapped widget to the client, here is a possible solution. The widget can provide a WritableValue that can be bound directly via databinding by the client. That means the binding goes over 3 parties: the clients target, the wrapping writable-value and the SWT source. The only drawback is that you have a direct dependency to Databinding in your widget. Here is a snippet.

    import org.eclipse.core.databinding.DataBindingContext;
    import org.eclipse.core.databinding.observable.value.WritableValue;
    import org.eclipse.jface.databinding.swt.ISWTObservableValue;
    import org.eclipse.jface.databinding.swt.WidgetProperties;
    import org.eclipse.swt.SWT;
    import org.eclipse.swt.custom.StyledText;
    import org.eclipse.swt.layout.FillLayout;
    import org.eclipse.swt.widgets.Composite;
    
    public class SQLSegmentEditor extends Composite {
    
        private final StyledText st;
    
        private final WritableValue value = new WritableValue();
    
        public SQLSegmentEditor(Composite parent, DataBindingContext ctx) {
            super(parent, SWT.NONE);
            assert ctx != null;
            setLayout(new FillLayout());
            st = new StyledText(this, SWT.WRAP | SWT.BORDER | SWT.V_SCROLL);
            ISWTObservableValue swtBinding = WidgetProperties.text(SWT.Modify)
                    .observe(st);
            ctx.bindValue(value, swtBinding);
        }
    
        public WritableValue getValue() {
            return value;
        }
    }
    

    So the client code would look like:

    DataBindingContext ctx = new DataBindingContext();
    SQLSegmentEditor sqlSegmentEditor = new SQLSegmentEditor(getParent(), ctx);
    IObservableValue modelObservable = //setup my model-observable
    ctx.bindValue(modelObservable, sqlSegmentEditor.getValue());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For this assignment I had to create my own string class. I initially wrote
I'm trying to create a simple date class, but I get an error on
If I wanted to create a simple class that has three instance variables and
Whe I had to create CMS in PHP I created simple unescape html function
Just for fun, I've been using python and gstreamer to create simple Linux audio
I'm trying to create a simple class to read a csv file and store
I created a simple test page on my website www.xaisoft.com and it had no
OK, here is how to re-create the problem had: Create a new project, using
I've had to create a custom membership provider for my current ASP .Net project
So I had to create this splash page in a very short amount of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.