1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.student.lum.lu.ui.main.client;
17
18
19
20 import org.kuali.student.common.ui.client.application.Application;
21 import org.kuali.student.common.ui.client.application.ApplicationContext;
22 import org.kuali.student.common.ui.client.mvc.Callback;
23 import org.kuali.student.common.ui.client.mvc.Controller;
24 import org.kuali.student.common.ui.client.mvc.breadcrumb.BreadcrumbManager;
25 import org.kuali.student.common.ui.client.mvc.history.HistoryManager;
26 import org.kuali.student.common.ui.client.service.MessagesRpcService;
27 import org.kuali.student.common.ui.client.util.BrowserUtils;
28 import org.kuali.student.common.ui.client.util.WindowTitleUtils;
29 import org.kuali.student.common.ui.client.widgets.ApplicationPanel;
30 import org.kuali.student.common.ui.client.widgets.KSFooter;
31 import org.kuali.student.lum.common.client.widgets.AppLocations;
32 import org.kuali.student.lum.lu.ui.main.client.controllers.ApplicationController;
33 import org.kuali.student.lum.lu.ui.main.client.theme.LumTheme;
34 import org.kuali.student.lum.lu.ui.main.client.widgets.ApplicationHeader;
35
36 import com.google.gwt.core.client.EntryPoint;
37 import com.google.gwt.core.client.GWT;
38 import com.google.gwt.dom.client.StyleInjector;
39 import com.google.gwt.user.client.rpc.SerializationException;
40 import com.google.gwt.user.client.rpc.SerializationStreamFactory;
41 import com.google.gwt.user.client.rpc.SerializationStreamReader;
42 import java.util.ArrayList;
43 import org.kuali.student.r2.common.messages.dto.MessageInfo;
44
45 public class LUMMainEntryPoint implements EntryPoint{
46
47 private ApplicationController manager = null;
48 private AppLocations locations = new AppLocations();
49 private ApplicationHeader header = GWT.create(ApplicationHeader.class);
50 @Override
51 public void onModuleLoad() {
52 final ApplicationContext context = Application.getApplicationContext();
53
54 final String injectString = LumTheme.INSTANCE.getLumCss().getCssString();
55 StyleInjector.injectStylesheet(injectString);
56
57 try {
58 loadMessages(context);
59 loadApp(context);
60 } catch (Exception e) {
61 GWT.log("Error loading entrypoint", e);
62 }
63 }
64
65 private void initScreen(){
66 manager = new ApplicationController("KualiStudent", header);
67 WindowTitleUtils.setApplicationTitle(Application.getApplicationContext().getMessage("applicationName"));
68 ApplicationPanel.get().add(manager);
69 ApplicationPanel.get().add(new KSFooter());
70 HistoryManager.bind(manager, locations);
71 BreadcrumbManager.bind(manager);
72 HistoryManager.processWindowLocation();
73 if(manager.getCurrentView() == null)
74 manager.showDefaultView(Controller.NO_OP_CALLBACK);
75 header.setHeaderTitle(Application.getApplicationContext().getMessage("applicationTitleLabel"));
76 }
77
78 private void loadMessages(final ApplicationContext context) throws SerializationException {
79 ArrayList<MessageInfo> commonMessageList = getMsgSerializedObject("commonMessages" );
80 ArrayList<MessageInfo> luMessageList = getMsgSerializedObject("luMessages" );
81
82 context.addMessages(commonMessageList);
83 context.addMessages(luMessageList);
84 }
85
86 @SuppressWarnings("unchecked")
87 public <T> T getMsgSerializedObject(String key ) throws SerializationException
88 {
89 String serialized = BrowserUtils.getString( key );
90 SerializationStreamFactory ssf = GWT.create( MessagesRpcService.class);
91 SerializationStreamReader ssr = ssf.createStreamReader( serialized );
92 T ret = (T)ssr.readObject();
93 return ret;
94 }
95
96 public void loadApp(final ApplicationContext context){
97 context.initializeContext(new Callback<Boolean>(){
98 @Override
99 public void exec(Boolean result) {
100 initScreen();
101 }
102 });
103 }
104
105 }