mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-16 11:21:18 +03:00
MacOSX: double click on a .ino file works again. Fixes #2888
This commit is contained in:
Binary file not shown.
@ -22,6 +22,7 @@
|
||||
|
||||
package processing.app;
|
||||
|
||||
import cc.arduino.contributions.DownloadableContributionVersionComparator;
|
||||
import cc.arduino.contributions.VersionHelper;
|
||||
import cc.arduino.contributions.libraries.ContributedLibrary;
|
||||
import cc.arduino.contributions.libraries.LibrariesIndexer;
|
||||
@ -30,7 +31,6 @@ import cc.arduino.contributions.libraries.ui.LibraryManagerUI;
|
||||
import cc.arduino.contributions.packages.ContributedPlatform;
|
||||
import cc.arduino.contributions.packages.ContributionInstaller;
|
||||
import cc.arduino.contributions.packages.ContributionsIndexer;
|
||||
import cc.arduino.contributions.DownloadableContributionVersionComparator;
|
||||
import cc.arduino.contributions.packages.ui.ContributionManagerUI;
|
||||
import cc.arduino.files.DeleteFilesOnShutdown;
|
||||
import cc.arduino.packages.DiscoveryManager;
|
||||
@ -79,7 +79,9 @@ public class Base {
|
||||
}
|
||||
};
|
||||
|
||||
static private boolean commandLine;
|
||||
private static boolean commandLine;
|
||||
public static volatile Base INSTANCE;
|
||||
|
||||
public static SplashScreenHelper splashScreenHelper = new SplashScreenHelper(SplashScreen.getSplashScreen());
|
||||
|
||||
// A single instance of the preferences window
|
||||
@ -104,7 +106,7 @@ public class Base {
|
||||
// p5 icon for the window
|
||||
// static Image icon;
|
||||
|
||||
// int editorCount;
|
||||
// int editorCount;
|
||||
List<Editor> editors = Collections.synchronizedList(new ArrayList<Editor>());
|
||||
Editor activeEditor;
|
||||
|
||||
@ -119,6 +121,10 @@ public class Base {
|
||||
|
||||
splashScreenHelper.splashText(_("Loading configuration..."));
|
||||
|
||||
if (OSUtils.isMacOS()) {
|
||||
ThinkDifferent.init();
|
||||
}
|
||||
|
||||
try {
|
||||
guardedMain(args);
|
||||
} catch (Throwable e) {
|
||||
@ -207,7 +213,7 @@ public class Base {
|
||||
untitledFolder = createTempFolder("untitled");
|
||||
DeleteFilesOnShutdown.add(untitledFolder);
|
||||
|
||||
new Base(args);
|
||||
INSTANCE = new Base(args);
|
||||
}
|
||||
|
||||
|
||||
@ -247,8 +253,6 @@ public class Base {
|
||||
|
||||
public Base(String[] args) throws Exception {
|
||||
getPlatform().init();
|
||||
if (OSUtils.isMacOS())
|
||||
ThinkDifferent.init(this);
|
||||
|
||||
String sketchbookPath = BaseNoGui.getSketchbookPath();
|
||||
|
||||
@ -274,7 +278,7 @@ public class Base {
|
||||
|
||||
CommandlineParser parser = CommandlineParser.newCommandlineParser(args);
|
||||
|
||||
for (String path: parser.getFilenames()) {
|
||||
for (String path : parser.getFilenames()) {
|
||||
// Correctly resolve relative paths
|
||||
File file = absoluteFile(path);
|
||||
|
||||
@ -312,6 +316,7 @@ public class Base {
|
||||
ContributionsIndexer indexer = new ContributionsIndexer(BaseNoGui.getSettingsFolder());
|
||||
ContributionInstaller installer = new ContributionInstaller(indexer) {
|
||||
private String lastStatus = "";
|
||||
|
||||
@Override
|
||||
protected void onProgress(Progress progress) {
|
||||
if (!lastStatus.equals(progress.getStatus())) {
|
||||
@ -357,6 +362,7 @@ public class Base {
|
||||
LibrariesIndexer indexer = new LibrariesIndexer(BaseNoGui.getSettingsFolder());
|
||||
LibraryInstaller installer = new LibraryInstaller(indexer) {
|
||||
private String lastStatus = "";
|
||||
|
||||
@Override
|
||||
protected void onProgress(Progress progress) {
|
||||
if (!lastStatus.equals(progress.getStatus())) {
|
||||
@ -374,7 +380,7 @@ public class Base {
|
||||
for (String library : parser.getLibraryToInstall().split(",")) {
|
||||
String[] libraryToInstallParts = library.split(":");
|
||||
|
||||
ContributedLibrary selected=null;
|
||||
ContributedLibrary selected = null;
|
||||
if (libraryToInstallParts.length == 2) {
|
||||
selected = indexer.getIndex().find(libraryToInstallParts[0], VersionHelper.valueOf(libraryToInstallParts[1]).toString());
|
||||
} else if (libraryToInstallParts.length == 1) {
|
||||
@ -427,8 +433,7 @@ public class Base {
|
||||
|
||||
// No errors exit gracefully
|
||||
System.exit(0);
|
||||
}
|
||||
else if (parser.isGuiMode()) {
|
||||
} else if (parser.isGuiMode()) {
|
||||
splashScreenHelper.splashText(_("Starting..."));
|
||||
|
||||
// Check if there were previously opened sketches to be restored
|
||||
@ -443,12 +448,10 @@ public class Base {
|
||||
if (Preferences.getBoolean("update.check")) {
|
||||
new UpdateCheck(this);
|
||||
}
|
||||
}
|
||||
else if (parser.isNoOpMode()) {
|
||||
} else if (parser.isNoOpMode()) {
|
||||
// Do nothing (intended for only changing preferences)
|
||||
System.exit(0);
|
||||
}
|
||||
else if (parser.isGetPrefMode()) {
|
||||
} else if (parser.isGetPrefMode()) {
|
||||
String value = Preferences.get(parser.getGetPref(), null);
|
||||
if (value != null) {
|
||||
System.out.println(value);
|
||||
@ -464,6 +467,7 @@ public class Base {
|
||||
* sketch that was used (if any), and restores other Editor settings.
|
||||
* The complement to "storePreferences", this is called when the
|
||||
* application is first launched.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected boolean restoreSketches() throws Exception {
|
||||
@ -570,8 +574,7 @@ public class Base {
|
||||
String untitledPath = untitledFolder.getAbsolutePath();
|
||||
if (path.startsWith(untitledPath)) {
|
||||
path = "";
|
||||
} else
|
||||
if (BaseNoGui.getPortableFolder() != null) {
|
||||
} else if (BaseNoGui.getPortableFolder() != null) {
|
||||
path = FileUtils.relativePath(BaseNoGui.getPortableFolder().toString(), path);
|
||||
if (path == null)
|
||||
path = "";
|
||||
@ -621,7 +624,7 @@ public class Base {
|
||||
if (activeEditor == null) {
|
||||
Rectangle screen = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration().getBounds();
|
||||
// If no current active editor, use default placement
|
||||
return new int[] {
|
||||
return new int[]{
|
||||
(screen.width - defaultWidth) / 2,
|
||||
(screen.height - defaultHeight) / 2,
|
||||
defaultWidth, defaultHeight, 0
|
||||
@ -647,7 +650,7 @@ public class Base {
|
||||
location[0] + location[2] > screen.width ||
|
||||
location[1] + location[3] > screen.height) {
|
||||
// Warp the next window to a randomish location on screen.
|
||||
return new int[] {
|
||||
return new int[]{
|
||||
(int) (Math.random() * (screen.width - defaultWidth)),
|
||||
(int) (Math.random() * (screen.height - defaultHeight)),
|
||||
defaultWidth, defaultHeight, 0
|
||||
@ -672,6 +675,7 @@ public class Base {
|
||||
/**
|
||||
* Handle creating a sketch folder, return its base .pde file
|
||||
* or null if the operation was canceled.
|
||||
*
|
||||
* @param shift whether shift is pressed, which will invert prompt setting
|
||||
* @param noPrompt disable prompt, no matter the setting
|
||||
*/
|
||||
@ -728,6 +732,7 @@ public class Base {
|
||||
|
||||
/**
|
||||
* Create a new untitled document in a new sketch window.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public void handleNew() throws Exception {
|
||||
@ -779,9 +784,11 @@ public class Base {
|
||||
|
||||
/**
|
||||
* Open a sketch, replacing the sketch in the current window.
|
||||
*
|
||||
* @param path Location of the primary pde file for the sketch.
|
||||
*/
|
||||
public void handleOpenReplace(File file) {
|
||||
System.out.println("handleOpenReplace");
|
||||
if (!activeEditor.checkModified()) {
|
||||
return; // sketch was modified, and user canceled
|
||||
}
|
||||
@ -798,6 +805,7 @@ public class Base {
|
||||
|
||||
/**
|
||||
* Prompt for a sketch to open, and open it in a new window.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public void handleOpenPrompt() throws Exception {
|
||||
@ -834,6 +842,7 @@ public class Base {
|
||||
|
||||
/**
|
||||
* Open a sketch in a new window.
|
||||
*
|
||||
* @param file File to open
|
||||
* @return the Editor object, so that properties (like 'untitled')
|
||||
* can be set by the caller
|
||||
@ -923,6 +932,7 @@ public class Base {
|
||||
|
||||
/**
|
||||
* Close a sketch as specified by its editor window.
|
||||
*
|
||||
* @param editor Editor object of the sketch to be closed.
|
||||
* @return true if succeeded in closing, false if canceled.
|
||||
*/
|
||||
@ -942,12 +952,12 @@ public class Base {
|
||||
// if (Preferences.getBoolean("sketchbook.closing_last_window_quits") ||
|
||||
// (editor.untitled && !editor.getSketch().isModified())) {
|
||||
if (OSUtils.isMacOS()) {
|
||||
Object[] options = { "OK", "Cancel" };
|
||||
Object[] options = {"OK", "Cancel"};
|
||||
String prompt =
|
||||
_("<html> " +
|
||||
"<head> <style type=\"text/css\">"+
|
||||
"b { font: 13pt \"Lucida Grande\" }"+
|
||||
"p { font: 11pt \"Lucida Grande\"; margin-top: 8px }"+
|
||||
"<head> <style type=\"text/css\">" +
|
||||
"b { font: 13pt \"Lucida Grande\" }" +
|
||||
"p { font: 11pt \"Lucida Grande\"; margin-top: 8px }" +
|
||||
"</style> </head>" +
|
||||
"<b>Are you sure you want to Quit?</b>" +
|
||||
"<p>Closing the last open sketch will quit Arduino.");
|
||||
@ -1004,9 +1014,11 @@ public class Base {
|
||||
|
||||
/**
|
||||
* Handler for File → Quit.
|
||||
*
|
||||
* @return false if canceled, true otherwise.
|
||||
*/
|
||||
public boolean handleQuit() {
|
||||
System.out.println("handleQuit");
|
||||
// If quit is canceled, this will be replaced anyway
|
||||
// by a later handleQuit() that is not canceled.
|
||||
storeSketches();
|
||||
@ -1037,6 +1049,7 @@ public class Base {
|
||||
|
||||
/**
|
||||
* Attempt to close each open sketch in preparation for quitting.
|
||||
*
|
||||
* @return false if canceled along the way
|
||||
*/
|
||||
protected boolean handleQuitEach() {
|
||||
@ -1215,7 +1228,7 @@ public class Base {
|
||||
addSketchesSubmenu(menu, lib, false);
|
||||
|
||||
LibraryList userLibs = getUserLibs();
|
||||
if (userLibs.size()>0) {
|
||||
if (userLibs.size() > 0) {
|
||||
menu.addSeparator();
|
||||
userLibs.sort();
|
||||
for (UserLibrary lib : userLibs)
|
||||
@ -1381,8 +1394,8 @@ public class Base {
|
||||
@SuppressWarnings("serial")
|
||||
Action action = new AbstractAction(board.getName()) {
|
||||
public void actionPerformed(ActionEvent actionevent) {
|
||||
selectBoard((TargetBoard)getValue("b"));
|
||||
filterVisibilityOfSubsequentBoardMenus(boardsCustomMenus, (TargetBoard)getValue("b"), 1);
|
||||
selectBoard((TargetBoard) getValue("b"));
|
||||
filterVisibilityOfSubsequentBoardMenus(boardsCustomMenus, (TargetBoard) getValue("b"), 1);
|
||||
|
||||
onBoardOrPortChange();
|
||||
rebuildImportMenu(Editor.importMenu);
|
||||
@ -1409,7 +1422,7 @@ public class Base {
|
||||
@SuppressWarnings("serial")
|
||||
Action subAction = new AbstractAction(_(boardCustomMenu.get(customMenuOption))) {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Preferences.set("custom_" + menuId, ((TargetBoard)getValue("board")).getId() + "_" + getValue("custom_menu_option"));
|
||||
Preferences.set("custom_" + menuId, ((TargetBoard) getValue("board")).getId() + "_" + getValue("custom_menu_option"));
|
||||
onBoardOrPortChange();
|
||||
}
|
||||
};
|
||||
@ -1778,8 +1791,6 @@ public class Base {
|
||||
// return PConstants.OTHER;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
static public Platform getPlatform() {
|
||||
return BaseNoGui.getPlatform();
|
||||
}
|
||||
@ -1815,6 +1826,7 @@ public class Base {
|
||||
* Convenience method to get a File object for the specified filename inside
|
||||
* the settings folder.
|
||||
* For now, only used by Preferences to get the preferences.txt file.
|
||||
*
|
||||
* @param filename A file inside the settings folder.
|
||||
* @return filename wrapped as a File object inside the settings folder
|
||||
*/
|
||||
@ -2025,6 +2037,7 @@ public class Base {
|
||||
|
||||
/**
|
||||
* Used to determine whether to disable the "Show Sketch Folder" option.
|
||||
*
|
||||
* @return true If a means of opening a folder is known to be available.
|
||||
*/
|
||||
static protected boolean openFolderAvailable() {
|
||||
@ -2208,7 +2221,6 @@ public class Base {
|
||||
// ...................................................................
|
||||
|
||||
|
||||
|
||||
// incomplete
|
||||
static public int showYesNoCancelQuestion(Editor editor, String title,
|
||||
String primary, String secondary) {
|
||||
@ -2235,16 +2247,16 @@ public class Base {
|
||||
// http://www.randelshofer.ch/quaqua/guide/joptionpane.html
|
||||
JOptionPane pane =
|
||||
new JOptionPane("<html> " +
|
||||
"<head> <style type=\"text/css\">"+
|
||||
"b { font: 13pt \"Lucida Grande\" }"+
|
||||
"p { font: 11pt \"Lucida Grande\"; margin-top: 8px }"+
|
||||
"<head> <style type=\"text/css\">" +
|
||||
"b { font: 13pt \"Lucida Grande\" }" +
|
||||
"p { font: 11pt \"Lucida Grande\"; margin-top: 8px }" +
|
||||
"</style> </head>" +
|
||||
"<b>Do you want to save changes to this sketch<BR>" +
|
||||
" before closing?</b>" +
|
||||
"<p>If you don't save, your changes will be lost.",
|
||||
JOptionPane.QUESTION_MESSAGE);
|
||||
|
||||
String[] options = new String[] {
|
||||
String[] options = new String[]{
|
||||
"Save", "Cancel", "Don't Save"
|
||||
};
|
||||
pane.setOptions(options);
|
||||
@ -2300,15 +2312,15 @@ public class Base {
|
||||
// http://www.randelshofer.ch/quaqua/guide/joptionpane.html
|
||||
JOptionPane pane =
|
||||
new JOptionPane("<html> " +
|
||||
"<head> <style type=\"text/css\">"+
|
||||
"b { font: 13pt \"Lucida Grande\" }"+
|
||||
"p { font: 11pt \"Lucida Grande\"; margin-top: 8px }"+
|
||||
"<head> <style type=\"text/css\">" +
|
||||
"b { font: 13pt \"Lucida Grande\" }" +
|
||||
"p { font: 11pt \"Lucida Grande\"; margin-top: 8px }" +
|
||||
"</style> </head>" +
|
||||
"<b>" + primary + "</b>" +
|
||||
"<p>" + secondary + "</p>",
|
||||
JOptionPane.QUESTION_MESSAGE);
|
||||
|
||||
String[] options = new String[] {
|
||||
String[] options = new String[]{
|
||||
"Yes", "No"
|
||||
};
|
||||
pane.setOptions(options);
|
||||
@ -2367,7 +2379,6 @@ public class Base {
|
||||
return null;
|
||||
}
|
||||
*/
|
||||
|
||||
static public File getContentFile(String name) {
|
||||
return BaseNoGui.getContentFile(name);
|
||||
}
|
||||
@ -2393,7 +2404,8 @@ public class Base {
|
||||
tracker.addImage(image, 0);
|
||||
try {
|
||||
tracker.waitForAll();
|
||||
} catch (InterruptedException e) { }
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
@ -2427,7 +2439,7 @@ public class Base {
|
||||
byte buffer[] = new byte[size];
|
||||
int offset = 0;
|
||||
int bytesRead;
|
||||
while ((bytesRead = input.read(buffer, offset, size-offset)) != -1) {
|
||||
while ((bytesRead = input.read(buffer, offset, size - offset)) != -1) {
|
||||
offset += bytesRead;
|
||||
if (bytesRead == 0) break;
|
||||
}
|
||||
@ -2437,13 +2449,12 @@ public class Base {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Read from a file with a bunch of attribute/value pairs
|
||||
* that are separated by = and ignore comments with #.
|
||||
*/
|
||||
static public HashMap<String,String> readSettings(File inputFile) {
|
||||
HashMap<String,String> outgoing = new HashMap<String,String>();
|
||||
static public HashMap<String, String> readSettings(File inputFile) {
|
||||
HashMap<String, String> outgoing = new HashMap<String, String>();
|
||||
if (!inputFile.exists()) return outgoing; // return empty hash
|
||||
|
||||
String lines[] = PApplet.loadStrings(inputFile);
|
||||
@ -2686,4 +2697,12 @@ public class Base {
|
||||
public static DiscoveryManager getDiscoveryManager() {
|
||||
return BaseNoGui.getDiscoveryManager();
|
||||
}
|
||||
|
||||
public Editor getActiveEditor() {
|
||||
return activeEditor;
|
||||
}
|
||||
|
||||
public List<Editor> getEditors() {
|
||||
return new LinkedList<Editor>(editors);
|
||||
}
|
||||
}
|
||||
|
@ -22,113 +22,95 @@
|
||||
|
||||
package processing.app.macosx;
|
||||
|
||||
import processing.app.Base;
|
||||
|
||||
import com.apple.eawt.*;
|
||||
import processing.app.Base;
|
||||
import processing.app.Editor;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* Deal with issues related to thinking different. This handles the basic
|
||||
* Mac OS X menu commands (and apple events) for open, about, prefs, etc.
|
||||
*
|
||||
* <p/>
|
||||
* Based on OSXAdapter.java from Apple DTS.
|
||||
*
|
||||
* <p/>
|
||||
* As of 0140, this code need not be built on platforms other than OS X,
|
||||
* because of the new platform structure which isolates through reflection.
|
||||
*/
|
||||
public class ThinkDifferent implements ApplicationListener {
|
||||
public class ThinkDifferent {
|
||||
|
||||
// pseudo-singleton model; no point in making multiple instances
|
||||
// of the EAWT application or our adapter
|
||||
private static ThinkDifferent adapter;
|
||||
// http://developer.apple.com/documentation/Java/Reference/1.4.2/appledoc/api/com/apple/eawt/Application.html
|
||||
private static Application application;
|
||||
private static final int MAX_WAIT_FOR_BASE = 10000;
|
||||
|
||||
// reference to the app where the existing quit, about, prefs code is
|
||||
private Base base;
|
||||
|
||||
|
||||
static public void init(Base base) {
|
||||
if (application == null) {
|
||||
//application = new com.apple.eawt.Application();
|
||||
application = com.apple.eawt.Application.getApplication();
|
||||
}
|
||||
if (adapter == null) {
|
||||
adapter = new ThinkDifferent(base);
|
||||
}
|
||||
application.addApplicationListener(adapter);
|
||||
application.setEnabledAboutMenu(true);
|
||||
application.setEnabledPreferencesMenu(true);
|
||||
}
|
||||
|
||||
|
||||
public ThinkDifferent(Base base) {
|
||||
this.base = base;
|
||||
}
|
||||
|
||||
|
||||
// implemented handler methods. These are basically hooks into existing
|
||||
// functionality from the main app, as if it came over from another platform.
|
||||
public void handleAbout(ApplicationEvent ae) {
|
||||
if (base != null) {
|
||||
ae.setHandled(true);
|
||||
base.handleAbout();
|
||||
} else {
|
||||
throw new IllegalStateException("handleAbout: Base instance detached from listener");
|
||||
static public void init() {
|
||||
Application application = Application.getApplication();
|
||||
application.setAboutHandler(new AboutHandler() {
|
||||
@Override
|
||||
public void handleAbout(AppEvent.AboutEvent aboutEvent) {
|
||||
if (waitForBase()) {
|
||||
Base.INSTANCE.handleAbout();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void handlePreferences(ApplicationEvent ae) {
|
||||
if (base != null) {
|
||||
base.handlePrefs();
|
||||
ae.setHandled(true);
|
||||
} else {
|
||||
throw new IllegalStateException("handlePreferences: Base instance detached from listener");
|
||||
});
|
||||
application.setPreferencesHandler(new PreferencesHandler() {
|
||||
@Override
|
||||
public void handlePreferences(AppEvent.PreferencesEvent preferencesEvent) {
|
||||
if (waitForBase()) {
|
||||
Base.INSTANCE.handlePrefs();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void handleOpenApplication(ApplicationEvent ae) {
|
||||
}
|
||||
|
||||
|
||||
public void handleOpenFile(ApplicationEvent ae) {
|
||||
// System.out.println("got open file event " + ae.getFilename());
|
||||
String filename = ae.getFilename();
|
||||
});
|
||||
application.setOpenFileHandler(new OpenFilesHandler() {
|
||||
@Override
|
||||
public void openFiles(final AppEvent.OpenFilesEvent openFilesEvent) {
|
||||
if (waitForBase()) {
|
||||
for (File file : openFilesEvent.getFiles()) {
|
||||
try {
|
||||
base.handleOpen(new File(filename));
|
||||
Base.INSTANCE.handleOpen(file);
|
||||
List<Editor> editors = Base.INSTANCE.getEditors();
|
||||
if (editors.size() == 2 && editors.get(0).getSketch().isUntitled()) {
|
||||
Base.INSTANCE.handleClose(editors.get(0));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
ae.setHandled(true);
|
||||
}
|
||||
|
||||
|
||||
public void handlePrintFile(ApplicationEvent ae) {
|
||||
// TODO implement os x print handler here (open app, call handlePrint, quit)
|
||||
}
|
||||
|
||||
|
||||
public void handleQuit(ApplicationEvent ae) {
|
||||
if (base != null) {
|
||||
/*
|
||||
/ You MUST setHandled(false) if you want to delay or cancel the quit.
|
||||
/ This is important for cross-platform development -- have a universal quit
|
||||
/ routine that chooses whether or not to quit, so the functionality is identical
|
||||
/ on all platforms. This example simply cancels the AppleEvent-based quit and
|
||||
/ defers to that universal method.
|
||||
*/
|
||||
boolean result = base.handleQuit();
|
||||
ae.setHandled(result);
|
||||
}
|
||||
});
|
||||
application.setQuitHandler(new QuitHandler() {
|
||||
@Override
|
||||
public void handleQuitRequestWith(AppEvent.QuitEvent quitEvent, QuitResponse quitResponse) {
|
||||
if (waitForBase()) {
|
||||
if (Base.INSTANCE.handleClose(Base.INSTANCE.getActiveEditor())) {
|
||||
quitResponse.performQuit();
|
||||
} else {
|
||||
throw new IllegalStateException("handleQuit: Base instance detached from listener");
|
||||
quitResponse.cancelQuit();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static boolean waitForBase() {
|
||||
int slept = 0;
|
||||
while (Base.INSTANCE == null) {
|
||||
if (slept >= MAX_WAIT_FOR_BASE) {
|
||||
return false;
|
||||
}
|
||||
sleep(100);
|
||||
slept += 100;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void sleep(int millis) {
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void handleReOpenApplication(ApplicationEvent arg0) {
|
||||
}
|
||||
}
|
@ -324,7 +324,7 @@
|
||||
<bundledocument extensions="ino,c,cpp,h"
|
||||
icon="macosx/template.app/Contents/Resources/pde.icns"
|
||||
name="Arduino Source File"
|
||||
role="Editor">
|
||||
role="Editor" ispackage="false">
|
||||
</bundledocument>
|
||||
|
||||
</bundleapp>
|
||||
|
Reference in New Issue
Block a user