Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » [DataBinding] WizardScreen not fully updated
[DataBinding] WizardScreen not fully updated [message #13026] Tue, 09 June 2009 14:04 Go to next message
Jochen Hebbrecht is currently offline Jochen HebbrechtFriend
Messages: 12
Registered: July 2009
Junior Member
Hi,

I studied the pages on
http://wiki.eclipse.org/index.php/JFace_Data_Binding and I have a good
perception of the JFace databinding.

I'm currently having a custom Eclipse plugin (which is an IWizard), where
I configured some databinding.

Have a look at the wizard: http://www.jochus.be/brol/databinding.png

I attached a listener to the list (above), to see if the databinding
worked great ... and it did :-). So great!

Now, I'm trying to change the datamodel from a service layer, which starts
running the moment I push finish.

And now comes my problem into play: there seems to be a delay in the
update of the screen. So "initial text" keeps on the screen for a very
long time (even if the service layer has sent updates). After a while, the
datamodel refreshes the view:
http://www.jochus.be/brol/databinding_finish.png
But as you can see, the line is not fully on the screen. It takes the
width of the "initial text".

So, my question is: how can I force my view to repaint faster? And make
the text fitting the screen?

Any idea's?

===================
= My view: =
===================
txtStatus = new Text(container, SWT.PUSH );
dataModel.setStatus("Initial textttttttttttttttttttttttttttttttttttt");

DataBindingContext dbc = new DataBindingContext();
IObservableValue modelObservable =
BeansObservables.observeValue(dataModel, "status");
dbc.bindValue(SWTObservables.observeText(txtStatus, SWT.Modify),
modelObservable, null, null);

===================
= My service =
===================
Iterator<IProjectConfigurer> projectConfigurerIterator =
projectConfigurers.iterator();
while (projectConfigurerIterator.hasNext()) {
IProjectConfigurer projectConfigurer = projectConfigurerIterator.next();
dataModel.setStatus(projectConfigurer.getClass().getName());
projectConfigurer.configure(project, monitor);
}

===================
= My datamodel =
===================
public class DataModel {
private PropertyChangeSupport changeSupport = new
PropertyChangeSupport(this);

public void addPropertyChangeListener(String propertyName,
PropertyChangeListener listener) {
changeSupport.addPropertyChangeListener(propertyName, listener);
}
public void removePropertyChangeListener(String propertyName,
PropertyChangeListener listener) {
changeSupport.removePropertyChangeListener(propertyName, listener);
}

private String status;

public void setStatus(String newStatus) {
String oldStatus = this.status;
this.status = newStatus;
changeSupport.firePropertyChange("status", oldStatus, newStatus);
}
public String getStatus() {
return status;
}
}
Re: [DataBinding] WizardScreen not fully updated [message #13196 is a reply to message #13026] Tue, 09 June 2009 22:22 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: TheRealHawk.Freenet.de

If you call layout() for the parent-composite you should the the updated
values.
--> But theoretically your code should work without this.

Where do you set the status?
Maybe there is your problem.

To see the full text you have to tell the label to grab the whole horizontal
space - so you have to set the right LayoutData depending on your Layout.

Markus

"Jochen Hebbrecht" <jochenhebbrecht@gmail.com> schrieb im Newsbeitrag
news:c8913443c18f437c07da604c72877c9f$1@www.eclipse.org...
> Hi,
>
> I studied the pages on
> http://wiki.eclipse.org/index.php/JFace_Data_Binding and I have a good
> perception of the JFace databinding.
>
> I'm currently having a custom Eclipse plugin (which is an IWizard), where
> I configured some databinding.
>
> Have a look at the wizard: http://www.jochus.be/brol/databinding.png
>
> I attached a listener to the list (above), to see if the databinding
> worked great ... and it did :-). So great!
>
> Now, I'm trying to change the datamodel from a service layer, which starts
> running the moment I push finish.
>
> And now comes my problem into play: there seems to be a delay in the
> update of the screen. So "initial text" keeps on the screen for a very
> long time (even if the service layer has sent updates). After a while, the
> datamodel refreshes the view:
> http://www.jochus.be/brol/databinding_finish.png
> But as you can see, the line is not fully on the screen. It takes the
> width of the "initial text".
>
> So, my question is: how can I force my view to repaint faster? And make
> the text fitting the screen?
>
> Any idea's?
>
> ===================
> = My view: =
> ===================
> txtStatus = new Text(container, SWT.PUSH );
> dataModel.setStatus("Initial textttttttttttttttttttttttttttttttttttt");
>
> DataBindingContext dbc = new DataBindingContext();
> IObservableValue modelObservable =
> BeansObservables.observeValue(dataModel, "status");
> dbc.bindValue(SWTObservables.observeText(txtStatus, SWT.Modify),
> modelObservable, null, null);
>
> ===================
> = My service =
> ===================
> Iterator<IProjectConfigurer> projectConfigurerIterator =
> projectConfigurers.iterator();
> while (projectConfigurerIterator.hasNext()) {
> IProjectConfigurer projectConfigurer = projectConfigurerIterator.next();
> dataModel.setStatus(projectConfigurer.getClass().getName());
> projectConfigurer.configure(project, monitor);
> }
>
> ===================
> = My datamodel =
> ===================
> public class DataModel {
> private PropertyChangeSupport changeSupport = new
> PropertyChangeSupport(this);
>
> public void addPropertyChangeListener(String propertyName,
> PropertyChangeListener listener) {
> changeSupport.addPropertyChangeListener(propertyName, listener);
> }
> public void removePropertyChangeListener(String propertyName,
> PropertyChangeListener listener) {
> changeSupport.removePropertyChangeListener(propertyName, listener);
> }
>
> private String status;
>
> public void setStatus(String newStatus) {
> String oldStatus = this.status;
> this.status = newStatus;
> changeSupport.firePropertyChange("status", oldStatus, newStatus);
> }
> public String getStatus() {
> return status;
> }
> }
>
>
Re: [DataBinding] WizardScreen not fully updated [message #13330 is a reply to message #13196] Wed, 10 June 2009 08:02 Go to previous messageGo to next message
Jochen Hebbrecht is currently offline Jochen HebbrechtFriend
Messages: 12
Registered: July 2009
Junior Member
Markus,

I think I found my problem. It's the way I invoked the run() method.
If I place it like this:

>> getContainer().run(false, true, op);

... the layout gets delayed and fucked up

>> getContainer().run(true, true, op);

Everything works like a charm! ;-)


BUT!
By placing the fork boolean at true, the following code gets broken:

>> IWorkbenchPage page =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage();

I'm getting a NullPointerException at the getActiveWorkbenchWindow
So I think my question should be: how can I get to my
ActiveWorkbenchWindow, without specifying the fork boolean to false.

Any idea's?

Jochen
Re: [DataBinding] WizardScreen not fully updated [message #13353 is a reply to message #13330] Wed, 10 June 2009 08:07 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi Jochen,

Could you stripp down your code so that we can run it locally (=create a
runnable snippet / OSGi plugin) and reproduce the problems you are having?

Tom

Jochen Hebbrecht schrieb:
> Markus,
>
> I think I found my problem. It's the way I invoked the run() method.
> If I place it like this:
>>> getContainer().run(false, true, op);
>
> .. the layout gets delayed and fucked up
>
>>> getContainer().run(true, true, op);
>
> Everything works like a charm! ;-)
>
>
> BUT! By placing the fork boolean at true, the following code gets broken:
>
>>> IWorkbenchPage page =
> PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage();
>
> I'm getting a NullPointerException at the getActiveWorkbenchWindow
> So I think my question should be: how can I get to my
> ActiveWorkbenchWindow, without specifying the fork boolean to false.
>
> Any idea's?
>
> Jochen
>
Re: [DataBinding] WizardScreen not fully updated [message #13413 is a reply to message #13353] Wed, 10 June 2009 13:03 Go to previous messageGo to next message
Jochen Hebbrecht is currently offline Jochen HebbrechtFriend
Messages: 12
Registered: July 2009
Junior Member
Hi Tom,

Have a look at:

http://members.lycos.nl/jochus/brol/SampleNewWizard.java
http://members.lycos.nl/jochus/brol/SampleNewWizardPage.java

If I run this code, everything works perfect.

In SampleNewWizard, search the line:

> getContainer().run(false, true, op);

If you replace this line with this one:

> getContainer().run(true, true, op);

... you will get a NullPointerExceptoin at:

> PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage();

That's logical, because if you look at the API:
http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse. platform.doc.isv/reference/api/org/eclipse/jface/operation/I RunnableContext.html,
you will see that for the fork boolean (true if the runnable should be run
in a separate thread, and false to run in the same thread), the value at
true will make it impossible to get the ActiveWorkbenchWindow.

How can I solve this problem?
I can't put it to false, because my datamodel doesn't update my view fast
enough.

Jochen



Tom Schindl wrote:

> Hi Jochen,

> Could you stripp down your code so that we can run it locally (=create a
> runnable snippet / OSGi plugin) and reproduce the problems you are having?

> Tom
Re: [DataBinding] WizardScreen not fully updated [message #14031 is a reply to message #13413] Wed, 10 June 2009 13:22 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi Jochen,

Could you provide me with a complete plugin I can simply drop into my
Eclipse and click somewhere. I don't have enough time to make up a
running test case my own from the sources you publish.

I hope that's not a too big problem.

Tom

Jochen Hebbrecht schrieb:
> Hi Tom,
>
> Have a look at:
>
> http://members.lycos.nl/jochus/brol/SampleNewWizard.java
> http://members.lycos.nl/jochus/brol/SampleNewWizardPage.java
>
> If I run this code, everything works perfect.
>
> In SampleNewWizard, search the line:
>
>> getContainer().run(false, true, op);
>
> If you replace this line with this one:
>
>> getContainer().run(true, true, op);
>
> .. you will get a NullPointerExceptoin at:
>
>> PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage();
>
> That's logical, because if you look at the API:
> http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse. platform.doc.isv/reference/api/org/eclipse/jface/operation/I RunnableContext.html,
> you will see that for the fork boolean (true if the runnable should be
> run in a separate thread, and false to run in the same thread), the
> value at true will make it impossible to get the ActiveWorkbenchWindow.
>
> How can I solve this problem?
> I can't put it to false, because my datamodel doesn't update my view
> fast enough.
>
> Jochen
>
>
>
> Tom Schindl wrote:
>
>> Hi Jochen,
>
>> Could you stripp down your code so that we can run it locally (=create a
>> runnable snippet / OSGi plugin) and reproduce the problems you are
>> having?
>
>> Tom
>
>
Re: [DataBinding] WizardScreen not fully updated [message #14047 is a reply to message #14031] Wed, 10 June 2009 14:05 Go to previous messageGo to next message
Jochen Hebbrecht is currently offline Jochen HebbrechtFriend
Messages: 12
Registered: July 2009
Junior Member
Hi Tom,

No problem at all! :-)
The source: http://members.lycos.nl/jochus/brol/SampleWizard.zip

* Import the project in Eclipse
* Press "Run"
* File > New ... > Sample Wizard
* Press finish

=> everything ok

* Change:
> getContainer().run(false, true, op);
...to...
> getContainer().run(true, true, op);


* Press "Run"
* File > New ... > Sample Wizard
* Press finish

=> nullpointerexception!



Tom Schindl wrote:

> Hi Jochen,

> Could you provide me with a complete plugin I can simply drop into my
> Eclipse and click somewhere. I don't have enough time to make up a
> running test case my own from the sources you publish.

> I hope that's not a too big problem.

> Tom
Re: [DataBinding] WizardScreen not fully updated [message #14081 is a reply to message #14047] Wed, 10 June 2009 15:20 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

Ok now I see the problem. Please read the JavaDoc from
IWorkbench#getActiveWorkbenchWindow()

-----8<-----
Returns the currently active window for this workbench (if any). Returns
null if there is no active workbench window. Returns null if called from
a non-UI thread.

Returns:
the active workbench window, or null if there is no active workbench
window or if called from a non-UI thread
-----8<-----

If you are passing true the operation is running in the none display
thread hence you get back null.

Rewriting your doFinish like this:
> private void doFinish(IProgressMonitor monitor) throws CoreException {
> PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
>
> public void run() {
> IWorkbenchPage p = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage();
> System.err.println(p);
> }
> });
>
> }

Should fix the problem.

Tom


Jochen Hebbrecht schrieb:
> Hi Tom,
>
> No problem at all! :-)
> The source: http://members.lycos.nl/jochus/brol/SampleWizard.zip
>
> * Import the project in Eclipse
> * Press "Run"
> * File > New ... > Sample Wizard
> * Press finish
>
> => everything ok
>
> * Change:
>> getContainer().run(false, true, op);
> ..to...
>> getContainer().run(true, true, op);
>
>
> * Press "Run"
> * File > New ... > Sample Wizard
> * Press finish
>
> => nullpointerexception!
>
>
>
> Tom Schindl wrote:
>
>> Hi Jochen,
>
>> Could you provide me with a complete plugin I can simply drop into my
>> Eclipse and click somewhere. I don't have enough time to make up a
>> running test case my own from the sources you publish.
>
>> I hope that's not a too big problem.
>
>> Tom
>
>
Re: [DataBinding] WizardScreen not fully updated [message #14177 is a reply to message #14081] Thu, 11 June 2009 08:53 Go to previous message
Jochen Hebbrecht is currently offline Jochen HebbrechtFriend
Messages: 12
Registered: July 2009
Junior Member
Thnx Tom, works like a charm! :-) !

Tom Schindl wrote:

> Hi,

> Ok now I see the problem. Please read the JavaDoc from
> IWorkbench#getActiveWorkbenchWindow()

> -----8<-----
> Returns the currently active window for this workbench (if any). Returns
> null if there is no active workbench window. Returns null if called from
> a non-UI thread.

> Returns:
> the active workbench window, or null if there is no active workbench
> window or if called from a non-UI thread
> -----8<-----

> If you are passing true the operation is running in the none display
> thread hence you get back null.

> Rewriting your doFinish like this:
>> private void doFinish(IProgressMonitor monitor) throws CoreException {
>> PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
>>
>> public void run() {
>> IWorkbenchPage p =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage();
>> System.err.println(p);
>> }
>> });
>>
>> }

> Should fix the problem.

> Tom
Previous Topic:WizardDialog, WizardPage Back, Next, Finish, Cancel Event Hooks
Next Topic:[Databinding] binding to objects attributes
Goto Forum:
  


Current Time: Fri Apr 19 21:42:41 GMT 2024

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

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

Back to the top