Skip to content

Commit e327bb0

Browse files
author
Federico Fissore
committed
MacOSX: better IDE
1 parent 4380e29 commit e327bb0

File tree

9 files changed

+100
-89
lines changed

9 files changed

+100
-89
lines changed

app/lib/apple.jar

7.35 KB
Binary file not shown.

app/src/processing/app/Base.java

+29-24
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,11 @@
2222

2323
package processing.app;
2424

25-
import java.awt.*;
26-
import java.awt.event.*;
27-
import java.io.*;
28-
import java.util.*;
29-
import java.util.List;
30-
31-
import javax.swing.*;
32-
3325
import cc.arduino.packages.DiscoveryManager;
3426
import processing.app.debug.TargetBoard;
3527
import processing.app.debug.TargetPackage;
3628
import processing.app.debug.TargetPlatform;
37-
import processing.app.helpers.CommandlineParser;
38-
import processing.app.helpers.FileUtils;
39-
import processing.app.helpers.GUIUserNotifier;
40-
import processing.app.helpers.OSUtils;
41-
import processing.app.helpers.PreferencesMap;
29+
import processing.app.helpers.*;
4230
import processing.app.helpers.filefilters.OnlyDirs;
4331
import processing.app.helpers.filefilters.OnlyFilesWithExtension;
4432
import processing.app.javax.swing.filechooser.FileNameExtensionFilter;
@@ -48,6 +36,14 @@
4836
import processing.app.packages.LibraryList;
4937
import processing.app.tools.MenuScroller;
5038
import processing.app.tools.ZipDeflater;
39+
40+
import javax.swing.*;
41+
import java.awt.*;
42+
import java.awt.event.*;
43+
import java.io.*;
44+
import java.util.*;
45+
import java.util.List;
46+
5147
import static processing.app.I18n._;
5248

5349

@@ -660,21 +656,30 @@ public void handleOpenReplace(File file) {
660656
*/
661657
public void handleOpenPrompt() throws Exception {
662658
// get the frontmost window frame for placing file dialog
663-
JFileChooser fd = new JFileChooser(Preferences.get("last.folder", getSketchbookFolder().getAbsolutePath()));
664-
fd.setDialogTitle(_("Open an Arduino sketch..."));
665-
fd.setFileSelectionMode(JFileChooser.FILES_ONLY);
666-
fd.setFileFilter(new FileNameExtensionFilter(_("Sketches (*.ino, *.pde)"), "ino", "pde"));
659+
FileDialog fd = new FileDialog(activeEditor, _("Open an Arduino sketch..."), FileDialog.LOAD);
660+
File lastFolder = new File(Preferences.get("last.folder", getSketchbookFolder().getAbsolutePath()));
661+
if (lastFolder.exists() && lastFolder.isFile()) {
662+
lastFolder = lastFolder.getParentFile();
663+
}
664+
fd.setDirectory(lastFolder.getAbsolutePath());
665+
666+
// Only show .pde files as eligible bachelors
667+
fd.setFilenameFilter(new FilenameFilter() {
668+
public boolean accept(File dir, String name) {
669+
return name.toLowerCase().endsWith(".ino")
670+
|| name.toLowerCase().endsWith(".pde");
671+
}
672+
});
667673

668-
Dimension preferredSize = fd.getPreferredSize();
669-
fd.setPreferredSize(new Dimension(preferredSize.width + 200, preferredSize.height + 200));
674+
fd.setVisible(true);
670675

671-
int returnVal = fd.showOpenDialog(activeEditor);
676+
String directory = fd.getDirectory();
677+
String filename = fd.getFile();
672678

673-
if (returnVal != JFileChooser.APPROVE_OPTION) {
674-
return;
675-
}
679+
// User canceled selection
680+
if (filename == null) return;
676681

677-
File inputFile = fd.getSelectedFile();
682+
File inputFile = new File(directory, filename);
678683

679684
Preferences.set("last.folder", inputFile.getAbsolutePath());
680685
handleOpen(inputFile);

app/src/processing/app/Sketch.java

+30-28
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,17 @@
3131
import processing.app.helpers.OSUtils;
3232
import processing.app.helpers.PreferencesMapException;
3333
import processing.app.packages.Library;
34-
import static processing.app.I18n._;
35-
36-
import java.io.*;
37-
import java.util.*;
3834

3935
import javax.swing.*;
36+
import java.awt.*;
37+
import java.io.File;
38+
import java.io.FilenameFilter;
39+
import java.io.IOException;
40+
import java.util.Arrays;
41+
import java.util.LinkedList;
42+
import java.util.List;
43+
44+
import static processing.app.I18n._;
4045

4146

4247
/**
@@ -632,29 +637,30 @@ protected boolean renameCodeToInoExtension(File pdeFile) {
632637
* because they can cause trouble.
633638
*/
634639
protected boolean saveAs() throws IOException {
635-
JFileChooser fd = new JFileChooser();
636-
fd.setDialogTitle(_("Save sketch folder as..."));
637-
fd.setDialogType(JFileChooser.SAVE_DIALOG);
640+
String newParentDir = null;
641+
String newName = null;
638642

643+
// get new name for folder
644+
FileDialog fd = new FileDialog(editor, _("Save sketch folder as..."), FileDialog.SAVE);
639645
if (isReadOnly() || isUntitled()) {
640646
// default to the sketchbook folder
641-
fd.setSelectedFile(new File(Base.getSketchbookFolder().getAbsolutePath(), data.getFolder().getName()));
647+
fd.setDirectory(Base.getSketchbookFolder().getAbsolutePath());
642648
} else {
643649
// default to the parent folder of where this was
644-
fd.setSelectedFile(data.getFolder());
650+
fd.setDirectory(data.getFolder().getParentFile().getAbsolutePath());
645651
}
652+
String oldName = data.getName();
653+
fd.setFile(oldName);
646654

647-
int returnVal = fd.showSaveDialog(editor);
655+
fd.setVisible(true);
656+
newParentDir = fd.getDirectory();
657+
newName = fd.getFile();
648658

649-
if (returnVal != JFileChooser.APPROVE_OPTION) {
650-
return false;
651-
}
659+
// user canceled selection
660+
if (newName == null) return false;
661+
newName = Sketch.checkName(newName);
652662

653-
File selectedFile = fd.getSelectedFile();
654-
655-
String newName = Sketch.checkName(selectedFile.getName());
656-
657-
File newFolder = new File(selectedFile.getParentFile(), newName);
663+
File newFolder = new File(newParentDir, newName);
658664

659665
// make sure there doesn't exist a .cpp file with that name already
660666
// but ignore this situation for the first tab, since it's probably being
@@ -778,20 +784,16 @@ public void handleAddFile() {
778784
}
779785

780786
// get a dialog, select a file to add to the sketch
781-
String prompt =
782-
_("Select an image or other data file to copy to your sketch");
783-
JFileChooser fd = new JFileChooser(Preferences.get("last.folder"));
784-
fd.setDialogTitle(prompt);
785-
786-
int returnVal = fd.showOpenDialog(editor);
787+
FileDialog fd = new FileDialog(editor, _("Select an image or other data file to copy to your sketch"), FileDialog.LOAD);
788+
fd.setVisible(true);
787789

788-
if (returnVal != JFileChooser.APPROVE_OPTION) {
789-
return;
790-
}
790+
String directory = fd.getDirectory();
791+
String filename = fd.getFile();
792+
if (filename == null) return;
791793

792794
// copy the file into the folder. if people would rather
793795
// it move instead of copy, they can do it by hand
794-
File sourceFile = fd.getSelectedFile();
796+
File sourceFile = new File(directory, filename);
795797

796798
// now do the work of adding the file
797799
boolean result = addFile(sourceFile);

app/src/processing/app/tools/Archiver.java

+37-31
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,22 @@
2323

2424
package processing.app.tools;
2525

26-
import processing.app.*;
27-
28-
import javax.swing.*;
26+
import processing.app.Base;
27+
import processing.app.Editor;
28+
import processing.app.Sketch;
29+
30+
import java.awt.*;
31+
import java.io.File;
32+
import java.io.FileOutputStream;
33+
import java.io.IOException;
34+
import java.text.NumberFormat;
35+
import java.text.SimpleDateFormat;
36+
import java.util.Date;
37+
import java.util.zip.ZipEntry;
38+
import java.util.zip.ZipOutputStream;
2939

3040
import static processing.app.I18n._;
3141

32-
import java.io.*;
33-
import java.text.*;
34-
import java.util.*;
35-
import java.util.zip.*;
36-
3742

3843
public class Archiver implements Tool {
3944
Editor editor;
@@ -107,36 +112,37 @@ public void run() {
107112
} while (newbie.exists());
108113

109114
// open up a prompt for where to save this fella
110-
JFileChooser fd = new JFileChooser();
111-
fd.setDialogTitle(_("Archive sketch as:"));
112-
fd.setDialogType(JFileChooser.SAVE_DIALOG);
113-
fd.setSelectedFile(newbie);
114-
115-
int returnVal = fd.showSaveDialog(editor);
115+
FileDialog fd = new FileDialog(editor, _("Archive sketch as:"), FileDialog.SAVE);
116+
fd.setDirectory(parent.getAbsolutePath());
117+
fd.setFile(newbie.getName());
118+
fd.setVisible(true);
116119

117-
if (returnVal != JFileChooser.APPROVE_OPTION) {
118-
editor.statusNotice(_("Archive sketch canceled."));
119-
return;
120-
}
120+
String directory = fd.getDirectory();
121+
String filename = fd.getFile();
121122

122-
newbie = fd.getSelectedFile();
123+
// only write the file if not canceled
124+
if (filename != null) {
125+
newbie = new File(directory, filename);
123126

124-
try {
125-
//System.out.println(newbie);
126-
FileOutputStream zipOutputFile = new FileOutputStream(newbie);
127-
ZipOutputStream zos = new ZipOutputStream(zipOutputFile);
127+
try {
128+
//System.out.println(newbie);
129+
FileOutputStream zipOutputFile = new FileOutputStream(newbie);
130+
ZipOutputStream zos = new ZipOutputStream(zipOutputFile);
128131

129-
// recursively fill the zip file
130-
buildZip(location, name, zos);
132+
// recursively fill the zip file
133+
buildZip(location, name, zos);
131134

132-
// close up the jar file
133-
zos.flush();
134-
zos.close();
135+
// close up the jar file
136+
zos.flush();
137+
zos.close();
135138

136-
editor.statusNotice("Created archive " + newbie.getName() + ".");
139+
editor.statusNotice("Created archive " + newbie.getName() + ".");
137140

138-
} catch (IOException e) {
139-
e.printStackTrace();
141+
} catch (IOException e) {
142+
e.printStackTrace();
143+
}
144+
} else {
145+
editor.statusNotice(_("Archive sketch canceled."));
140146
}
141147
}
142148

arduino-core/lib/apple.jar

7.35 KB
Binary file not shown.

build/build.xml

+2-5
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,8 @@
248248

249249
<target name="macosx-java-latest-build" if="macosx" depends="revision-check, macosx-checkos, subprojects-build" description="Build Mac OS X version">
250250
<antcall target="unzip">
251-
<param name="archive_file" value="${staging_folder}/appbundler-1.0ea.jar.zip" />
252-
<param name="archive_url" value="http://arduino.cc/download.php?f=/appbundler-1.0ea.jar.zip" />
251+
<param name="archive_file" value="${staging_folder}/appbundler-1.0ea-arduino.jar.zip" />
252+
<param name="archive_url" value="http://arduino.cc/download.php?f=/appbundler-1.0ea-arduino.jar.zip" />
253253
<param name="final_folder" value="${staging_folder}/appbundler" />
254254
<param name="dest_folder" value="${staging_folder}/appbundler" />
255255
</antcall>
@@ -277,7 +277,6 @@
277277
<arch name="i386"/>
278278

279279
<classpath refid="runtime.jars"/>
280-
<classpath file="./macosx/template.app/Contents/Resources/Java/quaqua.jar"/>
281280

282281
<option value="-Dapple.awt.application.name=Arduino" />
283282
<option value="-Dapple.laf.useScreenMenuBar=true"/>
@@ -314,8 +313,6 @@
314313
<copy todir="${staging_folder}/work/${staging_hardware_folder}/../">
315314
<fileset dir="shared" includes="lib/**" />
316315
<fileset file="shared/revisions.txt" />
317-
<file file="macosx/template.app/Contents/Resources/Java/quaqua.jar"/>
318-
<fileset file="macosx/template.app/Contents/Resources/Java/libquaqua*" />
319316
</copy>
320317

321318
<antcall target="macosx-build-common"/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20da27cce14b7c60d6ef2e2cac2f60df491c8e21

build/macosx/appbundler-1.0ea.jar.zip.sha

-1
This file was deleted.

build/shared/revisions.txt

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ ARDUINO 1.6.1
1717
* Fixed: status board was not changing when using custom menu @PaulStoffregen
1818
* Fixed: better error message when using a busy serial device
1919
* Fixed: missing bool operator on EthernetClient
20+
* MacOSX: back to native file dialogs and buttons, when using experimental version
2021

2122
ARDUINO 1.6.0 - 2015.02.09
2223

0 commit comments

Comments
 (0)