diff options
Diffstat (limited to 'src/cuchaz/enigma/gui/Gui.java')
| -rw-r--r-- | src/cuchaz/enigma/gui/Gui.java | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/src/cuchaz/enigma/gui/Gui.java b/src/cuchaz/enigma/gui/Gui.java index dd82b8e..febdfd4 100644 --- a/src/cuchaz/enigma/gui/Gui.java +++ b/src/cuchaz/enigma/gui/Gui.java | |||
| @@ -15,7 +15,6 @@ import java.awt.Color; | |||
| 15 | import java.awt.Container; | 15 | import java.awt.Container; |
| 16 | import java.awt.Dimension; | 16 | import java.awt.Dimension; |
| 17 | import java.awt.FlowLayout; | 17 | import java.awt.FlowLayout; |
| 18 | import java.awt.Font; | ||
| 19 | import java.awt.GridLayout; | 18 | import java.awt.GridLayout; |
| 20 | import java.awt.Rectangle; | 19 | import java.awt.Rectangle; |
| 21 | import java.awt.event.ActionEvent; | 20 | import java.awt.event.ActionEvent; |
| @@ -169,6 +168,7 @@ public class Gui | |||
| 169 | private EntryReference<Entry,Entry> m_reference; | 168 | private EntryReference<Entry,Entry> m_reference; |
| 170 | private JFileChooser m_jarFileChooser; | 169 | private JFileChooser m_jarFileChooser; |
| 171 | private JFileChooser m_mappingsFileChooser; | 170 | private JFileChooser m_mappingsFileChooser; |
| 171 | private JFileChooser m_exportFileChooser; | ||
| 172 | 172 | ||
| 173 | public Gui( ) | 173 | public Gui( ) |
| 174 | { | 174 | { |
| @@ -177,6 +177,8 @@ public class Gui | |||
| 177 | // init file choosers | 177 | // init file choosers |
| 178 | m_jarFileChooser = new JFileChooser(); | 178 | m_jarFileChooser = new JFileChooser(); |
| 179 | m_mappingsFileChooser = new JFileChooser(); | 179 | m_mappingsFileChooser = new JFileChooser(); |
| 180 | m_exportFileChooser = new JFileChooser(); | ||
| 181 | m_exportFileChooser.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY ); | ||
| 180 | 182 | ||
| 181 | // init frame | 183 | // init frame |
| 182 | m_frame = new JFrame( Constants.Name ); | 184 | m_frame = new JFrame( Constants.Name ); |
| @@ -637,6 +639,22 @@ public class Gui | |||
| 637 | } | 639 | } |
| 638 | menu.addSeparator(); | 640 | menu.addSeparator(); |
| 639 | { | 641 | { |
| 642 | JMenuItem item = new JMenuItem( "Export..." ); | ||
| 643 | menu.add( item ); | ||
| 644 | item.addActionListener( new ActionListener( ) | ||
| 645 | { | ||
| 646 | @Override | ||
| 647 | public void actionPerformed( ActionEvent event ) | ||
| 648 | { | ||
| 649 | if( m_exportFileChooser.showSaveDialog( m_frame ) == JFileChooser.APPROVE_OPTION ) | ||
| 650 | { | ||
| 651 | m_controller.export( m_exportFileChooser.getSelectedFile() ); | ||
| 652 | } | ||
| 653 | } | ||
| 654 | } ); | ||
| 655 | } | ||
| 656 | menu.addSeparator(); | ||
| 657 | { | ||
| 640 | JMenuItem item = new JMenuItem( "Exit" ); | 658 | JMenuItem item = new JMenuItem( "Exit" ); |
| 641 | menu.add( item ); | 659 | menu.add( item ); |
| 642 | item.addActionListener( new ActionListener( ) | 660 | item.addActionListener( new ActionListener( ) |
| @@ -686,6 +704,11 @@ public class Gui | |||
| 686 | m_frame.setDefaultCloseOperation( WindowConstants.DO_NOTHING_ON_CLOSE ); | 704 | m_frame.setDefaultCloseOperation( WindowConstants.DO_NOTHING_ON_CLOSE ); |
| 687 | } | 705 | } |
| 688 | 706 | ||
| 707 | public JFrame getFrame( ) | ||
| 708 | { | ||
| 709 | return m_frame; | ||
| 710 | } | ||
| 711 | |||
| 689 | public GuiController getController( ) | 712 | public GuiController getController( ) |
| 690 | { | 713 | { |
| 691 | return m_controller; | 714 | return m_controller; |
| @@ -887,7 +910,7 @@ public class Gui | |||
| 887 | { | 910 | { |
| 888 | m_infoPanel.removeAll(); | 911 | m_infoPanel.removeAll(); |
| 889 | JLabel label = new JLabel( "No identifier selected" ); | 912 | JLabel label = new JLabel( "No identifier selected" ); |
| 890 | unboldLabel( label ); | 913 | GuiTricks.unboldLabel( label ); |
| 891 | label.setHorizontalAlignment( JLabel.CENTER ); | 914 | label.setHorizontalAlignment( JLabel.CENTER ); |
| 892 | m_infoPanel.add( label ); | 915 | m_infoPanel.add( label ); |
| 893 | 916 | ||
| @@ -975,7 +998,7 @@ public class Gui | |||
| 975 | label.setPreferredSize( new Dimension( 100, label.getPreferredSize().height ) ); | 998 | label.setPreferredSize( new Dimension( 100, label.getPreferredSize().height ) ); |
| 976 | panel.add( label ); | 999 | panel.add( label ); |
| 977 | 1000 | ||
| 978 | panel.add( unboldLabel( new JLabel( value, JLabel.LEFT ) ) ); | 1001 | panel.add( GuiTricks.unboldLabel( new JLabel( value, JLabel.LEFT ) ) ); |
| 979 | } | 1002 | } |
| 980 | 1003 | ||
| 981 | private void onCaretMove( int pos ) | 1004 | private void onCaretMove( int pos ) |
| @@ -1059,7 +1082,7 @@ public class Gui | |||
| 1059 | // abort the rename | 1082 | // abort the rename |
| 1060 | JPanel panel = (JPanel)m_infoPanel.getComponent( 0 ); | 1083 | JPanel panel = (JPanel)m_infoPanel.getComponent( 0 ); |
| 1061 | panel.remove( panel.getComponentCount() - 1 ); | 1084 | panel.remove( panel.getComponentCount() - 1 ); |
| 1062 | panel.add( unboldLabel( new JLabel( m_reference.entry.getName(), JLabel.LEFT ) ) ); | 1085 | panel.add( GuiTricks.unboldLabel( new JLabel( m_reference.entry.getName(), JLabel.LEFT ) ) ); |
| 1063 | 1086 | ||
| 1064 | m_editor.grabFocus(); | 1087 | m_editor.grabFocus(); |
| 1065 | 1088 | ||
| @@ -1203,13 +1226,6 @@ public class Gui | |||
| 1203 | } | 1226 | } |
| 1204 | } | 1227 | } |
| 1205 | 1228 | ||
| 1206 | private JLabel unboldLabel( JLabel label ) | ||
| 1207 | { | ||
| 1208 | Font font = label.getFont(); | ||
| 1209 | label.setFont( font.deriveFont( font.getStyle() & ~Font.BOLD ) ); | ||
| 1210 | return label; | ||
| 1211 | } | ||
| 1212 | |||
| 1213 | private void redraw( ) | 1229 | private void redraw( ) |
| 1214 | { | 1230 | { |
| 1215 | m_frame.validate(); | 1231 | m_frame.validate(); |