diff --git a/src/main/java/jpass/ui/EntryDetailsTable.java b/src/main/java/jpass/ui/EntryDetailsTable.java index 0dc192d..ef9bf9b 100644 --- a/src/main/java/jpass/ui/EntryDetailsTable.java +++ b/src/main/java/jpass/ui/EntryDetailsTable.java @@ -45,7 +45,7 @@ import jpass.util.DateUtils; import jpass.xml.bind.Entry; -import static jpass.ui.JPassFrame.MESSAGES; +import static jpass.ui.JPassFrame.localizedMessages; import static jpass.util.Constants.VIEW_WINDOW_CREATED; import static jpass.util.Constants.VIEW_WINDOW_MODIFIED; import static jpass.util.Constants.VIEW_WINDOW_TITLE; @@ -61,11 +61,11 @@ public class EntryDetailsTable extends JTable { = DateUtils.createFormatter(Configuration.getInstance().get("date.format", "yyyy-MM-dd")); private enum DetailType { - TITLE(MESSAGES.getString(VIEW_WINDOW_TITLE), Entry::getTitle), - URL(MESSAGES.getString(VIEW_WINDOW_URL), Entry::getUrl), - USER(MESSAGES.getString(VIEW_WINDOW_USER), Entry::getUser), - MODIFIED(MESSAGES.getString(VIEW_WINDOW_MODIFIED), entry -> DateUtils.formatIsoDateTime(entry.getLastModification(), FORMATTER)), - CREATED(MESSAGES.getString(VIEW_WINDOW_CREATED), entry -> DateUtils.formatIsoDateTime(entry.getCreationDate(), FORMATTER)); + TITLE(localizedMessages.getString(VIEW_WINDOW_TITLE), Entry::getTitle), + URL(localizedMessages.getString(VIEW_WINDOW_URL), Entry::getUrl), + USER(localizedMessages.getString(VIEW_WINDOW_USER), Entry::getUser), + MODIFIED(localizedMessages.getString(VIEW_WINDOW_MODIFIED), entry -> DateUtils.formatIsoDateTime(entry.getLastModification(), FORMATTER)), + CREATED(localizedMessages.getString(VIEW_WINDOW_CREATED), entry -> DateUtils.formatIsoDateTime(entry.getCreationDate(), FORMATTER)); private final String description; private final Function valueMapper; diff --git a/src/main/java/jpass/ui/EntryDialog.java b/src/main/java/jpass/ui/EntryDialog.java index 7c5523e..f3372ef 100644 --- a/src/main/java/jpass/ui/EntryDialog.java +++ b/src/main/java/jpass/ui/EntryDialog.java @@ -54,13 +54,16 @@ import jpass.util.StringUtils; import jpass.xml.bind.Entry; -import static jpass.ui.JPassFrame.MESSAGES; +import static jpass.ui.JPassFrame.localizedMessages; import static jpass.ui.helper.EntryHelper.copyEntryField; import static jpass.util.Constants.BUTTON_MESSAGE_CANCEL; import static jpass.util.Constants.BUTTON_MESSAGE_OK; import static jpass.util.Constants.ENTRY_DIALOG_COPY_ENTRY; +import static jpass.util.Constants.ENTRY_DIALOG_FILL_TITLE_FIELD; import static jpass.util.Constants.ENTRY_DIALOG_GENERATE_ENTRY; import static jpass.util.Constants.ENTRY_DIALOG_SHOW_ENTRY; +import static jpass.util.Constants.ENTRY_DIALOG_TITLE_ALREADY_EXISTS; +import static jpass.util.Constants.PASSWORD_PASSWORDS_NOT_IDENTICAL; import static jpass.util.Constants.VIEW_WINDOW_NOTES; import static jpass.util.Constants.VIEW_WINDOW_PASSWORD; import static jpass.util.Constants.VIEW_WINDOW_REPEAT; @@ -126,15 +129,15 @@ public EntryDialog(JPassFrame parent, String title, Entry entry, boolean newEntr this.originalEcho = this.passwordField.getEchoChar(); this.repeatField = TextComponentFactory.newPasswordField(true); - this.showButton = new JToggleButton(MESSAGES.getString(ENTRY_DIALOG_SHOW_ENTRY), MessageDialog.getIcon("show")); + this.showButton = new JToggleButton(localizedMessages.getString(ENTRY_DIALOG_SHOW_ENTRY), MessageDialog.getIcon("show")); this.showButton.setActionCommand("show_button"); this.showButton.setMnemonic(KeyEvent.VK_S); this.showButton.addActionListener(this); - this.generateButton = new JButton(MESSAGES.getString(ENTRY_DIALOG_GENERATE_ENTRY), MessageDialog.getIcon("generate")); + this.generateButton = new JButton(localizedMessages.getString(ENTRY_DIALOG_GENERATE_ENTRY), MessageDialog.getIcon("generate")); this.generateButton.setActionCommand("generate_button"); this.generateButton.setMnemonic(KeyEvent.VK_G); this.generateButton.addActionListener(this); - this.copyButton = new JButton(MESSAGES.getString(ENTRY_DIALOG_COPY_ENTRY), MessageDialog.getIcon("keyring")); + this.copyButton = new JButton(localizedMessages.getString(ENTRY_DIALOG_COPY_ENTRY), MessageDialog.getIcon("keyring")); this.copyButton.setActionCommand("copy_button"); this.copyButton.setMnemonic(KeyEvent.VK_P); this.copyButton.addActionListener(this); @@ -149,15 +152,15 @@ public EntryDialog(JPassFrame parent, String title, Entry entry, boolean newEntr 5, 0); // xPad, yPad this.fieldPanel = new JPanel(new SpringLayout()); - this.fieldPanel.add(new JLabel(String.format("%s:", MESSAGES.getString(VIEW_WINDOW_TITLE)))); + this.fieldPanel.add(new JLabel(String.format("%s:", localizedMessages.getString(VIEW_WINDOW_TITLE)))); this.fieldPanel.add(this.titleField); - this.fieldPanel.add(new JLabel(String.format("%s:", MESSAGES.getString(VIEW_WINDOW_URL)))); + this.fieldPanel.add(new JLabel(String.format("%s:", localizedMessages.getString(VIEW_WINDOW_URL)))); this.fieldPanel.add(this.urlField); - this.fieldPanel.add(new JLabel(String.format("%s:", MESSAGES.getString(VIEW_WINDOW_USER_NAME)))); + this.fieldPanel.add(new JLabel(String.format("%s:", localizedMessages.getString(VIEW_WINDOW_USER_NAME)))); this.fieldPanel.add(this.userField); - this.fieldPanel.add(new JLabel(String.format("%s:", MESSAGES.getString(VIEW_WINDOW_PASSWORD)))); + this.fieldPanel.add(new JLabel(String.format("%s:", localizedMessages.getString(VIEW_WINDOW_PASSWORD)))); this.fieldPanel.add(this.passwordField); - this.fieldPanel.add(new JLabel(String.format("%s:", MESSAGES.getString(VIEW_WINDOW_REPEAT)))); + this.fieldPanel.add(new JLabel(String.format("%s:", localizedMessages.getString(VIEW_WINDOW_REPEAT)))); this.fieldPanel.add(this.repeatField); this.fieldPanel.add(new JLabel("")); this.fieldPanel.add(this.passwordButtonPanel); @@ -173,15 +176,15 @@ public EntryDialog(JPassFrame parent, String title, Entry entry, boolean newEntr this.notesPanel = new JPanel(new BorderLayout(5, 5)); this.notesPanel.setBorder(new EmptyBorder(0, 5, 0, 5)); - this.notesPanel.add(new JLabel(String.format("%s:", MESSAGES.getString(VIEW_WINDOW_NOTES))), BorderLayout.NORTH); + this.notesPanel.add(new JLabel(String.format("%s:", localizedMessages.getString(VIEW_WINDOW_NOTES))), BorderLayout.NORTH); this.notesPanel.add(new JScrollPane(this.notesField), BorderLayout.CENTER); - this.okButton = new JButton(MESSAGES.getString(BUTTON_MESSAGE_OK), MessageDialog.getIcon("accept")); + this.okButton = new JButton(localizedMessages.getString(BUTTON_MESSAGE_OK), MessageDialog.getIcon("accept")); this.okButton.setActionCommand("ok_button"); this.okButton.setMnemonic(KeyEvent.VK_O); this.okButton.addActionListener(this); - this.cancelButton = new JButton(MESSAGES.getString(BUTTON_MESSAGE_CANCEL), MessageDialog.getIcon("cancel")); + this.cancelButton = new JButton(localizedMessages.getString(BUTTON_MESSAGE_CANCEL), MessageDialog.getIcon("cancel")); this.cancelButton.setActionCommand("cancel_button"); this.cancelButton.setMnemonic(KeyEvent.VK_C); this.cancelButton.addActionListener(this); @@ -209,13 +212,13 @@ public void actionPerformed(ActionEvent e) { this.repeatField.setEchoChar(this.showButton.isSelected() ? NULL_ECHO : this.originalEcho); } else if ("ok_button".equals(command)) { if (this.titleField.getText().trim().isEmpty()) { - MessageDialog.showWarningMessage(this, "Please fill the title field."); + MessageDialog.showWarningMessage(this, localizedMessages.getString(ENTRY_DIALOG_FILL_TITLE_FIELD)); return; } else if (!checkEntryTitle()) { - MessageDialog.showWarningMessage(this, "Title is already exists,\nplease enter a different title."); + MessageDialog.showWarningMessage(this, localizedMessages.getString(ENTRY_DIALOG_TITLE_ALREADY_EXISTS)); return; } else if (!Arrays.equals(this.passwordField.getPassword(), this.repeatField.getPassword())) { - MessageDialog.showWarningMessage(this, "Password and repeated passwords are not identical."); + MessageDialog.showWarningMessage(this, localizedMessages.getString(PASSWORD_PASSWORDS_NOT_IDENTICAL)); return; } this.modifiedEntry = getEntryFromDialog(); diff --git a/src/main/java/jpass/ui/GeneratePasswordDialog.java b/src/main/java/jpass/ui/GeneratePasswordDialog.java index 56773a0..129eb97 100644 --- a/src/main/java/jpass/ui/GeneratePasswordDialog.java +++ b/src/main/java/jpass/ui/GeneratePasswordDialog.java @@ -51,11 +51,10 @@ import javax.swing.border.TitledBorder; import jpass.util.Configuration; -import jpass.util.Constants; import jpass.util.CryptUtils; import jpass.util.SpringUtilities; -import static jpass.ui.JPassFrame.MESSAGES; +import static jpass.ui.JPassFrame.localizedMessages; import static jpass.util.Constants.BUTTON_MESSAGE_ACCEPT; import static jpass.util.Constants.BUTTON_MESSAGE_CANCEL; import static jpass.util.Constants.BUTTON_MESSAGE_CLOSE; @@ -88,9 +87,9 @@ public final class GeneratePasswordDialog extends JDialog implements ActionListe * Options for password generation. */ private static final String[][] PASSWORD_OPTIONS = { - {MESSAGES.getString(VIEW_WINDOW_UPPER_CASE_LETTERS), "ABCDEFGHIJKLMNOPQRSTUVWXYZ"}, - {MESSAGES.getString(VIEW_WINDOW_LOWER_CASE_LETTERS), "abcdefghijklmnopqrstuvwxyz"}, - {MESSAGES.getString(VIEW_WINDOW_NUMBERS), "0123456789"} + {localizedMessages.getString(VIEW_WINDOW_UPPER_CASE_LETTERS), "ABCDEFGHIJKLMNOPQRSTUVWXYZ"}, + {localizedMessages.getString(VIEW_WINDOW_LOWER_CASE_LETTERS), "abcdefghijklmnopqrstuvwxyz"}, + {localizedMessages.getString(VIEW_WINDOW_NUMBERS), "0123456789"} }; private JCheckBox[] checkBoxes; @@ -145,12 +144,12 @@ public GeneratePasswordDialog(JDialog parent) { */ private void initDialog(final Component parent, final boolean showAcceptButton) { setModal(true); - setTitle(MESSAGES.getString(PASSWORD_GENERATE_PASSWORD)); + setTitle(localizedMessages.getString(PASSWORD_GENERATE_PASSWORD)); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); this.generatedPassword = null; this.lengthPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0)); - this.lengthLabel = new JLabel(String.format("%s:", MESSAGES.getString(PASSWORD_PASSWORD_LENGTH))); + this.lengthLabel = new JLabel(String.format("%s:", localizedMessages.getString(PASSWORD_PASSWORD_LENGTH))); this.lengthPanel.add(this.lengthLabel); int passwordGenerationLength = Configuration.getInstance().getInteger("default.password.generation.length", 14); @@ -165,14 +164,14 @@ private void initDialog(final Component parent, final boolean showAcceptButton) this.lengthPanel.add(this.lengthSpinner); this.charactersPanel = new JPanel(); - this.charactersPanel.setBorder(new TitledBorder(MESSAGES.getString(VIEW_WINDOW_SETTINGS))); + this.charactersPanel.setBorder(new TitledBorder(localizedMessages.getString(VIEW_WINDOW_SETTINGS))); this.charactersPanel.add(this.lengthPanel); this.checkBoxes = new JCheckBox[PASSWORD_OPTIONS.length]; for (int i = 0; i < PASSWORD_OPTIONS.length; i++) { this.checkBoxes[i] = new JCheckBox(PASSWORD_OPTIONS[i][0], true); this.charactersPanel.add(this.checkBoxes[i]); } - this.customSymbolsCheck = new JCheckBox(MESSAGES.getString(VIEW_WINDOW_CUSTOM_SYMBOLS)); + this.customSymbolsCheck = new JCheckBox(localizedMessages.getString(VIEW_WINDOW_CUSTOM_SYMBOLS)); this.customSymbolsCheck.setActionCommand("custom_symbols_check"); this.customSymbolsCheck.addActionListener(this); this.charactersPanel.add(this.customSymbolsCheck); @@ -184,11 +183,11 @@ private void initDialog(final Component parent, final boolean showAcceptButton) SpringUtilities.makeCompactGrid(this.charactersPanel, 6, 1, 5, 5, 5, 5); this.passwordPanel = new JPanel(new BorderLayout()); - this.passwordPanel.setBorder(new TitledBorder(MESSAGES.getString(PASSWORD_GENERATED_PASSWORD))); + this.passwordPanel.setBorder(new TitledBorder(localizedMessages.getString(PASSWORD_GENERATED_PASSWORD))); this.passwordField = TextComponentFactory.newTextField(); this.passwordPanel.add(this.passwordField, BorderLayout.NORTH); - this.generateButton = new JButton(MESSAGES.getString(ENTRY_DIALOG_GENERATE_ENTRY), MessageDialog.getIcon("generate")); + this.generateButton = new JButton(localizedMessages.getString(ENTRY_DIALOG_GENERATE_ENTRY), MessageDialog.getIcon("generate")); this.generateButton.setActionCommand("generate_button"); this.generateButton.addActionListener(this); this.generateButton.setMnemonic(KeyEvent.VK_G); @@ -199,15 +198,15 @@ private void initDialog(final Component parent, final boolean showAcceptButton) this.buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); if (showAcceptButton) { - this.acceptButton = new JButton(MESSAGES.getString(BUTTON_MESSAGE_ACCEPT), MessageDialog.getIcon("accept")); + this.acceptButton = new JButton(localizedMessages.getString(BUTTON_MESSAGE_ACCEPT), MessageDialog.getIcon("accept")); this.acceptButton.setActionCommand("accept_button"); this.acceptButton.setMnemonic(KeyEvent.VK_A); this.acceptButton.addActionListener(this); this.buttonPanel.add(this.acceptButton); - this.cancelButton = new JButton(MESSAGES.getString(BUTTON_MESSAGE_CANCEL), MessageDialog.getIcon("cancel")); + this.cancelButton = new JButton(localizedMessages.getString(BUTTON_MESSAGE_CANCEL), MessageDialog.getIcon("cancel")); } else { - this.cancelButton = new JButton(MESSAGES.getString(BUTTON_MESSAGE_CLOSE), MessageDialog.getIcon("close")); + this.cancelButton = new JButton(localizedMessages.getString(BUTTON_MESSAGE_CLOSE), MessageDialog.getIcon("close")); } this.cancelButton.setActionCommand("cancel_button"); @@ -248,7 +247,7 @@ public void actionPerformed(ActionEvent e) { } if (characterSet.isEmpty()) { - MessageDialog.showWarningMessage(this, MESSAGES.getString(PASSWORD_CAN_NOT_GENERATE_PASSWORD)); + MessageDialog.showWarningMessage(this, localizedMessages.getString(PASSWORD_CAN_NOT_GENERATE_PASSWORD)); return; } @@ -261,7 +260,7 @@ public void actionPerformed(ActionEvent e) { } else if ("accept_button".equals(command)) { this.generatedPassword = this.passwordField.getText(); if (this.generatedPassword.isEmpty()) { - MessageDialog.showWarningMessage(this, MESSAGES.getString(PASSWORD_GENERATE_PASSWORD_REQUEST)); + MessageDialog.showWarningMessage(this, localizedMessages.getString(PASSWORD_GENERATE_PASSWORD_REQUEST)); return; } dispose(); diff --git a/src/main/java/jpass/ui/JPassFrame.java b/src/main/java/jpass/ui/JPassFrame.java index 633364f..e9732f1 100644 --- a/src/main/java/jpass/ui/JPassFrame.java +++ b/src/main/java/jpass/ui/JPassFrame.java @@ -70,6 +70,7 @@ import static jpass.util.Constants.EDIT_MENU; import static jpass.util.Constants.FILE_MENU; import static jpass.util.Constants.HELP_MENU; +import static jpass.util.Constants.PANEL_SAVE_MODIFIED_QUESTION_MESSAGE; import static jpass.util.Constants.TOOLS_MENU; /** @@ -80,7 +81,7 @@ */ public final class JPassFrame extends JFrame { - public static ResourceBundle MESSAGES = null; + public static ResourceBundle localizedMessages = null; private static final Logger LOG = Logger.getLogger(JPassFrame.class.getName()); private static JPassFrame instance; @@ -113,7 +114,7 @@ private JPassFrame(String fileName, Locale locale) { LOG.log(Level.CONFIG, "Could not set application icon.", e); } - MESSAGES = ResourceBundle.getBundle("resources.languages.Messages", locale); + localizedMessages = ResourceBundle.getBundle("resources.languages.languages", locale); this.toolBar = new JToolBar(); this.toolBar.setFloatable(false); @@ -146,7 +147,7 @@ private JPassFrame(String fileName, Locale locale) { this.jpassMenuBar = new JMenuBar(); - this.fileMenu = new JMenu(MESSAGES.getString(FILE_MENU)); + this.fileMenu = new JMenu(localizedMessages.getString(FILE_MENU)); this.fileMenu.setMnemonic(KeyEvent.VK_F); this.fileMenu.add(MenuActionType.NEW_FILE.getAction()); this.fileMenu.add(MenuActionType.OPEN_FILE.getAction()); @@ -161,7 +162,7 @@ private JPassFrame(String fileName, Locale locale) { this.fileMenu.add(MenuActionType.EXIT.getAction()); this.jpassMenuBar.add(this.fileMenu); - this.editMenu = new JMenu(MESSAGES.getString(EDIT_MENU)); + this.editMenu = new JMenu(localizedMessages.getString(EDIT_MENU)); this.editMenu.setMnemonic(KeyEvent.VK_E); this.editMenu.add(MenuActionType.ADD_ENTRY.getAction()); this.editMenu.add(MenuActionType.EDIT_ENTRY.getAction()); @@ -175,13 +176,13 @@ private JPassFrame(String fileName, Locale locale) { this.editMenu.add(MenuActionType.FIND_ENTRY.getAction()); this.jpassMenuBar.add(this.editMenu); - this.toolsMenu = new JMenu(MESSAGES.getString(TOOLS_MENU)); + this.toolsMenu = new JMenu(localizedMessages.getString(TOOLS_MENU)); this.toolsMenu.setMnemonic(KeyEvent.VK_T); this.toolsMenu.add(MenuActionType.GENERATE_PASSWORD.getAction()); this.toolsMenu.add(MenuActionType.CLEAR_CLIPBOARD.getAction()); this.jpassMenuBar.add(this.toolsMenu); - this.helpMenu = new JMenu(MESSAGES.getString(HELP_MENU)); + this.helpMenu = new JMenu(localizedMessages.getString(HELP_MENU)); this.helpMenu.setMnemonic(KeyEvent.VK_H); this.helpMenu.add(MenuActionType.LICENSE.getAction()); this.helpMenu.addSeparator(); @@ -231,7 +232,7 @@ public static JPassFrame getInstance() { public static synchronized JPassFrame getInstance(String fileName) { if (instance == null) { - Locale locale = new Locale("es", "US"); + Locale locale = new Locale("es", "MX"); instance = new JPassFrame(fileName, locale); } return instance; @@ -298,9 +299,9 @@ public void refreshEntryTitleList(String selectTitle) { } if (searchCriteria.isEmpty()) { - this.statusPanel.setText(String.format("%s: %d", MESSAGES.getString(BOTTOM_MENU_ENTRIES_COUNT), entries.size())); + this.statusPanel.setText(String.format("%s: %d", localizedMessages.getString(BOTTOM_MENU_ENTRIES_COUNT), entries.size())); } else { - this.statusPanel.setText(String.format("%s: %d / %d", MESSAGES.getString(BOTTOM_MENU_ENTRIES_FOUND), this.entryDetailsTable.getRowCount(), entries.size())); + this.statusPanel.setText(String.format("%s: %d / %d", localizedMessages.getString(BOTTOM_MENU_ENTRIES_FOUND), this.entryDetailsTable.getRowCount(), entries.size())); } } @@ -323,7 +324,7 @@ public void exitFrame() { return; } if (this.model.isModified()) { - int option = showQuestionMessage(this, FileHelper.SAVE_MODIFIED_QUESTION_MESSAGE, YES_NO_CANCEL_OPTION); + int option = showQuestionMessage(this, localizedMessages.getString(PANEL_SAVE_MODIFIED_QUESTION_MESSAGE), YES_NO_CANCEL_OPTION); if (option == YES_OPTION) { FileHelper.saveFile(this, false, () -> System.exit(0)); return; diff --git a/src/main/java/jpass/ui/MessageDialog.java b/src/main/java/jpass/ui/MessageDialog.java index bae3b7c..0c9394d 100644 --- a/src/main/java/jpass/ui/MessageDialog.java +++ b/src/main/java/jpass/ui/MessageDialog.java @@ -61,7 +61,7 @@ import jpass.util.SpringUtilities; -import static jpass.ui.JPassFrame.MESSAGES; +import static jpass.ui.JPassFrame.localizedMessages; import static jpass.util.Constants.BUTTON_MESSAGE_CANCEL; import static jpass.util.Constants.BUTTON_MESSAGE_NO; import static jpass.util.Constants.BUTTON_MESSAGE_OK; @@ -118,23 +118,23 @@ private void initializeDialog(final Component parent, final Object message, fina JButton defaultButton; switch (optionType) { case YES_NO_OPTION: - defaultButton = createButton(MESSAGES.getString(BUTTON_MESSAGE_YES), YES_OPTION, getIcon("accept")); + defaultButton = createButton(localizedMessages.getString(BUTTON_MESSAGE_YES), YES_OPTION, getIcon("accept")); buttonPanel.add(defaultButton); - buttonPanel.add(createButton(MESSAGES.getString(BUTTON_MESSAGE_NO), NO_OPTION, getIcon("close"))); + buttonPanel.add(createButton(localizedMessages.getString(BUTTON_MESSAGE_NO), NO_OPTION, getIcon("close"))); break; case YES_NO_CANCEL_OPTION: - defaultButton = createButton(MESSAGES.getString(BUTTON_MESSAGE_YES), YES_OPTION, getIcon("accept")); + defaultButton = createButton(localizedMessages.getString(BUTTON_MESSAGE_YES), YES_OPTION, getIcon("accept")); buttonPanel.add(defaultButton); - buttonPanel.add(createButton(MESSAGES.getString(BUTTON_MESSAGE_NO), NO_OPTION, getIcon("close"))); - buttonPanel.add(createButton(MESSAGES.getString(BUTTON_MESSAGE_CANCEL), CANCEL_OPTION, getIcon("cancel"))); + buttonPanel.add(createButton(localizedMessages.getString(BUTTON_MESSAGE_NO), NO_OPTION, getIcon("close"))); + buttonPanel.add(createButton(localizedMessages.getString(BUTTON_MESSAGE_CANCEL), CANCEL_OPTION, getIcon("cancel"))); break; case OK_CANCEL_OPTION: - defaultButton = createButton(MESSAGES.getString(BUTTON_MESSAGE_OK), OK_OPTION, getIcon("accept")); + defaultButton = createButton(localizedMessages.getString(BUTTON_MESSAGE_OK), OK_OPTION, getIcon("accept")); buttonPanel.add(defaultButton); - buttonPanel.add(createButton(MESSAGES.getString(BUTTON_MESSAGE_CANCEL), CANCEL_OPTION, getIcon("cancel"))); + buttonPanel.add(createButton(localizedMessages.getString(BUTTON_MESSAGE_CANCEL), CANCEL_OPTION, getIcon("cancel"))); break; default: - defaultButton = createButton(MESSAGES.getString(BUTTON_MESSAGE_OK), OK_OPTION, getIcon("accept")); + defaultButton = createButton(localizedMessages.getString(BUTTON_MESSAGE_OK), OK_OPTION, getIcon("accept")); buttonPanel.add(defaultButton); break; } @@ -217,7 +217,7 @@ private static int showMessageDialog(final Component parent, final Object messag * @param message dialog message */ public static void showWarningMessage(final Component parent, final String message) { - showMessageDialog(parent, message, MESSAGES.getString(SHOW_MESSAGE_WARNING), getIcon("dialog_warning")); + showMessageDialog(parent, message, localizedMessages.getString(SHOW_MESSAGE_WARNING), getIcon("dialog_warning")); } /** @@ -227,7 +227,7 @@ public static void showWarningMessage(final Component parent, final String messa * @param message dialog message */ public static void showErrorMessage(final Component parent, final String message) { - showMessageDialog(parent, message, MESSAGES.getString(SHOW_MESSAGE_ERROR), getIcon("dialog_error")); + showMessageDialog(parent, message, localizedMessages.getString(SHOW_MESSAGE_ERROR), getIcon("dialog_error")); } /** @@ -237,7 +237,7 @@ public static void showErrorMessage(final Component parent, final String message * @param message dialog message */ public static void showInformationMessage(final Component parent, final String message) { - showMessageDialog(parent, message, MESSAGES.getString(SHOW_MESSAGE_INFORMATION), getIcon("dialog_info")); + showMessageDialog(parent, message, localizedMessages.getString(SHOW_MESSAGE_INFORMATION), getIcon("dialog_info")); } /** @@ -249,7 +249,7 @@ public static void showInformationMessage(final Component parent, final String m * @return selected option */ public static int showQuestionMessage(final Component parent, final String message, final int optionType) { - return showMessageDialog(parent, message, MESSAGES.getString(SHOW_MESSAGE_CONFIRMATION), getIcon("dialog_question"), optionType); + return showMessageDialog(parent, message, localizedMessages.getString(SHOW_MESSAGE_CONFIRMATION), getIcon("dialog_question"), optionType); } /** @@ -261,13 +261,13 @@ public static int showQuestionMessage(final Component parent, final String messa */ public static char[] showPasswordDialog(final Component parent, final boolean confirm) { JPanel panel = new JPanel(); - panel.add(new JLabel(String.format("%s:", MESSAGES.getString(VIEW_WINDOW_PASSWORD)))); + panel.add(new JLabel(String.format("%s:", localizedMessages.getString(VIEW_WINDOW_PASSWORD)))); final JPasswordField password = TextComponentFactory.newPasswordField(); panel.add(password); JPasswordField repeat = null; if (confirm) { repeat = TextComponentFactory.newPasswordField(); - panel.add(new JLabel(String.format("%s:", MESSAGES.getString(VIEW_WINDOW_REPEAT)))); + panel.add(new JLabel(String.format("%s:", localizedMessages.getString(VIEW_WINDOW_REPEAT)))); panel.add(repeat); } panel.setLayout(new SpringLayout()); @@ -275,12 +275,12 @@ public static char[] showPasswordDialog(final Component parent, final boolean co boolean incorrect = true; while (incorrect) { - int option = showMessageDialog(parent, panel, MESSAGES.getString(PASSWORD_ENTER_PASSWORD_REQUEST), getIcon("dialog_lock"), OK_CANCEL_OPTION); + int option = showMessageDialog(parent, panel, localizedMessages.getString(PASSWORD_ENTER_PASSWORD_REQUEST), getIcon("dialog_lock"), OK_CANCEL_OPTION); if (option == OK_OPTION) { if (password.getPassword().length == 0) { - showWarningMessage(parent, MESSAGES.getString(PASSWORD_ENTER_PASSWORD_REQUEST)); + showWarningMessage(parent, localizedMessages.getString(PASSWORD_ENTER_PASSWORD_REQUEST)); } else if (confirm && !Arrays.equals(password.getPassword(), repeat.getPassword())) { - showWarningMessage(parent, MESSAGES.getString(PASSWORD_PASSWORDS_NOT_IDENTICAL)); + showWarningMessage(parent, localizedMessages.getString(PASSWORD_PASSWORDS_NOT_IDENTICAL)); } else { incorrect = false; } diff --git a/src/main/java/jpass/ui/SearchPanel.java b/src/main/java/jpass/ui/SearchPanel.java index ca5a1ed..1f6a82d 100644 --- a/src/main/java/jpass/ui/SearchPanel.java +++ b/src/main/java/jpass/ui/SearchPanel.java @@ -46,6 +46,8 @@ import static javax.swing.KeyStroke.getKeyStroke; import static java.awt.event.KeyEvent.VK_ESCAPE; +import static jpass.ui.JPassFrame.localizedMessages; +import static jpass.util.Constants.PANEL_FIND; /** * Class for representing search panel. Search panel is hidden by default. @@ -71,7 +73,7 @@ public SearchPanel(Consumer searchCallback) { super(new BorderLayout()); setBorder(new EmptyBorder(2, 2, 2, 2)); - this.label = new JLabel("Find: ", MessageDialog.getIcon("find"), SwingConstants.LEADING); + this.label = new JLabel(String.format("%s: ", localizedMessages.getString(PANEL_FIND)), MessageDialog.getIcon("find"), SwingConstants.LEADING); this.criteriaField = TextComponentFactory.newTextField(); diff --git a/src/main/java/jpass/ui/StatusPanel.java b/src/main/java/jpass/ui/StatusPanel.java index 01d6c19..fa37290 100644 --- a/src/main/java/jpass/ui/StatusPanel.java +++ b/src/main/java/jpass/ui/StatusPanel.java @@ -30,10 +30,13 @@ import java.awt.BorderLayout; -import javax.swing.JLabel; -import javax.swing.JPanel; import javax.swing.JProgressBar; import javax.swing.border.EmptyBorder; +import javax.swing.JLabel; +import javax.swing.JPanel; + +import static jpass.ui.JPassFrame.localizedMessages; +import static jpass.util.Constants.PANEL_PROCESSING; /** * Class for representing a status bar. @@ -67,6 +70,6 @@ public String getText() { public void setProcessing(boolean processing) { this.progressBar.setVisible(processing); this.progressBar.setIndeterminate(processing); - setText(processing ? "Processing..." : " "); + setText(processing ? localizedMessages.getString(PANEL_PROCESSING) : " "); } } diff --git a/src/main/java/jpass/ui/action/MenuActionType.java b/src/main/java/jpass/ui/action/MenuActionType.java index 405fb14..bf2fb7e 100644 --- a/src/main/java/jpass/ui/action/MenuActionType.java +++ b/src/main/java/jpass/ui/action/MenuActionType.java @@ -46,7 +46,7 @@ import static javax.swing.KeyStroke.getKeyStroke; -import static jpass.ui.JPassFrame.MESSAGES; +import static jpass.ui.JPassFrame.localizedMessages; import static jpass.ui.helper.FileHelper.exportFile; import static jpass.ui.helper.FileHelper.importFile; import static jpass.ui.helper.FileHelper.openFile; @@ -85,71 +85,71 @@ * */ public enum MenuActionType { - NEW_FILE(new AbstractMenuAction(MESSAGES.getString(FILE_MENU_NEW), getIcon("new"), getKeyStroke(KeyEvent.VK_N, CTRL_DOWN_MASK)) { + NEW_FILE(new AbstractMenuAction(localizedMessages.getString(FILE_MENU_NEW), getIcon("new"), getKeyStroke(KeyEvent.VK_N, CTRL_DOWN_MASK)) { @Override public void actionPerformed(ActionEvent ev) { createNew(JPassFrame.getInstance()); } }), - OPEN_FILE(new AbstractMenuAction(MESSAGES.getString(Constants.FILE_MENU_OPEN_FILE), getIcon("open"), getKeyStroke(KeyEvent.VK_O, CTRL_DOWN_MASK)) { + OPEN_FILE(new AbstractMenuAction(localizedMessages.getString(Constants.FILE_MENU_OPEN_FILE), getIcon("open"), getKeyStroke(KeyEvent.VK_O, CTRL_DOWN_MASK)) { @Override public void actionPerformed(ActionEvent ev) { openFile(JPassFrame.getInstance()); } }), - SAVE_FILE(new AbstractMenuAction(MESSAGES.getString(FILE_MENU_SAVE), getIcon("save"), getKeyStroke(KeyEvent.VK_S, CTRL_DOWN_MASK)) { + SAVE_FILE(new AbstractMenuAction(localizedMessages.getString(FILE_MENU_SAVE), getIcon("save"), getKeyStroke(KeyEvent.VK_S, CTRL_DOWN_MASK)) { @Override public void actionPerformed(ActionEvent ev) { saveFile(JPassFrame.getInstance(), false); } }), - SAVE_AS_FILE(new AbstractMenuAction(MESSAGES.getString(FILE_MENU_SAVE_AS), getIcon("save_as"), null) { + SAVE_AS_FILE(new AbstractMenuAction(localizedMessages.getString(FILE_MENU_SAVE_AS), getIcon("save_as"), null) { @Override public void actionPerformed(ActionEvent ev) { saveFile(JPassFrame.getInstance(), true); } }), - EXPORT_XML(new AbstractMenuAction(MESSAGES.getString(FILE_MENU_EXPORT_TO_XML), getIcon("export"), null) { + EXPORT_XML(new AbstractMenuAction(localizedMessages.getString(FILE_MENU_EXPORT_TO_XML), getIcon("export"), null) { @Override public void actionPerformed(ActionEvent ev) { exportFile(JPassFrame.getInstance()); } }), - IMPORT_XML(new AbstractMenuAction(MESSAGES.getString(FILE_MENU_IMPORT_FROM_XML), getIcon("import"), null) { + IMPORT_XML(new AbstractMenuAction(localizedMessages.getString(FILE_MENU_IMPORT_FROM_XML), getIcon("import"), null) { @Override public void actionPerformed(ActionEvent ev) { importFile(JPassFrame.getInstance()); } }), - CHANGE_PASSWORD(new AbstractMenuAction(MESSAGES.getString(FILE_MENU_CHANGE_PASSWORD), getIcon("lock"), null) { + CHANGE_PASSWORD(new AbstractMenuAction(localizedMessages.getString(FILE_MENU_CHANGE_PASSWORD), getIcon("lock"), null) { @Override public void actionPerformed(ActionEvent ev) { JPassFrame parent = JPassFrame.getInstance(); char[] password = MessageDialog.showPasswordDialog(parent, true); if (password == null) { - MessageDialog.showInformationMessage(parent, MESSAGES.getString(PASSWORD_PASSWORD_NOT_MODIFIED)); + MessageDialog.showInformationMessage(parent, localizedMessages.getString(PASSWORD_PASSWORD_NOT_MODIFIED)); } else { parent.getModel().setPassword(password); parent.getModel().setModified(true); parent.refreshFrameTitle(); MessageDialog.showInformationMessage(parent, - MESSAGES.getString(PASSWORD_SUCCESSFULLY_MODIFIED)); + localizedMessages.getString(PASSWORD_SUCCESSFULLY_MODIFIED)); } } }), - GENERATE_PASSWORD(new AbstractMenuAction(MESSAGES.getString(TOOLS_MENU_GENERATE_PASSWORD), getIcon("generate"), getKeyStroke(KeyEvent.VK_Z, CTRL_DOWN_MASK)) { + GENERATE_PASSWORD(new AbstractMenuAction(localizedMessages.getString(TOOLS_MENU_GENERATE_PASSWORD), getIcon("generate"), getKeyStroke(KeyEvent.VK_Z, CTRL_DOWN_MASK)) { @Override public void actionPerformed(ActionEvent ev) { new GeneratePasswordDialog(JPassFrame.getInstance()); } }), - EXIT(new AbstractMenuAction(MESSAGES.getString(FILE_MENU_EXIT), getIcon("exit"), getKeyStroke(KeyEvent.VK_F4, ALT_DOWN_MASK)) { + EXIT(new AbstractMenuAction(localizedMessages.getString(FILE_MENU_EXIT), getIcon("exit"), getKeyStroke(KeyEvent.VK_F4, ALT_DOWN_MASK)) { @Override public void actionPerformed(ActionEvent ev) { JPassFrame.getInstance().exitFrame(); } }), - ABOUT(new AbstractMenuAction(MESSAGES.getString(HELP_MENU_ABOUT_JPASS), getIcon("info"), getKeyStroke(KeyEvent.VK_F1, 0)) { + ABOUT(new AbstractMenuAction(localizedMessages.getString(HELP_MENU_ABOUT_JPASS), getIcon("info"), getKeyStroke(KeyEvent.VK_F1, 0)) { @Override public void actionPerformed(ActionEvent ev) { StringBuilder sb = new StringBuilder(); @@ -162,37 +162,37 @@ public void actionPerformed(ActionEvent ev) { MessageDialog.showInformationMessage(JPassFrame.getInstance(), sb.toString()); } }), - LICENSE(new AbstractMenuAction(MESSAGES.getString(HELP_MENU_LICENSE), getIcon("license"), null) { + LICENSE(new AbstractMenuAction(localizedMessages.getString(HELP_MENU_LICENSE), getIcon("license"), null) { @Override public void actionPerformed(ActionEvent ev) { - MessageDialog.showTextFile(JPassFrame.getInstance(), MESSAGES.getString(HELP_MENU_LICENSE), "license.txt"); + MessageDialog.showTextFile(JPassFrame.getInstance(), localizedMessages.getString(HELP_MENU_LICENSE), "license.txt"); } }), - ADD_ENTRY(new AbstractMenuAction(MESSAGES.getString(EDIT_MENU_ADD_ENTRY), getIcon("entry_new"), getKeyStroke(KeyEvent.VK_Y, CTRL_DOWN_MASK)) { + ADD_ENTRY(new AbstractMenuAction(localizedMessages.getString(EDIT_MENU_ADD_ENTRY), getIcon("entry_new"), getKeyStroke(KeyEvent.VK_Y, CTRL_DOWN_MASK)) { @Override public void actionPerformed(ActionEvent ev) { EntryHelper.addEntry(JPassFrame.getInstance()); } }), - EDIT_ENTRY(new AbstractMenuAction(MESSAGES.getString(EDIT_MENU_EDIT_ENTRY), getIcon("entry_edit"), getKeyStroke(KeyEvent.VK_E, CTRL_DOWN_MASK)) { + EDIT_ENTRY(new AbstractMenuAction(localizedMessages.getString(EDIT_MENU_EDIT_ENTRY), getIcon("entry_edit"), getKeyStroke(KeyEvent.VK_E, CTRL_DOWN_MASK)) { @Override public void actionPerformed(ActionEvent ev) { EntryHelper.editEntry(JPassFrame.getInstance()); } }), - DUPLICATE_ENTRY(new AbstractMenuAction(MESSAGES.getString(EDIT_MENU_DUPLICATE_ENTRY), getIcon("entry_duplicate"), getKeyStroke(KeyEvent.VK_K, CTRL_DOWN_MASK)) { + DUPLICATE_ENTRY(new AbstractMenuAction(localizedMessages.getString(EDIT_MENU_DUPLICATE_ENTRY), getIcon("entry_duplicate"), getKeyStroke(KeyEvent.VK_K, CTRL_DOWN_MASK)) { @Override public void actionPerformed(ActionEvent ev) { EntryHelper.duplicateEntry(JPassFrame.getInstance()); } }), - DELETE_ENTRY(new AbstractMenuAction(MESSAGES.getString(EDIT_MENU_DELETE_ENTRY), getIcon("entry_delete"), getKeyStroke(KeyEvent.VK_D, CTRL_DOWN_MASK)) { + DELETE_ENTRY(new AbstractMenuAction(localizedMessages.getString(EDIT_MENU_DELETE_ENTRY), getIcon("entry_delete"), getKeyStroke(KeyEvent.VK_D, CTRL_DOWN_MASK)) { @Override public void actionPerformed(ActionEvent ev) { EntryHelper.deleteEntry(JPassFrame.getInstance()); } }), - COPY_URL(new AbstractMenuAction(MESSAGES.getString(EDIT_MENU_COPY_URL), getIcon("url"), getKeyStroke(KeyEvent.VK_U, CTRL_DOWN_MASK)) { + COPY_URL(new AbstractMenuAction(localizedMessages.getString(EDIT_MENU_COPY_URL), getIcon("url"), getKeyStroke(KeyEvent.VK_U, CTRL_DOWN_MASK)) { @Override public void actionPerformed(ActionEvent ev) { JPassFrame parent = JPassFrame.getInstance(); @@ -202,7 +202,7 @@ public void actionPerformed(ActionEvent ev) { } } }), - COPY_USER(new AbstractMenuAction(MESSAGES.getString(EDIT_MENU_COPY_USERNAME), getIcon("user"), getKeyStroke(KeyEvent.VK_B, CTRL_DOWN_MASK)) { + COPY_USER(new AbstractMenuAction(localizedMessages.getString(EDIT_MENU_COPY_USERNAME), getIcon("user"), getKeyStroke(KeyEvent.VK_B, CTRL_DOWN_MASK)) { @Override public void actionPerformed(ActionEvent ev) { JPassFrame parent = JPassFrame.getInstance(); @@ -212,7 +212,7 @@ public void actionPerformed(ActionEvent ev) { } } }), - COPY_PASSWORD(new AbstractMenuAction(MESSAGES.getString(EDIT_MENU_COPY_PASSWORD), getIcon("keyring"), getKeyStroke(KeyEvent.VK_C, CTRL_DOWN_MASK)) { + COPY_PASSWORD(new AbstractMenuAction(localizedMessages.getString(EDIT_MENU_COPY_PASSWORD), getIcon("keyring"), getKeyStroke(KeyEvent.VK_C, CTRL_DOWN_MASK)) { @Override public void actionPerformed(ActionEvent ev) { JPassFrame parent = JPassFrame.getInstance(); @@ -222,13 +222,13 @@ public void actionPerformed(ActionEvent ev) { } } }), - CLEAR_CLIPBOARD(new AbstractMenuAction(MESSAGES.getString(EDIT_MENU_CLEAR_CLIPBOARD), getIcon("clear"), getKeyStroke(KeyEvent.VK_X, CTRL_DOWN_MASK)) { + CLEAR_CLIPBOARD(new AbstractMenuAction(localizedMessages.getString(EDIT_MENU_CLEAR_CLIPBOARD), getIcon("clear"), getKeyStroke(KeyEvent.VK_X, CTRL_DOWN_MASK)) { @Override public void actionPerformed(ActionEvent ev) { EntryHelper.copyEntryField(JPassFrame.getInstance(), null); } }), - FIND_ENTRY(new AbstractMenuAction(MESSAGES.getString(EDIT_MENU_FIND_ENTRY), getIcon("find"), getKeyStroke(KeyEvent.VK_F, CTRL_DOWN_MASK)) { + FIND_ENTRY(new AbstractMenuAction(localizedMessages.getString(EDIT_MENU_FIND_ENTRY), getIcon("find"), getKeyStroke(KeyEvent.VK_F, CTRL_DOWN_MASK)) { @Override public void actionPerformed(ActionEvent ev) { JPassFrame.getInstance().getSearchPanel().setVisible(true); diff --git a/src/main/java/jpass/ui/helper/EntryHelper.java b/src/main/java/jpass/ui/helper/EntryHelper.java index 84ec309..124a12a 100644 --- a/src/main/java/jpass/ui/helper/EntryHelper.java +++ b/src/main/java/jpass/ui/helper/EntryHelper.java @@ -33,11 +33,17 @@ import jpass.util.ClipboardUtils; import jpass.xml.bind.Entry; +import static jpass.ui.JPassFrame.localizedMessages; import static jpass.ui.MessageDialog.showErrorMessage; import static jpass.ui.MessageDialog.showWarningMessage; import static jpass.ui.MessageDialog.showQuestionMessage; import static jpass.ui.MessageDialog.YES_NO_OPTION; import static jpass.ui.MessageDialog.YES_OPTION; +import static jpass.util.Constants.ENTRY_DIALOG_ADD_NEW_ENTRY; +import static jpass.util.Constants.ENTRY_DIALOG_DUPLICATE_ENTRY; +import static jpass.util.Constants.ENTRY_DIALOG_EDIT_ENTRY; +import static jpass.util.Constants.ENTRY_DIALOG_PLEASE_SELECT_ENTRY; +import static jpass.util.Constants.ENTRY_DIALOG_WANT_DELETE_ENTRY; /** * Helper class for entry operations. @@ -58,10 +64,10 @@ private EntryHelper() { */ public static void deleteEntry(JPassFrame parent) { if (parent.getEntryTitleTable().getSelectedRow() == -1) { - showWarningMessage(parent, "Please select an entry."); + showWarningMessage(parent, localizedMessages.getString(ENTRY_DIALOG_PLEASE_SELECT_ENTRY)); return; } - int option = showQuestionMessage(parent, "Do you really want to delete this entry?", YES_NO_OPTION); + int option = showQuestionMessage(parent, localizedMessages.getString(ENTRY_DIALOG_WANT_DELETE_ENTRY), YES_NO_OPTION); if (option == YES_OPTION) { String title = (String) parent.getEntryTitleTable().getValueAt(parent.getEntryTitleTable().getSelectedRow(), 0); parent.getModel().getEntries().getEntry().remove(parent.getModel().getEntryByTitle(title)); @@ -78,12 +84,12 @@ public static void deleteEntry(JPassFrame parent) { */ public static void duplicateEntry(JPassFrame parent) { if (parent.getEntryTitleTable().getSelectedRow() == -1) { - showWarningMessage(parent, "Please select an entry."); + showWarningMessage(parent, localizedMessages.getString(ENTRY_DIALOG_PLEASE_SELECT_ENTRY)); return; } String title = (String) parent.getEntryTitleTable().getValueAt(parent.getEntryTitleTable().getSelectedRow(), 0); Entry originalEntry = parent.getModel().getEntryByTitle(title); - EntryDialog dialog = new EntryDialog(parent, "Duplicate Entry", originalEntry, true); + EntryDialog dialog = new EntryDialog(parent, localizedMessages.getString(ENTRY_DIALOG_DUPLICATE_ENTRY), originalEntry, true); dialog.getModifiedEntry().ifPresent(entry -> { parent.getModel().getEntries().getEntry().add(entry); parent.getModel().setModified(true); @@ -99,12 +105,12 @@ public static void duplicateEntry(JPassFrame parent) { */ public static void editEntry(JPassFrame parent) { if (parent.getEntryTitleTable().getSelectedRow() == -1) { - showWarningMessage(parent, "Please select an entry."); + showWarningMessage(parent, localizedMessages.getString(ENTRY_DIALOG_PLEASE_SELECT_ENTRY)); return; } String title = (String) parent.getEntryTitleTable().getValueAt(parent.getEntryTitleTable().getSelectedRow(), 0); Entry originalEntry = parent.getModel().getEntryByTitle(title); - EntryDialog dialog = new EntryDialog(parent, "Edit Entry", originalEntry, false); + EntryDialog dialog = new EntryDialog(parent, localizedMessages.getString(ENTRY_DIALOG_EDIT_ENTRY), originalEntry, false); dialog.getModifiedEntry().ifPresent(entry -> { entry.setCreationDate(originalEntry.getCreationDate()); parent.getModel().getEntries().getEntry().remove(originalEntry); @@ -121,7 +127,7 @@ public static void editEntry(JPassFrame parent) { * @param parent parent component */ public static void addEntry(JPassFrame parent) { - EntryDialog dialog = new EntryDialog(parent, "Add New Entry", null, true); + EntryDialog dialog = new EntryDialog(parent, localizedMessages.getString(ENTRY_DIALOG_ADD_NEW_ENTRY), null, true); dialog.getModifiedEntry().ifPresent(entry -> { parent.getModel().getEntries().getEntry().add(entry); parent.getModel().setModified(true); @@ -138,7 +144,7 @@ public static void addEntry(JPassFrame parent) { */ public static Entry getSelectedEntry(JPassFrame parent) { if (parent.getEntryTitleTable().getSelectedRow() == -1) { - showWarningMessage(parent, "Please select an entry."); + showWarningMessage(parent, localizedMessages.getString(ENTRY_DIALOG_PLEASE_SELECT_ENTRY)); return null; } String title = (String) parent.getEntryTitleTable().getValueAt(parent.getEntryTitleTable().getSelectedRow(), 0); diff --git a/src/main/java/jpass/ui/helper/FileHelper.java b/src/main/java/jpass/ui/helper/FileHelper.java index 9a3f3ef..36c943c 100644 --- a/src/main/java/jpass/ui/helper/FileHelper.java +++ b/src/main/java/jpass/ui/helper/FileHelper.java @@ -40,6 +40,7 @@ import jpass.ui.action.Worker; import jpass.util.Configuration; +import static jpass.ui.JPassFrame.localizedMessages; import static jpass.ui.MessageDialog.showPasswordDialog; import static jpass.ui.MessageDialog.showWarningMessage; import static jpass.ui.MessageDialog.showQuestionMessage; @@ -47,6 +48,12 @@ import static jpass.ui.MessageDialog.YES_OPTION; import static jpass.ui.MessageDialog.YES_NO_CANCEL_OPTION; import static jpass.ui.MessageDialog.NO_OPTION; +import static jpass.util.Constants.PANEL_EXPORT; +import static jpass.util.Constants.PANEL_IMPORT; +import static jpass.util.Constants.PANEL_OPEN; +import static jpass.util.Constants.PANEL_SAVE; +import static jpass.util.Constants.PANEL_SAVE_MODIFIED_QUESTION_MESSAGE; +import static jpass.util.Constants.PANEL_UNENCRYPTED_DATA_WARNING_MESSAGE; import static jpass.util.StringUtils.stripString; import static java.lang.String.format; @@ -59,12 +66,6 @@ */ public final class FileHelper { - public static final String SAVE_MODIFIED_QUESTION_MESSAGE - = "The current file has been modified.\n" - + "Do you want to save the changes before closing?"; - private static final String UNENCRYPTED_DATA_WARNING_MESSAGE - = "Please note that all data will be stored unencrypted.\n" - + "Make sure you keep the exported file in a secure location."; private static final String OPEN_ERROR_CHECK_PASSWORD_ERROR_MESSAGE = "An error occured during the open operation.\nThe password might be incorrect.\n(Error: %s)"; private static final String CREATE_FILE_QUESTION_MESSAGE @@ -88,7 +89,7 @@ private FileHelper() { */ public static void createNew(final JPassFrame parent) { if (parent.getModel().isModified()) { - int option = showQuestionMessage(parent, SAVE_MODIFIED_QUESTION_MESSAGE, YES_NO_CANCEL_OPTION); + int option = showQuestionMessage(parent, localizedMessages.getString(PANEL_SAVE_MODIFIED_QUESTION_MESSAGE), YES_NO_CANCEL_OPTION); if (option == YES_OPTION) { saveFile(parent, false, () -> { parent.clearModel(); @@ -111,8 +112,8 @@ public static void createNew(final JPassFrame parent) { * @param parent parent component */ public static void exportFile(final JPassFrame parent) { - showWarningMessage(parent, UNENCRYPTED_DATA_WARNING_MESSAGE); - File file = showFileChooser(parent, "Export", "xml", XML_FILES); + showWarningMessage(parent, localizedMessages.getString(PANEL_UNENCRYPTED_DATA_WARNING_MESSAGE)); + File file = showFileChooser(parent, localizedMessages.getString(PANEL_EXPORT), "xml", XML_FILES); if (file == null) { return; } @@ -140,13 +141,13 @@ protected Void doInBackground() throws Exception { * @param parent parent component */ public static void importFile(final JPassFrame parent) { - File file = showFileChooser(parent, "Import", "xml", XML_FILES); + File file = showFileChooser(parent, localizedMessages.getString(PANEL_IMPORT), "xml", XML_FILES); if (file == null) { return; } final String fileName = file.getPath(); if (parent.getModel().isModified()) { - int option = showQuestionMessage(parent, SAVE_MODIFIED_QUESTION_MESSAGE, YES_NO_CANCEL_OPTION); + int option = showQuestionMessage(parent, localizedMessages.getString(PANEL_SAVE_MODIFIED_QUESTION_MESSAGE), YES_NO_CANCEL_OPTION); if (option == YES_OPTION) { saveFile(parent, false, () -> importFileInBackground(fileName, parent)); return; @@ -205,7 +206,7 @@ public static void saveFile(final JPassFrame parent, final boolean saveAs) { public static void saveFile(final JPassFrame parent, final boolean saveAs, final Runnable successCallback) { final String fileName; if (saveAs || parent.getModel().getFileName() == null) { - File file = showFileChooser(parent, "Save", "jpass", JPASS_DATA_FILES); + File file = showFileChooser(parent, localizedMessages.getString(PANEL_SAVE), "jpass", JPASS_DATA_FILES); if (file == null) { return; } @@ -264,12 +265,12 @@ protected void done() { * @param parent parent component */ public static void openFile(final JPassFrame parent) { - final File file = showFileChooser(parent, "Open", "jpass", JPASS_DATA_FILES); + final File file = showFileChooser(parent, localizedMessages.getString(PANEL_OPEN), "jpass", JPASS_DATA_FILES); if (file == null) { return; } if (parent.getModel().isModified()) { - int option = showQuestionMessage(parent, SAVE_MODIFIED_QUESTION_MESSAGE, YES_NO_CANCEL_OPTION); + int option = showQuestionMessage(parent, localizedMessages.getString(PANEL_SAVE_MODIFIED_QUESTION_MESSAGE), YES_NO_CANCEL_OPTION); if (option == YES_OPTION) { saveFile(parent, false, () -> openFileInBackground(file.getPath(), parent)); return; diff --git a/src/main/java/jpass/util/Constants.java b/src/main/java/jpass/util/Constants.java index b04e84b..a150f6b 100644 --- a/src/main/java/jpass/util/Constants.java +++ b/src/main/java/jpass/util/Constants.java @@ -1,6 +1,6 @@ package jpass.util; -public class Constants { +public final class Constants { private Constants() { // not intended to be instantiated } @@ -74,7 +74,23 @@ private Constants() { public static final String ENTRY_DIALOG_SHOW_ENTRY = "entryDialog.showEntry"; public static final String ENTRY_DIALOG_GENERATE_ENTRY = "entryDialog.generateEntry"; public static final String ENTRY_DIALOG_COPY_ENTRY = "entryDialog.copyEntry"; + public static final String ENTRY_DIALOG_FILL_TITLE_FIELD = "entryDialog.fillTitleField"; + public static final String ENTRY_DIALOG_TITLE_ALREADY_EXISTS = "entryDialog.titleAlreadyExists"; + public static final String ENTRY_DIALOG_PLEASE_SELECT_ENTRY = "entryDialog.pleaseSelectEntry"; + public static final String ENTRY_DIALOG_WANT_DELETE_ENTRY = "entryDialog.wantDeleteEntry"; + public static final String ENTRY_DIALOG_DUPLICATE_ENTRY = "entryDialog.duplicateEntry"; + public static final String ENTRY_DIALOG_EDIT_ENTRY = "entryDialog.editEntry"; + public static final String ENTRY_DIALOG_ADD_NEW_ENTRY = "entryDialog.addNewEntry"; public static final String BOTTOM_MENU_ENTRIES_COUNT = "bottomMenu.entriesCount"; - public static final String BOTTOM_MENU_ENTRIES_FOUND= "bottomMenu.entriesFound"; + public static final String BOTTOM_MENU_ENTRIES_FOUND = "bottomMenu.entriesFound"; + + public static final String PANEL_PROCESSING = "panel.processing"; + public static final String PANEL_FIND = "panel.find"; + public static final String PANEL_EXPORT = "panel.export"; + public static final String PANEL_IMPORT = "panel.import"; + public static final String PANEL_SAVE = "panel.save"; + public static final String PANEL_OPEN = "panel.open"; + public static final String PANEL_SAVE_MODIFIED_QUESTION_MESSAGE = "panel.saveModifiedQuestionMessage"; + public static final String PANEL_UNENCRYPTED_DATA_WARNING_MESSAGE = "panel.unencryptedDataWarningMessage"; } diff --git a/src/main/resources/resources/languages/Messages_en_US.properties b/src/main/resources/resources/languages/languages_en_US.properties similarity index 72% rename from src/main/resources/resources/languages/Messages_en_US.properties rename to src/main/resources/resources/languages/languages_en_US.properties index da55603..2d76116 100644 --- a/src/main/resources/resources/languages/Messages_en_US.properties +++ b/src/main/resources/resources/languages/languages_en_US.properties @@ -28,7 +28,7 @@ editMenu.editEntry=Edit Entry... editMenu.duplicateEntry=Duplicate Entry... editMenu.deleteEntry=Delete Entry... editMenu.copyURL=Copy URL -editMenu.copyUserName=Copy User Name +editMenu.copyUserName=Copy Username editMenu.copyPassword=Copy Password editMenu.clearClipboard=Clear Clipboard editMenu.findEntry=Find Entry @@ -68,6 +68,22 @@ buttonMessage.close=Close entryDialog.showEntry=Show entryDialog.generateEntry=Generate entryDialog.copyEntry=Copy +entryDialog.fillTitleField=Please fill the title field. +entryDialog.titleAlreadyExists=Title already exists,\nPlease enter a different title. +entryDialog.pleaseSelectEntry=Please select an entry. +entryDialog.wantDeleteEntry=Do you really want to delete this entry? +entryDialog.duplicateEntry=Duplicate Entry +entryDialog.editEntry=Edit Entry +entryDialog.addNewEntry=Add New Entry bottomMenu.entriesCount=Entries count -bottomMenu.entriesFound=Entries found \ No newline at end of file +bottomMenu.entriesFound=Entries found + +panel.processing=Processing... +panel.find=Find +panel.export=Export +panel.import=Import +panel.save=Save +panel.open=Open +panel.saveModifiedQuestionMessage=The current file has been modified.\nDo you want to save the changes before closing? +panel.unencryptedDataWarningMessage=Please note that all data will be stored unencrypted.\nMake sure you keep the exported file in a secure location. \ No newline at end of file diff --git a/src/main/resources/resources/languages/Messages_es_US.properties b/src/main/resources/resources/languages/languages_es_MX.properties similarity index 72% rename from src/main/resources/resources/languages/Messages_es_US.properties rename to src/main/resources/resources/languages/languages_es_MX.properties index 51d9169..125bef3 100644 --- a/src/main/resources/resources/languages/Messages_es_US.properties +++ b/src/main/resources/resources/languages/languages_es_MX.properties @@ -1,4 +1,4 @@ -#Strings for Menu Bar es_US locale +#Strings for Menu Bar es_MX locale menuBar.fileMenu=Archivo menuBar.editMenu=Editar menuBar.toolsMenu=Herramientas @@ -67,6 +67,22 @@ buttonMessage.close=Cerrar entryDialog.showEntry=Mostrar entryDialog.generateEntry=Generar entryDialog.copyEntry=Copiar +entryDialog.fillTitleField=Please fill the title field. +entryDialog.titleAlreadyExists=El título ya existe,\nPor favor introduzca un título diferente. +entryDialog.pleaseSelectEntry=Por favor, selecciona una entrada. +entryDialog.wantDeleteEntry=¿Realmente quieres eliminar esta entrada? +entryDialog.duplicateEntry=Duplicar Entrada +entryDialog.editEntry=Editar Entrada +entryDialog.addNewEntry=Agregar Nueva Entrada bottomMenu.entriesCount=Numero de entradas -bottomMenu.entriesFound=Entradas encontradas \ No newline at end of file +bottomMenu.entriesFound=Entradas encontradas + +panel.processing=Procesando... +panel.find=Encontrar +panel.export=Exportar +panel.import=Importar +panel.save=Guardar +panel.open=Abrir +panel.saveModifiedQuestionMessage=El archivo actual ha sido modificado.\n¿Deseas guardar los cambios antes de cerrar el programa? +panel.unencryptedDataWarningMessage=Note que toda la data se almancenará sin cifrar.\nAsegúrese de guardar el archivo exportado en un lugar seguro. \ No newline at end of file