1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.portalsite.menu;
18
19 import java.util.Locale;
20 import java.util.MissingResourceException;
21 import java.util.ResourceBundle;
22
23 import org.apache.jetspeed.om.folder.Folder;
24 import org.apache.jetspeed.om.folder.impl.StandardMenuDefinitionImpl;
25 import org.apache.jetspeed.portalsite.view.SiteView;
26
27 /***
28 * This class provides a menu definition for the standard
29 * back menu.
30 *
31 * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
32 * @version $Id: StandardBackMenuDefinition.java 516448 2007-03-09 16:25:47Z ate $
33 */
34 public class StandardBackMenuDefinition extends StandardMenuDefinitionImpl
35 {
36 /***
37 * StandardBackMenuDefinition - constructor
38 */
39 public StandardBackMenuDefinition()
40 {
41 super();
42 }
43
44 /***
45 * getName - get menu name
46 *
47 * @return menu name
48 */
49 public String getName()
50 {
51 return SiteView.STANDARD_BACK_MENU_NAME;
52 }
53
54 /***
55 * getOptions - get comma separated menu options if not specified as elements
56 *
57 * @return option paths specification
58 */
59 public String getOptions()
60 {
61
62 return ".." + Folder.PATH_SEPARATOR;
63 }
64
65 /***
66 * getSkin - get skin name for menu element
67 *
68 * @return skin name
69 */
70 public String getSkin()
71 {
72 return "breadcrumbs";
73 }
74
75 /***
76 * getTitle - get default title for menu
77 *
78 * @return title text
79 */
80 public String getTitle()
81 {
82
83 return getMenuTitleText(null, getTitleResourceKey());
84 }
85
86 /***
87 * getTitle - get locale specific title for menu from metadata
88 * protocol, with or without falback enabled
89 *
90 * @param locale preferred locale
91 * @param fallback whether to return default title
92 * @return title text
93 */
94 protected String getTitle(Locale locale, boolean fallback)
95 {
96
97 String title = getMenuTitleText(locale, getTitleResourceKey());
98 if (title != null)
99 {
100 return title;
101 }
102 return super.getTitle(locale, fallback);
103 }
104
105 /***
106 * getTitleResourceKey - get resource key used to lookup menu titles
107 *
108 * @return resource key
109 */
110 protected String getTitleResourceKey()
111 {
112 return "menu.title.back";
113 }
114
115 /***
116 * getMenuTitleText - lookup resource bundle based on locale
117 * and use to extract menu title text
118 *
119 * @param locale preferred locale
120 * @param key message key for text
121 */
122 protected String getMenuTitleText(Locale locale, String key)
123 {
124 try
125 {
126
127 ResourceBundle bundle = null;
128 if (locale != null)
129 {
130 bundle = ResourceBundle.getBundle("org.apache.jetspeed.portalsite.menu.resources.MenuTitles",locale);
131 }
132 else
133 {
134 bundle = ResourceBundle.getBundle("org.apache.jetspeed.portalsite.menu.resources.MenuTitles");
135 }
136
137
138 return bundle.getString(key);
139 }
140 catch (MissingResourceException mre)
141 {
142 }
143 return null;
144 }
145 }