[sikuli] 222/385: added some more options for multi-script-language support, but also introduced some quirks (text rendering in the tab :-(

Gilles Filippini pini at moszumanska.debian.org
Sun Jun 29 19:26:16 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 209cded21627b78984d23cf74fc61b0f6d452518
Author: Raimund Hocke <info at its-me-raiman.de>
Date:   Tue Feb 18 19:08:20 2014 +0100

    added some more options for multi-script-language support, but also introduced some quirks (text rendering in the tab :-(
---
 IDE/src/main/java/org/sikuli/ide/EditorPane.java   |  7 +++--
 .../java/org/sikuli/ide/NativeLayerForMac.java     |  2 +-
 IDE/src/main/java/org/sikuli/ide/SikuliIDE.java    | 35 ++++++++++++----------
 .../java/org/sikuli/ide/SikuliIDEPopUpMenu.java    | 24 ++++++++-------
 .../java/org/sikuli/ide/SikuliIDEStatusBar.java    | 11 +++++--
 5 files changed, 49 insertions(+), 30 deletions(-)

diff --git a/IDE/src/main/java/org/sikuli/ide/EditorPane.java b/IDE/src/main/java/org/sikuli/ide/EditorPane.java
index 2786d74..e0de5ba 100755
--- a/IDE/src/main/java/org/sikuli/ide/EditorPane.java
+++ b/IDE/src/main/java/org/sikuli/ide/EditorPane.java
@@ -139,7 +139,8 @@ public class EditorPane extends JTextPane implements KeyListener, CaretListener
 		}
 
 		if (paneIsEmpty || reInit) {
-			this.setText(String.format(Settings.TypeCommentDefault, getSikuliContentType()));
+//			this.setText(String.format(Settings.TypeCommentDefault, getSikuliContentType()));
+			this.setText("");
 		}
 
 		Debug.log(3, "InitTab: %s :--: %s", getContentType(), getEditorKit());
@@ -330,7 +331,9 @@ public class EditorPane extends JTextPane implements KeyListener, CaretListener
 		if (PreferencesUser.getInstance().getAtSaveMakeHTML()) {
 			convertSrcToHtml(getSrcBundle());
 		} else {
-			(new File(_editingFile.getAbsolutePath().replaceFirst("py", "html"))).delete();
+			String snameDir = new File(_editingFile.getAbsolutePath()).getParentFile().getName();
+			String sname = snameDir.replace(".sikuli", "") + ".html";
+			(new File(snameDir, sname)).delete();
 		}
 //TODO bundle image clean in Java
 		if (Settings.CPYTHON.equals(getSikuliContentType()) && PreferencesUser.getInstance().getAtSaveCleanBundle()) {
diff --git a/IDE/src/main/java/org/sikuli/ide/NativeLayerForMac.java b/IDE/src/main/java/org/sikuli/ide/NativeLayerForMac.java
index 1db74bc..84aa5b9 100755
--- a/IDE/src/main/java/org/sikuli/ide/NativeLayerForMac.java
+++ b/IDE/src/main/java/org/sikuli/ide/NativeLayerForMac.java
@@ -54,7 +54,7 @@ public class NativeLayerForMac implements NativeLayer, AboutHandler, Preferences
 			t.start();
 		} else if (fname.endsWith(".sikuli")) {
 			SikuliIDE ide = SikuliIDE.getInstance(null);
-			ide.loadFile(fname);
+			ide.restoreScriptFromSession(fname);
 		}
 	}
 
diff --git a/IDE/src/main/java/org/sikuli/ide/SikuliIDE.java b/IDE/src/main/java/org/sikuli/ide/SikuliIDE.java
index c61300e..20eb1cc 100755
--- a/IDE/src/main/java/org/sikuli/ide/SikuliIDE.java
+++ b/IDE/src/main/java/org/sikuli/ide/SikuliIDE.java
@@ -485,7 +485,7 @@ public class SikuliIDE extends JFrame {
 			Debug.log(3, "restore session at %d: " + filenames[i], restoredScripts + 1);
 			File f = new File(filenames[i]);
 			if (f.exists()) {
-				if (loadFile(filenames[i])) {
+				if (restoreScriptFromSession(filenames[i])) {
 					restoredScripts += 1;
 				}
 			}
@@ -500,7 +500,7 @@ public class SikuliIDE extends JFrame {
 			}
 			File f = new File(loadScript[i]);
 			if (f.exists()) {
-				if (loadFile(loadScript[i])) {
+				if (restoreScriptFromSession(loadScript[i])) {
 					ao = isAlreadyOpen(getCurrentCodePane().getCurrentSrcDir());
 					if (ao < 0) {
 						restoredScripts += 1;
@@ -514,7 +514,20 @@ public class SikuliIDE extends JFrame {
 		}
 	}
 
+	public boolean restoreScriptFromSession(String file) {
+		(new FileAction()).doNew(null);
+		getCurrentCodePane().loadFile(file);
+		if (getCurrentCodePane().hasEditingFile()) {
+			setCurrentFileTabTitle(file);
+			return true;
+		}
+		Debug.error("Can't load file " + file);
+//    (new FileAction()).doCloseTab(null);
+		return false;
+	}
+
   //</editor-fold>
+
 	//<editor-fold defaultstate="collapsed" desc="Support SikuliIDE">
 	public JMenu getFileMenu() {
 		return _fileMenu;
@@ -574,18 +587,6 @@ public class SikuliIDE extends JFrame {
 		}
 	}
 
-	public boolean loadFile(String file) {
-		(new FileAction()).doNew(null);
-		getCurrentCodePane().loadFile(file);
-		if (getCurrentCodePane().hasEditingFile()) {
-			setCurrentFileTabTitle(file);
-			return true;
-		}
-		Debug.error("Can't load file " + file);
-//    (new FileAction()).doCloseTab(null);
-		return false;
-	}
-
 	public ArrayList<String> getOpenedFilenames() {
 		int nTab = _mainPane.getTabCount();
 		File file = null;
@@ -2169,7 +2170,11 @@ public class SikuliIDE extends JFrame {
 				}
 				updateUndoRedoStates();
 				if (codePane != null) {
-					Debug.log(3, "SelectTab: %s :--: %s", codePane.getContentType(), codePane.getEditorKit());
+					String msg = String.format("SelectTab: (%s)", codePane.getSikuliContentType());
+					Debug.log(3, msg);
+					SikuliIDE.getStatusbar().setMessage(msg);
+					SikuliIDE.getStatusbar().setCurrentContentType(
+						SikuliIDE.this.getCurrentCodePane().getSikuliContentType());
 				}
 			}
 		});
diff --git a/IDE/src/main/java/org/sikuli/ide/SikuliIDEPopUpMenu.java b/IDE/src/main/java/org/sikuli/ide/SikuliIDEPopUpMenu.java
index b22d874..9b294b5 100644
--- a/IDE/src/main/java/org/sikuli/ide/SikuliIDEPopUpMenu.java
+++ b/IDE/src/main/java/org/sikuli/ide/SikuliIDEPopUpMenu.java
@@ -224,9 +224,13 @@ public class SikuliIDEPopUpMenu extends JPopupMenu {
 			}
 			if (error.isEmpty()) {
 				cp.reInit(targetEnding);
-				cp.setText(String.format(Settings.TypeCommentDefault, cp.getSikuliContentType()));
+//				cp.setText(String.format(Settings.TypeCommentDefault, cp.getSikuliContentType()));
+				cp.setText("");
 			}
-			Debug.log(3, "doSetType: completed " + error);
+			String msg = "doSetType: completed " + error + " (" + targetType + ")";
+			SikuliIDE.getStatusbar().setMessage(msg);
+			SikuliIDE.getStatusbar().setCurrentContentType(targetType);
+			Debug.log(3, msg);
 		}
 
     public void doMoveTab(ActionEvent ae) throws NoSuchMethodException {
@@ -234,16 +238,16 @@ public class SikuliIDEPopUpMenu extends JPopupMenu {
       if (getMenuText(0).contains("Insert")) {
         log(lvl, "doMoveTab: insert");
         doLoad(refTab.getSelectedIndex()+1);
-        setMenuText(0, "Move Tab");
-        setMenuText(3, "Open left");
+        setMenuText(2, "Move Tab");
+        setMenuText(5, "Open left");
         return;
       }
       refTab.resetLastClosed();
       boolean success = refTab.fireCloseTab(mouseTrigger, refTab.getSelectedIndex());
       log(lvl, "doMoveTab: success = %s", success);
       if (success && refTab.getLastClosed() != null) {
-        setMenuText(0, "Insert Tab");
-        setMenuText(3, "Insert Left");
+        setMenuText(2, "Insert Tab");
+        setMenuText(5, "Insert Left");
       }
     }
 
@@ -251,7 +255,7 @@ public class SikuliIDEPopUpMenu extends JPopupMenu {
       log(lvl, "doDuplicate: entered");
       fireIDEFileMenu("SAVE");
       fireIDEFileMenu("SAVE_AS");
-      setMenuText(3, "Insert left");
+      setMenuText(5, "Insert left");
       doOpenLeft(null);
     }
 
@@ -269,11 +273,11 @@ public class SikuliIDEPopUpMenu extends JPopupMenu {
 
     public void doOpenLeft(ActionEvent ae) throws NoSuchMethodException {
       log(lvl, "doOpenLeft: entered");
-      if (getMenuText(3).contains("Insert")) {
+      if (getMenuText(5).contains("Insert")) {
         log(lvl, "doMoveTab: insert left");
         doLoad(refTab.getSelectedIndex());
-        setMenuText(0, "Move Tab");
-        setMenuText(3, "Open left");
+        setMenuText(2, "Move Tab");
+        setMenuText(5, "Open left");
         return;
       }
       refTab.resetLastClosed();
diff --git a/IDE/src/main/java/org/sikuli/ide/SikuliIDEStatusBar.java b/IDE/src/main/java/org/sikuli/ide/SikuliIDEStatusBar.java
index 6d9aa8d..dd0e590 100755
--- a/IDE/src/main/java/org/sikuli/ide/SikuliIDEStatusBar.java
+++ b/IDE/src/main/java/org/sikuli/ide/SikuliIDEStatusBar.java
@@ -17,6 +17,7 @@ class SikuliIDEStatusBar extends JPanel {
 
   private JLabel _lblMsg;
   private JLabel _lblCaretPos;
+	private String currentContentType = "???";
 
   public SikuliIDEStatusBar() {
     setLayout(new BorderLayout());
@@ -27,6 +28,7 @@ class SikuliIDEStatusBar extends JPanel {
     _lblMsg = new JLabel();
     _lblMsg.setPreferredSize(new Dimension(400, 20));
     _lblMsg.setUI(new EmphasizedLabelUI());
+		_lblMsg.setFont(new Font("Monaco", Font.TRUETYPE_FONT, 11));
     _lblCaretPos = new JLabel();
     _lblCaretPos.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 15));
     _lblCaretPos.setUI(new EmphasizedLabelUI());
@@ -38,13 +40,18 @@ class SikuliIDEStatusBar extends JPanel {
 //      add(rightPanel, BorderLayout.EAST);
   }
 
+	public void setCurrentContentType(String currentContentType) {
+		this.currentContentType = currentContentType;
+		repaint();
+	}
+
   public void setCaretPosition(int row, int col) {
-    _lblCaretPos.setText(
-            SikuliIDEI18N._I("statusLineColumn", row, col));
+    _lblCaretPos.setText(String.format("(%s) | R: %d | C: %d", currentContentType, row, col));
   }
 
   public void setMessage(String text) {
     _lblMsg.setText("   " + text);
+		repaint();
   }
 
   public void resetMessage() {

-- 
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