[sikuli] 308/385: minor fixes for the multi scripting support
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 1fdcc0444f22554d2e3987838e23dffe0159bd73
Author: Raimund Hocke <rmhdevelop at me.com>
Date: Fri Feb 28 18:59:22 2014 +0100
minor fixes for the multi scripting support
---
.../main/java/org/sikuli/basics/SikuliScript.java | 8 ++++++-
.../src/main/java/org/sikuli/basics/SikuliX.java | 5 ++++-
.../java/org/sikuli/ide/EditorConsolePane.java | 5 +++--
IDE/src/main/java/org/sikuli/ide/EditorPane.java | 22 +++++++++++-------
.../java/org/sikuli/ide/SikuliIDEPopUpMenu.java | 26 +++++++++++++---------
5 files changed, 43 insertions(+), 23 deletions(-)
diff --git a/Basics/src/main/java/org/sikuli/basics/SikuliScript.java b/Basics/src/main/java/org/sikuli/basics/SikuliScript.java
index 96c0572..e03e0ae 100755
--- a/Basics/src/main/java/org/sikuli/basics/SikuliScript.java
+++ b/Basics/src/main/java/org/sikuli/basics/SikuliScript.java
@@ -24,6 +24,7 @@ public class SikuliScript {
private static Boolean runAsTest;
private static boolean isRunningInteractive = false;
+
public static void runningInteractive() {
isRunningInteractive = true;
SikuliX.displaySplash(null);
@@ -35,6 +36,9 @@ public class SikuliScript {
private static boolean isRunningScript = false;
+ static {
+ }
+
/**
* Main method
*
@@ -48,6 +52,8 @@ public class SikuliScript {
}
isRunningScript = true;
+
+ Settings.initScriptingSupport();
SikuliX.displaySplash(args);
@@ -137,7 +143,7 @@ public class SikuliScript {
if (runner == null) {
String givenRunnerName = cmdLine.getOptionValue(CommandArgsEnum.INTERACTIVE.longname());
if (givenRunnerName == null) {
- runner = SikuliX.getScriptRunner("jython", null, args);
+ runner = SikuliX.getScriptRunner(Settings.RDEFAULT, null, args);
} else {
runner = SikuliX.getScriptRunner(givenRunnerName, null, args);
if (runner == null) {
diff --git a/Basics/src/main/java/org/sikuli/basics/SikuliX.java b/Basics/src/main/java/org/sikuli/basics/SikuliX.java
index fde0bb0..8871c0f 100644
--- a/Basics/src/main/java/org/sikuli/basics/SikuliX.java
+++ b/Basics/src/main/java/org/sikuli/basics/SikuliX.java
@@ -228,6 +228,9 @@ public class SikuliX {
Iterator<IScriptRunner> scriptRunnerIterator = loader.iterator();
while (scriptRunnerIterator.hasNext()) {
IScriptRunner currentRunner = scriptRunnerIterator.next();
+ if (currentRunner.getName().startsWith("Not")) {
+ continue;
+ }
if ((name != null && currentRunner.getName().toLowerCase().equals(name.toLowerCase()))
|| (ending != null && currentRunner.hasFileEnding(ending) != null)) {
runner = currentRunner;
@@ -235,7 +238,7 @@ public class SikuliX {
break;
}
}
- if (runner == null) {
+ if (name != null && runner == null) {
if (name != null) {
Debug.error("Fatal error 121: Could not load script runner with name: %s", name);
SikuliX.terminate(121);
diff --git a/IDE/src/main/java/org/sikuli/ide/EditorConsolePane.java b/IDE/src/main/java/org/sikuli/ide/EditorConsolePane.java
index a6ea9cc..e0e4ad9 100755
--- a/IDE/src/main/java/org/sikuli/ide/EditorConsolePane.java
+++ b/IDE/src/main/java/org/sikuli/ide/EditorConsolePane.java
@@ -27,6 +27,7 @@ import javax.swing.text.*;
import javax.swing.text.html.*;
import org.sikuli.basics.Debug;
import org.sikuli.basics.IScriptRunner;
+import org.sikuli.basics.Settings;
import org.sikuli.basics.SikuliX;
public class EditorConsolePane extends JPanel implements Runnable {
@@ -61,7 +62,7 @@ public class EditorConsolePane extends JPanel implements Runnable {
if (ENABLE_IO_REDIRECT) {
int npipes = 2;
- NUM_PIPES = npipes * SikuliIDE.scriptRunner.size();
+ NUM_PIPES = npipes * Settings.scriptRunner.size();
pin = new PipedInputStream[NUM_PIPES];
reader = new Thread[NUM_PIPES];
for (int i = 0; i < NUM_PIPES; i++) {
@@ -69,7 +70,7 @@ public class EditorConsolePane extends JPanel implements Runnable {
}
int irunner = 0;
- for (IScriptRunner srunner : SikuliIDE.scriptRunner.values()) {
+ for (IScriptRunner srunner : Settings.scriptRunner.values()) {
if (srunner.doSomethingSpecial("redirect", pin)) {
Debug.log(2, "EditorConsolePane: stdout/stderr redirected to console"
+ " for " + srunner.getName());
diff --git a/IDE/src/main/java/org/sikuli/ide/EditorPane.java b/IDE/src/main/java/org/sikuli/ide/EditorPane.java
index bdd4687..51e01a5 100755
--- a/IDE/src/main/java/org/sikuli/ide/EditorPane.java
+++ b/IDE/src/main/java/org/sikuli/ide/EditorPane.java
@@ -153,6 +153,10 @@ public class EditorPane extends JTextPane implements KeyListener, CaretListener
}
SikuliIDE.getStatusbar().setCurrentContentType(getSikuliContentType());
Debug.log(3, "InitTab: (%s)", getSikuliContentType());
+ if (!Settings.hasTypeRunner(getSikuliContentType())) {
+ SikuliX.popup("No installed runner supports (" + getSikuliContentType() + ")\n"
+ + "Trying to run the script will crash IDE!", "... serious problem detected!");
+ }
}
public String getSikuliContentType() {
@@ -226,14 +230,16 @@ public class EditorPane extends JTextPane implements KeyListener, CaretListener
setSrcBundle(filename + "/");
File script = new File(filename);
_editingFile = FileManager.getScriptFile(script, null, null);
- editingType = _editingFile.getAbsolutePath().substring(_editingFile.getAbsolutePath().lastIndexOf(".") + 1);
- initBeforeLoad(editingType);
- try {
- this.read(new BufferedReader(new InputStreamReader(
- new FileInputStream(_editingFile), "UTF8")), null);
- } catch (Exception ex) {
- _editingFile = null;
- }
+ if (_editingFile != null) {
+ editingType = _editingFile.getAbsolutePath().substring(_editingFile.getAbsolutePath().lastIndexOf(".") + 1);
+ initBeforeLoad(editingType);
+ try {
+ this.read(new BufferedReader(new InputStreamReader(
+ new FileInputStream(_editingFile), "UTF8")), null);
+ } catch (Exception ex) {
+ _editingFile = null;
+ }
+ }
if (_editingFile != null) {
updateDocumentListeners();
setDirty(false);
diff --git a/IDE/src/main/java/org/sikuli/ide/SikuliIDEPopUpMenu.java b/IDE/src/main/java/org/sikuli/ide/SikuliIDEPopUpMenu.java
index 9d7c97c..4f9a58b 100644
--- a/IDE/src/main/java/org/sikuli/ide/SikuliIDEPopUpMenu.java
+++ b/IDE/src/main/java/org/sikuli/ide/SikuliIDEPopUpMenu.java
@@ -27,6 +27,8 @@ public class SikuliIDEPopUpMenu extends JPopupMenu {
private EditorPane refEditorPane = null;
public static final String POP_LINE = "POP_LINE";
private EditorLineNumberView refLineNumberView = null;
+
+ private static String[] selOptionsType = null;
private MouseEvent mouseTrigger;
@@ -192,7 +194,7 @@ public class SikuliIDEPopUpMenu extends JPopupMenu {
static final String RUN = "doRun";
static final String RUN_SLOW = "doRunSlow";
static final String RESET = "doReset";
-
+
public PopTabAction() {
super();
}
@@ -206,18 +208,20 @@ public class SikuliIDEPopUpMenu extends JPopupMenu {
Debug.log(3, "doSetType: selected");
String error = "";
EditorPane cp = SikuliIDE.getInstance().getCurrentCodePane();
- Set<String> types = Settings.TypeEndings.keySet();
- String[] selOptions = new String[types.size()];
- int i = 0;
- for (String e : types) {
- if (e.contains("plain")) {
- continue;
- }
- selOptions[i++] = e.replaceFirst(".*?\\/", "");
- }
+ if (selOptionsType == null) {
+ Set<String> types = Settings.TypeEndings.keySet();
+ selOptionsType = new String[types.size()];
+ int i = 0;
+ for (String e : types) {
+ if (e.contains("plain")) {
+ continue;
+ }
+ selOptionsType[i++] = e.replaceFirst(".*?\\/", "");
+ }
+ }
String currentType = cp.getSikuliContentType();
String targetType = SikuliX.popSelect("Select the Scripting Language ...",
- selOptions, currentType.replaceFirst(".*?\\/", ""));
+ selOptionsType, currentType.replaceFirst(".*?\\/", ""));
if (targetType == null) {
targetType = currentType;
} else {
--
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