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.core.messages.dto.MessageList; |
33 | |
import org.kuali.student.lum.common.client.widgets.AppLocations; |
34 | |
import org.kuali.student.lum.lu.ui.main.client.controllers.ApplicationController; |
35 | |
import org.kuali.student.lum.lu.ui.main.client.theme.LumTheme; |
36 | |
import org.kuali.student.lum.lu.ui.main.client.widgets.ApplicationHeader; |
37 | |
|
38 | |
import com.google.gwt.core.client.EntryPoint; |
39 | |
import com.google.gwt.core.client.GWT; |
40 | |
import com.google.gwt.dom.client.StyleInjector; |
41 | |
import com.google.gwt.user.client.rpc.SerializationException; |
42 | |
import com.google.gwt.user.client.rpc.SerializationStreamFactory; |
43 | |
import com.google.gwt.user.client.rpc.SerializationStreamReader; |
44 | |
|
45 | 0 | public class LUMMainEntryPoint implements EntryPoint{ |
46 | |
|
47 | 0 | private ApplicationController manager = null; |
48 | 0 | private AppLocations locations = new AppLocations(); |
49 | 0 | private ApplicationHeader header = GWT.create(ApplicationHeader.class); |
50 | |
@Override |
51 | |
public void onModuleLoad() { |
52 | 0 | final ApplicationContext context = Application.getApplicationContext(); |
53 | |
|
54 | 0 | final String injectString = LumTheme.INSTANCE.getLumCss().getCssString(); |
55 | 0 | StyleInjector.injectStylesheet(injectString); |
56 | |
|
57 | |
try { |
58 | 0 | loadMessages(context); |
59 | 0 | loadApp(context); |
60 | 0 | } catch (Exception e) { |
61 | 0 | GWT.log("Error loading entrypoint", e); |
62 | 0 | } |
63 | 0 | } |
64 | |
|
65 | |
private void initScreen(){ |
66 | 0 | manager = new ApplicationController("KualiStudent", header); |
67 | 0 | WindowTitleUtils.setApplicationTitle(Application.getApplicationContext().getMessage("applicationName")); |
68 | 0 | ApplicationPanel.get().add(manager); |
69 | 0 | ApplicationPanel.get().add(new KSFooter()); |
70 | 0 | HistoryManager.bind(manager, locations); |
71 | 0 | BreadcrumbManager.bind(manager); |
72 | 0 | HistoryManager.processWindowLocation(); |
73 | 0 | if(manager.getCurrentView() == null) |
74 | 0 | manager.showDefaultView(Controller.NO_OP_CALLBACK); |
75 | 0 | header.setHeaderTitle(Application.getApplicationContext().getMessage("applicationTitleLabel")); |
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 | |
} |