File tree Expand file tree Collapse file tree
src/java/gov/anl/aps/logr/portal/plugins Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -110,6 +110,17 @@ public void loadInfoActionForPropertyValue(PropertyValue propertyValue) {
110110 }
111111 }
112112
113+ public List <Object > getAllMenuBarItems () {
114+ List <Object > allItems = new ArrayList <>();
115+ for (PluginManagerBase pluginManager : pluginManagerSet ) {
116+ List <?> items = pluginManager .getMenuBarItems ();
117+ if (items != null && !items .isEmpty ()) {
118+ allItems .addAll (items );
119+ }
120+ }
121+ return allItems ;
122+ }
123+
113124 public PluginManagerBase getPluginManagerByName (String pluginName ) {
114125 for (PluginManagerBase pluginManager : pluginManagerSet ) {
115126 if (pluginManager .getPluginName ().equals (pluginName )) {
Original file line number Diff line number Diff line change 88import gov .anl .aps .logr .portal .model .jsf .handlers .PropertyTypeHandlerInterface ;
99import gov .anl .aps .logr .portal .utilities .ConfigurationUtility ;
1010import gov .anl .aps .logr .portal .utilities .SessionUtility ;
11+ import java .util .Collections ;
12+ import java .util .List ;
1113import java .util .Properties ;
1214
1315/**
@@ -97,8 +99,17 @@ public static Properties getDefaultPropertiesForPlugin(String pluginName) {
9799 }
98100
99101 /**
100- * Override to display an extras tab for configuration on the multi edit screen.
101- *
102+ * Override to provide menu bar items from a plugin.
103+ *
104+ * @return list of menu bar item objects, empty list by default
105+ */
106+ public List <?> getMenuBarItems () {
107+ return Collections .emptyList ();
108+ }
109+
110+ /**
111+ * Override to display an extras tab for configuration on the multi edit screen.
112+ *
102113 * @return display the extra tab when true
103114 */
104115 public boolean pluginHasCatalogMultiEditExtras () {
Original file line number Diff line number Diff line change @@ -56,7 +56,6 @@ See LICENSE file.
5656 </ c:forEach >
5757 </ p:submenu >
5858
59-
6059 < f:facet name ="options ">
6160 < p:menubar styleClass ="menuBarSupportingItems ">
6261
@@ -79,8 +78,27 @@ See LICENSE file.
7978 value ="Advanced Search "
8079 update ="@form "
8180 styleClass ="onlyIconMenuItem "
82- action ="#{searchController.performInputBoxSearchAdvamced()} " />
83-
81+ action ="#{searchController.performInputBoxSearchAdvamced()} " />
82+
83+ < c:forEach items ="#{cdbPluginManager.allMenuBarItems} " var ="pluginMenuItem ">
84+ < c:if test ="#{!pluginMenuItem.hasChildren} ">
85+ < p:menuitem value ="#{pluginMenuItem.text} "
86+ icon ="#{pluginMenuItem.icon} "
87+ url ="#{pluginMenuItem.href} "
88+ target ="_blank "/>
89+ </ c:if >
90+ < c:if test ="#{pluginMenuItem.hasChildren} ">
91+ < p:submenu label ="#{pluginMenuItem.text} "
92+ icon ="#{pluginMenuItem.icon} ">
93+ < c:forEach items ="#{pluginMenuItem.children} " var ="childItem ">
94+ < p:menuitem value ="#{childItem.text} "
95+ icon ="#{childItem.icon} "
96+ url ="#{childItem.href} "
97+ target ="_blank "/>
98+ </ c:forEach >
99+ </ p:submenu >
100+ </ c:if >
101+ </ c:forEach >
84102
85103 < ui:include src ="portalViewSupplementalMenubar.xhtml "/>
86104 < p:menuitem value ="Login " id ="loginButton " onclick ="PF('loginDialogWidget').show() " rendered ="#{!loginController.loggedIn} " icon ="fa fa-sign-in "/>
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (c) UChicago Argonne, LLC. All rights reserved.
3+ * See LICENSE file.
4+ */
5+ package gov .anl .aps .logr .portal .plugins .support .menuBarLinks ;
6+
7+ import java .util .List ;
8+
9+ public class MenuBarItemObject {
10+
11+ private String icon ;
12+ private String text ;
13+ private String href ;
14+ private List <MenuBarItemObject > children ;
15+
16+ public MenuBarItemObject () {
17+ }
18+
19+ public String getIcon () {
20+ return icon ;
21+ }
22+
23+ public void setIcon (String icon ) {
24+ this .icon = icon ;
25+ }
26+
27+ public String getText () {
28+ return text ;
29+ }
30+
31+ public void setText (String text ) {
32+ this .text = text ;
33+ }
34+
35+ public String getHref () {
36+ return href ;
37+ }
38+
39+ public void setHref (String href ) {
40+ this .href = href ;
41+ }
42+
43+ public List <MenuBarItemObject > getChildren () {
44+ return children ;
45+ }
46+
47+ public void setChildren (List <MenuBarItemObject > children ) {
48+ this .children = children ;
49+ }
50+
51+ public boolean getHasChildren () {
52+ return children != null && !children .isEmpty ();
53+ }
54+
55+ }
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (c) UChicago Argonne, LLC. All rights reserved.
3+ * See LICENSE file.
4+ */
5+ package gov .anl .aps .logr .portal .plugins .support .menuBarLinks ;
6+
7+ import com .google .gson .Gson ;
8+ import com .google .gson .GsonBuilder ;
9+ import com .google .gson .reflect .TypeToken ;
10+ import gov .anl .aps .logr .portal .plugins .PluginManagerBase ;
11+ import java .lang .reflect .Type ;
12+ import java .util .LinkedList ;
13+ import java .util .List ;
14+ import java .util .Properties ;
15+
16+ public class MenuBarLinksPluginManager extends PluginManagerBase {
17+
18+ private static final Properties MENU_BAR_LINKS_PROPERTIES = getDefaultPropertiesForPlugin ("menuBarLinks" );
19+
20+ private static final String MENU_ITEMS_KEY = "menuItems" ;
21+
22+ private static List <MenuBarItemObject > MENU_BAR_ITEMS ;
23+
24+ public String getMenuItemsJsonTextProperty () {
25+ return MENU_BAR_LINKS_PROPERTIES .getProperty (MENU_ITEMS_KEY , "" );
26+ }
27+
28+ private void loadMenuBarItems () {
29+ Type resultType = new TypeToken <LinkedList <MenuBarItemObject >>() {}.getType ();
30+ String json = getMenuItemsJsonTextProperty ();
31+
32+ Gson gson = new GsonBuilder ().create ();
33+ MENU_BAR_ITEMS = gson .fromJson (json , resultType );
34+ }
35+
36+ @ Override
37+ public List <?> getMenuBarItems () {
38+ if (MENU_BAR_ITEMS == null ) {
39+ loadMenuBarItems ();
40+ }
41+ return MENU_BAR_ITEMS ;
42+ }
43+
44+ }
Original file line number Diff line number Diff line change 1+ # JSON array of menu bar items [{ icon, text, href, children (optional) }]
2+ menuItems =[{"icon": "fa fa-external-link", "text": "Example App", "href": "https://example.com"}]
You can’t perform that action at this time.
0 commit comments