From 3af76b6a1a4fa5ddeb9918b2ef2f19b4a2cbc372 Mon Sep 17 00:00:00 2001 From: kascade Date: Sat, 13 Jan 2007 12:56:29 +0000 Subject: [PATCH] cleanup git-svn-id: http://svn.3splooges.com/romraider-arch/trunk@428 d2e2e1cd-ba16-0410-be16-b7c4453c7c2d --- src/enginuity/swing/ECUEditorMenuBar.java | 29 ++++++++++------------- src/enginuity/swing/ECUEditorToolBar.java | 21 ++++++++-------- 2 files changed, 23 insertions(+), 27 deletions(-) diff --git a/src/enginuity/swing/ECUEditorMenuBar.java b/src/enginuity/swing/ECUEditorMenuBar.java index 52511681..32890bd5 100644 --- a/src/enginuity/swing/ECUEditorMenuBar.java +++ b/src/enginuity/swing/ECUEditorMenuBar.java @@ -27,15 +27,8 @@ import enginuity.logger.EcuLogger; import enginuity.maps.Rom; import javax.management.modelmbean.XMLParseException; -import javax.swing.ButtonGroup; -import javax.swing.JFileChooser; +import javax.swing.*; import static javax.swing.JFrame.DISPOSE_ON_CLOSE; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JRadioButtonMenuItem; -import javax.swing.JSeparator; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; @@ -189,12 +182,9 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener { } public void updateMenu() { - String file = ""; - try { - file = " " + parent.getLastSelectedRom().getFileName() + " "; - } catch (NullPointerException ex) { - } - if (file.equals("")) { + String file = getLastSelectedRomFileName(); + + if ("".equals(file)) { saveImage.setEnabled(false); closeImage.setEnabled(false); closeAll.setEnabled(false); @@ -206,9 +196,9 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener { romProperties.setEnabled(true); } - saveImage.setText("Save" + file); - refreshImage.setText("Refresh" + file); - closeImage.setText("Close" + file); + saveImage.setText("Save " + file); + refreshImage.setText("Refresh " + file); + closeImage.setText("Close " + file); romProperties.setText(file + "Properties"); } @@ -341,4 +331,9 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener { } } } + + private String getLastSelectedRomFileName() { + Rom lastSelectedRom = parent.getLastSelectedRom(); + return lastSelectedRom == null ? "" : lastSelectedRom.getFileName() + " "; + } } \ No newline at end of file diff --git a/src/enginuity/swing/ECUEditorToolBar.java b/src/enginuity/swing/ECUEditorToolBar.java index 80243447..ac28fc2d 100644 --- a/src/enginuity/swing/ECUEditorToolBar.java +++ b/src/enginuity/swing/ECUEditorToolBar.java @@ -22,6 +22,7 @@ package enginuity.swing; import enginuity.ECUEditor; +import enginuity.maps.Rom; import javax.swing.*; import javax.swing.border.LineBorder; @@ -38,7 +39,6 @@ public class ECUEditorToolBar extends JToolBar implements ActionListener { private JButton closeImage = new JButton(new ImageIcon("./graphics/icon-close.png")); public ECUEditorToolBar(ECUEditor parent) { - super(); this.parent = parent; this.setFloatable(false); this.add(openImage); @@ -64,18 +64,14 @@ public class ECUEditorToolBar extends JToolBar implements ActionListener { } public void updateButtons() { - String file = ""; - try { - file = " " + parent.getLastSelectedRom().getFileName(); - } catch (NullPointerException ex) { - } + String file = getLastSelectedRomFileName(); openImage.setToolTipText("Open Image"); - saveImage.setToolTipText("Save" + file); - refreshImage.setToolTipText("Refresh" + file + " from saved copy"); - closeImage.setToolTipText("Close" + file); + saveImage.setToolTipText("Save " + file); + refreshImage.setToolTipText("Refresh " + file + " from saved copy"); + closeImage.setToolTipText("Close " + file); - if (file.equals("")) { + if ("".equals(file)) { saveImage.setEnabled(false); refreshImage.setEnabled(false); closeImage.setEnabled(false); @@ -112,4 +108,9 @@ public class ECUEditorToolBar extends JToolBar implements ActionListener { } } } + + private String getLastSelectedRomFileName() { + Rom lastSelectedRom = parent.getLastSelectedRom(); + return lastSelectedRom == null ? "" : lastSelectedRom.getFileName() + " "; + } } \ No newline at end of file