Beispiel #1
0
  public void addPanel(final WPanel panel) {
    panel.setCollapsible(true);
    panel.collapse();

    panel
        .expanded()
        .addListener(
            this,
            new Signal.Listener() {
              public void trigger() {
                onExpand(true, panel);
              }
            });

    panel
        .collapsed()
        .addListener(
            this,
            new Signal.Listener() {
              public void trigger() {
                onExpand(false, panel);
              }
            });

    super.addWidget(panel);
  }
Beispiel #2
0
  private void onExpand(boolean notUndo, WPanel sender) {
    WPanel panel = sender;

    if (notUndo) {
      wasExpanded_ = -1;

      for (int i = 0; i < getChildren().size(); ++i) {
        WPanel p = (WPanel) getChildren().get(i);
        if (p != panel) {
          if (!p.isCollapsed()) wasExpanded_ = i;
          p.collapse();
        }
      }
    } else {
      if (wasExpanded_ != -1) {
        WPanel p = (WPanel) getChildren().get(wasExpanded_);
        p.expand();
      }
    }
  }