gt:         if (t.getCause() != null) {
context: /*
   * Copyright 2007-2009 Sun Microsystems, Inc. All Rights Reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
   * 
   * This code is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License version 2
   * only, as published by the Free Software Foundation.
   * 
   * This code is distributed in the hope that it will be useful, but
   * WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   * General Public License version 2 for more details (a copy is
   * included in the LICENSE file that accompanied this code).
   * 
   * You should have received a copy of the GNU General Public License
   * version 2 along with this work; if not, write to the Free Software
   * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
   * 02110-1301 USA
   * 
   * Please contact Sun Microsystems, Inc., 16 Network Circle, Menlo
   * Park, CA 94025 or visit www.sun.com if you need additional
   * information or have any questions.
   */
  
  package com.sun.labs.aura.music.wsitm.client.ui;
  
  import com.google.gwt.event.dom.client.ClickEvent;
  import com.google.gwt.user.client.Command;
  import com.google.gwt.user.client.Cookies;
  import com.google.gwt.user.client.DeferredCommand;
  import com.google.gwt.user.client.ui.Button;
  import com.google.gwt.event.dom.client.ClickHandler;
  import com.google.gwt.user.client.ui.DialogBox;
  import com.google.gwt.user.client.ui.DockPanel;
  import com.google.gwt.user.client.ui.FlowPanel;
  import com.google.gwt.user.client.ui.Grid;
  import com.google.gwt.user.client.ui.HTML;
  import com.google.gwt.user.client.ui.HorizontalPanel;
  import com.google.gwt.user.client.ui.Label;
  import com.google.gwt.user.client.ui.PopupPanel;
  import com.google.gwt.user.client.ui.VerticalPanel;
  import com.google.gwt.user.client.ui.Widget;
  import com.google.gwt.user.client.Timer;
  import com.google.gwt.user.client.Window;
  import com.google.gwt.user.client.ui.DisclosurePanel;
  import com.google.gwt.user.client.ui.Image;
  import com.google.gwt.user.client.ui.TextBox;
  import com.sun.labs.aura.music.wsitm.agentspecific.impl.CssDefsImpl;
  import com.sun.labs.aura.music.wsitm.client.ClientDataManager;
  import com.sun.labs.aura.music.wsitm.client.WebException;
  import com.sun.labs.aura.music.wsitm.client.WebLib;
  import com.sun.labs.aura.music.wsitm.client.event.DEClickHandler;
  import org.cobogw.gwt.user.client.ui.RoundedLinePanel;
  import org.cobogw.gwt.user.client.ui.RoundedPanel;
  
  /**
   *
   * @author mailletf
   */
  public abstract class Popup {
  
      public static DialogBox getDialogBox() {
          final DialogBox popup = new DialogBox(true);
          return popup;
      }
  
      public static void showPopup(Widget w, String title) {
          showPopup(w, title, getDialogBox());
      }
  
      public static void showPopup(Widget w, String title, final DialogBox popup) {
  
          DockPanel docPanel = new DockPanel();
  
          Label closeButton = new Label("Close");
          closeButton.setStyleName("clickableLabel");
          closeButton.addStyleName("whiteTxt");
          closeButton.addClickHandler(new ClickHandler() {
              @Override
              public void onClick(ClickEvent ce) {
                  popup.hide();
              }
          });
  
          FlowPanel container = new FlowPanel();
          container.setStyleName("outerpopup");
          container.add(w);
  
          docPanel.add(container, DockPanel.CENTER);
          docPanel.add(closeButton, DockPanel.SOUTH);
          docPanel.setCellHorizontalAlignment(closeButton, DockPanel.ALIGN_RIGHT);
          popup.add(docPanel);
          popup.setText(title);
          popup.setAnimationEnabled(true);
          popup.center();
      }
  
      //public static PopupPanel getPopupPanel(int secTillAutoClose) {
      public static PopupPanel getPopupPanel() {
          //final PopupPanelAutoClose popup = new PopupPanelAutoClose(5);
          final PopupPanel popup = new PopupPanel(true);
          return popup;
      }
  
      public static void showRoundedPopup(Widget w, String title, int width) {
          showRoundedPopup(w, title, getPopupPanel(), -1, -1, width, true);
      }
      
      public static void showRoundedPopup(Widget w, String title, final PopupPanel popup, int width) {
          showRoundedPopup(w, title, popup, -1, -1, width, true);
      }
  
      public static void showRoundedPopup(Widget w, String title, final PopupPanel popup,
              int x, int y, int width) {
          showRoundedPopup(w, title, popup, x, y, width, true);
      }
  
      public static void showRoundedPopup(Widget w, String title, final PopupPanel popup, 
              int x, int y, int width, boolean showCloseButton) {
          
          Label titleLabel = null;
          if (title != null && title.length() > 0) {
              titleLabel = new Label(title);
              titleLabel.setStyleName("popupColors");
              titleLabel.addStyleName("popupTitle");
          }
          showRoundedPopup(w, titleLabel, popup, x, y, width, showCloseButton);
      }
  
      /**
       * Display a rounded popup window
       * @param w Content widget
       * @param title Title widget. Use alternate method signature to pass in string
       * @param popup Popup returned by getPopupPanel()
       * @param x Position. Set to -1 to center it
       * @param y Position. Set to -1 to center it
       * @param cdm ClientDataManager
       * @param width Width of the enclosed widget. Will be used to resize the popup on ie
       */
      public static void showRoundedPopup(Widget w, Widget title, final PopupPanel popup, 
              int x, int y, int width, boolean showCloseButton) {
  
          VerticalPanel vP = new VerticalPanel();
          if (showCloseButton) {
              Button b = new Button("Close");
              b.addClickHandler(new DEClickHandler<PopupPanel>(popup) {
  
                  @Override
                  public void onClick(ClickEvent ce) {
                      data.hide();
                  }
              });
  
              Grid hP = new Grid(1,2);
              if (title != null) {
                  hP.setWidget(0, 0, title);
              }
              hP.setWidget(0,1, b);
              hP.getCellFormatter().setWidth(0, 0, (width-53)+"px");
              hP.getCellFormatter().setWidth(0, 1, "50px");
              hP.getCellFormatter().setHorizontalAlignment(0, 1, HorizontalPanel.ALIGN_RIGHT);
              vP.add(hP);
          } else {
              if (title != null) {
                  vP.add(title);
              }
          }
  
          w.getElement().getStyle().setPropertyPx("padding", 5);
          w.addStyleName("popupColors");
          vP.add(w);
  
          Grid fP = new Grid(1,1);
          fP.setStyleName("popupColors");
          fP.setHeight("100%");
          fP.setWidget(0, 0, vP);
  
          RoundedLinePanel rp = new RoundedLinePanel(fP, RoundedPanel.ALL, 5);
          //rp.setCornerStyleName("popupColors");
          rp.setCornerColor("#005480", "#5382a1", "#5382a1");
          popup.add(rp);
          popup.setAnimationEnabled(true);
          CssDefsImpl.impl.setRoundedPopupWidth(popup, width);
  
          if (x==-1 && y==-1) {
              popup.center();
          } else {
              popup.setPopupPosition(x, y);
              popup.show();
          }
  
      }
  
      public static void showInformationPopup(Widget html, int secTillAutoClose,
              boolean closeButton) {
  
          PopupPanel popup = getPopupPanel();
  
          VerticalPanel hP = new VerticalPanel();
          hP.setSpacing(4);
          hP.add(html);
          hP.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT);
  
          hP.setWidth("600px");
          showRoundedPopup(hP, "Information", popup, -1, -1, 600, closeButton);
      }
  
      public static enum ERROR_MSG_PREFIX {
          NONE,
          ERROR_OCC_WHILE
      }
  
      /**
       * Silent errors don't necessarily need to be shown to the user. Could be retried
       * in the background
       */
      public static enum ERROR_LVL {
          CRITICAL,
          NORMAL,
          SILENT
      }
  
      public static String errorPrefixToStr(ERROR_MSG_PREFIX errPrefix) {
          if (errPrefix == ERROR_MSG_PREFIX.ERROR_OCC_WHILE) {
              return "An error occured while trying to ";
          } else {
              return "";
          }
      }
  
      private static HTML formatStack(Throwable t) {
          String s = t.toString()+"<br />"+WebLib.traceToString(t);
          s.replaceAll("\n", "<br />");
  
  