diff --git a/src/main/java/fr/uha/gabalier/util/languages/StringSources.java b/src/main/java/fr/uha/gabalier/util/languages/StringSources.java new file mode 100644 index 0000000..ef484bd --- /dev/null +++ b/src/main/java/fr/uha/gabalier/util/languages/StringSources.java @@ -0,0 +1,39 @@ +package fr.uha.gabalier.util.languages; + +import java.beans.Beans; +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +public class StringSources { + //////////////////////////////////////////////////////////////////////////// + // + // Constructor + // + //////////////////////////////////////////////////////////////////////////// + private StringSources() { + // do not instantiate + } + //////////////////////////////////////////////////////////////////////////// + // + // Bundle access + // + //////////////////////////////////////////////////////////////////////////// + private static final String BUNDLE_NAME = "fr.uha.gabalier.util.languages.stringsources"; //$NON-NLS-1$ + private static final ResourceBundle RESOURCE_BUNDLE = loadBundle(); + private static ResourceBundle loadBundle() { + return ResourceBundle.getBundle(BUNDLE_NAME); + } + //////////////////////////////////////////////////////////////////////////// + // + // Strings access + // + //////////////////////////////////////////////////////////////////////////// + public static String getString(String key) { + try { + ResourceBundle bundle = Beans.isDesignTime() ? loadBundle() : RESOURCE_BUNDLE; + return bundle.getString(key); + } catch (MissingResourceException e) { + return "!" + key + "!"; + } + } +} diff --git a/src/main/java/fr/uha/gabalier/util/languages/stringsources.properties b/src/main/java/fr/uha/gabalier/util/languages/stringsources.properties new file mode 100644 index 0000000..d55a42e --- /dev/null +++ b/src/main/java/fr/uha/gabalier/util/languages/stringsources.properties @@ -0,0 +1,9 @@ +#Eclipse messages class +#Thu Sep 27 17:27:39 CEST 2018 +Preview.cancelItem.text=Cancel +Preview.exitItem.text=Exit +Preview.fileMenu.text=File +Preview.loadItem.text=Load +Preview.other.text=status \: +Preview.statusText.text=0000 images loaded +Preview.this.title=Image Loader diff --git a/src/main/java/fr/uha/gabalier/util/languages/stringsources_en_GB.properties b/src/main/java/fr/uha/gabalier/util/languages/stringsources_en_GB.properties new file mode 100644 index 0000000..d55a42e --- /dev/null +++ b/src/main/java/fr/uha/gabalier/util/languages/stringsources_en_GB.properties @@ -0,0 +1,9 @@ +#Eclipse messages class +#Thu Sep 27 17:27:39 CEST 2018 +Preview.cancelItem.text=Cancel +Preview.exitItem.text=Exit +Preview.fileMenu.text=File +Preview.loadItem.text=Load +Preview.other.text=status \: +Preview.statusText.text=0000 images loaded +Preview.this.title=Image Loader diff --git a/src/main/java/fr/uha/gabalier/util/languages/stringsources_es_ES.properties b/src/main/java/fr/uha/gabalier/util/languages/stringsources_es_ES.properties new file mode 100644 index 0000000..81c0e54 --- /dev/null +++ b/src/main/java/fr/uha/gabalier/util/languages/stringsources_es_ES.properties @@ -0,0 +1,9 @@ +#Eclipse messages class +#Thu Sep 27 17:27:40 CEST 2018 +Preview.cancelItem.text=Cancelar +Preview.exitItem.text=Salir +Preview.fileMenu.text=Archivo +Preview.loadItem.text=Carga +Preview.other.text=Estatus \: +Preview.statusText.text=0000 im\u00E1genes cargadas +Preview.this.title=Cargador de im\u00E1genes diff --git a/src/main/java/fr/uha/gabalier/util/languages/stringsources_fr_FR.properties b/src/main/java/fr/uha/gabalier/util/languages/stringsources_fr_FR.properties new file mode 100644 index 0000000..cd2d24c --- /dev/null +++ b/src/main/java/fr/uha/gabalier/util/languages/stringsources_fr_FR.properties @@ -0,0 +1,9 @@ +#Eclipse messages class +#Thu Sep 27 17:27:39 CEST 2018 +Preview.cancelItem.text=Annuler +Preview.exitItem.text=Quitter +Preview.fileMenu.text=Fichier +Preview.loadItem.text=Charger +Preview.other.text=Status \: +Preview.statusText.text=0000 images charg\u00E9es +Preview.this.title=Visionneuse d'image diff --git a/src/main/java/fr/uha/gabalier/util/ressources/logo.jpg b/src/main/java/fr/uha/gabalier/util/ressources/logo.jpg new file mode 100644 index 0000000..a6f5329 Binary files /dev/null and b/src/main/java/fr/uha/gabalier/util/ressources/logo.jpg differ diff --git a/src/main/java/fr/uha/gabalier/view/Preview.java b/src/main/java/fr/uha/gabalier/view/Preview.java index ad9dc90..13ecded 100644 --- a/src/main/java/fr/uha/gabalier/view/Preview.java +++ b/src/main/java/fr/uha/gabalier/view/Preview.java @@ -9,6 +9,7 @@ import java.awt.event.InputEvent; import java.awt.event.KeyEvent; import java.util.ArrayList; import java.util.List; +import fr.uha.gabalier.util.languages.StringSources; public class Preview extends JFrame { @@ -33,6 +34,8 @@ public class Preview extends JFrame { private final JTextField statusText; public Preview() throws HeadlessException { + setIconImage(Toolkit.getDefaultToolkit().getImage(Preview.class.getResource("/fr/uha/gabalier/util/ressources/logo.jpg"))); + setTitle(StringSources.getString("Preview.this.title")); //$NON-NLS-1$ model = new ArrayList<>(); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); @@ -40,21 +43,21 @@ public class Preview extends JFrame { // UI elements JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); - JMenu fileMenu = new JMenu("File"); + JMenu fileMenu = new JMenu(StringSources.getString("Preview.fileMenu.text")); //$NON-NLS-1$ menuBar.add(fileMenu); - loadItem = new JMenuItem("Load"); + loadItem = new JMenuItem(StringSources.getString("Preview.loadItem.text")); //$NON-NLS-1$ fileMenu.add(loadItem); loadItem.addActionListener(actionEvent -> doLoad()); - cancelItem = new JMenuItem("Cancel"); + cancelItem = new JMenuItem(StringSources.getString("Preview.cancelItem.text")); //$NON-NLS-1$ fileMenu.add(cancelItem); cancelItem.addActionListener(actionEvent -> doCancel()); - final JMenuItem exitItem = new JMenuItem("Exit"); + final JMenuItem exitItem = new JMenuItem(StringSources.getString("Preview.exitItem.text")); //$NON-NLS-1$ exitItem.addActionListener(actionEvent -> doExit()); exitItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, InputEvent.CTRL_DOWN_MASK)); fileMenu.add(exitItem); - setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS)); + getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS)); imageView = new ImageView(model); final ImageController controller = new ImageController(model); @@ -73,8 +76,8 @@ public class Preview extends JFrame { final JPanel statusPanel = new JPanel(); getContentPane().add(statusPanel); - statusText = new JTextField("0000 images loaded"); - statusPanel.add(new JLabel("status :")); + statusText = new JTextField(StringSources.getString("Preview.statusText.text")); //$NON-NLS-1$ + statusPanel.add(new JLabel(StringSources.getString("Preview.other.text"))); //$NON-NLS-1$ statusPanel.add(statusText); pack();