OSDN Git Service

Fixed lots of warnings
[sudokuki/sudokuki.git] / src / classes / net / jankenpoi / sudokuki / ui / swing / CheatMenu.java
1 /*
2  * Sudokuki - essential sudoku game
3  * Copyright (C) 2007-2012 Sylvain Vedrenne
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  * 
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  * 
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 package net.jankenpoi.sudokuki.ui.swing;
19
20 import static net.jankenpoi.i18n.I18n._;
21
22 import java.awt.event.KeyEvent;
23 import java.util.Locale;
24
25 import javax.swing.Action;
26 import javax.swing.JFrame;
27 import javax.swing.JMenu;
28 import javax.swing.JMenuItem;
29
30 import net.jankenpoi.i18n.I18n;
31 import net.jankenpoi.i18n.LocaleListener;
32 import net.jankenpoi.sudokuki.ui.L10nComponent;
33 import net.jankenpoi.sudokuki.view.GridView;
34
35 @SuppressWarnings("serial")
36 public class CheatMenu extends JMenu implements L10nComponent {
37         
38         private final LocaleListener localeListener;
39         @Override
40         public void setL10nMessages(Locale locale, String languageCode) {
41                 setText(_("Solution..."));
42                 setIcon(StockIcons.ICON_SOLUTION_MENU);
43
44                 itemSetMemosHere.setText(_("Memos"));
45                 actionSetMemosHere.putValue(Action.SHORT_DESCRIPTION, _("Set memos"));
46                 itemSetAllMemos.setText(_("All memos"));
47                 actionSetAllMemos.putValue(Action.SHORT_DESCRIPTION, _("Set memos in all cells"));
48                 
49                 itemResolve.setText(_("Resolve"));
50                 actionResolve.putValue(Action.SMALL_ICON, StockIcons.ICON_GO_JUMP);
51                 actionResolve.putValue(Action.SHORT_DESCRIPTION, _("Resolve the grid"));
52                 actionResolve.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_R));
53         }
54
55         private final JMenuItem itemSetMemosHere = new JMenuItem();
56         private final JMenuItem itemSetAllMemos = new JMenuItem();
57         private final JMenuItem itemResolve = new JMenuItem();
58         private final Action actionSetMemosHere;
59         private final Action actionSetAllMemos;
60         private final Action actionResolve;
61         
62         public CheatMenu(ActionsRepository actions, JFrame parent, GridView view) {
63                 actionSetMemosHere = new SetMemosHereAction(_("Memos"),
64                                 StockIcons.ICON_SET_MEMOS_HERE, _("Set memos"), new Integer(
65                                                 KeyEvent.VK_T), view);
66                 actions.put("SetMemosHere", actionSetMemosHere);
67                 
68                 actionSetAllMemos = new SetAllMemosAction(_("All memos"),
69                                 StockIcons.ICON_SET_ALL_MEMOS, _("Set memos in all cells"), new Integer(
70                                                 KeyEvent.VK_X), view);
71                 actions.put("SetAllMemos", actionSetAllMemos);
72                 
73                 actionResolve = new ResolveAction(parent, _("Resolve"),
74                                 StockIcons.ICON_GO_JUMP, _("Resolve the grid"), new Integer(
75                                                 KeyEvent.VK_R), view);
76                 actions.put("ResolveGrid", actionResolve);
77                 
78                 addItems();
79                 setEnabled(true);
80                 setL10nMessages(null, _("DETECTED_LANGUAGE"));
81                 localeListener = new LocaleListenerImpl(this);
82                 I18n.addLocaleListener(localeListener);
83         }
84
85         private void addItems() {
86                 itemSetMemosHere.setAction(actionSetMemosHere);
87                 add(itemSetMemosHere);
88                 
89                 itemSetAllMemos.setAction(actionSetAllMemos);
90                 add(itemSetAllMemos);
91
92                 addSeparator();
93                 
94                 itemResolve.setAction(actionResolve);
95                 add(itemResolve);
96         }
97 }