| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
package org.homeunix.thecave.buddi.view.menu.items; |
| 5 | |
|
| 6 | |
import java.awt.event.ActionEvent; |
| 7 | |
import java.util.logging.Logger; |
| 8 | |
|
| 9 | |
import org.homeunix.thecave.buddi.i18n.keys.MenuKeys; |
| 10 | |
import org.homeunix.thecave.buddi.model.Account; |
| 11 | |
import org.homeunix.thecave.buddi.model.prefs.PrefsModel; |
| 12 | |
import org.homeunix.thecave.buddi.plugin.api.exception.InvalidValueException; |
| 13 | |
import org.homeunix.thecave.buddi.view.MainFrame; |
| 14 | |
|
| 15 | |
import ca.digitalcave.moss.swing.MossFrame; |
| 16 | |
import ca.digitalcave.moss.swing.MossMenuItem; |
| 17 | |
|
| 18 | |
public class EditUndeleteAccount extends MossMenuItem { |
| 19 | |
public static final long serialVersionUID = 0; |
| 20 | |
|
| 21 | |
public EditUndeleteAccount(MossFrame frame) { |
| 22 | 29974 | super(frame, PrefsModel.getInstance().getTranslator().get(MenuKeys.MENU_EDIT_UNDELETE_ACCOUNTS)); |
| 23 | 29974 | } |
| 24 | |
|
| 25 | |
@Override |
| 26 | |
public void actionPerformed(ActionEvent e) { |
| 27 | 0 | if (!(getFrame() instanceof MainFrame)) |
| 28 | 0 | throw new RuntimeException("Calling frame not instance of AccountFrame"); |
| 29 | |
|
| 30 | 0 | for (Account a : ((MainFrame) getFrame()).getSelectedAccounts()) { |
| 31 | |
try { |
| 32 | 0 | a.setDeleted(false); |
| 33 | |
} |
| 34 | 0 | catch (InvalidValueException ive){ |
| 35 | 0 | Logger.getLogger(this.getClass().getName()).warning("Error setting deleted flag to false on account"); |
| 36 | 0 | } |
| 37 | |
} |
| 38 | |
|
| 39 | 0 | ((MainFrame) getFrame()).updateContent(); |
| 40 | 0 | ((MainFrame) getFrame()).fireStructureChanged(); |
| 41 | 0 | } |
| 42 | |
|
| 43 | |
@Override |
| 44 | |
public void updateMenus() { |
| 45 | 169470 | super.updateMenus(); |
| 46 | |
|
| 47 | 169470 | this.setEnabled(((MainFrame) getFrame()).getSelectedAccounts().size() > 0); |
| 48 | |
|
| 49 | 169470 | this.setVisible(PrefsModel.getInstance().isShowDeleted()); |
| 50 | 169470 | } |
| 51 | |
} |