| 1 |  |   | 
  | 2 |  |   | 
  | 3 |  |   | 
  | 4 |  |   | 
  | 5 |  |   | 
  | 6 |  |   | 
  | 7 |  |   | 
  | 8 |  |   | 
  | 9 |  |   | 
  | 10 |  |   | 
  | 11 |  |   | 
  | 12 |  |   | 
  | 13 |  |   | 
  | 14 |  |   | 
  | 15 |  |   | 
  | 16 |  |  package org.kuali.student.core.organization.ui.client.view; | 
  | 17 |  |   | 
  | 18 |  |   | 
  | 19 |  |  import org.kuali.student.common.ui.client.application.Application; | 
  | 20 |  |  import org.kuali.student.common.ui.client.application.ApplicationComposite; | 
  | 21 |  |  import org.kuali.student.common.ui.client.application.ApplicationContext; | 
  | 22 |  |  import org.kuali.student.common.ui.client.application.KSAsyncCallback; | 
  | 23 |  |  import org.kuali.student.common.ui.client.mvc.Controller; | 
  | 24 |  |  import org.kuali.student.common.ui.client.service.MessagesRpcService; | 
  | 25 |  |  import org.kuali.student.common.ui.client.service.SecurityRpcService; | 
  | 26 |  |  import org.kuali.student.common.ui.client.service.SecurityRpcServiceAsync; | 
  | 27 |  |  import org.kuali.student.common.ui.client.util.BrowserUtils; | 
  | 28 |  |  import org.kuali.student.common.ui.client.widgets.ApplicationPanel; | 
  | 29 |  |  import org.kuali.student.core.messages.dto.MessageList; | 
  | 30 |  |  import org.kuali.student.core.organization.ui.client.mvc.controller.OrgApplicationManager; | 
  | 31 |  |  import org.kuali.student.core.organization.ui.client.theme.OrgTheme; | 
  | 32 |  |   | 
  | 33 |  |  import com.google.gwt.core.client.EntryPoint; | 
  | 34 |  |  import com.google.gwt.core.client.GWT; | 
  | 35 |  |  import com.google.gwt.dom.client.StyleInjector; | 
  | 36 |  |  import com.google.gwt.user.client.DOM; | 
  | 37 |  |  import com.google.gwt.user.client.History; | 
  | 38 |  |  import com.google.gwt.user.client.rpc.SerializationException; | 
  | 39 |  |  import com.google.gwt.user.client.rpc.SerializationStreamFactory; | 
  | 40 |  |  import com.google.gwt.user.client.ui.SimplePanel; | 
  | 41 |  |   | 
  | 42 | 0 |  public class OrgEntryPoint implements EntryPoint{ | 
  | 43 |  |   | 
  | 44 |  |      ApplicationComposite app; | 
  | 45 | 0 |      private OrgApplicationManager manager = null; | 
  | 46 | 0 |      SimplePanel content = new SimplePanel(); | 
  | 47 |  |   | 
  | 48 |  |   | 
  | 49 |  |      public void onModuleLoad() { | 
  | 50 | 0 |          final ApplicationContext context = Application.getApplicationContext(); | 
  | 51 | 0 |          final String injectString = OrgTheme.INSTANCE.getOrgCss().getCssString(); | 
  | 52 | 0 |          StyleInjector.injectStylesheet(injectString); | 
  | 53 |  |   | 
  | 54 | 0 |          loadApp(context); | 
  | 55 |  |   | 
  | 56 |  |          try { | 
  | 57 | 0 |              MessageList messageList =  getSerializedObject( "i18nMessages"); | 
  | 58 | 0 |              context.addMessages(messageList.getMessages()); | 
  | 59 |  |   | 
  | 60 | 0 |          } catch (Exception e) { | 
  | 61 | 0 |              GWT.log("Error on ModuleLoad",e); | 
  | 62 | 0 |          } | 
  | 63 |  |   | 
  | 64 |  |   | 
  | 65 |  |   | 
  | 66 |  |   | 
  | 67 | 0 |          History.fireCurrentHistoryState(); | 
  | 68 |  |   | 
  | 69 | 0 |          if(DOM.getElementById("loadingSpinner") != null) | 
  | 70 | 0 |              DOM.removeChild(ApplicationPanel.get().getElement(), DOM.getElementById("loadingSpinner")); | 
  | 71 | 0 |      } | 
  | 72 |  |   | 
  | 73 |  |       | 
  | 74 |  |   | 
  | 75 |  |   | 
  | 76 |  |   | 
  | 77 |  |   | 
  | 78 |  |   | 
  | 79 |  |   | 
  | 80 |  |   | 
  | 81 |  |   | 
  | 82 |  |   | 
  | 83 |  |   | 
  | 84 |  |   | 
  | 85 |  |   | 
  | 86 |  |   | 
  | 87 |  |   | 
  | 88 |  |   | 
  | 89 |  |   | 
  | 90 |  |   | 
  | 91 |  |   | 
  | 92 |  |   | 
  | 93 |  |   | 
  | 94 |  |   | 
  | 95 |  |   | 
  | 96 |  |   | 
  | 97 |  |      @SuppressWarnings("unchecked") | 
  | 98 |  |      public  <T> T getSerializedObject( String name ) throws SerializationException | 
  | 99 |  |      { | 
  | 100 | 0 |          String serialized = BrowserUtils.getString( name ); | 
  | 101 | 0 |          SerializationStreamFactory ssf = GWT.create( MessagesRpcService.class);  | 
  | 102 | 0 |          return (T)ssf.createStreamReader( serialized ).readObject(); | 
  | 103 |  |      } | 
  | 104 |  |   | 
  | 105 |  |      public void loadApp(final ApplicationContext context){ | 
  | 106 | 0 |          SecurityRpcServiceAsync securityRpc = GWT.create(SecurityRpcService.class); | 
  | 107 |  |   | 
  | 108 | 0 |          securityRpc.getPrincipalUsername(new KSAsyncCallback<String>(){ | 
  | 109 |  |              public void handleFailure(Throwable caught) { | 
  | 110 | 0 |                  context.setUserId("Unknown"); | 
  | 111 | 0 |                  initScreen(); | 
  | 112 | 0 |              } | 
  | 113 |  |   | 
  | 114 |  |              @Override | 
  | 115 |  |              public void onSuccess(String principalId) { | 
  | 116 | 0 |                  context.setUserId(principalId); | 
  | 117 | 0 |                  initScreen(); | 
  | 118 | 0 |              } | 
  | 119 |  |          }); | 
  | 120 | 0 |      } | 
  | 121 |  |   | 
  | 122 |  |      private void initScreen(){ | 
  | 123 | 0 |          app = new ApplicationComposite(); | 
  | 124 | 0 |          manager = new OrgApplicationManager(); | 
  | 125 | 0 |          app.setContent(manager); | 
  | 126 |  |   | 
  | 127 | 0 |          ApplicationPanel.get().add(app); | 
  | 128 | 0 |          if(manager.getCurrentView() == null) | 
  | 129 | 0 |              manager.showDefaultView(Controller.NO_OP_CALLBACK); | 
  | 130 | 0 |      } | 
  | 131 |  |  } |