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.ui.client.application.Application; |
20 | |
import org.kuali.student.common.ui.client.application.ApplicationContext; |
21 | |
import org.kuali.student.common.ui.client.application.KSAsyncCallback; |
22 | |
import org.kuali.student.common.ui.client.mvc.Controller; |
23 | |
import org.kuali.student.common.ui.client.mvc.breadcrumb.BreadcrumbManager; |
24 | |
import org.kuali.student.common.ui.client.mvc.history.HistoryManager; |
25 | |
import org.kuali.student.common.ui.client.service.MessagesRpcService; |
26 | |
import org.kuali.student.common.ui.client.service.SecurityRpcService; |
27 | |
import org.kuali.student.common.ui.client.service.SecurityRpcServiceAsync; |
28 | |
import org.kuali.student.common.ui.client.util.BrowserUtils; |
29 | |
import org.kuali.student.common.ui.client.util.WindowTitleUtils; |
30 | |
import org.kuali.student.common.ui.client.widgets.ApplicationPanel; |
31 | |
import org.kuali.student.common.ui.client.widgets.KSFooter; |
32 | |
import org.kuali.student.common.ui.client.widgets.headers.KSHeader; |
33 | |
import org.kuali.student.core.messages.dto.MessageList; |
34 | |
import org.kuali.student.lum.common.client.widgets.AppLocations; |
35 | |
import org.kuali.student.lum.lu.ui.main.client.controllers.ApplicationController; |
36 | |
import org.kuali.student.lum.lu.ui.main.client.theme.LumTheme; |
37 | |
import org.kuali.student.lum.lu.ui.main.client.widgets.ApplicationHeader; |
38 | |
|
39 | |
import com.google.gwt.core.client.EntryPoint; |
40 | |
import com.google.gwt.core.client.GWT; |
41 | |
import com.google.gwt.dom.client.StyleInjector; |
42 | |
import com.google.gwt.user.client.rpc.SerializationException; |
43 | |
import com.google.gwt.user.client.rpc.SerializationStreamFactory; |
44 | |
import com.google.gwt.user.client.rpc.SerializationStreamReader; |
45 | |
|
46 | 0 | public class LUMMainEntryPoint implements EntryPoint{ |
47 | |
|
48 | 0 | private ApplicationController manager = null; |
49 | 0 | private AppLocations locations = new AppLocations(); |
50 | 0 | private ApplicationHeader header = GWT.create(ApplicationHeader.class); |
51 | |
@Override |
52 | |
public void onModuleLoad() { |
53 | 0 | final ApplicationContext context = Application.getApplicationContext(); |
54 | |
|
55 | 0 | final String injectString = LumTheme.INSTANCE.getLumCss().getCssString(); |
56 | 0 | StyleInjector.injectStylesheet(injectString); |
57 | |
|
58 | |
try { |
59 | 0 | loadMessages(context); |
60 | 0 | loadApp(context); |
61 | 0 | } catch (Exception e) { |
62 | 0 | GWT.log("Error loading entrypoint", e); |
63 | 0 | } |
64 | 0 | } |
65 | |
|
66 | |
private void initScreen(){ |
67 | 0 | manager = new ApplicationController("KualiStudent", header); |
68 | 0 | WindowTitleUtils.setApplicationTitle(Application.getApplicationContext().getMessage("applicationName")); |
69 | 0 | ApplicationPanel.get().add(manager); |
70 | 0 | ApplicationPanel.get().add(new KSFooter()); |
71 | 0 | HistoryManager.bind(manager, locations); |
72 | 0 | BreadcrumbManager.bind(manager); |
73 | 0 | HistoryManager.processWindowLocation(); |
74 | 0 | if(manager.getCurrentView() == null) |
75 | 0 | manager.showDefaultView(Controller.NO_OP_CALLBACK); |
76 | 0 | } |
77 | |
|
78 | |
private void loadMessages(final ApplicationContext context) throws SerializationException { |
79 | 0 | MessageList commonMessageList = getMsgSerializedObject("commonMessages" ); |
80 | 0 | MessageList lumMessageList = getMsgSerializedObject("luMessages" ); |
81 | 0 | context.addMessages(commonMessageList.getMessages()); |
82 | 0 | context.addMessages(lumMessageList.getMessages()); |
83 | 0 | } |
84 | |
|
85 | |
@SuppressWarnings("unchecked") |
86 | |
public <T> T getMsgSerializedObject(String key ) throws SerializationException |
87 | |
{ |
88 | 0 | String serialized = BrowserUtils.getString( key ); |
89 | 0 | SerializationStreamFactory ssf = GWT.create( MessagesRpcService.class); |
90 | 0 | SerializationStreamReader ssr = ssf.createStreamReader( serialized ); |
91 | 0 | T ret = (T)ssr.readObject(); |
92 | 0 | return ret; |
93 | |
} |
94 | |
|
95 | |
public void loadApp(final ApplicationContext context){ |
96 | 0 | SecurityRpcServiceAsync securityRpc = GWT.create(SecurityRpcService.class); |
97 | |
|
98 | 0 | securityRpc.getPrincipalUsername(new KSAsyncCallback<String>(){ |
99 | |
public void handleFailure(Throwable caught) { |
100 | 0 | context.setUserId("Unknown"); |
101 | 0 | initScreen(); |
102 | 0 | } |
103 | |
|
104 | |
@Override |
105 | |
public void onSuccess(String principalId) { |
106 | 0 | context.setUserId(principalId); |
107 | 0 | initScreen(); |
108 | 0 | } |
109 | |
}); |
110 | 0 | } |
111 | |
|
112 | |
} |