Coverage Report - org.kuali.student.core.organization.ui.client.view.OrgEntryPoint
 
Classes in this File Line Coverage Branch Coverage Complexity
OrgEntryPoint
0%
0/29
0%
0/4
1.5
OrgEntryPoint$1
0%
0/7
N/A
1.5
 
 1  
 /**
 2  
  * Copyright 2010 The Kuali Foundation Licensed under the
 3  
  * Educational Community License, Version 2.0 (the "License"); you may
 4  
  * not use this file except in compliance with the License. You may
 5  
  * obtain a copy of the License at
 6  
  *
 7  
  * http://www.osedu.org/licenses/ECL-2.0
 8  
  *
 9  
  * Unless required by applicable law or agreed to in writing,
 10  
  * software distributed under the License is distributed on an "AS IS"
 11  
  * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 12  
  * or implied. See the License for the specific language governing
 13  
  * permissions and limitations under the License.
 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  
 //    private OrgMenu orgMenu = new OrgMenu(content);;
 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  
 //        StyleInjector.injectStylesheet(CoreUIResources.INSTANCE.generalCss().getText());
 65  
 
 66  
 //        History.addValueChangeHandler(orgMenu);
 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  
     /* Not used anywhere that I can tell GNL
 74  
     public Widget getContent(){
 75  
         DockPanel mainPanel = new DockPanel();
 76  
 
 77  
         Label pageTitle = new Label(Application.getApplicationContext().getMessage("orgAppTitle"));
 78  
         pageTitle.setStyleName("page-title");
 79  
         mainPanel.setStyleName("ks-main");
 80  
         mainPanel.add(pageTitle, DockPanel.NORTH);
 81  
 
 82  
 //        mainPanel.add(orgMenu, DockPanel.WEST);
 83  
 //        mainPanel.setCellWidth(orgMenu, "200px");
 84  
         mainPanel.add(content, DockPanel.CENTER);
 85  
 
 86  
 //        mainPanel.add(new KSButton("Logout", new ClickHandler() {
 87  
 //            @Override
 88  
 //            public void onClick(ClickEvent event) {
 89  
 //                orgMenu.saveState();
 90  
 //                Location.assign("http://localhost:18080/cas-server-webapp-3.3.2/login?service="+URL.encodeComponent(Location.getHref()));
 91  
 //            }}), DockPanel.NORTH);
 92  
 
 93  
         return mainPanel;
 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); // magic
 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  
 //        app.setContent(getContent());
 127  0
         ApplicationPanel.get().add(app);
 128  0
         if(manager.getCurrentView() == null)
 129  0
             manager.showDefaultView(Controller.NO_OP_CALLBACK);
 130  0
     }
 131  
 }