1 | |
package org.kuali.student.common.ui.client.util; |
2 | |
|
3 | |
import com.google.gwt.user.client.Window; |
4 | |
|
5 | 0 | public class WindowTitleUtils { |
6 | |
|
7 | 0 | private static String contextTitle = ""; |
8 | 0 | private static String appTitle = ""; |
9 | 0 | private static String subTitle = ""; |
10 | |
|
11 | |
public static void setApplicationTitle(String title){ |
12 | 0 | appTitle = title; |
13 | 0 | contextTitle = ""; |
14 | 0 | subTitle = ""; |
15 | 0 | Window.setTitle(generateWindowTitle()); |
16 | 0 | } |
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
public static void setContextTitle(String title){ |
23 | 0 | contextTitle = title; |
24 | 0 | subTitle = ""; |
25 | 0 | Window.setTitle(generateWindowTitle()); |
26 | 0 | } |
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
public static void setSubtitle(String title){ |
32 | 0 | subTitle = title; |
33 | 0 | Window.setTitle(generateWindowTitle()); |
34 | 0 | } |
35 | |
|
36 | |
private static String generateWindowTitle(){ |
37 | 0 | String title = null; |
38 | 0 | if(appTitle != null && !appTitle.equals("")){ |
39 | 0 | title = appTitle; |
40 | |
} |
41 | |
|
42 | 0 | if(contextTitle != null && !contextTitle.equals("")){ |
43 | 0 | if(title != null){ |
44 | 0 | if(!contextTitle.equals(appTitle)){ |
45 | 0 | title = title + ": " + contextTitle; |
46 | |
} |
47 | |
} |
48 | |
else{ |
49 | 0 | title = contextTitle; |
50 | |
} |
51 | |
} |
52 | |
|
53 | 0 | if(subTitle != null && !subTitle.equals("")){ |
54 | 0 | if(title != null){ |
55 | 0 | if(!subTitle.equals(contextTitle)){ |
56 | 0 | title = title + " - " + subTitle; |
57 | |
} |
58 | |
} |
59 | |
else{ |
60 | 0 | title = subTitle; |
61 | |
} |
62 | |
} |
63 | |
|
64 | 0 | if(title == null){ |
65 | 0 | title = "KS"; |
66 | |
} |
67 | |
|
68 | 0 | return title; |
69 | |
} |
70 | |
} |