Skip to content

Commit 7761639

Browse files
committed
disable Export button when no platforms selected, save export prefs
1 parent 77e513b commit 7761639

3 files changed

Lines changed: 74 additions & 68 deletions

File tree

java/src/processing/mode/java/JavaBuild.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ protected boolean exportApplication() throws IOException, SketchException {
792792
boolean embedJava = (platform == PApplet.platform) &&
793793
Preferences.getBoolean("export.application.embed_java");
794794

795-
if (Preferences.getBoolean("export.application.platform." + platformName)) {
795+
if (Preferences.getBoolean(JavaEditor.EXPORT_PREFIX + platformName)) {
796796
if (Library.hasMultipleArch(platform, importedLibraries)) {
797797
// export the 32-bit version
798798
folder = new File(sketch.getFolder(), "application." + platformName + "32");

java/src/processing/mode/java/JavaEditor.java

Lines changed: 53 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -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;

todo.txt

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,34 @@ X make download-jdk-macosx target work properly
33
X remove "pair is" debug messages
44
X create sketchbook subfolders on startup
55
X https://github.com/processing/processing/issues/3548
6+
X save export settings to preferences
7+
X disable Export button when no platforms selected
8+
_ export allowed with untitled sketches
9+
_ also with examples?
610

711

8-
_ if no platforms selected in export, will still say "done exporting!"
9-
_ maybe if none selected, should default select the current platform
10-
_ why are none selected in the first place? not getting saved?
12+
earlier/cleaning
13+
X CM ongoing notes and questions
14+
X https://github.com/processing/processing/issues/3440
15+
X Contribution Manager design is really rough
16+
X https://github.com/processing/processing/issues/3464
1117

1218

13-
3.0 final
19+
known issues
1420
_ launch4j doesn't work from folders with non-native charsets
1521
_ anything in CP1252 on an English Windows system is fine
1622
_ but anything else reports "font sadness" b/c it's using the system JRE
1723
_ https://github.com/processing/processing/issues/3543
18-
_ CM ongoing notes and questions
19-
_ https://github.com/processing/processing/issues/3440
20-
_ Contribution Manager design is really rough
21-
_ https://github.com/processing/processing/issues/3464
24+
25+
26+
_ if no platforms selected in export, will still say "done exporting!"
27+
_ maybe if none selected, should default select the current platform
28+
_ why are none selected in the first place? not getting saved?
29+
30+
31+
3.0 final
32+
_ Contributions Manager UI design
33+
_ https://github.com/processing/processing/issues/3482
2234
_ Ready to add contributed example packages?
2335
_ https://github.com/processing/processing/issues/2953
2436
_ processing-java isn't working in OSX 10.11 El Capitan

0 commit comments

Comments
 (0)