MenuItem menuItem = new MenuItem(portletName);
menuItem.setAttribute("portletKey", portletKey);
addPortletMenu.addItem(menuItem);
}
addPortlet = new IMenuButton(MSG.common_title_add_portlet(), addPortletMenu);
addPortlet.setIcon("[skin]/images/actions/add.png");
addPortlet.setAutoFit(true);
addPortletMenu.addItemClickHandler(new ItemClickHandler() {
public void onItemClick(ItemClickEvent itemClickEvent) {
String key = itemClickEvent.getItem().getAttribute("portletKey");
String name = itemClickEvent.getItem().getTitle();
try {
addPortlet(key, name);
} catch (Exception ex) {
CoreGUI.getErrorHandler().handleError(MSG.view_dashboardsManager_error3(), ex);
}
}
});
CanvasItem addCanvas = new CanvasItem();
addCanvas.setShowTitle(false);
addCanvas.setCanvas(addPortlet);
addCanvas.setStartRow(false);
addCanvas.setEndRow(false);
ColorButtonItem picker = new ColorButtonItem("colorButton", MSG.common_title_background());
picker.setStartRow(false);
picker.setEndRow(false);
picker.setCurrentColor(storedDashboard.getConfiguration().getSimpleValue(Dashboard.CFG_BACKGROUND, "transparent"));
picker.setColorSelectedHandler(new ColorSelectedHandler() {
@Override
public void onColorSelected(ColorSelectedEvent event) {
String selectedColor = event.getColor();
if (selectedColor != null) {
setBackgroundColor(selectedColor);
storedDashboard.getConfiguration().put(new PropertySimple(Dashboard.CFG_BACKGROUND, selectedColor));
save();
}
}
});
//refresh interval
Menu refreshMenu = new Menu();
refreshMenu.setShowShadow(true);
refreshMenu.setShadowDepth(10);
refreshMenu.setAutoWidth();
refreshMenu.setHeight(15);
ClickHandler menuClick = new ClickHandler() {
@Override
public void onClick(MenuItemClickEvent event) {
String selection = event.getItem().getTitle();
refreshInterval = 0;
if (selection != null) {
if (selection.equals(STOP)) {
refreshInterval = STOP_VALUE;
} else if (selection.equals(REFRESH1)) {
refreshInterval = REFRESH1_VALUE;
} else if (selection.equals(REFRESH5)) {
refreshInterval = REFRESH5_VALUE;
} else if (selection.equals(REFRESH10)) {
refreshInterval = REFRESH10_VALUE;
} else {//unable to locate value disable refresh
refreshInterval = STOP_VALUE;//
}
UserSessionManager.getUserPreferences().setPageRefreshInterval(refreshInterval,
new UpdatePortletRefreshCallback());
}
}
};
String[] refreshIntervals = { STOP, REFRESH1, REFRESH5, REFRESH10 };
Integer[] refreshValues = { STOP_VALUE, REFRESH1_VALUE, REFRESH5_VALUE, REFRESH10_VALUE };
refreshMenuMappings = new HashMap<Integer, String>();
refreshMenuItems = new MenuItem[refreshIntervals.length];
int retrievedRefreshInterval = REFRESH1_VALUE;
if (null != UserSessionManager.getUserPreferences()) {
retrievedRefreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval();
}
for (int i = 0; i < refreshIntervals.length; i++) {
MenuItem item = new MenuItem(refreshIntervals[i], "");
item.addClickHandler(menuClick);
refreshMenuMappings.put(refreshValues[i], refreshIntervals[i]);
if (retrievedRefreshInterval == refreshValues[i]) {
item.setIcon(ImageManager.getAvailabilityIcon(true));
}
refreshMenuItems[i] = item;
}
refreshMenu.setItems(refreshMenuItems);
refreshMenuButton = new IMenuButton(MSG.common_title_refreshInterval(), refreshMenu);
refreshMenu.setAutoHeight();
refreshMenuButton.getMenu().setItems(refreshMenuItems);
refreshMenuButton.setWidth(140);
refreshMenuButton.setShowTitle(true);
refreshMenuButton.setTop(0);