Skip to content
This repository has been archived by the owner on Feb 9, 2021. It is now read-only.

Commit

Permalink
BZ-1008471: this nasty bug use to happen when parent was just attache…
Browse files Browse the repository at this point in the history
…d and not yet properly resized, but even in this case we resize everything to 0 width and 0 height... so when the parent were properly resized, all the panels were already setted to 0/0. this commit seems to fix it.
  • Loading branch information
porcelli committed Nov 5, 2013
1 parent 81098e1 commit 4b42667
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 15 deletions.
Expand Up @@ -2,6 +2,7 @@

import javax.annotation.PostConstruct;

import com.google.gwt.core.client.Scheduler;
import com.google.gwt.dom.client.Style;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.Widget;
Expand Down Expand Up @@ -95,9 +96,15 @@ public void setFocus( boolean hasFocus ) {
@Override
public void onResize() {
final Widget parent = getParent();
if ( parent != null ) {
if ( parent != null && parent.isAttached() ) {
final int width = parent.getOffsetWidth();
final int height = parent.getOffsetHeight();
if ( width == 0 && height == 0 ) {
scheduleResize( this );
return;
}

setPixelSize( width, height );
presenter.onResize( width, height );
widget.onResize();
super.onResize();
Expand Down
Expand Up @@ -2,6 +2,8 @@

import javax.inject.Inject;

import com.google.gwt.core.client.Scheduler;
import com.google.gwt.user.client.ui.RequiresResize;
import com.google.gwt.user.client.ui.ResizeComposite;
import com.google.gwt.user.client.ui.Widget;
import org.uberfire.client.workbench.BeanFactory;
Expand Down Expand Up @@ -133,4 +135,13 @@ public P getPresenter() {
return this.presenter;
}

protected void scheduleResize( final RequiresResize widget ) {
Scheduler.get().scheduleDeferred( new Scheduler.ScheduledCommand() {
@Override
public void execute() {
widget.onResize();
}
} );
}

}
Expand Up @@ -122,9 +122,13 @@ public void setFocus( boolean hasFocus ) {
@Override
public void onResize() {
final Widget parent = getParent();
if ( parent != null ) {
if ( parent != null && parent.isAttached() ) {
final int width = parent.getOffsetWidth();
final int height = parent.getOffsetHeight();
if ( width == 0 && height == 0 ) {
scheduleResize( this );
return;
}
setPixelSize( width, height );
presenter.onResize( width, height );

Expand Down
Expand Up @@ -382,21 +382,18 @@ public HandlerRegistration addSelectionHandler( final SelectionHandler<PartDefin

@Override
public void onResize() {
final Widget parent = getParent();
if ( parent != null ) {
if ( !getParent().isAttached() ) {
return;
}
final Widget panel = getParent().getParent();
if ( panel != null ) {
final int width;
final int height;
if ( parent.getParent() != null ) {
if ( parent.getParent().getParent() != null ) {
width = parent.getParent().getParent().getOffsetWidth();
height = parent.getParent().getParent().getOffsetHeight();
} else {
width = parent.getParent().getOffsetWidth();
height = parent.getParent().getOffsetHeight();
}
} else {
width = parent.getOffsetWidth();
height = parent.getOffsetHeight();
width = panel.getOffsetWidth();
height = panel.getOffsetHeight();
if ( width == 0 && height == 0 ) {
scheduleResize();
return;
}
content.setPixelSize( width, height );
header.setWidth( width + "px" );
Expand Down

0 comments on commit 4b42667

Please sign in to comment.