@Subscribe public void changeShotcutStyle(ChangeShotCutEvent event) { for (ShotcutSection section : shotcutPanelList) { for (NativeButton shotcutBtn : section.getShotcuts()) { ShotcutItem shotcut = (ShotcutItem) shotcutBtn.getData(); if (event.getAction().equals(shotcut.getAction())) { shotcutBtn.addStyleName("v-nativebutton-selected"); } else { shotcutBtn.removeStyleName("v-nativebutton-selected"); } } } }
@Override public void buttonClick(ClickEvent event) { Button btn = event.getButton(); ShotcutItem item = (ShotcutItem) btn.getData(); String action = item.getAction(); if (SystemProperty.PAGE_TYPE.equals(item.getType())) { PageChangeEvent pageChangeEvent = new PageChangeEvent(action); eventBus.post(pageChangeEvent); } else { ContentChangeEvent changeEvent = new ContentChangeEvent(); changeEvent.setPresenterName(action); eventBus.post(changeEvent); } // change the head menu to home page. changeToHomeMenuStyle(); // change shotcut menu style. changeShotCutStyle(action); }
public NativeButton createNativeButton(ShotcutItem item) { NativeButton itemButton = new NativeButton(message.getString(item.getLabel())); itemButton.setHtmlContentAllowed(true); itemButton.setWidth("100%"); String icon = item.getIcon(); if (icon != null) { itemButton.setIcon(new ThemeResource(icon)); } itemButton.setData(item); itemButton.addListener(this); if (PresenterProperty.HOME.equals(item.getAction())) { itemButton.addStyleName("v-nativebutton-selected"); } if (PresenterProperty.NOTIFICATION.equals(item.getAction())) { notifyButton = itemButton; } shotcuts.add(itemButton); shotcutMaps.put(item.getAction(), itemButton); return itemButton; }
public void setShotcutLabel(String action, int number) { NativeButton itemButton = shotcutMaps.get(action); if (itemButton != null) { ShotcutItem item = (ShotcutItem) itemButton.getData(); if (item.getNumber() != number) { if (number == 0) { itemButton.setCaption(message.getString(item.getLabel())); item.setNumber(Long.valueOf(number)); } else { itemButton.setCaption( message.getString(item.getLabel()) + " <span style=\"" + InnerStyle.notify_Number + "\">" + number + "</span>"); item.setNumber(Long.valueOf(number)); } } } }