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 | |
import org.kuali.student.common.messages.dto.MessageList; |
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 | |
|
43 | 0 | public class LUMMainEntryPoint implements EntryPoint{ |
44 | |
|
45 | 0 | private ApplicationController manager = null; |
46 | 0 | private AppLocations locations = new AppLocations(); |
47 | 0 | private ApplicationHeader header = GWT.create(ApplicationHeader.class); |
48 | |
@Override |
49 | |
public void onModuleLoad() { |
50 | 0 | final ApplicationContext context = Application.getApplicationContext(); |
51 | |
|
52 | 0 | final String injectString = LumTheme.INSTANCE.getLumCss().getCssString(); |
53 | 0 | StyleInjector.injectStylesheet(injectString); |
54 | |
|
55 | |
try { |
56 | 0 | loadMessages(context); |
57 | 0 | loadApp(context); |
58 | 0 | } catch (Exception e) { |
59 | 0 | GWT.log("Error loading entrypoint", e); |
60 | 0 | } |
61 | 0 | } |
62 | |
|
63 | |
private void initScreen(){ |
64 | 0 | manager = new ApplicationController("KualiStudent", header); |
65 | 0 | WindowTitleUtils.setApplicationTitle(Application.getApplicationContext().getMessage("applicationName")); |
66 | 0 | ApplicationPanel.get().add(manager); |
67 | 0 | ApplicationPanel.get().add(new KSFooter()); |
68 | 0 | HistoryManager.bind(manager, locations); |
69 | 0 | BreadcrumbManager.bind(manager); |
70 | 0 | HistoryManager.processWindowLocation(); |
71 | 0 | if(manager.getCurrentView() == null) |
72 | 0 | manager.showDefaultView(Controller.NO_OP_CALLBACK); |
73 | 0 | header.setHeaderTitle(Application.getApplicationContext().getMessage("applicationTitleLabel")); |
74 | 0 | } |
75 | |
|
76 | |
private void loadMessages(final ApplicationContext context) throws SerializationException { |
77 | 0 | MessageList commonMessageList = getMsgSerializedObject("commonMessages" ); |
78 | 0 | MessageList lumMessageList = getMsgSerializedObject("luMessages" ); |
79 | 0 | context.addMessages(commonMessageList.getMessages()); |
80 | 0 | context.addMessages(lumMessageList.getMessages()); |
81 | 0 | } |
82 | |
|
83 | |
@SuppressWarnings("unchecked") |
84 | |
public <T> T getMsgSerializedObject(String key ) throws SerializationException |
85 | |
{ |
86 | 0 | String serialized = BrowserUtils.getString( key ); |
87 | 0 | SerializationStreamFactory ssf = GWT.create( MessagesRpcService.class); |
88 | 0 | SerializationStreamReader ssr = ssf.createStreamReader( serialized ); |
89 | 0 | T ret = (T)ssr.readObject(); |
90 | 0 | return ret; |
91 | |
} |
92 | |
|
93 | |
public void loadApp(final ApplicationContext context){ |
94 | 0 | context.initializeContext(new Callback<Boolean>(){ |
95 | |
@Override |
96 | |
public void exec(Boolean result) { |
97 | 0 | initScreen(); |
98 | 0 | } |
99 | |
}); |
100 | 0 | } |
101 | |
|
102 | |
} |