Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » ScrolledComposite#showControl doesn't work for new children
ScrolledComposite#showControl doesn't work for new children [message #505890] Tue, 05 January 2010 14:03 Go to next message
Ralf Zahn is currently offline Ralf ZahnFriend
Messages: 32
Registered: July 2009
Member
Hi,

as I know, the bounds of UI widgets are set by rendering them in the
browser and sending the bounds back to the server during the next request.
I have a ScrolledComposite, wherein some child widgets are created. I
want to scroll down to the widget that I have just created. But the
showControl-Method needs the widget to have bounds specified, and the
widget has the bounds (0,0,0,0) because it was not yet rendered in the
browser.

So how to solve the problem?
- Using UICallback and starting a Job that will check the widget to
have bounds set and then call the showControl-method within the UI
thread. (Disadvantages: delay in scrolling within the UI, single
sourcing is more complicated, a job is shown in the progress bar)
- Using the setOrigin method and estimating the bounds of the widget.
(I guess this does not work because the origin is handled before
calculating the bounds at the client, so it will only scroll to the
widget that already existed before)
- Modifying the showControl method not to use bounds, but adding an
attribute to the UI component containing a scroll command and sending it
to the client. (Advantages: transparency for single sourcing, no UI delay)

What about other methods of other widgets requiring bounds?
Re: ScrolledComposite#showControl doesn't work for new children [message #505898 is a reply to message #505890] Tue, 05 January 2010 14:24 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2359
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi Ralf,

the controls bounds are calculated on the server side when the layout is
performed. When you add a new children to the ScrolledComposite try to
force the re-layouting at the end.

HTH,
Ivan

On 1/5/2010 4:03 PM, Ralf Zahn wrote:
> Hi,
>
> as I know, the bounds of UI widgets are set by rendering them in the
> browser and sending the bounds back to the server during the next
> request.
> I have a ScrolledComposite, wherein some child widgets are created. I
> want to scroll down to the widget that I have just created. But the
> showControl-Method needs the widget to have bounds specified, and the
> widget has the bounds (0,0,0,0) because it was not yet rendered in the
> browser.
>
> So how to solve the problem?
> - Using UICallback and starting a Job that will check the widget to
> have bounds set and then call the showControl-method within the UI
> thread. (Disadvantages: delay in scrolling within the UI, single
> sourcing is more complicated, a job is shown in the progress bar)
> - Using the setOrigin method and estimating the bounds of the widget.
> (I guess this does not work because the origin is handled before
> calculating the bounds at the client, so it will only scroll to the
> widget that already existed before)
> - Modifying the showControl method not to use bounds, but adding an
> attribute to the UI component containing a scroll command and sending
> it to the client. (Advantages: transparency for single sourcing, no
> UI delay)
>
> What about other methods of other widgets requiring bounds?
Re: ScrolledComposite#showControl doesn't work for new children [message #506018 is a reply to message #505898] Tue, 05 January 2010 18:47 Go to previous messageGo to next message
Ralf Zahn is currently offline Ralf ZahnFriend
Messages: 32
Registered: July 2009
Member
Okay, I previously called scrolledComposite.layout(), instead
scrolledComposite.getBody().layout() is correct.

Now I have the problem that the origin is calculated correctly, but not
executed at the client. The controls, that were created during the
current request cycle, cannot be made visible by scrolling. It seems
that (at the client) the scrolling is executed before the new child
controls are added.

If the ScrolledComposite contains A, B, C, D, the client area can show 2
elements (A,B), and I add two further children E and F, call
showControl(F) during the same request, the ScrolledComposite will show
C,D. The next request adds G, H, but scrolls to E,F and so on.


Ivan Furnadjiev schrieb:
> Hi Ralf,
>
> the controls bounds are calculated on the server side when the layout is
> performed. When you add a new children to the ScrolledComposite try to
> force the re-layouting at the end.
>
> HTH,
> Ivan
>
> On 1/5/2010 4:03 PM, Ralf Zahn wrote:
>> Hi,
>>
>> as I know, the bounds of UI widgets are set by rendering them in the
>> browser and sending the bounds back to the server during the next
>> request.
>> I have a ScrolledComposite, wherein some child widgets are created. I
>> want to scroll down to the widget that I have just created. But the
>> showControl-Method needs the widget to have bounds specified, and the
>> widget has the bounds (0,0,0,0) because it was not yet rendered in the
>> browser.
>>
>> So how to solve the problem?
>> - Using UICallback and starting a Job that will check the widget to
>> have bounds set and then call the showControl-method within the UI
>> thread. (Disadvantages: delay in scrolling within the UI, single
>> sourcing is more complicated, a job is shown in the progress bar)
>> - Using the setOrigin method and estimating the bounds of the widget.
>> (I guess this does not work because the origin is handled before
>> calculating the bounds at the client, so it will only scroll to the
>> widget that already existed before)
>> - Modifying the showControl method not to use bounds, but adding an
>> attribute to the UI component containing a scroll command and sending
>> it to the client. (Advantages: transparency for single sourcing, no
>> UI delay)
>>
>> What about other methods of other widgets requiring bounds?
Re: ScrolledComposite#showControl doesn't work for new children [message #506020 is a reply to message #506018] Tue, 05 January 2010 18:56 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2359
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Ralf,

can you provide a snippet that demonstrate the problem?

Best,
Ivan

On 1/5/2010 8:47 PM, Ralf Zahn wrote:
> Okay, I previously called scrolledComposite.layout(), instead
> scrolledComposite.getBody().layout() is correct.
>
> Now I have the problem that the origin is calculated correctly, but
> not executed at the client. The controls, that were created during the
> current request cycle, cannot be made visible by scrolling. It seems
> that (at the client) the scrolling is executed before the new child
> controls are added.
>
> If the ScrolledComposite contains A, B, C, D, the client area can show
> 2 elements (A,B), and I add two further children E and F, call
> showControl(F) during the same request, the ScrolledComposite will
> show C,D. The next request adds G, H, but scrolls to E,F and so on.
>
>
> Ivan Furnadjiev schrieb:
>> Hi Ralf,
>>
>> the controls bounds are calculated on the server side when the layout
>> is performed. When you add a new children to the ScrolledComposite
>> try to force the re-layouting at the end.
>>
>> HTH,
>> Ivan
>>
>> On 1/5/2010 4:03 PM, Ralf Zahn wrote:
>>> Hi,
>>>
>>> as I know, the bounds of UI widgets are set by rendering them in the
>>> browser and sending the bounds back to the server during the next
>>> request.
>>> I have a ScrolledComposite, wherein some child widgets are created.
>>> I want to scroll down to the widget that I have just created. But
>>> the showControl-Method needs the widget to have bounds specified,
>>> and the widget has the bounds (0,0,0,0) because it was not yet
>>> rendered in the browser.
>>>
>>> So how to solve the problem?
>>> - Using UICallback and starting a Job that will check the widget to
>>> have bounds set and then call the showControl-method within the UI
>>> thread. (Disadvantages: delay in scrolling within the UI, single
>>> sourcing is more complicated, a job is shown in the progress bar)
>>> - Using the setOrigin method and estimating the bounds of the
>>> widget. (I guess this does not work because the origin is handled
>>> before calculating the bounds at the client, so it will only scroll
>>> to the widget that already existed before)
>>> - Modifying the showControl method not to use bounds, but adding an
>>> attribute to the UI component containing a scroll command and
>>> sending it to the client. (Advantages: transparency for single
>>> sourcing, no UI delay)
>>>
>>> What about other methods of other widgets requiring bounds?
Re: ScrolledComposite#showControl doesn't work for new children [message #506035 is a reply to message #506020] Tue, 05 January 2010 14:56 Go to previous messageGo to next message
Ralf Zahn is currently offline Ralf ZahnFriend
Messages: 32
Registered: July 2009
Member
package de.ars.rap.example;

import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.eclipse.ui.part.ViewPart;

/**
* Example view.
*
* @author Ralf Zahn, ARS Computer und Consulting GmbH
*/
public class ScrolledCompositeView extends ViewPart {

private FormToolkit toolkit;
private ScrolledForm scrollComposite;

/**
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(Composit e)
*/
@Override
public void createPartControl( Composite parent ) {
this.toolkit = new FormToolkit( parent.getDisplay() );
scrollComposite = toolkit.createScrolledForm( parent );
scrollComposite.getBody().setLayout(
GridLayoutFactory.fillDefaults().equalWidth( false ).spacing(
5, 10 )
.numColumns( 1 ).create() );
Control lastControl = null;
for ( int i = 0; i < 100; i++ ) {
final Label lbl = new Label( scrollComposite.getBody(), SWT.NONE );
lbl.setLayoutData( GridDataFactory.fillDefaults().grab( true, false )
.create() );
lbl.setText( "Label " + i );
lastControl = lbl;
}
scrollComposite.getBody().layout();
scrollComposite.showControl( lastControl );
}

/**
* @see org.eclipse.ui.part.WorkbenchPart#setFocus()
*/
@Override
public void setFocus() {
this.scrollComposite.setFocus();
}
}
Re: ScrolledComposite#showControl doesn't work for new children [message #506046 is a reply to message #506035] Tue, 05 January 2010 15:52 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2359
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi Ralf,

instead using:
scrollComposite.getBody().layout();
use:
scrollComposite.reflow( true );

Best,
Ivan

On 1/5/2010 9:51 PM, Ralf Zahn wrote:
> package de.ars.rap.example;
>
> import org.eclipse.jface.layout.GridDataFactory;
> import org.eclipse.jface.layout.GridLayoutFactory;
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.widgets.Composite;
> import org.eclipse.swt.widgets.Control;
> import org.eclipse.swt.widgets.Label;
> import org.eclipse.ui.forms.widgets.FormToolkit;
> import org.eclipse.ui.forms.widgets.ScrolledForm;
> import org.eclipse.ui.part.ViewPart;
>
> /**
> * Example view.
> *
> * @author Ralf Zahn, ARS Computer und Consulting GmbH
> */
> public class ScrolledCompositeView extends ViewPart {
>
> private FormToolkit toolkit;
> private ScrolledForm scrollComposite;
>
> /**
> * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(Composit e)
> */
> @Override
> public void createPartControl( Composite parent ) {
> this.toolkit = new FormToolkit( parent.getDisplay() );
> scrollComposite = toolkit.createScrolledForm( parent );
> scrollComposite.getBody().setLayout(
> GridLayoutFactory.fillDefaults().equalWidth( false ).spacing(
> 5, 10 )
> .numColumns( 1 ).create() );
> Control lastControl = null;
> for ( int i = 0; i < 100; i++ ) {
> final Label lbl = new Label( scrollComposite.getBody(), SWT.NONE );
> lbl.setLayoutData( GridDataFactory.fillDefaults().grab( true,
> false )
> .create() );
> lbl.setText( "Label " + i );
> lastControl = lbl;
> }
> scrollComposite.getBody().layout();
> scrollComposite.showControl( lastControl );
> }
>
> /**
> * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
> */
> @Override
> public void setFocus() {
> this.scrollComposite.setFocus();
> }
> }
>
Re: ScrolledComposite#showControl doesn't work for new children [message #506047 is a reply to message #506046] Tue, 05 January 2010 21:07 Go to previous message
Ralf Zahn is currently offline Ralf ZahnFriend
Messages: 32
Registered: July 2009
Member
Wow, you made my day. ;-)

Thanks!

Ivan Furnadjiev schrieb:
> Hi Ralf,
>
> instead using:
> scrollComposite.getBody().layout();
> use:
> scrollComposite.reflow( true );
>
> Best,
> Ivan
Previous Topic:update 1.3M4 and UITests Error
Next Topic:Some characters are not entering KeyPress event
Goto Forum:
  


Current Time: Wed Dec 08 14:01:29 GMT 2021

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

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

Back to the top