From: <gda...@us...> - 2012-05-10 14:44:03
|
Revision: 2831 http://abbot.svn.sourceforge.net/abbot/?rev=2831&view=rev Author: gdavison Date: 2012-05-10 14:43:52 +0000 (Thu, 10 May 2012) Log Message: ----------- Minor tweak to simplify clipboard code and to fix intermittent failures in a test due to a EDT violation. Modified Paths: -------------- abbot/trunk/lib/costello.jar abbot/trunk/src/abbot/editor/ScriptEditor.java abbot/trunk/test/abbot/editor/ScriptEditorTest.java Modified: abbot/trunk/lib/costello.jar =================================================================== (Binary files differ) Modified: abbot/trunk/src/abbot/editor/ScriptEditor.java =================================================================== --- abbot/trunk/src/abbot/editor/ScriptEditor.java 2012-05-09 16:10:38 UTC (rev 2830) +++ abbot/trunk/src/abbot/editor/ScriptEditor.java 2012-05-10 14:43:52 UTC (rev 2831) @@ -1312,13 +1312,19 @@ setEnabled(ACTION_STEP_CUT, haveScript && haveSelection); setEnabled(ACTION_STEP_COPY, haveScript && haveSelection); - // Only allow string pastes + // Only allow string pastes, hope it works Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); - Transferable transferable = clipboard.getContents(null); + boolean stringOnClipboard; + try { + stringOnClipboard = clipboard.isDataFlavorAvailable(DataFlavor.stringFlavor); + } + catch (IllegalArgumentException iae) { + // if we cannot access the clipboard give up. + stringOnClipboard = false; + } setEnabled(ACTION_STEP_PASTE, haveScript && haveSelection && - (transferable!=null - && transferable.isDataFlavorSupported(DataFlavor.stringFlavor))); + (stringOnClipboard)); setEnabled(ACTION_STEP_DELETE, haveScript && haveSelection); Modified: abbot/trunk/test/abbot/editor/ScriptEditorTest.java =================================================================== --- abbot/trunk/test/abbot/editor/ScriptEditorTest.java 2012-05-09 16:10:38 UTC (rev 2830) +++ abbot/trunk/test/abbot/editor/ScriptEditorTest.java 2012-05-10 14:43:52 UTC (rev 2831) @@ -10,6 +10,8 @@ import abbot.script.Script; +import abbot.util.AWT; + import java.awt.EventQueue; import java.util.concurrent.TimeUnit; @@ -58,7 +60,7 @@ /** Open a new, empty script. */ public void testNewScript() throws Throwable { // Try a file that exists - File file = File.createTempFile(getName(), ".xml"); + final File file = File.createTempFile(getName(), ".xml"); file.deleteOnExit(); editor.newScript(file, false); // Default script should always get a launch + terminate @@ -69,10 +71,18 @@ script.hasTerminate()); // Try a file that doesn't exist - file = File.createTempFile(getName(), ".xml"); - file.delete(); - editor.newScript(file, false); - file.deleteOnExit(); + final File newFile = File.createTempFile(getName(), ".xml"); + newFile.deleteOnExit(); + newFile.delete(); + + // Test was failing due to this EDT violation + AWT.invokeAndWait(new Runnable() { + public void run() { + editor.newScript(newFile, false); + } + }); + + script = (Script)editor.getResolverContext(); assertTrue("Script should have a launch step", script.hasLaunch()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |