diff --git a/lib/arduino-core.jar b/lib/arduino-core.jar
index 0cc5af8d..320904a3 100644
Binary files a/lib/arduino-core.jar and b/lib/arduino-core.jar differ
diff --git a/lib/pde.jar b/lib/pde.jar
index fae3009d..259b6d7f 100644
Binary files a/lib/pde.jar and b/lib/pde.jar differ
diff --git a/pom.xml b/pom.xml
index 5e74edd4..a588d489 100644
--- a/pom.xml
+++ b/pom.xml
@@ -77,7 +77,7 @@
default
arduino
arduino-core
- 1.6.12
+ 1.8.5
jar
true
@@ -111,7 +111,7 @@
arduino
arduino-core
provided
- 1.6.12
+ 1.8.5
org.apache.poi
diff --git a/src/main/java/com/ardublock/ArduBlockTool.java b/src/main/java/com/ardublock/ArduBlockTool.java
index 866a8c9e..79c8e0aa 100644
--- a/src/main/java/com/ardublock/ArduBlockTool.java
+++ b/src/main/java/com/ardublock/ArduBlockTool.java
@@ -1,5 +1,7 @@
package com.ardublock;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
@@ -11,6 +13,7 @@
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
+import javax.swing.JFrame;
import processing.app.Editor;
import processing.app.EditorTab;
@@ -38,6 +41,18 @@ public void init(Editor editor) {
context.setArduinoVersionString(arduinoVersion);
context.setEditor(editor);
System.out.println("Arduino Version: " + arduinoVersion);
+
+ // Don't just "close" Ardublock, see if there's something to save first.
+ // Note to self: Code here only affects behaviour when we're an Arduino Tool,
+ // not when run directly - See Main.java for that.
+ //ArduBlockTool.openblocksFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
+ ArduBlockTool.openblocksFrame.addWindowListener( new WindowAdapter()
+ {
+ public void windowClosing(WindowEvent e)
+ {
+ ArduBlockTool.openblocksFrame.doCloseArduBlockFile();
+ }
+ });
}
}
@@ -46,6 +61,7 @@ public void run() {
ArduBlockTool.editor.toFront();
ArduBlockTool.openblocksFrame.setVisible(true);
ArduBlockTool.openblocksFrame.toFront();
+ ArduBlockTool.openblocksFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
} catch (Exception e) {
}
diff --git a/src/main/java/com/ardublock/Main.java b/src/main/java/com/ardublock/Main.java
index 938b2a23..9c744642 100644
--- a/src/main/java/com/ardublock/Main.java
+++ b/src/main/java/com/ardublock/Main.java
@@ -1,9 +1,11 @@
package com.ardublock;
+import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;
import javax.swing.JFrame;
+import javax.swing.JOptionPane;
import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.SAXException;
@@ -31,7 +33,21 @@ public void startArdublock() throws SAXException, IOException, ParserConfigurati
private void startOpenblocksFrame() throws SAXException, IOException, ParserConfigurationException
{
openblocksFrame = new OpenblocksFrame();
- openblocksFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+ // Don't just "close" Ardublock, see if there's something to save first.
+ // Note to self: This only affects behaviour when we're run directly,
+ // not when we're an Arduino Tool - See ArduBlockTool.java for that.
+
+ //openblocksFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+ openblocksFrame.addWindowListener( new WindowAdapter()
+ {
+ public void windowClosing(WindowEvent e)
+ {
+ openblocksFrame.doCloseArduBlockFile();
+ }
+ });
+
Context context = Context.getContext();
context.setInArduino(false);
openblocksFrame.setVisible(true);
diff --git a/src/main/java/com/ardublock/ui/OpenblocksFrame.java b/src/main/java/com/ardublock/ui/OpenblocksFrame.java
index 17024d2f..cefed165 100644
--- a/src/main/java/com/ardublock/ui/OpenblocksFrame.java
+++ b/src/main/java/com/ardublock/ui/OpenblocksFrame.java
@@ -74,7 +74,6 @@ public OpenblocksFrame()
this.setLayout(new BorderLayout());
//put the frame to the center of screen
this.setLocationRelativeTo(null);
- //this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
uiMessageBundle = ResourceBundle.getBundle("com/ardublock/block/ardublock");
@@ -235,23 +234,24 @@ private void loadFile()
}
}
- public void doSaveArduBlockFile()
+ public boolean doSaveArduBlockFile()
{
if (!context.isWorkspaceChanged())
{
- return ;
+ return true;
}
String saveString = getArduBlockString();
if (context.getSaveFilePath() == null)
{
- chooseFileAndSave(saveString);
+ return chooseFileAndSave(saveString);
}
else
{
File saveFile = new File(context.getSaveFilePath());
writeFileAndUpdateFrame(saveString, saveFile);
+ return true;
}
}
@@ -269,21 +269,22 @@ public void doSaveAsArduBlockFile()
}
- private void chooseFileAndSave(String ardublockString)
+ private boolean chooseFileAndSave(String ardublockString)
{
File saveFile = letUserChooseSaveFile();
saveFile = checkFileSuffix(saveFile);
if (saveFile == null)
{
- return ;
+ return false;
}
if (saveFile.exists() && !askUserOverwriteExistedFile())
{
- return ;
+ return false;
}
writeFileAndUpdateFrame(ardublockString, saveFile);
+ return true;
}
private String getArduBlockString()
@@ -336,18 +337,66 @@ public void doNewArduBlockFile()
if (context.isWorkspaceChanged())
{
int optionValue = JOptionPane.showOptionDialog(this, uiMessageBundle.getString("message.question.newfile_on_workspace_changed"), uiMessageBundle.getString("message.title.question"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, JOptionPane.YES_OPTION);
- if (optionValue != JOptionPane.YES_OPTION)
+
+ switch (optionValue)
{
- return ;
+ case JOptionPane.YES_OPTION:
+ doSaveArduBlockFile();
+ //break;
+ case JOptionPane.NO_OPTION:
+ this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+ context.resetWorksapce();
+ context.setWorkspaceChanged(false);
+ this.setTitle(this.makeFrameTitle());
+ this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ break;
+ case JOptionPane.CANCEL_OPTION:
+ break;
}
}
- this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
- context.resetWorksapce();
- context.setWorkspaceChanged(false);
- this.setTitle(this.makeFrameTitle());
- this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ else
+ {
+ // If workspace unchanged just start a new Ardublock
+ this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+ context.resetWorksapce();
+ context.setWorkspaceChanged(false);
+ this.setTitle(this.makeFrameTitle());
+ this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ }
+
}
+ public void doCloseArduBlockFile()
+ {
+ if (context.isWorkspaceChanged())
+ {
+ int optionValue = JOptionPane.showOptionDialog(this, uiMessageBundle.getString("message.question.close_on_workspace_changed"), uiMessageBundle.getString("message.title.question"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, JOptionPane.YES_OPTION);
+ switch (optionValue)
+ {
+ case JOptionPane.YES_OPTION:
+ if (doSaveArduBlockFile())
+ {
+ setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+ }
+ else
+ {
+ setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
+ }
+ break;
+ case JOptionPane.NO_OPTION:
+ setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+ break;
+ case JOptionPane.CANCEL_OPTION:
+ setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
+ break;
+ }
+ }
+ else
+ {
+ setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+ }
+
+ }
private File checkFileSuffix(File saveFile)
diff --git a/src/main/resources/com/ardublock/block/Skins/Highclare/ardublock.properties b/src/main/resources/com/ardublock/block/Skins/Highclare/ardublock.properties
index a675645b..398ebd16 100644
--- a/src/main/resources/com/ardublock/block/Skins/Highclare/ardublock.properties
+++ b/src/main/resources/com/ardublock/block/Skins/Highclare/ardublock.properties
@@ -557,10 +557,11 @@ ardublock.translator.exception.subroutineNotDeclared=subroutine not declared
message.title.error=Error
message.title.question=Question
-message.content.open_unsaved=You have unsaved work which may be lost!\n Do you want to save your work before opening a new file?
+message.content.open_unsaved=You have unsaved work which will be lost!\n Do you want to save your work before opening a different Ardublock program?
message.content.overwrite=Do you want overwrite existing file?
message.file_not_found=File Not Found or Permission Denied
-message.question.newfile_on_workspace_changed=You have unsaved work which will be lost if you click 'YES' !\n Do you want to start a new Ardublock program?
+message.question.newfile_on_workspace_changed=You have unsaved work which will be lost!\n Do you want to save your work before starting a new Ardublock program?
+message.question.close_on_workspace_changed=You have unsaved work which may be lost!\n Do you want to save your work before before closing the Ardublock program?
bc.repeat_times=Repetitions
diff --git a/src/main/resources/com/ardublock/block/Skins/TC/ardublock.properties b/src/main/resources/com/ardublock/block/Skins/TC/ardublock.properties
index a675645b..398ebd16 100644
--- a/src/main/resources/com/ardublock/block/Skins/TC/ardublock.properties
+++ b/src/main/resources/com/ardublock/block/Skins/TC/ardublock.properties
@@ -557,10 +557,11 @@ ardublock.translator.exception.subroutineNotDeclared=subroutine not declared
message.title.error=Error
message.title.question=Question
-message.content.open_unsaved=You have unsaved work which may be lost!\n Do you want to save your work before opening a new file?
+message.content.open_unsaved=You have unsaved work which will be lost!\n Do you want to save your work before opening a different Ardublock program?
message.content.overwrite=Do you want overwrite existing file?
message.file_not_found=File Not Found or Permission Denied
-message.question.newfile_on_workspace_changed=You have unsaved work which will be lost if you click 'YES' !\n Do you want to start a new Ardublock program?
+message.question.newfile_on_workspace_changed=You have unsaved work which will be lost!\n Do you want to save your work before starting a new Ardublock program?
+message.question.close_on_workspace_changed=You have unsaved work which may be lost!\n Do you want to save your work before before closing the Ardublock program?
bc.repeat_times=Repetitions
diff --git a/src/main/resources/com/ardublock/block/Skins/all-master/ardublock.properties b/src/main/resources/com/ardublock/block/Skins/all-master/ardublock.properties
index 20a992b7..69024426 100644
--- a/src/main/resources/com/ardublock/block/Skins/all-master/ardublock.properties
+++ b/src/main/resources/com/ardublock/block/Skins/all-master/ardublock.properties
@@ -586,11 +586,11 @@ ardublock.translator.exception.subroutineNotDeclared=subroutine not declared
message.title.error=Error
message.title.question=Question
-message.content.open_unsaved=Ardublock program has changed, do you want to save?
+message.content.open_unsaved=You have unsaved work which will be lost!\n Do you want to save your work before opening a different Ardublock program?
message.content.overwrite=Do you want overwrite existing file?
message.file_not_found=File Not Found or Permission Denied
-message.question.newfile_on_workspace_changed=The program has changed, do you want to create a new Ardublock file?
-
+message.question.newfile_on_workspace_changed=You have unsaved work which will be lost!\n Do you want to save your work before starting a new Ardublock program?
+message.question.close_on_workspace_changed=You have unsaved work which may be lost!\n Do you want to save your work before before closing the Ardublock program?
bc.repeat_times=times
# Descriptions of all Block
diff --git a/src/main/resources/com/ardublock/block/Skins/slim/ardublock.properties b/src/main/resources/com/ardublock/block/Skins/slim/ardublock.properties
index be085787..531a521a 100644
--- a/src/main/resources/com/ardublock/block/Skins/slim/ardublock.properties
+++ b/src/main/resources/com/ardublock/block/Skins/slim/ardublock.properties
@@ -557,10 +557,11 @@ ardublock.translator.exception.subroutineNotDeclared=subroutine not declared
message.title.error=Error
message.title.question=Question
-message.content.open_unsaved=You have unsaved work which may be lost!\n Do you want to save your work before opening a new file?
+message.content.open_unsaved=You have unsaved work which will be lost!\n Do you want to save your work before opening a different Ardublock program?
message.content.overwrite=Do you want overwrite existing file?
message.file_not_found=File Not Found or Permission Denied
-message.question.newfile_on_workspace_changed=You have unsaved work which will be lost if you click 'YES' !\n Do you want to start a new Ardublock program?
+message.question.newfile_on_workspace_changed=You have unsaved work which will be lost!\n Do you want to save your work before starting a new Ardublock program?
+message.question.close_on_workspace_changed=You have unsaved work which may be lost!\n Do you want to save your work before before closing the Ardublock program?
bc.repeat_times=Repetitions
diff --git a/src/main/resources/com/ardublock/block/ardublock.properties b/src/main/resources/com/ardublock/block/ardublock.properties
index 20a992b7..69024426 100644
--- a/src/main/resources/com/ardublock/block/ardublock.properties
+++ b/src/main/resources/com/ardublock/block/ardublock.properties
@@ -586,11 +586,11 @@ ardublock.translator.exception.subroutineNotDeclared=subroutine not declared
message.title.error=Error
message.title.question=Question
-message.content.open_unsaved=Ardublock program has changed, do you want to save?
+message.content.open_unsaved=You have unsaved work which will be lost!\n Do you want to save your work before opening a different Ardublock program?
message.content.overwrite=Do you want overwrite existing file?
message.file_not_found=File Not Found or Permission Denied
-message.question.newfile_on_workspace_changed=The program has changed, do you want to create a new Ardublock file?
-
+message.question.newfile_on_workspace_changed=You have unsaved work which will be lost!\n Do you want to save your work before starting a new Ardublock program?
+message.question.close_on_workspace_changed=You have unsaved work which may be lost!\n Do you want to save your work before before closing the Ardublock program?
bc.repeat_times=times
# Descriptions of all Block