1 /* 2 * aTunes 3 * Copyright (C) Alex Aranda, Sylvain Gaudard and contributors 4 * 5 * See http://www.atunes.org/wiki/index.php?title=Contributing for information about contributors 6 * 7 * http://www.atunes.org 8 * http://sourceforge.net/projects/atunes 9 * 10 * This program is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU General Public License 12 * as published by the Free Software Foundation; either version 2 13 * of the License, or (at your option) any later version. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 */ 20 21 package net.sourceforge.atunes.gui.views.menus; 22 23 import javax.swing.JPopupMenu; 24 import javax.swing.event.PopupMenuEvent; 25 import javax.swing.event.PopupMenuListener; 26 27 import net.sourceforge.atunes.model.IBeanFactory; 28 import net.sourceforge.atunes.model.IControlsBuilder; 29 30 /** 31 * Play list popup menu 32 * 33 * @author alex 34 * 35 */ 36 public class PlayListPopupMenu extends JPopupMenu { 37 38 private static final long serialVersionUID = -3624790857729577320L; 39 40 private IBeanFactory beanFactory; 41 42 /** 43 * @param beanFactory 44 */ setBeanFactory(final IBeanFactory beanFactory)45 public void setBeanFactory(final IBeanFactory beanFactory) { 46 this.beanFactory = beanFactory; 47 } 48 49 /** 50 * Initializes menu 51 */ initialize()52 public void initialize() { 53 this.beanFactory.getBean(PlayListMenuFiller.class).fillPopUpMenu(this); 54 this.beanFactory.getBean(IControlsBuilder.class) 55 .applyComponentOrientation(this); 56 addPopupMenuListener(new PopupMenuListener() { 57 58 @Override 59 public void popupMenuWillBecomeVisible(PopupMenuEvent e) { 60 PlayListPopupMenu.this.beanFactory.getBean( 61 PlayListMenuFiller.class).updatePlayListMenuItems(); 62 } 63 64 @Override 65 public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { 66 } 67 68 @Override 69 public void popupMenuCanceled(PopupMenuEvent e) { 70 } 71 }); 72 } 73 } 74