[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.rcp] Re: How to get form MessageManager?

Hi Josip,

JMaslac schrieb:
Hi, Thomas!

Thanks for the help. Works like a charm! :)
I found out that something like:

IMessageManager manager = new MessageManager();

also works, but because MessageManager is in a package marked internal, the
use of it is discouraged.

That's the point.

So, I'll stick with your code! :)

Btw, if you are willin to share to code for the mentioned bridge between
Databinding and message manager I would be grateful!! Because, and that's
not hard to guess:), that's exactly what I need to implement also..


Sure, I'm willing to share some of my code regarding databinding, form handling and message handling. I attached a complete Eclipse project with working code that shows my form handling functionality.


The project defines a view "Sample View" with contains just two input fields. The top one validates the given input on Focus out, the bottom one while modifying. The internal validate is stupid and just enforces, that the given text starts with "IPC". If not, you'll see the error message above the form.

There is a big class involved - the FormManager. If you have a look at it, I suppose, it seems very complicated to you :) In our project we build it to have a framework class which is responsible for creating all controls which gets part of a form. That gives us the chance to control something like the binding and messaging. There some kind of layout setup, but you can ignore that. The important methods are:

- setBinding(): which can be refactored because of duplicate code
- connectBindingToMessageManager(): does what you really want :)

We introduced an abstraction for the databinding found in **DataBindingConfig**. With that, a binding between a model object and a property can be defined for a control under respect of a update strategy with an optional validator.

In SampleView.createPartControl() you can see the setup.

I hope you understand how it's working. If you have further questions, I 'm observing the topic :)

bye
Thomas



Josip.


"Thomas Fahrmeyer" <lauritziu_ii@xxxxxxxx> wrote in message news:frdab6$ifi$1@xxxxxxxxxxxxxxxxxxxx
Hi,

what I did to make it work was to create a ManagedForm:

IMessageManager manager = new ManagedForm(m_formToolkit,
m_form).getMessageManager();

In all my code I'm using m_form instead of the managed form being created.
It recognized no side effects. I used the message manager a lot. I
implemented a bridge between Databinding and the message manager, to get
validation messages to be shown in the message area. Works like a charm :)

-Thomas


JMaslac schrieb:
Hi,

I'm using eclipse forms. I have a view and in it I've created a form. The
question is - how can I get/create MessageManager that's associated with
that form?

My code is as follows:

----
  public void createPartControl(final Composite p_parent) {

    m_formToolkit = new FormToolkit(p_parent.getDisplay());
    m_form = m_formToolkit.createForm(p_parent);
    m_formBody = m_form.getBody();
....
-----

I've seen how it's done in org.eclipse.ui.forms.example's
ErrorMessagesPage.java (managedForm.getMessageManager();) but that
doesn't help me much. At least I don't see how because I don't have
managed form in my program.

Thanks,

Josip











Attachment: FormsSample.zip
Description: Zip archive