[prev in list] [next in list] [prev in thread] [next in thread] 

List:       jedit-cvs
Subject:    [ jEdit-commits ] [ HaXeSideKick plugin ] HaXeSideKick jEdit plugin
From:       "Dion Amago" <dionjwa () users ! sourceforge ! net>
Date:       2010-10-29 19:27:24
Message-ID: E1PBubl-0003yg-ST () sfp-scmshell-1 ! v30 ! ch3 ! sourceforge ! com
[Download RAW message or body]

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "HaXeSideKick jEdit plugin".

The branch, master has been updated
       via  a2a4d82360ebd4c6ebf15c5df800ea3cb1ab2e8d (commit)
      from  ce58498f7e3ea6a6020951c6a2aa03c0e8bdb3d6 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit a2a4d82360ebd4c6ebf15c5df800ea3cb1ab2e8d
Author: dionjwa <dionjw@gmail.com>
Date:   Fri Oct 29 14:27:11 2010 -0500

    haxe -cmd blah doesn't work when called from java. Keep to the old way of \
launching, but now project specific

diff --git a/HaXeSideKick.props b/HaXeSideKick.props
index 724b63d..042d5aa 100644
--- a/HaXeSideKick.props
+++ b/HaXeSideKick.props
@@ -70,14 +70,15 @@ options.haxe.label=HaXe
 options.haxe.code=new sidekick.haxe.HaXeOptionPane();
 
 # Option Pane values and labels
-options.haxe.launchCommand=/usr/bin/open deploy/out.swf
-options.haxe.launchCommand.label=Launch output command
-#Keep null to use the system default
-options.haxe.installDir=System Default
-options.haxe.installDir.label=Haxe executable path (leave empty for default)
-options.haxe.stdDir.label=Std lib path
-options.haxe.haxelibDir.label=Haxelib path
-# options.haxe.compilerLocation.label=Compiler location:
+# options.haxe.launchCommand=/usr/bin/open deploy/out.swf
+# options.haxe.launchCommand.label=Launch output command
+# #Keep null to use the system default
+# options.haxe.installDir=System Default
+# options.haxe.installDir.label=Haxe executable path (leave empty for default)
+options.haxe.stdDir.label=HaXe std lib path. Only change if installed in a \
non-default location, otherwise leave empty.  +options.haxe.stdDir=
+# options.haxe.haxelibDir.label=Haxelib path
+# # options.haxe.compilerLocation.label=Compiler location:
 options.haxe.defaultInstallDirMac=/usr/lib/haxe
 options.haxe.defaultInstallDirLinux=/usr/lib/haxe
 options.haxe.defaultInstallDirWindows=C:\\Program Files\\Motion-Twin\\haxe
@@ -86,6 +87,7 @@ options.haxe.defaultInstallDirWindows7=C:\\Program Files \
(x86)\\Motion-Twin\\hax  #ProjectViewer optionpanel
 options.haxe-project-options.label=HaXe Paths
 options.haxe.projectHXMLFile.label=Project hxml file (for project building/code \
completion) +options.haxe.projectLaunchCommand.label=Launch command (haxe -cmd "XXX" \
build.hxml)  options.haxe.projectStdDir.label=Project specific haXe std library \
location (advanced use only)  options.haxe.projectHaxeExecutable.label=Project \
specific haxe compiler (advanced use only)  
diff --git a/src/sidekick/haxe/HaXeOptionPane.java \
b/src/sidekick/haxe/HaXeOptionPane.java index 2072c79..5239d29 100644
--- a/src/sidekick/haxe/HaXeOptionPane.java
+++ b/src/sidekick/haxe/HaXeOptionPane.java
@@ -1,18 +1,17 @@
 package sidekick.haxe;
 
+import java.awt.GridBagConstraints;
 import java.io.File;
 
+import javax.swing.JLabel;
 import javax.swing.JTextField;
 import org.gjt.sp.jedit.AbstractOptionPane;
 import org.gjt.sp.jedit.jEdit;
 
 public class HaXeOptionPane extends AbstractOptionPane
 {
-//    private JCheckBox buildOnSave;
-    private JTextField launchCommand;
-    private JTextField installDir;
+    public static final String HAXE_LIBRARY_PATH = "options.haxe.stdDir";
 
-    private JTextField haxelibDir;
     private JTextField stdDir;
 
     public HaXeOptionPane ()
@@ -23,27 +22,11 @@ public class HaXeOptionPane extends AbstractOptionPane
     @Override
     public void _init ()
     {
-//        buildOnSave = new \
                JCheckBox(jEdit.getProperty("options.haxe.buildOnSave.label"),
-//            jEdit.getBooleanProperty("options.haxe.buildOnSave", true));
-//        addComponent(buildOnSave);
-
-        launchCommand = new \
                JTextField(jEdit.getProperty("options.haxe.launchCommand"));
-        addComponent(jEdit.getProperty("options.haxe.launchCommand.label"), \
                launchCommand);
-
-        String installDirTxt = jEdit.getProperty("options.haxe.installDir");
-        installDirTxt = installDirTxt == null || installDirTxt.trim().equals("") ? \
                HaXeSideKickPlugin.getSystemDefaultHaxeInstallPath() : installDirTxt;
-        installDir = new JTextField(installDirTxt);
-        addComponent(jEdit.getProperty("options.haxe.installDir.label"), \
                installDir);
-
-        String haxelibDirTxt = jEdit.getProperty("options.haxe.haxelibDir");
-        haxelibDirTxt = haxelibDirTxt == null || haxelibDirTxt.trim().equals("") ? \
HaXeSideKickPlugin.getSystemDefaultHaxeInstallPath() + File.separator + "haxelib" : \
                haxelibDirTxt;
-        haxelibDir = new JTextField(haxelibDirTxt);
-        addComponent(jEdit.getProperty("options.haxe.haxelibDir.label"), \
                haxelibDir);
-
-        String stdDirTxt = jEdit.getProperty("options.haxe.stdDir");
+        String stdDirTxt = jEdit.getProperty(HAXE_LIBRARY_PATH);
         stdDirTxt = stdDirTxt == null || stdDirTxt.trim().equals("") ? \
HaXeSideKickPlugin.getSystemDefaultHaxeInstallPath() + File.separator + "std" : \
stdDirTxt;  stdDir = new JTextField(stdDirTxt);
-        addComponent(jEdit.getProperty("options.haxe.stdDir.label"), stdDir);
+        addComponent(new JLabel(jEdit.getProperty(HAXE_LIBRARY_PATH + ".label")));
+        addComponent(stdDir, GridBagConstraints.HORIZONTAL);
 
         revalidate();
     }
@@ -54,13 +37,6 @@ public class HaXeOptionPane extends AbstractOptionPane
     @Override
     public void _save ()
     {
-        jEdit.setProperty("options.haxe.launchCommand", launchCommand.getText());
-        jEdit.setProperty("options.haxe.installDir", installDir.getText() == null || \
installDir.getText().trim().equals("") ? \
                HaXeSideKickPlugin.getSystemDefaultHaxeInstallPath() : \
                installDir.getText());
-
-        jEdit.setProperty("options.haxe.stdDir", stdDir.getText() == null || \
stdDir.getText().trim().equals("") ? \
HaXeSideKickPlugin.getSystemDefaultHaxeInstallPath() + File.separator + "std" : \
                stdDir.getText());
-        jEdit.setProperty("options.haxe.haxelibDir", haxelibDir.getText() == null || \
haxelibDir.getText().trim().equals("") ? \
HaXeSideKickPlugin.getSystemDefaultHaxeInstallPath() + File.separator + "haxelib" : \
                haxelibDir.getText());
-
-//        jEdit.setBooleanProperty("options.haxe.buildOnSave", \
buildOnSave.isSelected()); +        jEdit.setProperty(HAXE_LIBRARY_PATH, \
stdDir.getText() == null || stdDir.getText().trim().equals("") ? \
HaXeSideKickPlugin.getSystemDefaultHaxeInstallPath() + File.separator + "std" : \
stdDir.getText());  }
-
 }
diff --git a/src/sidekick/haxe/HaXeSideKickPlugin.java \
b/src/sidekick/haxe/HaXeSideKickPlugin.java index cdbbc5f..6f57be2 100644
--- a/src/sidekick/haxe/HaXeSideKickPlugin.java
+++ b/src/sidekick/haxe/HaXeSideKickPlugin.java
@@ -48,11 +48,7 @@ public class HaXeSideKickPlugin extends EditPlugin
 
     public static HaxeCompilerOutput buildProject ()
     {
-        return buildProject(jEdit.getActiveView().getEditPane());
-    }
-
-    public static HaxeCompilerOutput buildProject (EditPane editPane)
-    {
+        EditPane editPane = jEdit.getActiveView().getEditPane();
     	if (editPane == null) {
             JOptionPane.showMessageDialog(null, "EditPane is null", "Error", \
JOptionPane.ERROR_MESSAGE);  return null;
@@ -70,7 +66,8 @@ public class HaXeSideKickPlugin extends EditPlugin
 
         HaxeCompilerOutput output = getHaxeBuildOutput(editPane, 0, false, true);
         if (output != null) {
-            handleBuildErrors(output.output.errors, _errorSource, \
output.getProjectRoot(), getBuildFile(editPane.getBuffer())); +            \
handleBuildErrors(output.output.errors, _errorSource, output.getProjectRoot(), \
getBuildFile()); +            trace(output);
         }
         return output;
     }
@@ -160,8 +157,8 @@ public class HaXeSideKickPlugin extends EditPlugin
         return null;
     }
 
-    // Get the first *.hxml file we find
-    public static File getBuildFile (Buffer buffer)
+    // Get the project defined hxml file.
+    public static File getBuildFile ()
     {
         VPTProject prj = getCurrentProject();
         if (prj == null) {
@@ -173,7 +170,7 @@ public class HaXeSideKickPlugin extends EditPlugin
             return buildFile;
         }
 
-        JOptionPane.showMessageDialog(null, "No .hxml file found in the project root \
folder, nor any parent folder.", "Error", JOptionPane.ERROR_MESSAGE); +        \
JOptionPane.showMessageDialog(null, "No .hxml file found in the project root folder", \
"Error", JOptionPane.ERROR_MESSAGE);  return null;
     }
 
@@ -212,14 +209,14 @@ public class HaXeSideKickPlugin extends EditPlugin
     	    return null;
     	}
 
-        File hxmlFile = getBuildFile(editPane.getBuffer());
+        File hxmlFile = getBuildFile();
 
 
         if (hxmlFile == null) {
             Log.log(
                 Log.ERROR,
                 NAME,
-                "Attempting to build haxe project, but no *.hxml at the project \
root, or in a parent directory of the current buffer."); +                "Attempting \
to build haxe project, but no *.hxml at the project root.");  if (showErrorPopups) {
                 GUIUtilities.error(jEdit.getActiveView(), "haxe.error.noBuildFile", \
null);  }
@@ -324,15 +321,22 @@ public class HaXeSideKickPlugin extends EditPlugin
     {
         HaxeCompilerOutput output = buildProject();
         if (output != null && !isErrors()) {
-            String launchCommand = jEdit.getProperty("options.haxe.launchCommand");
-            executeShellCommand(launchCommand, \
                output.buildFile.getParentFile().getAbsolutePath());
-        } else {
-            String msg = "Cannot launch project due to errors or failed build";
-            Log.log(Log.MESSAGE, NAME, msg);
-            jEdit.getFirstView().getStatus().setMessage(msg);
+            String launchCommand = \
getLaunchCommand();//jEdit.getProperty("options.haxe.launchCommand"); +            if \
(launchCommand != null) { +                executeShellCommand(launchCommand, \
output.buildFile.getParentFile().getAbsolutePath()); +            }
         }
     }
 
+    protected static String getLaunchCommand ()
+    {
+        VPTProject prj = getCurrentProject();
+        if (prj == null) {
+            return null;
+        }
+        return prj.getProperty(ProjectOptionPane.PROJECT_LAUNCH_CMD);
+    }
+
     public static void trace (Object... arguments)
     {
         StringBuffer sb = new StringBuffer();
@@ -373,7 +377,7 @@ public class HaXeSideKickPlugin extends EditPlugin
             importTokens = new HashSet<String>();
             importTokens.add(importString);
         } else {
-            importTokens = getImportableClasses(lines);
+            importTokens = getImportableTokens(lines);
         }
 
 
@@ -383,7 +387,7 @@ public class HaXeSideKickPlugin extends EditPlugin
         importTokens.remove("Public");
 
         Set<String> existingImports = getCurrentImports(lines);
-        Map<String, Set<String>> classPackages = getImportableClasses(buffer);
+        Map<String, Set<String>> classPackages = getAllImportableClasses();
 
         if (classPackages == null || classPackages.size() == 0) {
         	return;
@@ -557,7 +561,7 @@ public class HaXeSideKickPlugin extends EditPlugin
         return result;
     }
 
-    protected static Set<String> getImportableClasses (final String[] lines)
+    protected static Set<String> getImportableTokens (final String[] lines)
     {
         Set<String> importTokens = new HashSet<String>();
 
@@ -611,9 +615,9 @@ public class HaXeSideKickPlugin extends EditPlugin
         return importTokens;
     }
 
-    protected static Map<String, Set<String>> getAllClassPackages (Buffer buffer)
+    protected static Map<String, Set<String>> getAllClassPackages ()
     {
-        File hxmlFile = HaXeSideKickPlugin.getBuildFile(buffer);
+        File hxmlFile = HaXeSideKickPlugin.getBuildFile();
         if (hxmlFile == null) {
             Log.log(Log.ERROR, "HaXe", "No .hxml file found to get class paths");
             JOptionPane.showMessageDialog(null, "No .hxml file found to get class \
paths", "Warning", JOptionPane.ERROR_MESSAGE); @@ -653,7 +657,7 @@ public class \
HaXeSideKickPlugin extends EditPlugin  {
         Map<String, Set<String>> classPackages = new HashMap<String, Set<String>>();
         Set<String> classPaths = new HashSet<String>();
-        Set<String> stdLibs = new HashSet<String>();
+        Set<String> haxelibs = new HashSet<String>();
 
         if (!hxmlFile.exists()) {
             Log.log(Log.ERROR, "HaXe", "*.hxml file doesn't exist: " + hxmlFile);
@@ -676,7 +680,7 @@ public class HaXeSideKickPlugin extends EditPlugin
 
                 m = libPattern.matcher(str);
                 if (m.matches()) {
-                    stdLibs.add(m.group(1));
+                    haxelibs.add(m.group(1));
                 }
             }
             in.close();
@@ -685,9 +689,10 @@ public class HaXeSideKickPlugin extends EditPlugin
             Log.log(Log.ERROR, "HaXe", e.toString());
         }
 
+        //Create a regex pattern for searching the haxelibs
         StringBuilder libsString = new StringBuilder();
         libsString.append(".*(");
-        Iterator<String> libsIter = stdLibs.iterator();
+        Iterator<String> libsIter = haxelibs.iterator();
         if (libsIter.hasNext()) {
             libsString.append(libsIter.next());
         }
@@ -697,17 +702,7 @@ public class HaXeSideKickPlugin extends EditPlugin
         libsString.append(").*");
         Pattern libsPattern = Pattern.compile(libsString.toString());
 
-        //jEdit.getProperty("options.haxe.installDir");
-        //Add the system classpaths
-        String installDirString = jEdit.getProperty(OPTION_PREFIX + "installDir");
-
-        if (installDirString == null || installDirString.trim().equals("") || \
                installDirString.indexOf("System Default") >= 0) {
-        	installDirString = HaXeSideKickPlugin.getSystemDefaultHaxeInstallPath();
-        }
-
-
-        File haxelib = new File(jEdit.getProperty("options.haxe.haxelibDir"));//new \
File(jEdit.getProperty("options.haxe.stdDir"));//installDir.getAbsolutePath() + \
                File.separator + "lib");
-
+        File haxelib = new File(getHaxelibPath());
         if (!haxelib.exists()) {
             JOptionPane.showMessageDialog(null, "haxelib folder " + haxelib + " \
doesn't exist.  Check the \"Installation Directory\" option in Plugins->Plugin \
Options->Haxe", "Error", JOptionPane.ERROR_MESSAGE);  }
@@ -727,7 +722,11 @@ public class HaXeSideKickPlugin extends EditPlugin
             Log.log(Log.ERROR, "HaXe", "HaXe stdlib directory doesn't exist: " + \
haxelib);  }
 
-        classPaths.add(jEdit.getProperty("options.haxe.stdDir"));
+        if (getStdLibPath() != null) {
+            classPaths.add(getStdLibPath());
+        } else {
+            Log.log(Log.ERROR, null, "Could not find haxe std lib path");
+        }
 
         // Go through the classpaths and add the *.hx files
         try {
@@ -810,21 +809,19 @@ public class HaXeSideKickPlugin extends EditPlugin
         }
     }
 
-    protected static Map<String, Set<String>> getImportableClasses (Buffer buffer)
+    protected static Map<String, Set<String>> getAllImportableClasses ()
     {
-        if (jEdit.getPlugin("projectviewer.ProjectPlugin", false) != null) {
-            String projectRoot = getCurrentProject() == null ? null : \
                getCurrentProject().getRootPath();//getProjectRoot();
-            if (currentProjectRootForImporting != projectRoot) {
-                currentProjectRootForImporting = projectRoot;
-                importableClassesCache = getAllClassPackages(buffer);
-            }
+        String projectRoot = getCurrentProject() == null ? null : \
getCurrentProject().getRootPath();//getProjectRoot(); +        if \
(currentProjectRootForImporting != projectRoot) { +            \
currentProjectRootForImporting = projectRoot; +            importableClassesCache = \
getAllClassPackages();  }
 
         if (importableClassesCache != null) {
             return importableClassesCache;
         }
 
-        return getAllClassPackages(buffer);
+        return getAllClassPackages();
     }
 
     protected static void checkAndUpdateProjectHaxeBuildFile (VPTProject prj)
@@ -845,6 +842,35 @@ public class HaXeSideKickPlugin extends EditPlugin
         }
     }
 
+    protected static String getHaxelibPath ()
+    {
+        String[] envp = {"HOME=" + System.getProperty("user.home")};
+        SystemProcessOutput output = JavaSystemCaller.systemCall("haxelib config", \
System.getProperty("user.home"), null, envp); +        String path = \
output.output.trim(); +        if (path.charAt(path.length() - 1) == '/') {
+            path = path.substring(0, path.length() - 1);
+        }
+        return path;
+    }
+
+    protected static String getStdLibPath ()
+    {
+        VPTProject prj = getCurrentProject();
+        if (prj != null) {
+            String libraryPathProp = \
prj.getProperty(ProjectOptionPane.PROJECT_STD_DIR); +            if (libraryPathProp \
!= null && libraryPathProp.trim().length() > 0) { +                trace("returning \
project std dir"); +                return libraryPathProp.trim();
+            }
+        }
+        String path = System.getenv("HAXE_LIBRARY_PATH");
+        if (path != null && path.trim().length() > 0) {
+            return path;
+        }
+
+        return getSystemDefaultHaxeInstallPath() + File.separator + "std";
+    }
+
 
     protected static Pattern patternVar = Pattern.compile(".*[ \t]var[ \t].*:[ \
                \t]*([A-Za-z0-9_]+).*");
     protected static Pattern patternExtends = Pattern.compile("^.*class[ \
\t]+([A-Za-z0-9_]+)[ \t]extends[ \t]([A-Za-z0-9_]+).*"); @@ -862,4 +888,3 @@ public \
class HaXeSideKickPlugin extends EditPlugin  private static String \
currentProjectRootForImporting;  
 }
-
diff --git a/src/sidekick/haxe/JavaSystemCaller.java \
b/src/sidekick/haxe/JavaSystemCaller.java index d48097f..29c0ed1 100644
--- a/src/sidekick/haxe/JavaSystemCaller.java
+++ b/src/sidekick/haxe/JavaSystemCaller.java
@@ -134,7 +134,7 @@ public final class JavaSystemCaller
                 }
                 final Process proc = rt.exec(processCommand, envp, workingDir);
                 Log.log(Log.NOTICE, "JavaSystemCaller", "processCommand=" + \
                processCommand +
-                    "\nworkingDir=" + workingDir + "\nenvp=" + \
Arrays.toString(envp)); +                    ", workingDir=" + workingDir + ", envp=" \
+ Arrays.toString(envp));  // any error message?
                 final StreamGobbler errorGobbler = new
                     StreamGobbler(proc.getErrorStream(), "ERROR");
diff --git a/src/sidekick/haxe/ProjectOptionPane.java \
b/src/sidekick/haxe/ProjectOptionPane.java index 1cb9bca..bc37dca 100644
--- a/src/sidekick/haxe/ProjectOptionPane.java
+++ b/src/sidekick/haxe/ProjectOptionPane.java
@@ -17,12 +17,14 @@ public class ProjectOptionPane extends AbstractOptionPane
     public static final String PROJECT_HXML_FILE = "projectHXMLFile";
     public static final String PROJECT_STD_DIR = "projectStdDir";
     public static final String PROJECT_HAXE_EXECUTABLE = "projectHaxeExecutable";
+    public static final String PROJECT_LAUNCH_CMD = "projectLaunchCommand";
 
     VPTProject project;
 
     private JTextField hxmlFile;
     private JTextField haxeStdDir;
     private JTextField haxeExecutable;
+    private JTextField launchCommand;
 
     public ProjectOptionPane(VPTProject project)
     {
@@ -39,6 +41,10 @@ public class ProjectOptionPane extends AbstractOptionPane
         addComponent(jEdit.getProperty(OPTION_PREFIX + PROJECT_HXML_FILE + \
".label"), hxmlFile);  
         addSeparator();
+        launchCommand = new JTextField(project.getProperty(PROJECT_LAUNCH_CMD));
+        addComponent(jEdit.getProperty(OPTION_PREFIX + PROJECT_LAUNCH_CMD + \
".label"), launchCommand); +
+        addSeparator();
         haxeStdDir = new JTextField(project.getProperty(PROJECT_STD_DIR));
         addComponent(jEdit.getProperty(OPTION_PREFIX + PROJECT_STD_DIR + ".label"), \
haxeStdDir);  
@@ -53,6 +59,9 @@ public class ProjectOptionPane extends AbstractOptionPane
         if (hxmlFile.getText().trim().length() > 0) {
             project.setProperty(PROJECT_HXML_FILE, hxmlFile.getText().trim());
         }
+        if (launchCommand.getText().trim().length() > 0) {
+            project.setProperty(PROJECT_LAUNCH_CMD, launchCommand.getText().trim());
+        }
         if (haxeStdDir.getText().trim().length() > 0) {
             project.setProperty(PROJECT_STD_DIR, haxeStdDir.getText().trim());
         }

-----------------------------------------------------------------------

Summary of changes:
 HaXeSideKick.props                        |   18 +++--
 src/sidekick/haxe/HaXeOptionPane.java     |   38 ++--------
 src/sidekick/haxe/HaXeSideKickPlugin.java |  117 +++++++++++++++++-----------
 src/sidekick/haxe/JavaSystemCaller.java   |    2 +-
 src/sidekick/haxe/ProjectOptionPane.java  |    9 ++
 5 files changed, 98 insertions(+), 86 deletions(-)


hooks/post-receive
-- 
HaXeSideKick jEdit plugin

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
jEdit-CVS mailing list
jEdit-CVS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jedit-cvs


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic