[sikuli] 313/385: revised the use of NativeSupport (prior NativeLayer...) - currently only used on Mac
Gilles Filippini
pini at moszumanska.debian.org
Sun Jun 29 19:26:27 UTC 2014
This is an automated email from the git hooks/post-receive script.
pini pushed a commit to tag upstream/1.1.0_beta1
in repository sikuli.
commit 3c9d3ca795e96698cd00cd1907ad5ddb5f6b71e1
Author: Raimund Hocke <rmhdevelop at me.com>
Date: Sat Mar 1 21:26:13 2014 +0100
revised the use of NativeSupport (prior NativeLayer...) - currently only used on Mac
---
IDE/src/main/java/org/sikuli/ide/NativeLayer.java | 13 ----
.../java/org/sikuli/ide/NativeLayerForLinux.java | 18 -----
.../java/org/sikuli/ide/NativeLayerForMac.java | 79 ----------------------
.../java/org/sikuli/ide/NativeLayerForWindows.java | 18 -----
.../main/java/org/sikuli/ide/NativeSupport.java | 13 ++++
.../main/java/org/sikuli/ide/NativeSupportMac.java | 65 ++++++++++++++++++
IDE/src/main/java/org/sikuli/ide/SikuliIDE.java | 34 ++++++----
pom.xml | 4 +-
8 files changed, 102 insertions(+), 142 deletions(-)
diff --git a/IDE/src/main/java/org/sikuli/ide/NativeLayer.java b/IDE/src/main/java/org/sikuli/ide/NativeLayer.java
deleted file mode 100755
index 0c938ec..0000000
--- a/IDE/src/main/java/org/sikuli/ide/NativeLayer.java
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * Copyright 2010-2013, Sikuli.org
- * Released under the MIT License.
- *
- * modified RaiMan 2013
- */
-package org.sikuli.ide;
-
-public interface NativeLayer {
- public void initApp();
- public void initIDE(SikuliIDE ide);
-}
-
diff --git a/IDE/src/main/java/org/sikuli/ide/NativeLayerForLinux.java b/IDE/src/main/java/org/sikuli/ide/NativeLayerForLinux.java
deleted file mode 100755
index 4d5565f..0000000
--- a/IDE/src/main/java/org/sikuli/ide/NativeLayerForLinux.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Copyright 2010-2013, Sikuli.org
- * Released under the MIT License.
- *
- * modified RaiMan 2013
- */
-package org.sikuli.ide;
-
-public class NativeLayerForLinux implements NativeLayer {
-
- @Override
- public void initApp() {
- }
-
- @Override
- public void initIDE(SikuliIDE ide) {
- }
-}
diff --git a/IDE/src/main/java/org/sikuli/ide/NativeLayerForMac.java b/IDE/src/main/java/org/sikuli/ide/NativeLayerForMac.java
deleted file mode 100755
index 84aa5b9..0000000
--- a/IDE/src/main/java/org/sikuli/ide/NativeLayerForMac.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright 2010-2013, Sikuli.org
- * Released under the MIT License.
- *
- * modified RaiMan 2013
- */
-package org.sikuli.ide;
-
-import com.apple.eawt.*;
-import java.io.File;
-import java.util.List;
-import org.sikuli.basics.Debug;
-
-// http://lists.apple.com/archives/mac-games-dev/2001/Sep/msg00113.html
-// full key table: http://www.mactech.com/articles/mactech/Vol.04/04.12/Macinkeys/
-// modifiers code: http://www.mactech.com/macintosh-c/chap02-1.html
-public class NativeLayerForMac implements NativeLayer, AboutHandler, PreferencesHandler, OpenFilesHandler, QuitHandler {
-
- private static final String me = "NativeLayerForMac: ";
-
- @Override
- public void initIDE(final SikuliIDE ide) {
- }
-
- @Override
- public void handleAbout(AppEvent.AboutEvent evt) {
- Debug.log(5, "NativeLayerforMac: aboutHandler entered");
- SikuliIDE.getInstance().doAbout();
- }
-
- @Override
- public void handlePreferences(AppEvent.PreferencesEvent evt) {
- SikuliIDE.getInstance().showPreferencesWindow();
- }
-
- @Override
- public void openFiles(AppEvent.OpenFilesEvent evt) {
- List<File> fnameList = evt.getFiles();
- final String fname = fnameList.get(0).getPath();
- Debug.log(2, "opening " + fname);
- if (fname.endsWith(".skl")) {
- SikuliIDE._runningSkl = true;
- Thread t = new Thread() {
- @Override
- public void run() {
- try {
- SikuliIDE.main(new String[] {fname});
- } catch (Exception e) {
- Debug.error(me + "openFiles: Problem starting IDE\n%s", e.getMessage());
- }
- }
- };
- t.setDaemon(false);
- t.start();
- } else if (fname.endsWith(".sikuli")) {
- SikuliIDE ide = SikuliIDE.getInstance(null);
- ide.restoreScriptFromSession(fname);
- }
- }
-
- @Override
- public void handleQuitRequestWith(AppEvent.QuitEvent evt, QuitResponse resp) {
- if (! SikuliIDE.getInstance().quit()) resp.cancelQuit();
- else resp.performQuit();
- }
-
- @Override
- public void initApp() {
-
- Application.getApplication().setAboutHandler(this);
- Application.getApplication().setPreferencesHandler(this);
- Application.getApplication().setOpenFileHandler(this);
- Application.getApplication().setQuitHandler(this);
-
-
- System.setProperty("apple.laf.useScreenMenuBar", "true");
- System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Sikuli IDE");
- }
-}
diff --git a/IDE/src/main/java/org/sikuli/ide/NativeLayerForWindows.java b/IDE/src/main/java/org/sikuli/ide/NativeLayerForWindows.java
deleted file mode 100755
index ef2b510..0000000
--- a/IDE/src/main/java/org/sikuli/ide/NativeLayerForWindows.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Copyright 2010-2013, Sikuli.org
- * Released under the MIT License.
- *
- * modified RaiMan 2013
- */
-package org.sikuli.ide;
-
-public class NativeLayerForWindows implements NativeLayer {
-
- @Override
- public void initApp() {
- }
-
- @Override
- public void initIDE(SikuliIDE ide) {
- }
-}
diff --git a/IDE/src/main/java/org/sikuli/ide/NativeSupport.java b/IDE/src/main/java/org/sikuli/ide/NativeSupport.java
new file mode 100755
index 0000000..464d056
--- /dev/null
+++ b/IDE/src/main/java/org/sikuli/ide/NativeSupport.java
@@ -0,0 +1,13 @@
+/*
+ * Copyright 2010-2014, Sikuli.org, sikulix.com
+ * Released under the MIT License.
+ *
+ * modified RaiMan
+ */
+package org.sikuli.ide;
+
+public interface NativeSupport {
+ public void initApp(boolean debug);
+ public void initIDE(SikuliIDE ide);
+}
+
diff --git a/IDE/src/main/java/org/sikuli/ide/NativeSupportMac.java b/IDE/src/main/java/org/sikuli/ide/NativeSupportMac.java
new file mode 100644
index 0000000..d0f549b
--- /dev/null
+++ b/IDE/src/main/java/org/sikuli/ide/NativeSupportMac.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2010-2014, Sikuli.org, sikulix.com
+ * Released under the MIT License.
+ *
+ * modified RaiMan
+ */
+package org.sikuli.ide;
+
+import com.apple.eawt.*;
+
+public class NativeSupportMac implements NativeSupport, AboutHandler, PreferencesHandler, QuitHandler {
+
+ private boolean debug = false;
+
+ private void p(String msg, Object... args) {
+ if (debug) {
+ System.out.println(String.format(msg, args));
+ }
+ }
+
+ @Override
+ public void handleAbout(AppEvent.AboutEvent evt) {
+ p("[debug] IDE: NativeSupportMac: aboutHandler entered");
+ SikuliIDE.getInstance().doAbout();
+ }
+
+ @Override
+ public void handlePreferences(AppEvent.PreferencesEvent evt) {
+ p("[debug] IDE: NativeSupportMac: prefsHandler entered");
+ SikuliIDE.getInstance().showPreferencesWindow();
+ }
+
+ @Override
+ public void handleQuitRequestWith(AppEvent.QuitEvent evt, QuitResponse resp) {
+ p("[debug] IDE: NativeSupportMac: quitHandler entered");
+ if (!SikuliIDE.getInstance().quit()) {
+ resp.cancelQuit();
+ } else {
+ resp.performQuit();
+ }
+ }
+
+ @Override
+ public void initApp(boolean d) {
+ debug = d;
+ Exception e = null;
+ try {
+ Application.getApplication().setAboutHandler(this);
+ Application.getApplication().setPreferencesHandler(this);
+ Application.getApplication().setQuitHandler(this);
+ p("[debug] IDE: NativeSupportMac: set handler success");
+ } catch (Exception ex) {
+ e = ex;
+ }
+ if (e != null) {
+ p("[error] IDE: NativeSupportMac: set handler problem\n%s", e.getMessage());
+ }
+ System.setProperty("apple.laf.useScreenMenuBar", "true");
+ System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Sikuli IDE");
+ }
+
+ @Override
+ public void initIDE(SikuliIDE ide) {
+ }
+}
\ No newline at end of file
diff --git a/IDE/src/main/java/org/sikuli/ide/SikuliIDE.java b/IDE/src/main/java/org/sikuli/ide/SikuliIDE.java
index e466a12..f6df9b4 100755
--- a/IDE/src/main/java/org/sikuli/ide/SikuliIDE.java
+++ b/IDE/src/main/java/org/sikuli/ide/SikuliIDE.java
@@ -54,7 +54,6 @@ import org.sikuli.script.Key;
public class SikuliIDE extends JFrame {
private static String me = "IDE";
- private static String mem = "";
private static int lvl = 3;
private static void log(int level, String message, Object... args) {
@@ -69,7 +68,7 @@ public class SikuliIDE extends JFrame {
final static int WARNING_DO_NOTHING = 0;
final static int IS_SAVE_ALL = 3;
static boolean _runningSkl = false;
- private static NativeLayer _native;
+ private static NativeSupport nativeSupport;
private Dimension _windowSize = null;
private Point _windowLocation = null;
private boolean smallScreen = false;
@@ -267,8 +266,7 @@ public class SikuliIDE extends JFrame {
Settings.showJavaInfo();
Settings.printArgs();
-// we should open the IDE
- initNativeLayer();
+ initNativeSupport();
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
//UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
@@ -276,8 +274,8 @@ public class SikuliIDE extends JFrame {
log(-1, "Problem loading UIManager!\nError: %s", e.getMessage());
}
- if (Settings.isMac()) {
- _native.initApp();
+ if (nativeSupport != null) {
+ nativeSupport.initApp(Debug.getDebugLevel() > 2 ? true : false);
try {
Thread.sleep(1000);
} catch (InterruptedException ie) {
@@ -299,7 +297,9 @@ public class SikuliIDE extends JFrame {
prefs.setDefaults(prefs.getUserType());
}
- _native.initIDE(this);
+ if (nativeSupport != null) {
+ nativeSupport.initIDE(this);
+ }
IResourceLoader loader = FileManager.getNativeLoader("basic", args);
loader.check(Settings.SIKULI_LIB);
@@ -412,7 +412,17 @@ public class SikuliIDE extends JFrame {
super.setTitle(SikuliIDESettings.SikuliVersion + " - " + title);
}
- static private void initNativeLayer() {
+ static private void initNativeSupport() {
+// String jb = FileManager.getJarName();
+// ClassPool pool = ClassPool.getDefault();
+// try {
+// pool.appendClassPath(jb);
+// pool.find("resources.NativeSupportMac");
+// CtClass nsm = pool.get("resources.NativeSupportMac");
+// nativeSupport = (NativeSupport) nsm.toClass().newInstance();
+// } catch (Exception ex) {
+// log(-1, "JavAssist: problem:%s", ex.getMessage());
+// }
String os = "unknown";
if (Settings.isWindows()) {
os = "Windows";
@@ -421,14 +431,14 @@ public class SikuliIDE extends JFrame {
} else if (Settings.isLinux()) {
os = "Linux";
}
- String className = "org.sikuli.ide.NativeLayerFor" + os;
-
+ String className = "org.sikuli.ide.NativeSupport" + os;
try {
Class c = Class.forName(className);
Constructor constr = c.getConstructor();
- _native = (NativeLayer) constr.newInstance();
+ nativeSupport = (NativeSupport) constr.newInstance();
+ log(lvl, "Native support found for " + os);
} catch (Exception e) {
- log(-1, "Reflection problem: org.sikuli.ide.NativeLayerFor...!\nError: %s", e.getMessage());
+ log(-1, "No native support for %s\n%s", os, e.getMessage());
}
}
diff --git a/pom.xml b/pom.xml
index 7a6435c..2de718d 100755
--- a/pom.xml
+++ b/pom.xml
@@ -37,8 +37,8 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <exclude.nativelayer.mac>NativeLayerForMac.java</exclude.nativelayer.mac>
- <exclude.nativelayer.null>NativeLayerForNothing</exclude.nativelayer.null>
+ <exclude.nativelayer.mac>NativeSupportMac.java</exclude.nativelayer.mac>
+ <exclude.nativelayer.null>NativeSupportForNothing</exclude.nativelayer.null>
<sikuli.jartype>plain.xml</sikuli.jartype>
<sikuli.jarname>${project.version}</sikuli.jarname>
<sikuli.usedversion>1.1.0-Beta1</sikuli.usedversion>
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/sikuli.git
More information about the pkg-java-commits
mailing list