this.autoRefresh = autoRefresh;
setup();
}
private void setup(){
Menu refreshMenu = new Menu();
refreshMenu.setShowShadow(true);
refreshMenu.setShadowDepth(10);
refreshMenu.setAutoWidth();
refreshMenu.setHeight(15);
com.smartgwt.client.widgets.menu.events.ClickHandler menuClick = new com.smartgwt.client.widgets.menu.events.ClickHandler() {
@Override
public void onClick(MenuItemClickEvent event) {
String selection = event.getItem().getTitle();
refreshInterval = 0;
if (selection != null) {
for (RefreshSelectItemData item : RefreshSelectItemData.values()) {
if (selection.equals(item.getLabel())) {
refreshInterval = item.getTimeSpanInSeconds();
}
}
UserSessionManager.getUserPreferences().setPageRefreshInterval(refreshInterval,
new RefreshCallback());
}
}
};
refreshMenuMappings = new HashMap<Integer, String>();
refreshMenuItems = new MenuItem[RefreshSelectItemData.values().length];
List<MenuItem> menuItemList = new ArrayList<MenuItem>(RefreshSelectItemData.values().length);
int retrievedRefreshInterval = RefreshSelectItemData.refresh1.getTimeSpanInSeconds();
if (null != UserSessionManager.getUserPreferences()) {
retrievedRefreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval();
}
for (RefreshSelectItemData item : RefreshSelectItemData.values()) {
MenuItem menuItem = new MenuItem(item.getLabel(), "");
menuItem.addClickHandler(menuClick);
refreshMenuMappings.put(item.getTimeSpanInSeconds(), item.getLabel());
if (retrievedRefreshInterval == item.getTimeSpanInSeconds()) {
menuItem.setIcon(ImageManager.getAvailabilityIcon(true));
}
menuItemList.add(menuItem);
}
refreshMenuItems = menuItemList.toArray(new MenuItem[menuItemList.size()]);
refreshMenu.setItems(refreshMenuItems);
setMenu(refreshMenu);
refreshMenu.setAutoHeight();
setTitle(MSG.common_title_refreshInterval());
setWidth(140);
setShowTitle(true);
setTop(0);
setIconOrientation("left");