| 1 | |
|
| 2 | |
|
| 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.BudgetCategory; |
| 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.BudgetCategoryEditorDialog; |
| 19 | |
|
| 20 | |
import ca.digitalcave.moss.swing.MossMenuItem; |
| 21 | |
import ca.digitalcave.moss.swing.exception.WindowOpenException; |
| 22 | |
|
| 23 | |
public class EditModifyBudgetCategory extends MossMenuItem{ |
| 24 | |
public static final long serialVersionUID = 0; |
| 25 | |
|
| 26 | |
public EditModifyBudgetCategory(MainFrame frame) { |
| 27 | 256 | super(frame, PrefsModel.getInstance().getTranslator().get(MenuKeys.MENU_EDIT_MODIFY_BUDGET_CATEGORIES), |
| 28 | |
KeyStroke.getKeyStroke(KeyEvent.VK_E, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() + KeyEvent.SHIFT_MASK)); |
| 29 | 256 | } |
| 30 | |
|
| 31 | |
@Override |
| 32 | |
public void actionPerformed(ActionEvent e) { |
| 33 | 0 | for (BudgetCategory bc : ((MainFrame) getFrame()).getSelectedBudgetCategories()) { |
| 34 | 0 | BudgetCategoryEditorDialog editor = new BudgetCategoryEditorDialog((MainFrame) getFrame(), (Document) ((MainFrame) getFrame()).getDocument(), bc, null); |
| 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 | |
|
| 45 | |
|
| 46 | |
|
| 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 | 420 | super.updateMenus(); |
| 57 | |
|
| 58 | 420 | this.setEnabled(((MainFrame) getFrame()).getSelectedBudgetCategories().size() > 0); |
| 59 | 420 | } |
| 60 | |
} |