2 * Sudokuki - essential sudoku game
3 * Copyright (C) 2007-2012 Sylvain Vedrenne
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.
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.
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/>.
18 package net.jankenpoi.sudokuki.ui.swing;
20 import static net.jankenpoi.i18n.I18n._;
22 import java.awt.event.KeyEvent;
23 import java.util.Locale;
25 import javax.swing.Action;
26 import javax.swing.JFrame;
27 import javax.swing.JMenu;
28 import javax.swing.JMenuItem;
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;
35 @SuppressWarnings("serial")
36 public class CheatMenu extends JMenu implements L10nComponent {
38 private final LocaleListener localeListener;
40 public void setL10nMessages(Locale locale, String languageCode) {
41 setText(_("Solution..."));
42 setIcon(StockIcons.ICON_SOLUTION_MENU);
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"));
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));
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;
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);
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);
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);
80 setL10nMessages(null, _("DETECTED_LANGUAGE"));
81 localeListener = new LocaleListenerImpl(this);
82 I18n.addLocaleListener(localeListener);
85 private void addItems() {
86 itemSetMemosHere.setAction(actionSetMemosHere);
87 add(itemSetMemosHere);
89 itemSetAllMemos.setAction(actionSetAllMemos);
94 itemResolve.setAction(actionResolve);