"menuinfo.update", ""));
}
void showPopupMenu(final Action item) {
final AbstractButton btn = (AbstractButton) item
.getValue(ToolBar.ACTION_VALUE);
JPopupMenu popup = null;
if (item == mFilterAction) {
ScrollableMenu menu = new SelectFilterPopup(MainFrame.getInstance());
popup = menu.getPopupMenu();
} else if (item == mGoToDateAction) {
popup = new JPopupMenu();
Date curDate = Date.getCurrentDate().addDays(-1);
if(TvDataBase.getInstance().dataAvailable(curDate)) {
popup.add(createDateMenuItem(curDate));
}
curDate = curDate.addDays(1);
Date maxDate = TvDataBase.getInstance().getMaxSupportedDate();
while (maxDate.getNumberOfDaysSince(curDate) >= 0) {
if(!TvDataBase.getInstance().dataAvailable(curDate)) {
break;
}
if (curDate.isFirstDayOfWeek()) {
popup.addSeparator();
}
popup.add(createDateMenuItem(curDate));
curDate = curDate.addDays(1);
}
} else if (item == mScrollToChannelAction) {
ScrollableMenu menu = new ScrollableMenu();
popup = menu.getPopupMenu();
Channel[] channels = Settings.propSubscribedChannels.getChannelArray();
for (Channel channel : channels) {
menu.add(createChannelMenuItem(channel, btn));
}
} else if (item == mScrollToTimeAction) {
popup = new JPopupMenu();
int[] array = Settings.propTimeButtons.getIntArray();
for (int element : array) {
popup.add(createTimeMenuItem(element, btn));
}
if (popup.getComponentCount() > 0) {
popup.addSeparator();
}
JMenuItem menuItem = new JMenuItem(TVBrowserActions.scrollToNow.getValue(Action.NAME).toString());
menuItem.setHorizontalTextPosition(SwingConstants.CENTER);
menuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
MainFrame.getInstance().scrollToNow();
btn.setSelected(false);
MainFrame.getInstance().updateToolbar();
}
});
popup.add(menuItem);
}
if (popup != null) {
popup.addPopupMenuListener(new PopupMenuListener() {
public void popupMenuCanceled(PopupMenuEvent e) { }
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
AbstractButton button = (AbstractButton) item
.getValue(ToolBar.ACTION_VALUE);
if (item == mFilterAction) {
button.setSelected(!FilterManagerImpl.getInstance().getCurrentFilter().equals(FilterManagerImpl.getInstance().getDefaultFilter()));
setFilterButtonSelected(button.isSelected());
}
if (item == mGoToDateAction) {
button.setSelected(false);
}
MainFrame.getInstance().updateToolbar();
}