private void startWhenFrameActive() { myLog.setText(null); addInfo("Waiting for IDE frame activation", -1, MESSAGE_COLOR, 0); myRunner = new PlaybackRunner(myCodeEditor.getText(), this, false, true, false); VirtualFile file = pathToFile(); if (file != null) { VirtualFile scriptDir = file.getParent(); if (scriptDir != null) { myRunner.setScriptDir(new File(scriptDir.getPresentableUrl())); } } new Thread("playback debugger") { @Override public void run() { new WaitFor(60000) { @Override protected boolean condition() { return KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow() instanceof IdeFrame || myRunner == null; } }; if (myRunner == null) { message(null, "Script stopped", -1, Type.message, true); return; } message(null, "Starting script...", -1, Type.message, true); TimeoutUtil.sleep(1000); if (myRunner == null) { message(null, "Script stopped", -1, Type.message, true); return; } final PlaybackRunner runner = myRunner; myRunner.run().doWhenProcessed(new Runnable() { @Override public void run() { if (runner == myRunner) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { myRunner = null; } }); } } }); } }.start(); }
private void startWhenFrameActive() { myLog.setText(null); addInfo("Waiting for IDE frame activation", -1, MESSAGE_COLOR, 0); myRunner = new PlaybackRunner(myCodeEditor.getText(), this, false, true, false); VirtualFile file = pathToFile(); if (file != null) { VirtualFile scriptDir = file.getParent(); if (scriptDir != null) { myRunner.setScriptDir(new File(scriptDir.getPresentableUrl())); } } new Thread() { @Override public void run() { new WaitFor() { @Override protected boolean condition() { return KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow() instanceof IdeFrame || myRunner == null; } }; if (myRunner == null) { message(null, "Script stopped", -1, Type.message, true); return; } message(null, "Starting script...", -1, Type.message, true); try { sleep(1000); } catch (InterruptedException e) {} if (myRunner == null) { message(null, "Script stopped", -1, Type.message, true); return; } final PlaybackRunner runner = myRunner; myRunner.run().doWhenProcessed(new Runnable() { @Override public void run() { if (runner == myRunner) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { myRunner = null; } }); } } }); } }.start(); }
private void startWhenFrameActive() { myLog.setText(null); addInfo("Waiting for IDE frame activation", -1, MESSAGE_COLOR, 0); myRunner = new PlaybackRunner(myCodeEditor.getText(), this, false, true, false); VirtualFile file = pathToFile(); if (file != null) { VirtualFile scriptDir = file.getParent(); if (scriptDir != null) { myRunner.setScriptDir(new File(scriptDir.getPresentableUrl())); } } new Thread() { @Override public void run() { new WaitFor() { @Override protected boolean condition() { return KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow() instanceof IdeFrame || myRunner == null; } }; if (myRunner == null) { message(null, "Script stopped", -1, Type.message, true); return; } message(null, "Starting script...", -1, Type.message, true); try { sleep(1000); } catch (InterruptedException e) { } if (myRunner == null) { message(null, "Script stopped", -1, Type.message, true); return; } final PlaybackRunner runner = myRunner; myRunner.run().doWhenProcessed(new Runnable() { @Override public void run() { if (runner == myRunner) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { myRunner = null; } }); } } }); } }.start(); }