Coverage Report - com.buckosoft.fibs.BuckoFIBS.gui.playerList.PlayerListPopupMenu
 
Classes in this File Line Coverage Branch Coverage Complexity
PlayerListPopupMenu
0%
0/88
0%
0/20
1.611
 
 1  
 /******************************************************************************
 2  
  * PlayerListPopupMenu.java - The popup menu for the PlayerList
 3  
  * $Id$
 4  
  * 
 5  
  * BuckoFIBS - Backgammon by BuckoSoft
 6  
  * Copyright© 2009,2010 - Dick Balaska - BuckoSoft, Corp.
 7  
  * 
 8  
  * $Log$
 9  
  * Revision 1.5  2011/01/01 06:12:31  dick
 10  
  * Don't need to keep GroupManager local.
 11  
  *
 12  
  * Revision 1.4  2011/01/01 00:19:08  dick
 13  
  * Build the groups for the submenu.
 14  
  *
 15  
  * Revision 1.3  2010/03/03 13:12:21  inim
 16  
  * Replaced (c) sign in comment mangled by CVS default encoding back to UTF-8
 17  
  *
 18  
  * Revision 1.2  2010/03/03 12:19:49  inim
 19  
  * Moved source to UTF8 encoding from CP1252 encoding. To this end all source files' (c) message was updated to "Copyright© 2009,2010 - Dick Balaska - BuckoSoft, Corp.". This replaces the (c) sign to UTF8, and adds the new year 2010.
 20  
  *
 21  
  * Revision 1.1  2010/02/04 05:57:53  inim
 22  
  * Mavenized project folder layout
 23  
  *
 24  
  * Revision 1.5  2010/01/24 06:21:36  dick
 25  
  * Don't update the playerList if the popupmenu is open, it gets confused.
 26  
  *
 27  
  * Revision 1.4  2010/01/23 06:26:04  dick
 28  
  * Add the RepBot menu.
 29  
  *
 30  
  * Revision 1.3  2009/02/14 15:46:36  dick
 31  
  * BuckoFIBS is released under the GNU license.
 32  
  *
 33  
  * Revision 1.2  2009/02/01 21:28:25  dick
 34  
  * Handle the InvitePopupSubmenu.
 35  
  *
 36  
  * Revision 1.1  2009/01/28 19:39:44  dick
 37  
  * package com.buckosoft.fibs.gui.playerList becomes com.buckosoft.fibs.BuckoFIBS.gui.playerList.
 38  
  *
 39  
  * Revision 1.3  2009/01/24 17:08:03  dick
 40  
  * Javadoc.
 41  
  *
 42  
  * Revision 1.2  2008/12/12 14:46:36  dick
 43  
  * Enable the Watch command.
 44  
  *
 45  
  * Revision 1.1  2008/04/07 08:08:25  dick
 46  
  * The popup menu for the PlayerList.
 47  
  */
 48  
 
 49  
 /* 
 50  
  * This program is free software: you can redistribute it and/or modify
 51  
  * it under the terms of the GNU General Public License as published by
 52  
  * the Free Software Foundation, either version 3 of the License, or
 53  
  * (at your option) any later version.
 54  
  *
 55  
  * This program is distributed in the hope that it will be useful,
 56  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 57  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 58  
  * GNU General Public License for more details.
 59  
  *
 60  
  * You should have received a copy of the GNU General Public License
 61  
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 62  
  *
 63  
  * The Original Code is BuckoFIBS, <http://www.buckosoft.com/BuckoFIBS/>.
 64  
  * The Initial Developer of the Original Code is Dick Balaska and BuckoSoft, Corp.
 65  
  * 
 66  
  */
 67  
 package com.buckosoft.fibs.BuckoFIBS.gui.playerList;
 68  
 
 69  
 import java.awt.event.ActionEvent;
 70  
 import java.awt.event.ActionListener;
 71  
 
 72  
 import javax.swing.JMenuItem;
 73  
 import javax.swing.JPopupMenu;
 74  
 
 75  
 import com.buckosoft.fibs.BuckoFIBS.GroupManager;
 76  
 import com.buckosoft.fibs.BuckoFIBS.gui.playerList.group.GroupPopupSubmenu;
 77  
 import com.buckosoft.fibs.domain.Player;
 78  
 
 79  
 /** The popup menu for the PlayerList.
 80  
  * @author Dick Balaska
 81  
  * @since 2008/04/07
 82  
  * @version $Revision$ <br> $Date$
 83  
  * @see <a href="http://cvs.buckosoft.com/Projects/BuckoFIBS/BuckoFIBS/src/main/java/com/buckosoft/fibs/BuckoFIBS/gui/playerList/PlayerListPopupMenu.java">cvs PlayerListPopupMenu.java</a>
 84  
  */
 85  
 public class PlayerListPopupMenu extends JPopupMenu implements ActionListener {
 86  
         private        final static boolean DEBUG = false;
 87  
         private static final long serialVersionUID = 1L;
 88  
 
 89  0
         private JMenuItem watchMenuItem = null;
 90  0
         private JMenuItem lookMenuItem = null;
 91  0
         private JMenuItem unwatchMenuItem = null;
 92  0
         private JMenuItem whoisMenuItem = null;
 93  0
         private JMenuItem viewProfileMenuItem = null;
 94  0
         private JMenuItem updateMenuItem = null;
 95  0
         private        InvitePopupSubmenu        invitePopupSubmenu = null;
 96  0
         private RepBotPopupSubmenu        repbotPopupSubmenu = null;
 97  0
         private GroupPopupSubmenu        groupPopupSubmenu = null;
 98  
 
 99  0
         private        ActionListener        menuHandler = null;  //  @jve:decl-index=0:
 100  
 
 101  
         private        Player                player;
 102  
         
 103  
         public final static String s_setVisible = "setVisible";
 104  
         /**
 105  
          * This method initializes 
 106  
          * 
 107  
          */
 108  
         public PlayerListPopupMenu() {
 109  0
                 super();
 110  0
                 initialize();
 111  0
         }
 112  
 
 113  
         /**
 114  
          * This method initializes this
 115  
          * 
 116  
          */
 117  
         private void initialize() {
 118  0
                 this.add(getInvitePopupSubmenu());
 119  0
                 this.add(getGroupPopupSubmenu());
 120  0
         this.addSeparator();
 121  0
         this.add(getLookMenuItem());
 122  0
         this.add(getWatchMenuItem());
 123  0
         this.add(getUnwatchMenuItem());
 124  0
         this.addSeparator();
 125  0
                 this.add(getRepBotPopupSubmenu());
 126  0
         this.add(getWhoisMenuItem());
 127  0
         this.add(getViewProfileMenuItem());
 128  0
         this.add(getUpdateMenuItem());
 129  
                         
 130  0
         }
 131  
 
 132  
         /** Set our reference to the object that will receive menu events
 133  
          * @param c The ActionListener object
 134  
          */ 
 135  
         public        void setMenuHandler(ActionListener c) {
 136  0
                 this.menuHandler = c;
 137  0
                 this.getInvitePopupSubmenu().setMenuHandler(c);
 138  0
                 this.getRepBotPopupSubmenu().setMenuHandler(c);
 139  0
         }
 140  
 
 141  
         public void setGroupManager(GroupManager groupManager) {
 142  0
                 this.getGroupPopupSubmenu().setGroupManager(groupManager);
 143  0
         }
 144  
         
 145  
         /** Set the Player who was selected when this menu opened.
 146  
          * @param player The Player selected
 147  
          */
 148  
         public void setPlayer(Player player) {
 149  0
                 this.player = player;
 150  0
         }
 151  
 
 152  
         /** Get the Player who was selected when this menu opened.
 153  
          * @return The Player selected
 154  
          */
 155  
         public Player getPlayer() {
 156  0
                 return(player);
 157  
         }
 158  
 
 159  
         /* (non-Javadoc)
 160  
          * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
 161  
          */
 162  
         public void actionPerformed(ActionEvent e) {
 163  0
                 menuHandler.actionPerformed(e);
 164  0
         }
 165  
 
 166  
         /**
 167  
          * This method initializes watchMenuItem        
 168  
          *         
 169  
          * @return javax.swing.JMenuItem        
 170  
          */
 171  
         private JMenuItem getWatchMenuItem() {
 172  0
                 if (watchMenuItem == null) {
 173  0
                         watchMenuItem = new JMenuItem();
 174  0
                         watchMenuItem.setText("Watch");
 175  0
                         watchMenuItem.addActionListener(this);
 176  
                 }
 177  0
                 return watchMenuItem;
 178  
         }
 179  
 
 180  
         /**
 181  
          * This method initializes lookMenuItem        
 182  
          *         
 183  
          * @return javax.swing.JMenuItem        
 184  
          */
 185  
         private JMenuItem getLookMenuItem() {
 186  0
                 if (lookMenuItem == null) {
 187  0
                         lookMenuItem = new JMenuItem();
 188  0
                         lookMenuItem.setText("Look");
 189  0
                         lookMenuItem.setEnabled(false);
 190  0
                         lookMenuItem.addActionListener(this);
 191  
                 }
 192  0
                 return lookMenuItem;
 193  
         }
 194  
 
 195  
         /**
 196  
          * This method initializes unwatchMenuItem        
 197  
          *         
 198  
          * @return javax.swing.JMenuItem        
 199  
          */
 200  
         private JMenuItem getUnwatchMenuItem() {
 201  0
                 if (unwatchMenuItem == null) {
 202  0
                         unwatchMenuItem = new JMenuItem();
 203  0
                         unwatchMenuItem.setText("Unwatch");
 204  0
                         unwatchMenuItem.setEnabled(false);
 205  0
                         unwatchMenuItem.addActionListener(this);
 206  
                 }
 207  0
                 return unwatchMenuItem;
 208  
         }
 209  
 
 210  
         /**
 211  
          * This method initializes whoisMenuItem        
 212  
          *         
 213  
          * @return javax.swing.JMenuItem        
 214  
          */
 215  
         private JMenuItem getWhoisMenuItem() {
 216  0
                 if (whoisMenuItem == null) {
 217  0
                         whoisMenuItem = new JMenuItem();
 218  0
                         whoisMenuItem.setText("Whois");
 219  0
                         whoisMenuItem.setEnabled(false);
 220  0
                         whoisMenuItem.addActionListener(this);
 221  
                 }
 222  0
                 return whoisMenuItem;
 223  
         }
 224  
 
 225  
         /**
 226  
          * This method initializes viewProfileMenuItem        
 227  
          *         
 228  
          * @return javax.swing.JMenuItem        
 229  
          */
 230  
         private JMenuItem getViewProfileMenuItem() {
 231  0
                 if (viewProfileMenuItem == null) {
 232  0
                         viewProfileMenuItem = new JMenuItem();
 233  0
                         viewProfileMenuItem.setText("View Profile");
 234  0
                         viewProfileMenuItem.setEnabled(false);
 235  0
                         viewProfileMenuItem.addActionListener(this);
 236  
                 }
 237  0
                 return viewProfileMenuItem;
 238  
         }
 239  
 
 240  
         /**
 241  
          * This method initializes updateMenuItem        
 242  
          *         
 243  
          * @return javax.swing.JMenuItem        
 244  
          */
 245  
         private JMenuItem getUpdateMenuItem() {
 246  0
                 if (updateMenuItem == null) {
 247  0
                         updateMenuItem = new JMenuItem();
 248  0
                         updateMenuItem.setText("Update");
 249  0
                         updateMenuItem.setEnabled(true);
 250  0
                         updateMenuItem.addActionListener(this);
 251  
                 }
 252  0
                 return updateMenuItem;
 253  
         }
 254  
 
 255  
         protected        InvitePopupSubmenu        getInvitePopupSubmenu() {
 256  0
                 if (invitePopupSubmenu == null) {
 257  0
                         invitePopupSubmenu = new InvitePopupSubmenu();
 258  0
                         invitePopupSubmenu.addActionListener(this);
 259  
                 }
 260  0
                 return(invitePopupSubmenu);
 261  
         }
 262  
 
 263  
         protected        RepBotPopupSubmenu        getRepBotPopupSubmenu() {
 264  0
                 if (repbotPopupSubmenu == null) {
 265  0
                         repbotPopupSubmenu = new RepBotPopupSubmenu();
 266  0
                         repbotPopupSubmenu.addActionListener(this);
 267  
                 }
 268  0
                 return(repbotPopupSubmenu);
 269  
         }
 270  
 
 271  
         protected GroupPopupSubmenu getGroupPopupSubmenu() {
 272  0
                 if (groupPopupSubmenu == null) {
 273  0
                         groupPopupSubmenu = new GroupPopupSubmenu();
 274  
                 }
 275  0
                 return(groupPopupSubmenu);
 276  
         }
 277  
 
 278  
         /* (non-Javadoc)
 279  
          * @see javax.swing.JPopupMenu#setVisible(boolean)
 280  
          */
 281  
         @Override
 282  
         public void setVisible(boolean arg0) {
 283  0
                 super.setVisible(arg0);
 284  
                 if (DEBUG)
 285  
                         System.out.println("PlayerListPopupMenu: setVisible(" + arg0 + ")");
 286  0
                 ActionEvent ae = new ActionEvent(this, 0, s_setVisible, arg0 ? 1 : 0);
 287  0
                 this.actionPerformed(ae);
 288  0
         }
 289  
 
 290  
         public void rebuildGroups() {
 291  0
                 this.groupPopupSubmenu.repopulate(player);
 292  0
         }
 293  
 }