Internationalize ECUEditorToolBar Class

This commit is contained in:
Dale Schultz 2020-04-05 12:43:54 -04:00
parent 94fbf00101
commit f3986acc04
3 changed files with 25 additions and 9 deletions

View File

@ -0,0 +1,5 @@
OPEN = Open Image
SAVEAS = Save {0} As New Image...
REFRESH = Refresh {0} from saved copy
CLOSE = Close {0}
EXCEPTION = Exception

View File

@ -407,7 +407,7 @@ public class ECUEditor extends AbstractFrame {
public String getLastSelectedRomFileName() { public String getLastSelectedRomFileName() {
Rom lastSelRom = getLastSelectedRom(); Rom lastSelRom = getLastSelectedRom();
return lastSelRom == null ? "" : lastSelRom.getFileName() + " "; return lastSelRom == null ? "" : lastSelRom.getFileName();
} }
public void setLastSelectedRom(Rom lastSelectedRom) { public void setLastSelectedRom(Rom lastSelectedRom) {

View File

@ -1,6 +1,6 @@
/* /*
* RomRaider Open-Source Tuning, Logging and Reflashing * RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com * Copyright (C) 2006-2020 RomRaider.com
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -27,6 +27,8 @@ import java.awt.FlowLayout;
import java.awt.Image; import java.awt.Image;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.text.MessageFormat;
import java.util.ResourceBundle;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
import javax.swing.JButton; import javax.swing.JButton;
@ -36,11 +38,14 @@ import javax.swing.JToolBar;
import com.romraider.Settings; import com.romraider.Settings;
import com.romraider.editor.ecu.ECUEditor; import com.romraider.editor.ecu.ECUEditor;
import com.romraider.editor.ecu.ECUEditorManager; import com.romraider.editor.ecu.ECUEditorManager;
import com.romraider.util.ResourceUtil;
import com.romraider.util.SettingsManager; import com.romraider.util.SettingsManager;
public class ECUEditorToolBar extends JToolBar implements ActionListener { public class ECUEditorToolBar extends JToolBar implements ActionListener {
private static final long serialVersionUID = 7778170684606193919L; private static final long serialVersionUID = 7778170684606193919L;
private static final ResourceBundle rb = new ResourceUtil().getBundle(
ECUEditorToolBar.class.getName());
private final JButton openImage = new JButton(); private final JButton openImage = new JButton();
private final JButton saveImage = new JButton(); private final JButton saveImage = new JButton();
private final JButton refreshImage = new JButton(); private final JButton refreshImage = new JButton();
@ -101,10 +106,13 @@ public class ECUEditorToolBar extends JToolBar implements ActionListener {
public void updateButtons() { public void updateButtons() {
String file = getEditor().getLastSelectedRomFileName(); String file = getEditor().getLastSelectedRomFileName();
openImage.setToolTipText("Open Image"); openImage.setToolTipText(rb.getString("OPEN"));
saveImage.setToolTipText("Save " + file + " As New Image..."); saveImage.setToolTipText(MessageFormat.format(
refreshImage.setToolTipText("Refresh " + file + " from saved copy"); rb.getString("SAVEAS"), file));
closeImage.setToolTipText("Close " + file); refreshImage.setToolTipText(MessageFormat.format(
rb.getString("REFRESH"), file));
closeImage.setToolTipText(MessageFormat.format(
rb.getString("CLOSE"), file));
if ("".equals(file)) { if ("".equals(file)) {
saveImage.setEnabled(false); saveImage.setEnabled(false);
@ -125,7 +133,8 @@ public class ECUEditorToolBar extends JToolBar implements ActionListener {
((ECUEditorMenuBar) getEditor().getJMenuBar()).openImageDialog(); ((ECUEditorMenuBar) getEditor().getJMenuBar()).openImageDialog();
} catch (Exception ex) { } catch (Exception ex) {
JOptionPane.showMessageDialog(getEditor(), new DebugPanel(ex, JOptionPane.showMessageDialog(getEditor(), new DebugPanel(ex,
getSettings().getSupportURL()), "Exception", JOptionPane.ERROR_MESSAGE); getSettings().getSupportURL()),
rb.getString("EXCEPTION"), JOptionPane.ERROR_MESSAGE);
} }
} else if (e.getSource() == saveImage) { } else if (e.getSource() == saveImage) {
try { try {
@ -133,7 +142,8 @@ public class ECUEditorToolBar extends JToolBar implements ActionListener {
getEditor().refreshUI(); getEditor().refreshUI();
} catch (Exception ex) { } catch (Exception ex) {
JOptionPane.showMessageDialog(getEditor(), new DebugPanel(ex, JOptionPane.showMessageDialog(getEditor(), new DebugPanel(ex,
getSettings().getSupportURL()), "Exception", JOptionPane.ERROR_MESSAGE); getSettings().getSupportURL()),
rb.getString("EXCEPTION"), JOptionPane.ERROR_MESSAGE);
} }
} else if (e.getSource() == closeImage) { } else if (e.getSource() == closeImage) {
getEditor().closeImage(); getEditor().closeImage();
@ -142,7 +152,8 @@ public class ECUEditorToolBar extends JToolBar implements ActionListener {
((ECUEditorMenuBar) getEditor().getJMenuBar()).refreshImage(); ((ECUEditorMenuBar) getEditor().getJMenuBar()).refreshImage();
} catch (Exception ex) { } catch (Exception ex) {
JOptionPane.showMessageDialog(getEditor(), new DebugPanel(ex, JOptionPane.showMessageDialog(getEditor(), new DebugPanel(ex,
getSettings().getSupportURL()), "Exception", JOptionPane.ERROR_MESSAGE); getSettings().getSupportURL()),
rb.getString("EXCEPTION"), JOptionPane.ERROR_MESSAGE);
} }
} }
} }