Skip to content

Commit

Permalink
fix compatibility with Arduino > 1.6.12
Browse files Browse the repository at this point in the history
  • Loading branch information
facchinm committed Oct 21, 2016
1 parent fdb6015 commit 0e89af0
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 3 deletions.
Binary file added lib/arduino-core.jar
Binary file not shown.
Binary file modified lib/pde.jar
Binary file not shown.
26 changes: 24 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,23 @@
<repositoryLayout>default</repositoryLayout>
<groupId>arduino</groupId>
<artifactId>pde</artifactId>
<version>1.0</version>
<version>1.1</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
<goals>
<goal>install-file</goal>
</goals>
</execution>
<execution>
<id>install-arduino-core</id>
<phase>validate</phase>
<configuration>
<file>${basedir}/lib/arduino-core.jar</file>
<repositoryLayout>default</repositoryLayout>
<groupId>arduino</groupId>
<artifactId>arduino-core</artifactId>
<version>1.6.12</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
Expand Down Expand Up @@ -89,7 +105,13 @@
<groupId>arduino</groupId>
<artifactId>pde</artifactId>
<scope>provided</scope>
<version>1.0</version>
<version>1.1</version>
</dependency>
<dependency>
<groupId>arduino</groupId>
<artifactId>arduino-core</artifactId>
<scope>provided</scope>
<version>1.6.12</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
Expand Down
24 changes: 23 additions & 1 deletion src/main/java/com/ardublock/ArduBlockTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;

import processing.app.Editor;
import processing.app.EditorTab;
import processing.app.SketchFile;
import processing.app.tools.Tool;

import com.ardublock.core.Context;
Expand Down Expand Up @@ -69,7 +74,24 @@ public void didNew()
}

public void didGenerate(String source) {
ArduBlockTool.editor.setText(source);
java.lang.reflect.Method method;
try {
// pre Arduino 1.6.12
Class ed = ArduBlockTool.editor.getClass();
Class[] cArg = new Class[1];
cArg[0] = String.class;
method = ed.getMethod("setText", cArg);
method.invoke(ArduBlockTool.editor, source);
}
catch (NoSuchMethodException e) {
ArduBlockTool.editor.getCurrentTab().setText(source);
} catch (IllegalAccessException e) {
ArduBlockTool.editor.getCurrentTab().setText(source);
} catch (SecurityException e) {
ArduBlockTool.editor.getCurrentTab().setText(source);
} catch (InvocationTargetException e) {
ArduBlockTool.editor.getCurrentTab().setText(source);
}
ArduBlockTool.editor.handleExport(false);
}

Expand Down

0 comments on commit 0e89af0

Please sign in to comment.