CloudMessage.java :  » Contact » webdroid » com » androidapps » cloud » messaging » client » Android Open Source

Android Open Source » Contact » webdroid 
webdroid » com » androidapps » cloud » messaging » client » CloudMessage.java
package com.androidapps.cloud.messaging.client;

import com.androidapps.cloud.messaging.shared.LoginInfo;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RadioButton;
import com.google.gwt.user.client.ui.RootPanel;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class CloudMessage implements EntryPoint {
  /**
   * The message displayed to the user when the server cannot be reached or
   * returns an error.
   */
  private static final String SERVER_ERROR = "An error occurred while "
      + "attempting to contact the server. Please check your network "
      + "connection and try again.";

  LoginServiceAsync loginService = GWT.create(LoginService.class);
  LoginInfo loginInfo;  
  
  /**
   * This is the entry point method.
   */
  public void onModuleLoad() {
    final HorizontalPanel uniNaviPanel = new HorizontalPanel();  
    loginService.login(GWT.getHostPageBaseURL(), new AsyncCallback<LoginInfo>() {
      
      @Override
      public void onSuccess(LoginInfo result) {
        loginInfo = result;
        if(loginInfo.isLoggedIn())
        {
          AndroidMessaging messaging = new AndroidMessaging();
          
          //uniNaviPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
          uniNaviPanel.add(new Label("welcome " + loginInfo.getNickname() + ","));
          uniNaviPanel.add(new Anchor("Log Out",loginInfo.getLogoutUrl()));
          Label hiddenLabel = new Label();
          uniNaviPanel.add(hiddenLabel);
          hiddenLabel.setWidth("100px");
          
          RootPanel.get("uniNav").add(uniNaviPanel);
          RootPanel.get("nameFieldContainer").add(messaging);
          
          
          
        }
        else
        {
          Window.Location.assign(loginInfo.getLoginUrl());
        }
        
      }
      
      @Override
      public void onFailure(Throwable caught) {
        Window.alert("Failed to reach server. Check your network settings and try reconnecting");
        
      }
    });  
    
      
    
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.