@@ -676,8 +676,26 @@ public void handleExportApplication() {
676676 }
677677
678678
679- // JPanel presentColorPanel;
680- // JTextField presentColorPanel;
679+ // Can't be .windows because that'll be stripped off as a per-platform pref
680+ static final String EXPORT_PREFIX = "export.application.platform_" ;
681+ static final String EXPORT_MACOSX = EXPORT_PREFIX + "macosx" ;
682+ static final String EXPORT_WINDOWS = EXPORT_PREFIX + "windows" ;
683+ static final String EXPORT_LINUX = EXPORT_PREFIX + "linux" ;
684+
685+ final JButton exportButton = new JButton (Language .text ("prompt.export" ));
686+ final JButton cancelButton = new JButton (Language .text ("prompt.cancel" ));
687+
688+ final JCheckBox windowsButton = new JCheckBox ("Windows" );
689+ final JCheckBox macosxButton = new JCheckBox ("Mac OS X" );
690+ final JCheckBox linuxButton = new JCheckBox ("Linux" );
691+
692+
693+ protected void updateExportButton () {
694+ exportButton .setEnabled (windowsButton .isSelected () ||
695+ macosxButton .isSelected () ||
696+ linuxButton .isSelected ());
697+ }
698+
681699
682700 protected boolean exportApplicationPrompt () throws IOException , SketchException {
683701 JPanel panel = new JPanel ();
@@ -704,41 +722,45 @@ protected boolean exportApplicationPrompt() throws IOException, SketchException
704722// label2.getPreferredSize().width);
705723 panel .add (Box .createVerticalStrut (12 ));
706724
707- final JCheckBox windowsButton = new JCheckBox ("Windows" );
708- //windowsButton.setMnemonic(KeyEvent.VK_W);
709- windowsButton .setSelected (Preferences .getBoolean ("export.application.platform.windows" ));
725+ // final JCheckBox windowsButton = new JCheckBox("Windows");
726+ // final JCheckBox macosxButton = new JCheckBox("Mac OS X");
727+ // final JCheckBox linuxButton = new JCheckBox("Linux");
728+
729+ windowsButton .setSelected (Preferences .getBoolean (EXPORT_WINDOWS ));
710730 windowsButton .addItemListener (new ItemListener () {
711731 public void itemStateChanged (ItemEvent e ) {
712- Preferences .setBoolean ("export.application.platform.windows" , windowsButton .isSelected ());
732+ Preferences .setBoolean (EXPORT_WINDOWS , windowsButton .isSelected ());
733+ updateExportButton ();
713734 }
714735 });
715736
716737 // Only possible to export OS X applications on OS X
717738 if (!Base .isMacOS ()) {
718739 // Make sure they don't have a previous 'true' setting for this
719- Preferences .setBoolean ("export.application.platform.macosx" , false );
740+ Preferences .setBoolean (EXPORT_MACOSX , false );
720741 }
721- final JCheckBox macosxButton = new JCheckBox ("Mac OS X" );
722- macosxButton .setSelected (Preferences .getBoolean ("export.application.platform.macosx" ));
742+ macosxButton .setSelected (Preferences .getBoolean (EXPORT_MACOSX ));
723743 macosxButton .addItemListener (new ItemListener () {
724744 public void itemStateChanged (ItemEvent e ) {
725- Preferences .setBoolean ("export.application.platform.macosx" , macosxButton .isSelected ());
745+ Preferences .setBoolean (EXPORT_MACOSX , macosxButton .isSelected ());
746+ updateExportButton ();
726747 }
727748 });
728749 if (!Base .isMacOS ()) {
729750 macosxButton .setEnabled (false );
730751 macosxButton .setToolTipText (Language .text ("export.tooltip.macosx" ));
731752 }
732753
733- final JCheckBox linuxButton = new JCheckBox ("Linux" );
734- //linuxButton.setMnemonic(KeyEvent.VK_L);
735- linuxButton .setSelected (Preferences .getBoolean ("export.application.platform.linux" ));
754+ linuxButton .setSelected (Preferences .getBoolean (EXPORT_LINUX ));
736755 linuxButton .addItemListener (new ItemListener () {
737756 public void itemStateChanged (ItemEvent e ) {
738- Preferences .setBoolean ("export.application.platform.linux" , linuxButton .isSelected ());
757+ Preferences .setBoolean (EXPORT_LINUX , linuxButton .isSelected ());
758+ updateExportButton ();
739759 }
740760 });
741761
762+ updateExportButton (); // do the initial enable/disable based on prefs.txt
763+
742764 JPanel platformPanel = new JPanel ();
743765 //platformPanel.setLayout(new BoxLayout(platformPanel, BoxLayout.X_AXIS));
744766 platformPanel .add (windowsButton );
@@ -953,26 +975,34 @@ public void mousePressed(MouseEvent event) {
953975
954976 panel .add (signPanel );
955977 }
956- //System.out.println(panel.getPreferredSize());
957- // panel.setMinimumSize(new Dimension(316, 461));
958- // panel.setPreferredSize(new Dimension(316, 461));
959- // panel.setMaximumSize(new Dimension(316, 461));
960978
961979 //
962980
963- String [] options = { Language .text ("prompt.export" ), Language .text ("prompt.cancel" ) };
981+ //String[] options = { Language.text("prompt.export"), Language.text("prompt.cancel") };
982+ final JButton [] options = { exportButton , cancelButton };
964983
965984 final JOptionPane optionPane = new JOptionPane (panel ,
966985 JOptionPane .PLAIN_MESSAGE ,
967986 JOptionPane .YES_NO_OPTION ,
968987 null ,
969988 options ,
970- options [0 ]);
989+ exportButton ); // options[0]);
971990
972991
973992 final JDialog dialog = new JDialog (this , Language .text ("export" ), true );
974993 dialog .setContentPane (optionPane );
975- // System.out.println(optionPane.getLayout());
994+
995+ exportButton .addActionListener (new ActionListener () {
996+ public void actionPerformed (ActionEvent e ) {
997+ optionPane .setValue (exportButton );
998+ }
999+ });
1000+
1001+ cancelButton .addActionListener (new ActionListener () {
1002+ public void actionPerformed (ActionEvent e ) {
1003+ optionPane .setValue (cancelButton );
1004+ }
1005+ });
9761006
9771007 optionPane .addPropertyChangeListener (new PropertyChangeListener () {
9781008 public void propertyChange (PropertyChangeEvent e ) {
@@ -998,52 +1028,16 @@ public void propertyChange(PropertyChangeEvent e) {
9981028 bounds .y + (bounds .height - dialog .getSize ().height ) / 2 );
9991029 dialog .setVisible (true );
10001030
1001- //System.out.println(panel.getSize());
1002-
10031031 Object value = optionPane .getValue ();
1004- if (value .equals (options [ 0 ] )) {
1032+ if (value .equals (exportButton )) {
10051033 return jmode .handleExportApplication (sketch );
1006- } else if (value .equals (options [ 1 ] ) || value .equals (Integer .valueOf (-1 ))) {
1034+ } else if (value .equals (cancelButton ) || value .equals (Integer .valueOf (-1 ))) {
10071035 // closed window by hitting Cancel or ESC
10081036 statusNotice (Language .text ("export.notice.exporting.cancel" ));
10091037 }
10101038 return false ;
10111039 }
10121040
1013- /*
1014- Color bgcolor = Preferences.getColor("run.present.bgcolor");
1015- final ColorChooser c = new ColorChooser(JavaEditor.this, true, bgcolor,
1016- "Select", new ActionListener() {
1017-
1018- @Override
1019- public void actionPerformed(ActionEvent e) {
1020- Preferences.setColor("run.present.bgcolor", c.getColor());
1021- }
1022- });
1023- */
1024-
1025- /*
1026- class ColorListener implements ActionListener {
1027- ColorChooser chooser;
1028- String prefName;
1029-
1030- public ColorListener(String prefName) {
1031- this.prefName = prefName;
1032- Color color = Preferences.getColor(prefName);
1033- chooser = new ColorChooser(JavaEditor.this, true, color, "Select", this);
1034- chooser.show();
1035- }
1036-
1037- @Override
1038- public void actionPerformed(ActionEvent e) {
1039- Color color = chooser.getColor();
1040- Preferences.setColor(prefName, color);
1041- // presentColorPanel.setBackground(color);
1042- presentColorPanel.repaint();
1043- chooser.hide();
1044- }
1045- }
1046- */
10471041
10481042 class ColorPreference extends JPanel implements ActionListener {
10491043 ColorChooser chooser ;
0 commit comments