View Javadoc

1   /**
2    * 
3    */
4   package org.appfuse.webapp.client.ui;
5   
6   import org.appfuse.webapp.client.application.Application;
7   import org.appfuse.webapp.client.application.base.security.LoginEvent;
8   import org.appfuse.webapp.client.application.base.security.LogoutEvent;
9   
10  import com.github.gwtbootstrap.client.ui.Alert;
11  import com.github.gwtbootstrap.client.ui.base.AlertBase;
12  import com.github.gwtbootstrap.client.ui.constants.AlertType;
13  import com.google.gwt.place.shared.PlaceChangeEvent;
14  import com.google.gwt.uibinder.client.UiField;
15  import com.google.gwt.user.client.Window;
16  import com.google.gwt.user.client.ui.Composite;
17  import com.google.gwt.user.client.ui.FlowPanel;
18  import com.google.gwt.user.client.ui.NotificationMole;
19  import com.google.gwt.user.client.ui.SimplePanel;
20  
21  /**
22   * @author ivangsa
23   *
24   */
25  public abstract class Shell extends Composite implements LoginEvent.Handler, LogoutEvent.Handler {
26  
27      protected Application application;
28  
29      @UiField
30      SimplePanel contentsPanel;
31  
32      @UiField
33      NotificationMole mole;
34  
35      @UiField
36      FlowPanel messages;
37  
38      /**
39       * Contents Panel
40       * 
41       * @return
42       */
43      public SimplePanel getContentsPanel() {
44          return contentsPanel;
45      }
46  
47      /**
48       * @return the notification mole for loading feedback
49       */
50      public NotificationMole getMole() {
51          return mole;
52      }
53  
54      public void clearMessages() {
55          messages.clear();
56      }
57  
58      /**
59       * Add an user message to the shell.
60       * 
61       * Messages live on screen until next {@link PlaceChangeEvent}.
62       * 
63       * @param alert
64       */
65      public void addMessage(final AlertBase alert) {
66          messages.add(alert);
67          Window.scrollTo(0, 0);
68      }
69  
70      /**
71       * 
72       * @param html
73       * @param alertType
74       */
75      public void addMessage(final String html, final AlertType alertType) {
76          final Alert alert = new Alert(html);
77          alert.setType(alertType);
78          addMessage(alert);
79      }
80  
81      public void setApplication(Application application) {
82          this.application = application;
83      }
84  
85  }