| 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.BudgetCategory; |
| 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.MossMenuItem; |
| 16 | |
|
| 17 | |
public class EditUndeleteBudgetCategory extends MossMenuItem{ |
| 18 | |
public static final long serialVersionUID = 0; |
| 19 | |
|
| 20 | |
public EditUndeleteBudgetCategory(MainFrame frame) { |
| 21 | 256 | super(frame, PrefsModel.getInstance().getTranslator().get(MenuKeys.MENU_EDIT_UNDELETE_BUDGET_CATEGORIES)); |
| 22 | 256 | } |
| 23 | |
|
| 24 | |
@Override |
| 25 | |
public void actionPerformed(ActionEvent e) { |
| 26 | 0 | if (!(getFrame() instanceof MainFrame)) |
| 27 | 0 | throw new RuntimeException("Calling frame not instance of BudgetFrame"); |
| 28 | |
|
| 29 | 0 | for (BudgetCategory bc : ((MainFrame) getFrame()).getSelectedBudgetCategories()) { |
| 30 | |
try { |
| 31 | 0 | bc.setDeleted(false); |
| 32 | |
} |
| 33 | 0 | catch (InvalidValueException ive){ |
| 34 | 0 | Logger.getLogger(this.getClass().getName()).warning("Error setting deleted flag to false on budget category"); |
| 35 | 0 | } |
| 36 | |
} |
| 37 | |
|
| 38 | 0 | ((MainFrame) getFrame()).updateContent(); |
| 39 | 0 | ((MainFrame) getFrame()).fireStructureChanged(); |
| 40 | 0 | } |
| 41 | |
|
| 42 | |
@Override |
| 43 | |
public void updateMenus() { |
| 44 | 420 | super.updateMenus(); |
| 45 | |
|
| 46 | 420 | this.setEnabled(((MainFrame) getFrame()).getSelectedBudgetCategories().size() > 0); |
| 47 | |
|
| 48 | 420 | this.setVisible(PrefsModel.getInstance().isShowDeleted()); |
| 49 | 420 | } |
| 50 | |
} |