From 2d12592a298c0f2d1b64635d51ad1c5453fc4532 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 6 Apr 2008 16:10:36 +0000 Subject: [PATCH] move i18n gui components to subpackage of i18n git-svn-id: http://trooper/svn/projects/jSite/trunk@622 c3eda9e8-030b-0410-8277-bc7414b0a119 --- .../pterodactylus/jsite/gui/EditNodeDialog.java | 2 + src/net/pterodactylus/jsite/gui/I18nAction.java | 89 ---------------------- src/net/pterodactylus/jsite/gui/I18nLabel.java | 68 ----------------- src/net/pterodactylus/jsite/gui/I18nMenu.java | 61 --------------- src/net/pterodactylus/jsite/gui/MainWindow.java | 2 + .../pterodactylus/jsite/gui/ManageNodesDialog.java | 1 + .../pterodactylus/jsite/gui/SwingInterface.java | 1 + .../pterodactylus/jsite/i18n/gui/I18nAction.java | 89 ++++++++++++++++++++++ .../pterodactylus/jsite/i18n/gui/I18nLabel.java | 68 +++++++++++++++++ src/net/pterodactylus/jsite/i18n/gui/I18nMenu.java | 61 +++++++++++++++ 10 files changed, 224 insertions(+), 218 deletions(-) delete mode 100644 src/net/pterodactylus/jsite/gui/I18nAction.java delete mode 100644 src/net/pterodactylus/jsite/gui/I18nLabel.java delete mode 100644 src/net/pterodactylus/jsite/gui/I18nMenu.java create mode 100644 src/net/pterodactylus/jsite/i18n/gui/I18nAction.java create mode 100644 src/net/pterodactylus/jsite/i18n/gui/I18nLabel.java create mode 100644 src/net/pterodactylus/jsite/i18n/gui/I18nMenu.java diff --git a/src/net/pterodactylus/jsite/gui/EditNodeDialog.java b/src/net/pterodactylus/jsite/gui/EditNodeDialog.java index 73602fc..a8597ef 100644 --- a/src/net/pterodactylus/jsite/gui/EditNodeDialog.java +++ b/src/net/pterodactylus/jsite/gui/EditNodeDialog.java @@ -39,6 +39,8 @@ import javax.swing.border.EtchedBorder; import net.pterodactylus.jsite.i18n.I18n; import net.pterodactylus.jsite.i18n.I18nable; +import net.pterodactylus.jsite.i18n.gui.I18nAction; +import net.pterodactylus.jsite.i18n.gui.I18nLabel; import net.pterodactylus.jsite.main.Version; import net.pterodactylus.util.swing.SwingUtils; diff --git a/src/net/pterodactylus/jsite/gui/I18nAction.java b/src/net/pterodactylus/jsite/gui/I18nAction.java deleted file mode 100644 index 77733ae..0000000 --- a/src/net/pterodactylus/jsite/gui/I18nAction.java +++ /dev/null @@ -1,89 +0,0 @@ -package net.pterodactylus.jsite.gui; - -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.Icon; - -import net.pterodactylus.jsite.i18n.I18n; -import net.pterodactylus.jsite.i18n.I18nable; - -/** - * Helper class that initializes actions with values from {@link I18n}. - * - * @author David ‘Bombe’ Roden <bombe@freenetproject.org> - * @version $Id$ - */ -public abstract class I18nAction extends AbstractAction implements I18nable { - - /** The I18n basename. */ - private final String i18nName; - - /** - * Creates a new action that uses the given name as base name to get values - * from {@link I18n}. - * - * @param i18nName - * The base name of the action - */ - public I18nAction(String i18nName) { - this(i18nName, null); - } - - /** - * Creates a new action that uses the given name as base name to get values - * from {@link I18n} and the given icon. - * - * @param i18nName - * The base name of the action - * @param icon - * The icon for the action - */ - public I18nAction(String i18nName, Icon icon) { - this(i18nName, true, icon); - } - - /** - * Creates a new action that uses the given name as base name to get values - * from {@link I18n}. - * - * @param i18nName - * The base name of the action - * @param enabled - * Whether the action should be enabled - */ - public I18nAction(String i18nName, boolean enabled) { - this(i18nName, enabled, null); - } - - /** - * Creates a new action that uses the given name as base name to get values - * from {@link I18n} and the given icon. - * - * @param i18nName - * The base name of the action - * @param enabled - * Whether the action should be enabled - * @param icon - * The icon for the action - */ - public I18nAction(String i18nName, boolean enabled, Icon icon) { - this.i18nName = i18nName; - if (icon != null) { - putValue(Action.SMALL_ICON, icon); - } - setEnabled(enabled); - updateI18n(); - } - - /** - * {@inheritDoc} - */ - public void updateI18n() { - putValue(Action.NAME, I18n.get(i18nName + ".name")); - putValue(Action.MNEMONIC_KEY, I18n.getKey(i18nName + ".mnemonic")); - putValue(Action.ACCELERATOR_KEY, I18n.getKeyStroke(i18nName + ".accelerator")); - putValue(Action.SHORT_DESCRIPTION, I18n.get(i18nName + ".shortDescription")); - putValue(Action.LONG_DESCRIPTION, I18n.get(i18nName + ".longDescription")); - } - -} \ No newline at end of file diff --git a/src/net/pterodactylus/jsite/gui/I18nLabel.java b/src/net/pterodactylus/jsite/gui/I18nLabel.java deleted file mode 100644 index ffcb549..0000000 --- a/src/net/pterodactylus/jsite/gui/I18nLabel.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * jSite2 - I18nLabel.java - - * Copyright © 2008 David Roden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package net.pterodactylus.jsite.gui; - -import java.awt.Component; - -import javax.swing.JLabel; - -import net.pterodactylus.jsite.i18n.I18n; -import net.pterodactylus.jsite.i18n.I18nable; - -/** - * Label that can update itself from {@link I18n}. - * - * @author David ‘Bombe’ Roden <bombe@freenetproject.org> - * @version $Id$ - */ -public class I18nLabel extends JLabel implements I18nable { - - /** The I18n basename of the label. */ - private final String i18nBasename; - - /** - * Creates a new label with the given I18n basename that optionally is a - * label for the given component. - * - * @param i18nBasename - * The I18n basename of the label - * @param component - * The component that is activated by the label, or - * null if this label should not activate a - * component - */ - public I18nLabel(String i18nBasename, Component component) { - super(); - this.i18nBasename = i18nBasename; - updateI18n(); - if (component != null) { - setLabelFor(component); - } - } - - /** - * {@inheritDoc} - */ - public void updateI18n() { - setText(I18n.get(i18nBasename + ".name")); - setDisplayedMnemonic(I18n.getKey(i18nBasename + ".mnemonic")); - } - -} diff --git a/src/net/pterodactylus/jsite/gui/I18nMenu.java b/src/net/pterodactylus/jsite/gui/I18nMenu.java deleted file mode 100644 index 2b64211..0000000 --- a/src/net/pterodactylus/jsite/gui/I18nMenu.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * jSite2 - I18nMenu.java - - * Copyright © 2008 David Roden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package net.pterodactylus.jsite.gui; - -import javax.swing.JMenu; - -import net.pterodactylus.jsite.i18n.I18n; -import net.pterodactylus.jsite.i18n.I18nable; - -/** - * Menu that receives its properties from {@link I18n}. - * - * @author David ‘Bombe’ Roden <bombe@freenetproject.org> - * @version $Id$ - */ -public class I18nMenu extends JMenu implements I18nable { - - /** The {@link I18n} basename. */ - private final String i18nBasename; - - /** - * Creates a new menu with the given {@link I18n} basename. - * - * @param i18nBasename - * The basename of the {@link I18n} properties - */ - public I18nMenu(String i18nBasename) { - this.i18nBasename = i18nBasename; - updateI18n(); - } - - // - // INTERFACE I18nable - // - - /** - * {@inheritDoc} - */ - public void updateI18n() { - setText(I18n.get(i18nBasename + ".name")); - setMnemonic(I18n.getKey(i18nBasename + ".mnemonic")); - } - -} diff --git a/src/net/pterodactylus/jsite/gui/MainWindow.java b/src/net/pterodactylus/jsite/gui/MainWindow.java index 694cc98..92b7ab0 100644 --- a/src/net/pterodactylus/jsite/gui/MainWindow.java +++ b/src/net/pterodactylus/jsite/gui/MainWindow.java @@ -30,6 +30,8 @@ import javax.swing.JToolBar; import net.pterodactylus.jsite.i18n.I18n; import net.pterodactylus.jsite.i18n.I18nable; +import net.pterodactylus.jsite.i18n.gui.I18nAction; +import net.pterodactylus.jsite.i18n.gui.I18nMenu; import net.pterodactylus.jsite.main.Version; import net.pterodactylus.util.swing.StatusBar; import net.pterodactylus.util.swing.SwingUtils; diff --git a/src/net/pterodactylus/jsite/gui/ManageNodesDialog.java b/src/net/pterodactylus/jsite/gui/ManageNodesDialog.java index 447618c..e47a9b9 100644 --- a/src/net/pterodactylus/jsite/gui/ManageNodesDialog.java +++ b/src/net/pterodactylus/jsite/gui/ManageNodesDialog.java @@ -43,6 +43,7 @@ import net.pterodactylus.jsite.core.Core; import net.pterodactylus.jsite.core.Node; import net.pterodactylus.jsite.i18n.I18n; import net.pterodactylus.jsite.i18n.I18nable; +import net.pterodactylus.jsite.i18n.gui.I18nAction; import net.pterodactylus.jsite.main.Version; import net.pterodactylus.util.swing.SwingUtils; diff --git a/src/net/pterodactylus/jsite/gui/SwingInterface.java b/src/net/pterodactylus/jsite/gui/SwingInterface.java index e55fffa..1210a49 100644 --- a/src/net/pterodactylus/jsite/gui/SwingInterface.java +++ b/src/net/pterodactylus/jsite/gui/SwingInterface.java @@ -28,6 +28,7 @@ import net.pterodactylus.jsite.core.Core; import net.pterodactylus.jsite.core.CoreListener; import net.pterodactylus.jsite.core.Node; import net.pterodactylus.jsite.i18n.I18n; +import net.pterodactylus.jsite.i18n.gui.I18nAction; /** * TODO diff --git a/src/net/pterodactylus/jsite/i18n/gui/I18nAction.java b/src/net/pterodactylus/jsite/i18n/gui/I18nAction.java new file mode 100644 index 0000000..07860fe --- /dev/null +++ b/src/net/pterodactylus/jsite/i18n/gui/I18nAction.java @@ -0,0 +1,89 @@ +package net.pterodactylus.jsite.i18n.gui; + +import javax.swing.AbstractAction; +import javax.swing.Action; +import javax.swing.Icon; + +import net.pterodactylus.jsite.i18n.I18n; +import net.pterodactylus.jsite.i18n.I18nable; + +/** + * Helper class that initializes actions with values from {@link I18n}. + * + * @author David ‘Bombe’ Roden <bombe@freenetproject.org> + * @version $Id$ + */ +public abstract class I18nAction extends AbstractAction implements I18nable { + + /** The I18n basename. */ + private final String i18nName; + + /** + * Creates a new action that uses the given name as base name to get values + * from {@link I18n}. + * + * @param i18nName + * The base name of the action + */ + public I18nAction(String i18nName) { + this(i18nName, null); + } + + /** + * Creates a new action that uses the given name as base name to get values + * from {@link I18n} and the given icon. + * + * @param i18nName + * The base name of the action + * @param icon + * The icon for the action + */ + public I18nAction(String i18nName, Icon icon) { + this(i18nName, true, icon); + } + + /** + * Creates a new action that uses the given name as base name to get values + * from {@link I18n}. + * + * @param i18nName + * The base name of the action + * @param enabled + * Whether the action should be enabled + */ + public I18nAction(String i18nName, boolean enabled) { + this(i18nName, enabled, null); + } + + /** + * Creates a new action that uses the given name as base name to get values + * from {@link I18n} and the given icon. + * + * @param i18nName + * The base name of the action + * @param enabled + * Whether the action should be enabled + * @param icon + * The icon for the action + */ + public I18nAction(String i18nName, boolean enabled, Icon icon) { + this.i18nName = i18nName; + if (icon != null) { + putValue(Action.SMALL_ICON, icon); + } + setEnabled(enabled); + updateI18n(); + } + + /** + * {@inheritDoc} + */ + public void updateI18n() { + putValue(Action.NAME, I18n.get(i18nName + ".name")); + putValue(Action.MNEMONIC_KEY, I18n.getKey(i18nName + ".mnemonic")); + putValue(Action.ACCELERATOR_KEY, I18n.getKeyStroke(i18nName + ".accelerator")); + putValue(Action.SHORT_DESCRIPTION, I18n.get(i18nName + ".shortDescription")); + putValue(Action.LONG_DESCRIPTION, I18n.get(i18nName + ".longDescription")); + } + +} \ No newline at end of file diff --git a/src/net/pterodactylus/jsite/i18n/gui/I18nLabel.java b/src/net/pterodactylus/jsite/i18n/gui/I18nLabel.java new file mode 100644 index 0000000..06f6b6e --- /dev/null +++ b/src/net/pterodactylus/jsite/i18n/gui/I18nLabel.java @@ -0,0 +1,68 @@ +/* + * jSite2 - I18nLabel.java - + * Copyright © 2008 David Roden + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +package net.pterodactylus.jsite.i18n.gui; + +import java.awt.Component; + +import javax.swing.JLabel; + +import net.pterodactylus.jsite.i18n.I18n; +import net.pterodactylus.jsite.i18n.I18nable; + +/** + * Label that can update itself from {@link I18n}. + * + * @author David ‘Bombe’ Roden <bombe@freenetproject.org> + * @version $Id$ + */ +public class I18nLabel extends JLabel implements I18nable { + + /** The I18n basename of the label. */ + private final String i18nBasename; + + /** + * Creates a new label with the given I18n basename that optionally is a + * label for the given component. + * + * @param i18nBasename + * The I18n basename of the label + * @param component + * The component that is activated by the label, or + * null if this label should not activate a + * component + */ + public I18nLabel(String i18nBasename, Component component) { + super(); + this.i18nBasename = i18nBasename; + updateI18n(); + if (component != null) { + setLabelFor(component); + } + } + + /** + * {@inheritDoc} + */ + public void updateI18n() { + setText(I18n.get(i18nBasename + ".name")); + setDisplayedMnemonic(I18n.getKey(i18nBasename + ".mnemonic")); + } + +} diff --git a/src/net/pterodactylus/jsite/i18n/gui/I18nMenu.java b/src/net/pterodactylus/jsite/i18n/gui/I18nMenu.java new file mode 100644 index 0000000..e94a27a --- /dev/null +++ b/src/net/pterodactylus/jsite/i18n/gui/I18nMenu.java @@ -0,0 +1,61 @@ +/* + * jSite2 - I18nMenu.java - + * Copyright © 2008 David Roden + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +package net.pterodactylus.jsite.i18n.gui; + +import javax.swing.JMenu; + +import net.pterodactylus.jsite.i18n.I18n; +import net.pterodactylus.jsite.i18n.I18nable; + +/** + * Menu that receives its properties from {@link I18n}. + * + * @author David ‘Bombe’ Roden <bombe@freenetproject.org> + * @version $Id$ + */ +public class I18nMenu extends JMenu implements I18nable { + + /** The {@link I18n} basename. */ + private final String i18nBasename; + + /** + * Creates a new menu with the given {@link I18n} basename. + * + * @param i18nBasename + * The basename of the {@link I18n} properties + */ + public I18nMenu(String i18nBasename) { + this.i18nBasename = i18nBasename; + updateI18n(); + } + + // + // INTERFACE I18nable + // + + /** + * {@inheritDoc} + */ + public void updateI18n() { + setText(I18n.get(i18nBasename + ".name")); + setMnemonic(I18n.getKey(i18nBasename + ".mnemonic")); + } + +} -- 2.7.4