Coverage Report - org.homeunix.thecave.buddi.view.menu.items.EditModifyAccount
 
Classes in this File Line Coverage Branch Coverage Complexity
EditModifyAccount
35%
5/14
25%
1/4
1.5
EditModifyAccount$1
0%
0/3
N/A
1.5
 
 1  
 /*
 2  
  * Created on Aug 6, 2007 by wyatt
 3  
  */
 4  
 package org.homeunix.thecave.buddi.view.menu.items;
 5  
 
 6  
 import java.awt.Toolkit;
 7  
 import java.awt.event.ActionEvent;
 8  
 import java.awt.event.KeyEvent;
 9  
 
 10  
 import javax.swing.KeyStroke;
 11  
 import javax.swing.SwingUtilities;
 12  
 
 13  
 import org.homeunix.thecave.buddi.i18n.keys.MenuKeys;
 14  
 import org.homeunix.thecave.buddi.model.Account;
 15  
 import org.homeunix.thecave.buddi.model.Document;
 16  
 import org.homeunix.thecave.buddi.model.prefs.PrefsModel;
 17  
 import org.homeunix.thecave.buddi.view.MainFrame;
 18  
 import org.homeunix.thecave.buddi.view.dialogs.AccountEditorDialog;
 19  
 
 20  
 import ca.digitalcave.moss.swing.MossMenuItem;
 21  
 import ca.digitalcave.moss.swing.exception.WindowOpenException;
 22  
 
 23  
 public class EditModifyAccount extends MossMenuItem {
 24  
         public static final long serialVersionUID = 0;
 25  
         
 26  
         public EditModifyAccount(MainFrame frame) {
 27  29974
                 super(frame, PrefsModel.getInstance().getTranslator().get(MenuKeys.MENU_EDIT_MODIFY_ACCOUNTS),
 28  
                                 KeyStroke.getKeyStroke(KeyEvent.VK_E, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() + KeyEvent.SHIFT_MASK));
 29  29974
         }
 30  
         
 31  
         @Override
 32  
         public void actionPerformed(ActionEvent e) {
 33  0
                 for (Account a : ((MainFrame) getFrame()).getSelectedAccounts()) {
 34  0
                         AccountEditorDialog editor = new AccountEditorDialog((MainFrame) getFrame(), (Document) ((MainFrame) getFrame()).getDocument(), a);
 35  
                         try {
 36  0
                                 editor.openWindow();
 37  
                         }
 38  0
                         catch (WindowOpenException woe){}
 39  0
                 }
 40  
 
 41  0
                 ((MainFrame) getFrame()).fireStructureChanged();
 42  0
                 ((MainFrame) getFrame()).updateContent();
 43  
                 
 44  
                 //We add this to the end of the AWT event thread to allow the 
 45  
                 // structure change to register first.  Otherwise, the tree
 46  
                 // will not unroll again.
 47  0
                 SwingUtilities.invokeLater(new Runnable(){
 48  
                         public void run() {
 49  0
                                 ((MainFrame) getFrame()).updateContent();
 50  0
                         }
 51  
                 });
 52  0
         }
 53  
 
 54  
         @Override
 55  
         public void updateMenus() {
 56  169470
                 super.updateMenus();
 57  
                 
 58  169470
                 this.setEnabled(((MainFrame) getFrame()).getSelectedAccounts().size() > 0);
 59  169470
         }
 60  
 }