Revision: 19955
http://jedit.svn.sourceforge.net/jedit/?rev=19955&view=rev
Author: evanpw
Date: 2011-09-12 14:38:34 +0000 (Mon, 12 Sep 2011)
Log Message:
-----------
Merge request #3405235 - Fixed bug in loading files on startup under Mac OS X
Modified Paths:
--------------
jEdit/branches/4.4.x/doc/CHANGES.txt
jEdit/branches/4.4.x/jars/MacOSX/macosx/MacOSXPlugin.java
jEdit/branches/4.4.x/org/gjt/sp/jedit/jEdit.java
Property Changed:
----------------
jEdit/branches/4.4.x/
Property changes on: jEdit/branches/4.4.x
___________________________________________________________________
Modified: svn:mergeinfo
- /jEdit/branches/4.4.x-merge-request-for-r18847-r18954-r19206-r19210:19223
/jEdit/branches/4.4.x-merge-request-for-r19197:19216
/jEdit/branches/4.4.x-merge-request-for-r19201:19218,19229
/jEdit/branches/docking_framework:13128-13258
/jEdit/trunk:18847,18954,18960-18961,19052,19084,19118,19121,19124,19138,19172,19185,19197,19199-19206,19208-19214,19246,19263,19289,19297-19299,19318,19325,19327,19346,19349-19350,19353,19377,19422,19489,19491,19501,19530,19547,19560-19561,19568-19571,19578,19588-19589,19592,19645,19720,19724,19770,19833-19834,19846,19848-19849,19895,19900
+ /jEdit/branches/4.4.x-merge-request-for-r18847-r18954-r19206-r19210:19223
/jEdit/branches/4.4.x-merge-request-for-r19197:19216
/jEdit/branches/4.4.x-merge-request-for-r19201:19218,19229
/jEdit/branches/docking_framework:13128-13258
/jEdit/trunk:18847,18954,18960-18961,19052,19084,19118,19121,19124,19138,19172,19185,19197,19199-19206,19208-19214,19246,19263,19289,19297-19299,19318,19325,19327,19346,19349-19350,19353,19377,19422,19489,19491,19501,19530,19547,19560-19561,19568-19571,19578,19588-19589,19592,19645,19720,19724,19770,19833-19834,19846,19848-19849,19895,19900,19932-19933
Modified: jEdit/branches/4.4.x/doc/CHANGES.txt
===================================================================
--- jEdit/branches/4.4.x/doc/CHANGES.txt 2011-09-11 19:26:12 UTC (rev 19954)
+++ jEdit/branches/4.4.x/doc/CHANGES.txt 2011-09-12 14:38:34 UTC (rev 19955)
@@ -4,8 +4,8 @@
{{{ Version 4.4.2
-Thanks to Björn "Vampire" Kautler, Alan Ezust, and Matthieu Casanova for
-contributing to this release.
+Thanks to Björn "Vampire" Kautler, Alan Ezust, Matthieu Casanova, and
+Evan Wright for contributing to this release.
{{{ Bug Fixes
- Untitled buffer should not be created on VFS without write capability
@@ -34,6 +34,10 @@
- Error Widget now use the same color as Invalid token instead of being always
red (Matthieu Casanova)
+
+- Fix for tracker 3034220, jEdit fails to load text-file under Mac OS X
+ (#3034220 - Evan Wright)
+
}}}
{{{ Miscellaneous
Modified: jEdit/branches/4.4.x/jars/MacOSX/macosx/MacOSXPlugin.java
===================================================================
--- jEdit/branches/4.4.x/jars/MacOSX/macosx/MacOSXPlugin.java 2011-09-11 19:26:12 UTC (rev 19954)
+++ jEdit/branches/4.4.x/jars/MacOSX/macosx/MacOSXPlugin.java 2011-09-12 14:38:34 UTC (rev 19955)
@@ -33,6 +33,7 @@
import org.gjt.sp.jedit.msg.*;
import org.gjt.sp.util.Log;
import org.gjt.sp.util.StandardUtilities;
+import org.gjt.sp.util.ThreadUtilities;
//}}}
public class MacOSXPlugin extends EBPlugin
@@ -51,33 +52,45 @@
{
if(osok())
{
- try {
- // Generate and register the OSXAdapter, passing it a hash of all the methods we wish to
- // use as delegates for various com.apple.eawt.ApplicationListener methods
- OSXAdapter.setQuitHandler(this, getClass().getDeclaredMethod("handleQuit", (Class[])null));
- OSXAdapter.setAboutHandler(this, getClass().getDeclaredMethod("handleAbout", (Class[])null));
- OSXAdapter.setPreferencesHandler(this, getClass().getDeclaredMethod("handlePreferences", (Class[])null));
- OSXAdapter.setFileHandler(this, getClass().getDeclaredMethod("handleOpenFile", new Class[] { String.class }));
- OSXAdapter.setReOpenApplicationHandler(this, getClass().getDeclaredMethod("handleReOpenApplication", (Class[])null));
-
- String lf = jEdit.getProperty("lookAndFeel");
- if(lf != null && lf.length() != 0)
+ Runnable setup = new Runnable() {
+ public void run()
{
- // Fix key bindings for OS X for anything other than Aqua LNF
- // See: http://lists.apple.com/archives/java-dev/2008/Apr/msg00209.html
- if (!UIManager.getLookAndFeel().isNativeLookAndFeel())
+ try
{
- Log.log(Log.DEBUG, this, "Fixing keybindingds on current LNF");
- UIDefaults uid = UIManager.getLookAndFeelDefaults();
- fixMacKeyBindings(uid);
+ MacOSXPlugin listener = MacOSXPlugin.this;
+ Class theClass = listener.getClass();
+
+ // Generate and register the OSXAdapter, passing it a hash of all the methods we wish to
+ // use as delegates for various com.apple.eawt.ApplicationListener methods
+ OSXAdapter.setQuitHandler(listener, theClass.getDeclaredMethod("handleQuit", (Class[])null));
+ OSXAdapter.setAboutHandler(listener, theClass.getDeclaredMethod("handleAbout", (Class[])null));
+ OSXAdapter.setPreferencesHandler(listener, theClass.getDeclaredMethod("handlePreferences", (Class[])null));
+ OSXAdapter.setFileHandler(listener, theClass.getDeclaredMethod("handleOpenFile", new Class[] { String.class }));
+ OSXAdapter.setReOpenApplicationHandler(listener, theClass.getDeclaredMethod("handleReOpenApplication", (Class[])null));
+
+ String lf = jEdit.getProperty("lookAndFeel");
+ if(lf != null && lf.length() != 0)
+ {
+ // Fix key bindings for OS X for anything other than Aqua LNF
+ // See: http://lists.apple.com/archives/java-dev/2008/Apr/msg00209.html
+ if (!UIManager.getLookAndFeel().isNativeLookAndFeel())
+ {
+ Log.log(Log.DEBUG, this, "Fixing keybindingds on current LNF");
+ UIDefaults uid = UIManager.getLookAndFeelDefaults();
+ fixMacKeyBindings(uid);
+ }
+ }
+
}
+ catch (Exception e)
+ {
+ System.err.println("Error while loading the OSXAdapter:" + e);
+ e.printStackTrace();
+ }
}
- }
- catch (Exception e)
- {
- System.err.println("Error while loading the OSXAdapter:");
- e.printStackTrace();
- }
+ };
+
+ ThreadUtilities.runInDispatchThread(setup);
}
} //}}}
@@ -112,18 +125,28 @@
File file = new File(filepath);
if(file.exists())
{
- View view = jEdit.getActiveView();
- if(view == null)
- view = PerspectiveManager.loadPerspective(false);
-
if(file.isDirectory())
{
// TODO: What to do with dirs?
//VFSBrowser.browseDirectory(jEdit.getActiveView(), file.getPath());
return;
}
- if (jEdit.openFile(view, file.getPath()) == null)
- Log.log(Log.ERROR, this, "Unable to open file: " + filepath);
+
+ if (jEdit.isStartupDone())
+ {
+ View view = jEdit.getActiveView();
+ if (view == null)
+ {
+ view = PerspectiveManager.loadPerspective(false);
+ }
+
+ if (jEdit.openFile(view, file.getPath()) == null)
+ Log.log(Log.ERROR, this, "Unable to open file: " + filepath);
+ }
+ else
+ {
+ jEdit.openFileAfterStartup(file.getPath());
+ }
}
else
{
Modified: jEdit/branches/4.4.x/org/gjt/sp/jedit/jEdit.java
===================================================================
--- jEdit/branches/4.4.x/org/gjt/sp/jedit/jEdit.java 2011-09-11 19:26:12 UTC (rev 19954)
+++ jEdit/branches/4.4.x/org/gjt/sp/jedit/jEdit.java 2011-09-12 14:38:34 UTC (rev 19955)
@@ -1431,6 +1431,30 @@
//{{{ openFile() methods
/**
+ * Opens a file, either immediately if the application is finished starting up,
+ * or after the first view has been created if not.
+ * @param path The file path
+ *
+ * @return the buffer if succesfully loaded immediately, or null otherwise
+ *
+ * @since jEdit 4.4.2
+ */
+ public static Buffer openFileAfterStartup(String path)
+ {
+ if (isStartupDone())
+ {
+ return openFile(getActiveView(), path);
+ }
+ else
+ {
+ // These additional file names will be treated just as if they had
+ // been passed on the command line
+ additionalFiles.add(path);
+ return null;
+ }
+ }
+
+ /**
* Opens a file. Note that as of jEdit 2.5pre1, this may return
* null if the buffer could not be opened.
* @param view The view to open the file in
@@ -3098,6 +3122,7 @@
private static View activeView;
private static Vector<Boolean> startupDone = new Vector<Boolean>();
+ private static Vector<String> additionalFiles = new Vector<String>();
private static Thread mainThread;
//}}}
@@ -3868,7 +3893,21 @@
if(view == null)
view = newView(null,null);
- Buffer buffer = openFiles(null,userDir,args);
+ Buffer buffer;
+
+ // Treat the elements of additionalFiles just like command-line arguments
+ if (!additionalFiles.isEmpty())
+ {
+ String[] newArgs = new String[additionalFiles.size() + args.length];
+ additionalFiles.copyInto(newArgs);
+ System.arraycopy(args, 0, newArgs, additionalFiles.size(), args.length);
+ buffer = openFiles(null,userDir,newArgs);
+ }
+ else
+ {
+ buffer = openFiles(null,userDir,args);
+ }
+
if(buffer != null)
view.setBuffer(buffer,true);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|