2 * Sudokuki - essential sudoku game
\r
3 * Copyright (C) 2007-2011 Sylvain Vedrenne
\r
5 * This program is free software: you can redistribute it and/or modify
\r
6 * it under the terms of the GNU General Public License as published by
\r
7 * the Free Software Foundation, either version 3 of the License, or
\r
8 * (at your option) any later version.
\r
10 * This program is distributed in the hope that it will be useful,
\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 * GNU General Public License for more details.
\r
15 * You should have received a copy of the GNU General Public License
\r
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
\r
18 package net.jankenpoi.sudokuki.ui.swing;
\r
20 import static net.jankenpoi.i18n.I18n._;
\r
22 import java.awt.event.KeyEvent;
\r
23 import java.util.Locale;
\r
25 import javax.swing.Action;
\r
26 import javax.swing.JFrame;
\r
27 import javax.swing.JMenu;
\r
28 import javax.swing.JMenuItem;
\r
30 import net.jankenpoi.i18n.I18n;
\r
31 import net.jankenpoi.i18n.LocaleListener;
\r
32 import net.jankenpoi.sudokuki.ui.L10nComponent;
\r
33 import net.jankenpoi.sudokuki.view.GridView;
\r
35 @SuppressWarnings("serial")
\r
36 public class HelpMenu extends JMenu implements L10nComponent {
\r
38 private final JFrame parent;
\r
39 private final JMenuItem itemCheckUpdate = new JMenuItem();
\r
40 private final Action actionCheckUpdate;
\r
41 private final JMenuItem itemUpdateSite = new JMenuItem();
\r
42 private final Action actionOpenUpdateSite;
\r
43 private final JMenuItem itemTranslate = new JMenuItem();
\r
44 private final Action actionTranslate;
\r
45 private final JMenuItem itemAbout = new JMenuItem();
\r
46 private final Action actionAbout;
\r
48 private final LocaleListener localeListener;
\r
50 public void setL10nMessages(Locale locale, String languageCode) {
\r
53 itemCheckUpdate.setText(_("Update"));
\r
54 actionCheckUpdate.putValue(Action.SMALL_ICON, StockIcons.ICON_VIEW_REFRESH);
\r
55 actionCheckUpdate.putValue(Action.SHORT_DESCRIPTION, _("Check for updates"));
\r
56 actionCheckUpdate.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_U));
\r
58 itemUpdateSite.setText(_("Download"));
\r
59 actionOpenUpdateSite.putValue(Action.SMALL_ICON, StockIcons.ICON_UPDATE_AVAILABLE);
\r
60 actionOpenUpdateSite.putValue(Action.SHORT_DESCRIPTION, _("Download new version"));
\r
61 actionOpenUpdateSite.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_D));
\r
63 itemTranslate.setText(_("Translate this application"));
\r
64 actionTranslate.putValue(Action.SMALL_ICON, StockIcons.ICON_TRANSLATE);
\r
65 actionTranslate.putValue(Action.SHORT_DESCRIPTION, _(_("Help translate this application")));
\r
66 actionTranslate.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_T));
\r
68 itemAbout.setText(_("About..."));
\r
69 actionAbout.putValue(Action.SMALL_ICON, StockIcons.ICON_HELP_ABOUT);
\r
70 actionAbout.putValue(Action.SHORT_DESCRIPTION, _("About Sudokuki..."));
\r
71 actionAbout.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_P));
\r
74 HelpMenu(ActionsRepository actions, JFrame frame, SwingGrid grid, GridView view) {
\r
75 this.parent = frame;
\r
76 setMnemonic(KeyEvent.VK_H);
\r
77 getAccessibleContext().setAccessibleDescription(
\r
78 "The only menu in this program that has menu items");
\r
80 actionOpenUpdateSite = new OpenUpdateSiteAction(parent);
\r
81 actions.put("OpenUpdateSite", actionOpenUpdateSite);
\r
82 actionCheckUpdate = new CheckUpdateAction(parent, actionOpenUpdateSite);
\r
83 actions.put("CheckUpdate", actionCheckUpdate);
\r
85 actionTranslate = new TranslateAction(parent);
\r
86 actions.put("Translate", actionTranslate);
\r
88 actionAbout = new AboutAction(parent, grid, "", null, "", Integer.valueOf(0));
\r
89 actions.put("About", actionAbout);
\r
91 setL10nMessages(null, null);
\r
92 localeListener = new LocaleListenerImpl(this);
\r
93 I18n.addLocaleListener(localeListener);
\r
96 private void addItems(GridView view) {
\r
97 itemCheckUpdate.setAction(actionCheckUpdate);
\r
98 add(itemCheckUpdate);
\r
100 itemUpdateSite.setAction(actionOpenUpdateSite);
\r
101 add(itemUpdateSite);
\r
105 itemTranslate.setAction(actionTranslate);
\r
106 add(itemTranslate);
\r
110 itemAbout.setAction(actionAbout);
\r