MacOSX: better IDE

This commit is contained in:
Federico Fissore 2015-03-03 12:54:15 +01:00
parent 4380e2930e
commit e327bb091a
9 changed files with 105 additions and 94 deletions

Binary file not shown.

View File

@ -22,23 +22,11 @@
package processing.app;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import java.util.List;
import javax.swing.*;
import cc.arduino.packages.DiscoveryManager;
import processing.app.debug.TargetBoard;
import processing.app.debug.TargetPackage;
import processing.app.debug.TargetPlatform;
import processing.app.helpers.CommandlineParser;
import processing.app.helpers.FileUtils;
import processing.app.helpers.GUIUserNotifier;
import processing.app.helpers.OSUtils;
import processing.app.helpers.PreferencesMap;
import processing.app.helpers.*;
import processing.app.helpers.filefilters.OnlyDirs;
import processing.app.helpers.filefilters.OnlyFilesWithExtension;
import processing.app.javax.swing.filechooser.FileNameExtensionFilter;
@ -48,6 +36,14 @@ import processing.app.packages.Library;
import processing.app.packages.LibraryList;
import processing.app.tools.MenuScroller;
import processing.app.tools.ZipDeflater;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import java.util.List;
import static processing.app.I18n._;
@ -660,21 +656,30 @@ public class Base {
*/
public void handleOpenPrompt() throws Exception {
// get the frontmost window frame for placing file dialog
JFileChooser fd = new JFileChooser(Preferences.get("last.folder", getSketchbookFolder().getAbsolutePath()));
fd.setDialogTitle(_("Open an Arduino sketch..."));
fd.setFileSelectionMode(JFileChooser.FILES_ONLY);
fd.setFileFilter(new FileNameExtensionFilter(_("Sketches (*.ino, *.pde)"), "ino", "pde"));
Dimension preferredSize = fd.getPreferredSize();
fd.setPreferredSize(new Dimension(preferredSize.width + 200, preferredSize.height + 200));
int returnVal = fd.showOpenDialog(activeEditor);
if (returnVal != JFileChooser.APPROVE_OPTION) {
return;
FileDialog fd = new FileDialog(activeEditor, _("Open an Arduino sketch..."), FileDialog.LOAD);
File lastFolder = new File(Preferences.get("last.folder", getSketchbookFolder().getAbsolutePath()));
if (lastFolder.exists() && lastFolder.isFile()) {
lastFolder = lastFolder.getParentFile();
}
fd.setDirectory(lastFolder.getAbsolutePath());
File inputFile = fd.getSelectedFile();
// Only show .pde files as eligible bachelors
fd.setFilenameFilter(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.toLowerCase().endsWith(".ino")
|| name.toLowerCase().endsWith(".pde");
}
});
fd.setVisible(true);
String directory = fd.getDirectory();
String filename = fd.getFile();
// User canceled selection
if (filename == null) return;
File inputFile = new File(directory, filename);
Preferences.set("last.folder", inputFile.getAbsolutePath());
handleOpen(inputFile);

View File

@ -31,12 +31,17 @@ import processing.app.forms.PasswordAuthorizationDialog;
import processing.app.helpers.OSUtils;
import processing.app.helpers.PreferencesMapException;
import processing.app.packages.Library;
import static processing.app.I18n._;
import java.io.*;
import java.util.*;
import javax.swing.*;
import java.awt.*;
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import static processing.app.I18n._;
/**
@ -632,29 +637,30 @@ public class Sketch {
* because they can cause trouble.
*/
protected boolean saveAs() throws IOException {
JFileChooser fd = new JFileChooser();
fd.setDialogTitle(_("Save sketch folder as..."));
fd.setDialogType(JFileChooser.SAVE_DIALOG);
String newParentDir = null;
String newName = null;
// get new name for folder
FileDialog fd = new FileDialog(editor, _("Save sketch folder as..."), FileDialog.SAVE);
if (isReadOnly() || isUntitled()) {
// default to the sketchbook folder
fd.setSelectedFile(new File(Base.getSketchbookFolder().getAbsolutePath(), data.getFolder().getName()));
fd.setDirectory(Base.getSketchbookFolder().getAbsolutePath());
} else {
// default to the parent folder of where this was
fd.setSelectedFile(data.getFolder());
fd.setDirectory(data.getFolder().getParentFile().getAbsolutePath());
}
String oldName = data.getName();
fd.setFile(oldName);
int returnVal = fd.showSaveDialog(editor);
fd.setVisible(true);
newParentDir = fd.getDirectory();
newName = fd.getFile();
if (returnVal != JFileChooser.APPROVE_OPTION) {
return false;
}
// user canceled selection
if (newName == null) return false;
newName = Sketch.checkName(newName);
File selectedFile = fd.getSelectedFile();
String newName = Sketch.checkName(selectedFile.getName());
File newFolder = new File(selectedFile.getParentFile(), newName);
File newFolder = new File(newParentDir, newName);
// make sure there doesn't exist a .cpp file with that name already
// but ignore this situation for the first tab, since it's probably being
@ -778,20 +784,16 @@ public class Sketch {
}
// get a dialog, select a file to add to the sketch
String prompt =
_("Select an image or other data file to copy to your sketch");
JFileChooser fd = new JFileChooser(Preferences.get("last.folder"));
fd.setDialogTitle(prompt);
FileDialog fd = new FileDialog(editor, _("Select an image or other data file to copy to your sketch"), FileDialog.LOAD);
fd.setVisible(true);
int returnVal = fd.showOpenDialog(editor);
if (returnVal != JFileChooser.APPROVE_OPTION) {
return;
}
String directory = fd.getDirectory();
String filename = fd.getFile();
if (filename == null) return;
// copy the file into the folder. if people would rather
// it move instead of copy, they can do it by hand
File sourceFile = fd.getSelectedFile();
File sourceFile = new File(directory, filename);
// now do the work of adding the file
boolean result = addFile(sourceFile);

View File

@ -23,17 +23,22 @@
package processing.app.tools;
import processing.app.*;
import processing.app.Base;
import processing.app.Editor;
import processing.app.Sketch;
import javax.swing.*;
import java.awt.*;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import static processing.app.I18n._;
import java.io.*;
import java.text.*;
import java.util.*;
import java.util.zip.*;
public class Archiver implements Tool {
Editor editor;
@ -107,36 +112,37 @@ public class Archiver implements Tool {
} while (newbie.exists());
// open up a prompt for where to save this fella
JFileChooser fd = new JFileChooser();
fd.setDialogTitle(_("Archive sketch as:"));
fd.setDialogType(JFileChooser.SAVE_DIALOG);
fd.setSelectedFile(newbie);
FileDialog fd = new FileDialog(editor, _("Archive sketch as:"), FileDialog.SAVE);
fd.setDirectory(parent.getAbsolutePath());
fd.setFile(newbie.getName());
fd.setVisible(true);
int returnVal = fd.showSaveDialog(editor);
String directory = fd.getDirectory();
String filename = fd.getFile();
if (returnVal != JFileChooser.APPROVE_OPTION) {
// only write the file if not canceled
if (filename != null) {
newbie = new File(directory, filename);
try {
//System.out.println(newbie);
FileOutputStream zipOutputFile = new FileOutputStream(newbie);
ZipOutputStream zos = new ZipOutputStream(zipOutputFile);
// recursively fill the zip file
buildZip(location, name, zos);
// close up the jar file
zos.flush();
zos.close();
editor.statusNotice("Created archive " + newbie.getName() + ".");
} catch (IOException e) {
e.printStackTrace();
}
} else {
editor.statusNotice(_("Archive sketch canceled."));
return;
}
newbie = fd.getSelectedFile();
try {
//System.out.println(newbie);
FileOutputStream zipOutputFile = new FileOutputStream(newbie);
ZipOutputStream zos = new ZipOutputStream(zipOutputFile);
// recursively fill the zip file
buildZip(location, name, zos);
// close up the jar file
zos.flush();
zos.close();
editor.statusNotice("Created archive " + newbie.getName() + ".");
} catch (IOException e) {
e.printStackTrace();
}
}

Binary file not shown.

View File

@ -248,8 +248,8 @@
<target name="macosx-java-latest-build" if="macosx" depends="revision-check, macosx-checkos, subprojects-build" description="Build Mac OS X version">
<antcall target="unzip">
<param name="archive_file" value="${staging_folder}/appbundler-1.0ea.jar.zip" />
<param name="archive_url" value="http://arduino.cc/download.php?f=/appbundler-1.0ea.jar.zip" />
<param name="archive_file" value="${staging_folder}/appbundler-1.0ea-arduino.jar.zip" />
<param name="archive_url" value="http://arduino.cc/download.php?f=/appbundler-1.0ea-arduino.jar.zip" />
<param name="final_folder" value="${staging_folder}/appbundler" />
<param name="dest_folder" value="${staging_folder}/appbundler" />
</antcall>
@ -277,7 +277,6 @@
<arch name="i386"/>
<classpath refid="runtime.jars"/>
<classpath file="./macosx/template.app/Contents/Resources/Java/quaqua.jar"/>
<option value="-Dapple.awt.application.name=Arduino" />
<option value="-Dapple.laf.useScreenMenuBar=true"/>
@ -314,8 +313,6 @@
<copy todir="${staging_folder}/work/${staging_hardware_folder}/../">
<fileset dir="shared" includes="lib/**" />
<fileset file="shared/revisions.txt" />
<file file="macosx/template.app/Contents/Resources/Java/quaqua.jar"/>
<fileset file="macosx/template.app/Contents/Resources/Java/libquaqua*" />
</copy>
<antcall target="macosx-build-common"/>

View File

@ -0,0 +1 @@
20da27cce14b7c60d6ef2e2cac2f60df491c8e21

View File

@ -1 +0,0 @@
28b3ccde1631791575a11f73e5fd0097df566fe2

View File

@ -17,6 +17,7 @@ ARDUINO 1.6.1
* Fixed: status board was not changing when using custom menu @PaulStoffregen
* Fixed: better error message when using a busy serial device
* Fixed: missing bool operator on EthernetClient
* MacOSX: back to native file dialogs and buttons, when using experimental version
ARDUINO 1.6.0 - 2015.02.09