Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GWT StackPanel limitation?

Tags:

java

gwt

Is there a component like the StackPanel or DecoratedStackPanel that has the ability of showing more than one panel in the stack at a time? Id like to have the option of expanding all or collapsing any number of the panels I want.

like image 405
stuff22 Avatar asked Oct 26 '22 02:10

stuff22


1 Answers

Ok, since I got no answer, this is what has worked for me. Google doesn't make it real easy to extend existing panels to add or modify functionality, so what I did was I downloaded the source, copied StackPanel.java, DecoratorPanel.java and DecoratedStackPanel.java into a package in my gwt project.

The main change I really needed to do was to change the behavior of the showStack(int index) in the StackPanel.java class from

  public void showStack(int index) {
    if ((index >= getWidgetCount()) || (index < 0) || (index == visibleStack)) {
      return;
    }

    if (visibleStack >= 0) {
      setStackVisible(visibleStack, false);
    }

    visibleStack = index;
    setStackVisible(visibleStack, true);    }

to something like this:

 public void showStack(int index) {

    if ((index >= getWidgetCount()) || index < 0) {
       return;
    }

    visibleStack = index;
    setStackVisible(visibleStack, !getWidget(visibleStack).isVisible());


  }

I'm sure it's possible to clean this up a bit, but this did the trick. The reason the other classes need to be copied over to the same package is because StackPanel.java references some of their methods that only have package visibility.

like image 67
stuff22 Avatar answered Nov 15 '22 07:11

stuff22