From: <kp...@us...> - 2010-04-27 14:07:19
|
Revision: 17696 http://jedit.svn.sourceforge.net/jedit/?rev=17696&view=rev Author: kpouer Date: 2010-04-27 14:07:12 +0000 (Tue, 27 Apr 2010) Log Message: ----------- Force showing messages and dialog on EventQueue thread to fix exceptions when using Substance look & feel Modified Paths: -------------- plugins/FTP/trunk/FTP.props plugins/FTP/trunk/ftp/SFtpConnection.java Modified: plugins/FTP/trunk/FTP.props =================================================================== --- plugins/FTP/trunk/FTP.props 2010-04-27 03:25:47 UTC (rev 17695) +++ plugins/FTP/trunk/FTP.props 2010-04-27 14:07:12 UTC (rev 17696) @@ -3,7 +3,7 @@ plugin.ftp.FtpPlugin.name=FTP plugin.ftp.FtpPlugin.author=Slava Pestov, Nicholas O'Leary, Vadim Voituk -plugin.ftp.FtpPlugin.version=0.9.7 +plugin.ftp.FtpPlugin.version=0.9.8 plugin.ftp.FtpPlugin.dev.revision=$Rev$ plugin.ftp.FtpPlugin.docs=index.html plugin.ftp.FtpPlugin.depend.0=jedit 04.03.04.00 Modified: plugins/FTP/trunk/ftp/SFtpConnection.java =================================================================== --- plugins/FTP/trunk/ftp/SFtpConnection.java 2010-04-27 03:25:47 UTC (rev 17695) +++ plugins/FTP/trunk/ftp/SFtpConnection.java 2010-04-27 14:07:12 UTC (rev 17696) @@ -26,9 +26,12 @@ import ftp.FtpVFS.FtpDirectoryEntry; +import java.awt.*; import java.io.*; +import java.lang.reflect.InvocationTargetException; import java.util.*; import javax.swing.JOptionPane; + import org.gjt.sp.jedit.jEdit; import org.gjt.sp.jedit.MiscUtilities; import org.gjt.sp.util.Log; @@ -302,19 +305,70 @@ keyAttempts++; return true; } - public boolean promptYesNo(String message) + public boolean promptYesNo(final String message) { - Object[] options={ "yes", "no" }; - int foo=JOptionPane.showOptionDialog(null, - message, - "Warning", - JOptionPane.DEFAULT_OPTION, - JOptionPane.WARNING_MESSAGE, - null, options, options[0]); - return foo==0; + final int ret[] = new int[1]; + try + { + Runnable runnable = new Runnable() + { + public void run() + { + Object[] options = {"yes", "no"}; + ret[0] = JOptionPane.showOptionDialog(jEdit.getActiveView(), + message, + "Warning", + JOptionPane.DEFAULT_OPTION, + JOptionPane.WARNING_MESSAGE, + null, options, options[0]); + } + }; + if (EventQueue.isDispatchThread()) + { + runnable.run(); + } + else + { + EventQueue.invokeAndWait(runnable); + } + } + catch (InterruptedException e) + { + Log.log(Log.ERROR, this, e); + } + catch (InvocationTargetException e) + { + Log.log(Log.ERROR, this, e); + } + return ret[0]==0; } - public void showMessage(String message) + public void showMessage(final String message) { - JOptionPane.showMessageDialog(null, message); + try + { + Runnable runnable = new Runnable() + { + public void run() + { + JOptionPane.showMessageDialog(jEdit.getActiveView(), message); + } + }; + if (EventQueue.isDispatchThread()) + { + runnable.run(); + } + else + { + EventQueue.invokeAndWait(runnable); + } + } + catch (InterruptedException e) + { + Log.log(Log.ERROR, this, e); + } + catch (InvocationTargetException e) + { + Log.log(Log.ERROR, this, e); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |