Coverage Report - wjhk.jupload2.gui.JUploadMainPopupMenu
 
Classes in this File Line Coverage Branch Coverage Complexity
JUploadMainPopupMenu
100 %
11/11
N/A
1
 
 1  
 package wjhk.jupload2.gui;
 2  
 
 3  
 import java.awt.event.ActionEvent;
 4  
 import java.awt.event.KeyEvent;
 5  
 
 6  
 import javax.swing.Action;
 7  
 import javax.swing.JMenuItem;
 8  
 import javax.swing.JPopupMenu;
 9  
 import javax.swing.KeyStroke;
 10  
 import javax.swing.TransferHandler;
 11  
 
 12  
 import wjhk.jupload2.policies.UploadPolicy;
 13  
 
 14  
 /**
 15  
  * The main contextual menu of the applet. It contains currently, only the paste
 16  
  * action.
 17  
  * 
 18  
  * @author etienne_sf
 19  
  */
 20  
 public class JUploadMainPopupMenu extends JPopupMenu {
 21  
 
 22  
     /** A generated serialVersionUID, to avoid warning during compilation */
 23  
     private static final long serialVersionUID = 4204344561680290852L;
 24  
 
 25  
     /**
 26  
      * The current upload policy.
 27  
      */
 28  
     private UploadPolicy uploadPolicy;
 29  
 
 30  
     /**
 31  
      * The current upload panel. Can't be retrieve by
 32  
      * uploadPolicy.getAppel().getUploadPanel(), as the menu is cosntructed from
 33  
      * JUploadPanel constructor. That is: the applet did not get the
 34  
      * JUploadPanel reference (getUploadPanel returns null);
 35  
      */
 36  
     @SuppressWarnings("unused")
 37  
     private JUploadPanel uploadPanel;
 38  
 
 39  33
     JUploadMainPopupMenu(UploadPolicy uploadPolicy, JUploadPanel uploadPanel) {
 40  33
         this.uploadPolicy = uploadPolicy;
 41  33
         this.uploadPanel = uploadPanel;
 42  
 
 43  
         // ////////////////////////////////////////////////////////////////////////
 44  
         // Creation of the menu items
 45  
         // ////////////////////////////////////////////////////////////////////////
 46  33
         JMenuItem menuItem = new JMenuItem(this.uploadPolicy.getLocalizedString("menuitem_paste"));
 47  66
         menuItem.setActionCommand((String) TransferHandler.getPasteAction()
 48  33
                 .getValue(Action.NAME));
 49  33
         menuItem.addActionListener(uploadPanel.getActionListener());
 50  33
         menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V,
 51  
                 ActionEvent.CTRL_MASK));
 52  33
         menuItem.setMnemonic(KeyEvent.VK_P);
 53  
 
 54  33
         add(menuItem);
 55  33
     }
 56  
 
 57  
 }