Commit 78a04c48 authored by Andrey Filippov's avatar Andrey Filippov

bug fixes, tool state support

parent b418558a
...@@ -238,6 +238,9 @@ public class LaunchCore { ...@@ -238,6 +238,9 @@ public class LaunchCore {
project, project,
resource, resource,
logBuildStamp); logBuildStamp);
if (VDTLaunchUtil.getRunner().getRunningBuilds().isAlreadyOpen(tool.getName())){
return;
}
DebugUITools.launch(launchConfig, ILaunchManager.RUN_MODE); DebugUITools.launch(launchConfig, ILaunchManager.RUN_MODE);
} catch (CoreException e) { } catch (CoreException e) {
IStatus status = e.getStatus(); IStatus status = e.getStatus();
......
...@@ -21,12 +21,19 @@ import java.util.Iterator; ...@@ -21,12 +21,19 @@ import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.IStreamListener; import org.eclipse.debug.core.IStreamListener;
import org.eclipse.debug.core.model.IStreamMonitor; import org.eclipse.debug.core.model.IStreamMonitor;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.ui.console.IConsole; import org.eclipse.ui.console.IConsole;
import org.eclipse.ui.console.ConsolePlugin; import org.eclipse.ui.console.ConsolePlugin;
import org.eclipse.ui.console.IConsoleManager; import org.eclipse.ui.console.IConsoleManager;
import com.elphel.vdt.core.tools.ToolsCore;
import com.elphel.vdt.core.tools.params.Tool;
import com.elphel.vdt.core.tools.params.Tool.TOOL_STATE;
import com.elphel.vdt.ui.MessageUI;
import com.elphel.vdt.veditor.VerilogPlugin; import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.veditor.preference.PreferenceStrings; import com.elphel.vdt.veditor.preference.PreferenceStrings;
...@@ -58,14 +65,13 @@ public class RunningBuilds { ...@@ -58,14 +65,13 @@ public class RunningBuilds {
} }
private Map<IConsole,MonListener> parserListeners=null; // consoles mapped to pairs of monitors and listeners private Map<IConsole,MonListener> parserListeners=null; // consoles mapped to pairs of monitors and listeners
// that should be disconnected when parser is terminated // that should be disconnected when parser is terminated
// int nextBuildStep=0;
private final Map<String, VDTRunnerConfiguration> unfinishedBuilds; private final Map<String, VDTRunnerConfiguration> unfinishedBuilds;
public RunningBuilds(){ public RunningBuilds(){
parserListeners= new ConcurrentHashMap<IConsole,MonListener>(); parserListeners= new ConcurrentHashMap<IConsole,MonListener>();
unfinishedBuilds = new ConcurrentHashMap<String, VDTRunnerConfiguration>(); unfinishedBuilds = new ConcurrentHashMap<String, VDTRunnerConfiguration>();
IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager(); IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager();
// This is not used, just for testing
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) { if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
System.out.println("***Addded console listeners"); System.out.println("***Addded console listeners");
} }
...@@ -75,7 +81,7 @@ public class RunningBuilds { ...@@ -75,7 +81,7 @@ public class RunningBuilds {
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) { if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
System.out.println("+++ Added: "+consoles[i].getName()); System.out.println("+++ Added: "+consoles[i].getName());
} }
// Only shows added consoles setConsole(consoles[i]);
} }
} }
public void consolesRemoved(IConsole[] consoles){ public void consolesRemoved(IConsole[] consoles){
...@@ -89,14 +95,18 @@ public class RunningBuilds { ...@@ -89,14 +95,18 @@ public class RunningBuilds {
} }
} }
}); });
} }
public void addMonListener(IConsole parserConsole, IStreamMonitor monitor, IStreamListener listener){ public void addMonListener(IConsole parserConsole, IStreamMonitor monitor, IStreamListener listener){
synchronized (parserListeners){
parserListeners.put(parserConsole, new MonListener(monitor, listener)); parserListeners.put(parserConsole, new MonListener(monitor, listener));
} }
}
private void removeMonListener(IConsole parserConsole){ private void removeMonListener(IConsole parserConsole){
MonListener monListener=parserListeners.remove(parserConsole); MonListener monListener;
synchronized (parserListeners){
monListener=parserListeners.remove(parserConsole);
}
if (monListener!=null){ if (monListener!=null){
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) { if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
System.out.println("--- Removing listener from the terminated parser console "+parserConsole.getName()); System.out.println("--- Removing listener from the terminated parser console "+parserConsole.getName());
...@@ -121,22 +131,26 @@ public class RunningBuilds { ...@@ -121,22 +131,26 @@ public class RunningBuilds {
System.out.print("Got console name:"+consoleName); System.out.print("Got console name:"+consoleName);
} }
VDTRunnerConfiguration runConfig=unfinishedBuilds.get(consoleName); VDTRunnerConfiguration runConfig=unfinishedBuilds.get(consoleName);
/*
if (runConfig.hasConsole(console)){ if (runConfig.hasConsole(console)){
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) { if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
System.out.println(consoleName+" -> GOT IT"); System.out.println(consoleName+" -> GOT IT");
} }
return consoleName; return consoleName;
} }
*/
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) { if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
System.out.println(consoleName+" -> no luck"); System.out.println(consoleName+" -> no luck");
} }
} }
return null; return null;
} }
public void removeConsole(IConsole console){
public void removeConsoleOld(IConsole console){
String consoleName=findConsoleParent(console); String consoleName=findConsoleParent(console);
if (consoleName!=null){ if (consoleName!=null){
VDTRunnerConfiguration runConfig=unfinishedBuilds.get(consoleName); VDTRunnerConfiguration runConfig=unfinishedBuilds.get(consoleName);
/*
runConfig.removeConsole(console); runConfig.removeConsole(console);
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) { if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
System.out.println("Removing console "+console.getName()+" from runConfig for "+consoleName); System.out.println("Removing console "+console.getName()+" from runConfig for "+consoleName);
...@@ -147,6 +161,7 @@ public class RunningBuilds { ...@@ -147,6 +161,7 @@ public class RunningBuilds {
} }
unfinishedBuilds.remove(consoleName); unfinishedBuilds.remove(consoleName);
} }
*/
} else { } else {
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) { if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
System.out.println("Console "+console.getName()+" did not belong here"); System.out.println("Console "+console.getName()+" did not belong here");
...@@ -158,8 +173,9 @@ public class RunningBuilds { ...@@ -158,8 +173,9 @@ public class RunningBuilds {
} }
public VDTRunnerConfiguration resumeConfiguration(String consoleName){ public VDTRunnerConfiguration resumeConfiguration(String consoleName){
System.out.println("VDTRunnerConfiguration#resumeConfiguration("+consoleName+")");
VDTRunnerConfiguration conf=unfinishedBuilds.get(consoleName); VDTRunnerConfiguration conf=unfinishedBuilds.get(consoleName);
unfinishedBuilds.remove(consoleName); // unfinishedBuilds.remove(consoleName); //
return conf; return conf;
} }
...@@ -169,11 +185,120 @@ public class RunningBuilds { ...@@ -169,11 +185,120 @@ public class RunningBuilds {
} }
public void removeConfiguration(String consoleName){ public void removeConfiguration(String consoleName){
System.out.println("VDTRunnerConfiguration#removeConfiguration("+consoleName+")");
unfinishedBuilds.remove(consoleName); unfinishedBuilds.remove(consoleName);
System.out.println("Running consoles:");
listConfigurations();
} }
public void saveUnfinished(String consoleName, VDTRunnerConfiguration configuration ){ public void saveUnfinished(String consoleName, VDTRunnerConfiguration configuration ){
System.out.println("VDTRunnerConfiguration#saveUnfinished("+consoleName+", configuration)");
unfinishedBuilds.put(consoleName, configuration); unfinishedBuilds.put(consoleName, configuration);
System.out.println("Running consoles:");
listConfigurations();
}
public void listConfigurations(){
Iterator<String> iter=unfinishedBuilds.keySet().iterator();
int i=0;
while (iter.hasNext()) {
String consoleName=iter.next();
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
System.out.print(i+": "+consoleName);
}
} }
}
public boolean findConsole(IConsole iConsole){
String needleConsoleName=iConsole.getName();
Iterator<String> iter=unfinishedBuilds.keySet().iterator();
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
System.out.println("findConsole("+needleConsoleName+")");
}
while (iter.hasNext()) {
String consoleName=iter.next();
if (needleConsoleName.equals(consoleName)){
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) System.out.print("Got match");
return true;
}
}
return false;
}
public boolean setConsole(IConsole iConsole){ // from add console;
String needleConsoleName=iConsole.getName();
Iterator<String> iter=unfinishedBuilds.keySet().iterator();
while (iter.hasNext()) {
String consoleName=iter.next();
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
System.out.print("needleConsoleName="+needleConsoleName+", consoleName= "+consoleName);
}
if (needleConsoleName.equals(consoleName)){
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) System.out.print("Got match");
VDTRunnerConfiguration runConfig=unfinishedBuilds.get(consoleName);
runConfig.setIConsole(iConsole);
// Add console listener here to detect change name
final IConsole fIconsole=iConsole;
final String fConsoleName=fIconsole.getName();
final IPropertyChangeListener fListener =new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
if (!fConsoleName.equals(fIconsole.getName())){
fIconsole.removePropertyChangeListener(this);
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
System.out.println(">>> "+fConsoleName+" -> "+fIconsole.getName());
}
removeConsole(fIconsole); // changed name means "<terminated>..."
}
}
};
fIconsole.addPropertyChangeListener(fListener);
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)){
System.out.println("fiCons.getName()="+fIconsole.getName()+"addPropertyChangeListener()");
}
return true;
}
}
return false;
}
// Only for closing consoles
public boolean removeConsole(IConsole iConsole){ // from add console;
Iterator<String> iter=unfinishedBuilds.keySet().iterator();
while (iter.hasNext()) {
String consoleName=iter.next();
VDTRunnerConfiguration runConfig=unfinishedBuilds.get(consoleName);
if (runConfig.getIConsole()==iConsole){ // same instance
runConfig.setIConsole(null);
Tool tool=ToolsCore.getTool(runConfig.getToolName());
if (tool.getState()==TOOL_STATE.KEPT_OPEN) {
tool.setState(TOOL_STATE.NEW);
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) System.out.print("Killed open console");
return true;
}
}
}
return false;
}
public boolean isAlreadyOpen(String toolName){ // from add console;
Iterator<String> iter=unfinishedBuilds.keySet().iterator();
while (iter.hasNext()) {
String consoleName=iter.next();
VDTRunnerConfiguration runConfig=unfinishedBuilds.get(consoleName);
if (toolName.equals(runConfig.getToolName())){
Tool tool=ToolsCore.getTool(runConfig.getToolName());
tool.setRunning(false);
tool.updateViewStateIcon();
if (tool.getState()==TOOL_STATE.KEPT_OPEN) {
MessageUI.error("Termninal that starts by this tool ("+toolName+") is already open in console \""+consoleName+"\"");
return true;
}
}
}
return false;
}
} // class RunningBuilds } // class RunningBuilds
...@@ -277,33 +277,35 @@ public class ToolLogFile { ...@@ -277,33 +277,35 @@ public class ToolLogFile {
} }
} catch (IOException e) { } catch (IOException e) {
System.out.println("Failed to append error log file "+ System.out.println("Failed to append error log file "+
(singleFile?targetOutIFile:targetErrIFile).toString()); (singleFile?targetOutIFile:targetErrIFile).toString()+" string was:"+string);
if (singleFile) closeOut(); if (singleFile) closeOut();
else closeErr(); else closeErr();
// close(); // close();
} }
} }
public void closeOut(){ public void closeOut(){ // should be called first
if (logOutWriter!=null) { if ((logOutWriter!=null) && ((logErrWriter==null) || (logErrWriter==logOutWriter))) {
try { try {
logOutWriter.close(); logOutWriter.close();
if(debugPrint) System.out.println("closeOut(), wrote "+outBytes+" bytes"); if(debugPrint) System.out.println("closeOut(), wrote "+outBytes+" bytes");
} catch (IOException e) { } catch (IOException e) {
System.out.println("Failed to close log file "+targetOutIFile.toString()); System.out.println("Failed to close log file "+targetOutIFile.toString());
} }
logOutWriter=null;
} }
} }
public void closeErr(){ public void closeErr(){
if (logErrWriter!=null) if (logErrWriter!=null) {
try { try {
logErrWriter.close(); logErrWriter.close();
if(debugPrint) System.out.println("closeErr(), wrote "+errBytes+" bytes"); if(debugPrint) System.out.println("closeErr(), wrote "+errBytes+" bytes");
} catch (IOException e) { } catch (IOException e) {
System.out.println("Failed to close error log file "+targetErrIFile.toString()); System.out.println("Failed to close error log file "+targetErrIFile.toString());
} }
logErrWriter=null;
}
} }
public FileReader getOutReader(){ public FileReader getOutReader(){
......
...@@ -92,7 +92,7 @@ public class VDTConsoleRunner{ ...@@ -92,7 +92,7 @@ public class VDTConsoleRunner{
String playBackStamp=runConfig.getPlayBackStamp(); String playBackStamp=runConfig.getPlayBackStamp();
if (playBackStamp!=null){ if (playBackStamp!=null){
System.out.println("Wrong, it should be playback, not run, as playBackStamp = "+playBackStamp+ "(not null)"); System.out.println("Wrong, it should be playback, not run, as playBackStamp = "+playBackStamp+ "(not null)");
return null; VDTLaunchUtil.getRunner().abortLaunch(runConfig.getOriginalConsoleName());
} }
...@@ -113,14 +113,7 @@ public class VDTConsoleRunner{ ...@@ -113,14 +113,7 @@ public class VDTConsoleRunner{
} }
if (iCons==null) { if (iCons==null) {
MessageUI.error("Specified console: "+consolePrefix+" is not found (was looking for \""+consoleStartsWith+"\""); MessageUI.error("Specified console: "+consolePrefix+" is not found (was looking for \""+consoleStartsWith+"\"");
Tool tool=ToolsCore.getTool(runConfig.getToolName()); VDTLaunchUtil.getRunner().abortLaunch(runConfig.getOriginalConsoleName());
tool.setDirty(false);
tool.setState(TOOL_STATE.FAILURE);
tool.setRunning(false);
tool.setFinishTimeStamp();
tool.updateViewStateIcon();
//removeConfiguration
VDTLaunchUtil.getRunner().getRunningBuilds().removeConfiguration(runConfig.getOriginalConsoleName());
return null; return null;
} }
// try to send // try to send
...@@ -189,8 +182,6 @@ public class VDTConsoleRunner{ ...@@ -189,8 +182,6 @@ public class VDTConsoleRunner{
final IStreamsProxy2 fSendOutputToStreamProxy= stdoutStreamProxy; final IStreamsProxy2 fSendOutputToStreamProxy= stdoutStreamProxy;
// connect input streams of the parsers to the out from the console process // connect input streams of the parsers to the out from the console process
IStreamMonitor consoleOutStreamMonitor=null;
IStreamMonitor consoleErrStreamMonitor=null;
runConfig.resetConsoleText(); runConfig.resetConsoleText();
String interrupt=buildParamsItem.getInterrupt(); // Not yet used String interrupt=buildParamsItem.getInterrupt(); // Not yet used
runConfig.setConsoleFinish(buildParamsItem.getPrompt()); runConfig.setConsoleFinish(buildParamsItem.getPrompt());
...@@ -220,7 +211,8 @@ public class VDTConsoleRunner{ ...@@ -220,7 +211,8 @@ public class VDTConsoleRunner{
//final ToolLogFile fToolLogFile=toolLogFile; //final ToolLogFile fToolLogFile=toolLogFile;
//errorListener=null; //errorListener=null;
// if (fSendErrorsToStreamProxy!=null){ // if (fSendErrorsToStreamProxy!=null){
consoleErrStreamMonitor=consoleInStreamProxy.getErrorStreamMonitor();
final IStreamMonitor consoleErrStreamMonitor=consoleInStreamProxy.getErrorStreamMonitor();
errorListener=new IStreamListener(){ errorListener=new IStreamListener(){
public void streamAppended(String text, IStreamMonitor monitor){ public void streamAppended(String text, IStreamMonitor monitor){
if (fSendErrorsToStreamProxy!=null) { if (fSendErrorsToStreamProxy!=null) {
...@@ -236,19 +228,19 @@ public class VDTConsoleRunner{ ...@@ -236,19 +228,19 @@ public class VDTConsoleRunner{
} }
if (runConfig.addConsoleText(text)){ if (runConfig.addConsoleText(text)){
if (debugPrint) System.out.println("Got finish sequence"); if (debugPrint) System.out.println("Got finish sequence");
// TODO: launch continuation of the build process consoleErrStreamMonitor.removeListener(errorListener);
finishConsolescript(); // got here when computer running Vivado was disconnected finishConsolescript(); // got here when computer running Vivado was disconnected
} }
} }
}; };
VDTLaunchUtil.getRunner().getRunningBuilds().addMonListener( // to remove listener when parser is terminated if (processErr!=null) VDTLaunchUtil.getRunner().getRunningBuilds().addMonListener( // to remove listener when parser is terminated
DebugUITools.getConsole(processErr), //IConsole parserConsole, DebugUITools.getConsole(processErr), //IConsole parserConsole,
consoleErrStreamMonitor, consoleErrStreamMonitor,
errorListener); errorListener);
consoleErrStreamMonitor.addListener(errorListener); consoleErrStreamMonitor.addListener(errorListener);
outputListener=null; outputListener=null;
// if (fSendOutputToStreamProxy!=null){ // if (fSendOutputToStreamProxy!=null){
consoleOutStreamMonitor=consoleInStreamProxy.getOutputStreamMonitor(); final IStreamMonitor consoleOutStreamMonitor=consoleInStreamProxy.getOutputStreamMonitor();
outputListener=new IStreamListener(){ outputListener=new IStreamListener(){
public void streamAppended(String text, IStreamMonitor monitor){ public void streamAppended(String text, IStreamMonitor monitor){
if (fSendOutputToStreamProxy!=null){ if (fSendOutputToStreamProxy!=null){
...@@ -264,11 +256,12 @@ public class VDTConsoleRunner{ ...@@ -264,11 +256,12 @@ public class VDTConsoleRunner{
if (runConfig.addConsoleText(text)){ if (runConfig.addConsoleText(text)){
if (debugPrint) System.out.println("Got finish sequence"); if (debugPrint) System.out.println("Got finish sequence");
// TODO: launch continuation of the build process // TODO: launch continuation of the build process
consoleOutStreamMonitor.removeListener(outputListener);
finishConsolescript(); finishConsolescript();
} }
} }
}; };
VDTLaunchUtil.getRunner().getRunningBuilds().addMonListener( // to remove listener when parser is terminated if (processOut!=null) VDTLaunchUtil.getRunner().getRunningBuilds().addMonListener( // to remove listener when parser is terminated
DebugUITools.getConsole(processOut), //IConsole parserConsole, DebugUITools.getConsole(processOut), //IConsole parserConsole,
consoleOutStreamMonitor, consoleOutStreamMonitor,
outputListener); outputListener);
...@@ -276,11 +269,12 @@ public class VDTConsoleRunner{ ...@@ -276,11 +269,12 @@ public class VDTConsoleRunner{
// } // }
//Problems occurred when invoking code from plug-in: "org.eclipse.ui.console". //Problems occurred when invoking code from plug-in: "org.eclipse.ui.console".
//Exception occurred during console property change notification. //Exception occurred during console property change notification.
outStream.setColor(new Color(null, 128, 128, 255)); outStream.setColor(new Color(null, 128, 128, 255)); // org.eclipse.swt.SWTException: Invalid thread access
try { try {
for (int i=0;i<arguments.length;i++){ for (int i=0;i<arguments.length;i++){
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.LOCAL_ECHO)) { if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.LOCAL_ECHO)) {
outStream.write(arguments[i]+"\n"); // writes to console itself outStream.write(arguments[i]+"\n"); // writes to console itself
System.out.println("--->"+arguments[i]+"\n");
} }
consoleInStreamProxy.write(arguments[i]+"\n"); consoleInStreamProxy.write(arguments[i]+"\n");
} }
...@@ -294,6 +288,7 @@ public class VDTConsoleRunner{ ...@@ -294,6 +288,7 @@ public class VDTConsoleRunner{
if (debugPrint) System.out.println("Setting timeout "+timeout); if (debugPrint) System.out.println("Setting timeout "+timeout);
final int fTimeout = timeout; final int fTimeout = timeout;
timer=new Timer(); timer=new Timer();
System.out.println("VDTConsoleRunner(): setting timer "+fTimeout*1000);
timer.schedule(new TimerTask() { timer.schedule(new TimerTask() {
@Override @Override
public void run() { public void run() {
...@@ -313,11 +308,10 @@ public class VDTConsoleRunner{ ...@@ -313,11 +308,10 @@ public class VDTConsoleRunner{
if (debugPrint) System.out.println("finishConsolescript()"); if (debugPrint) System.out.println("finishConsolescript()");
String playBackStamp=runConfig.getPlayBackStamp(); String playBackStamp=runConfig.getPlayBackStamp();
if (playBackStamp!=null){ if (playBackStamp!=null){
// happened when Vivaod console was disconnected with old console listener still attached // happened when Vivado console was disconnected with old console listener still attached
// they should be removed when a parser process is terminated // they should be removed when a parser process is terminated
System.out.println("Wrong, it should be playback, not run, as playBackStamp = "+playBackStamp+ "(not null)"); System.out.println("Wrong, it should be playback, not run, as playBackStamp = "+playBackStamp+ "(not null)");
VDTLaunchUtil.getRunner().abortLaunch(runConfig.getOriginalConsoleName());
return; return;
} }
if (timer!=null){ if (timer!=null){
...@@ -329,6 +323,7 @@ public class VDTConsoleRunner{ ...@@ -329,6 +323,7 @@ public class VDTConsoleRunner{
} }
if (consoleInStreamProxy==null) { if (consoleInStreamProxy==null) {
System.out.println("Bug: consoleInStreamProxy == null"); System.out.println("Bug: consoleInStreamProxy == null");
VDTLaunchUtil.getRunner().abortLaunch(runConfig.getOriginalConsoleName());
return; // or continue other commands? return; // or continue other commands?
} }
if (errorListener !=null) { // disconnect error stream listener if (errorListener !=null) { // disconnect error stream listener
...@@ -401,13 +396,7 @@ public class VDTConsoleRunner{ ...@@ -401,13 +396,7 @@ public class VDTConsoleRunner{
!runConfig.gotGood() && !runConfig.gotGood() &&
(buildParamsItem.getSuccessString()!=null) && (buildParamsItem.getSuccessString()!=null) &&
(buildParamsItem.getFailureString()==null))){ (buildParamsItem.getFailureString()==null))){
tool.setDirty(false); VDTLaunchUtil.getRunner().abortLaunch(runConfig.getOriginalConsoleName());
tool.setState(TOOL_STATE.FAILURE);
tool.setRunning(false);
tool.setFinishTimeStamp();
tool.updateViewStateIcon();
//removeConfiguration
VDTLaunchUtil.getRunner().getRunningBuilds().removeConfiguration(runConfig.getOriginalConsoleName());
return; return;
} }
if (runConfig.gotGood()){ if (runConfig.gotGood()){
......
...@@ -27,6 +27,7 @@ import org.eclipse.core.runtime.NullProgressMonitor; ...@@ -27,6 +27,7 @@ import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate; import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
import org.eclipse.swt.widgets.Display;
import com.elphel.vdt.Txt; import com.elphel.vdt.Txt;
import com.elphel.vdt.core.tools.contexts.BuildParamsItem; import com.elphel.vdt.core.tools.contexts.BuildParamsItem;
...@@ -111,14 +112,26 @@ public class VDTLaunchConfigurationDelegate implements ILaunchConfigurationDeleg ...@@ -111,14 +112,26 @@ public class VDTLaunchConfigurationDelegate implements ILaunchConfigurationDeleg
runConfig.setControlFiles((String[])controlFiles.toArray(new String[controlFiles.size()])); runConfig.setControlFiles((String[])controlFiles.toArray(new String[controlFiles.size()]));
// String consoleName=VDTRunner.renderProcessLabel(runConfig.getToolName()); // String consoleName=VDTRunner.renderProcessLabel(runConfig.getToolName());
String consoleName=runConfig.getOriginalConsoleName(); final String consoleName=runConfig.getOriginalConsoleName();
runner.getRunningBuilds().saveUnfinished(consoleName, runConfig ); runner.getRunningBuilds().saveUnfinished(consoleName, runConfig );
String playBackStamp=VDTLaunchUtil.getLogBuildStamp(configuration); // got null String playBackStamp=VDTLaunchUtil.getLogBuildStamp(configuration); // got null
runConfig.setPlayBackStamp(playBackStamp); // null runConfig.setPlayBackStamp(playBackStamp); // null
if (playBackStamp==null){ if (playBackStamp==null){
runner.resumeLaunch(consoleName); // actual run of the tools // Causes "Invalid thread access" when trying to write to console output if got there directly, not through console event
// runner.resumeLaunch(consoleName); // actual run of the tools
// try from Display thread
Display.getDefault().syncExec(new Runnable() {
public void run() {
try {
VDTLaunchUtil.getRunner().resumeLaunch(consoleName);
} catch (CoreException e) {
System.out.println("Failed to resumeLaunch");
} //, fiCons, this); // replace with console
}
});
} else { } else {
runConfig.setBuildStep(-1); // to cause errors if will try to continue runConfig.setBuildStep(-1); // to cause errors if will try to continue
runner.logPlaybackLaunch(consoleName); // tool logs playback with parsing runner.logPlaybackLaunch(consoleName); // tool logs playback with parsing
......
...@@ -95,7 +95,7 @@ public class VDTProgramRunner { ...@@ -95,7 +95,7 @@ public class VDTProgramRunner {
* @param monitor progress monitor or <code>null</code> * @param monitor progress monitor or <code>null</code>
* @exception CoreException if an exception occurs while launching * @exception CoreException if an exception occurs while launching
*/ */
public IProcess run( VDTRunnerConfiguration configuration public IProcess run( VDTRunnerConfiguration runConfig
, String consoleLabel , String consoleLabel
, ILaunch launch , ILaunch launch
, IProgressMonitor monitor , IProgressMonitor monitor
...@@ -105,20 +105,20 @@ public class VDTProgramRunner { ...@@ -105,20 +105,20 @@ public class VDTProgramRunner {
if (monitor == null) { if (monitor == null) {
monitor = new NullProgressMonitor(); monitor = new NullProgressMonitor();
} }
// int numItem=configuration.getBuildStep(); // int numItem=runConfig.getBuildStep();
VDTRunner runner = VDTLaunchUtil.getRunner(); VDTRunner runner = VDTLaunchUtil.getRunner();
BuildParamsItem buildParamsItem = configuration.getArgumentsItemsArray()[numItem]; // uses already calculated BuildParamsItem buildParamsItem = runConfig.getArgumentsItemsArray()[numItem]; // uses already calculated
String patternErrors= combinePatterns(buildParamsItem.getErrors(), configuration.getPatternErrors()) ; String patternErrors= combinePatterns(buildParamsItem.getErrors(), runConfig.getPatternErrors()) ;
String patternWarnings=combinePatterns(buildParamsItem.getWarnings(),configuration.getPatternWarnings()) ; String patternWarnings=combinePatterns(buildParamsItem.getWarnings(),runConfig.getPatternWarnings()) ;
String patternInfo= combinePatterns(buildParamsItem.getInfo(), configuration.getPatternInfo()) ; String patternInfo= combinePatterns(buildParamsItem.getInfo(), runConfig.getPatternInfo()) ;
IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1); IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1);
subMonitor.beginTask(Txt.s("Launch.Message.Launching"), 2); subMonitor.beginTask(Txt.s("Launch.Message.Launching"), 2);
subMonitor.subTask(Txt.s("Launch.Message.ConstructingCommandLine")); subMonitor.subTask(Txt.s("Launch.Message.ConstructingCommandLine"));
String toolTolaunch = configuration.getToolToLaunch(); String toolTolaunch = runConfig.getToolToLaunch();
String[] arguments = configuration.getToolArguments(); String[] arguments = runConfig.getToolArguments();
boolean isShell= configuration.getIsShell(); boolean isShell= runConfig.getIsShell();
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) { if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
System.out.println("patternErrors= \""+ patternErrors+"\""); System.out.println("patternErrors= \""+ patternErrors+"\"");
System.out.println("patternWarnings= \""+patternWarnings+"\""); System.out.println("patternWarnings= \""+patternWarnings+"\"");
...@@ -159,29 +159,32 @@ public class VDTProgramRunner { ...@@ -159,29 +159,32 @@ public class VDTProgramRunner {
System.out.println("cmdLine["+i+"] = \""+cmdLine[i]+"\""); System.out.println("cmdLine["+i+"] = \""+cmdLine[i]+"\"");
} }
} }
String[] controlFiles = configuration.getControlFiles(); String[] controlFiles = runConfig.getControlFiles();
runner.log(null,cmdLine, controlFiles, false, true); /* Appears in the console of the target Eclipse (immediately erased) */ runner.log(null,cmdLine, controlFiles, false, true); /* Appears in the console of the target Eclipse (immediately erased) */
runner.log(null,cmdLine, controlFiles, false, false); /* Appears in the console of the parent Eclipse */ runner.log(null,cmdLine, controlFiles, false, false); /* Appears in the console of the parent Eclipse */
String[] envp = configuration.getEnvironment(); String[] envp = runConfig.getEnvironment();
subMonitor.worked(1); subMonitor.worked(1);
// check for cancellation // check for cancellation
if (monitor.isCanceled()) { if (monitor.isCanceled()) {
VDTLaunchUtil.getRunner().abortLaunch(runConfig.getOriginalConsoleName());
return null; return null;
} }
subMonitor.subTask(Txt.s("Launch.Message.Starting")); subMonitor.subTask(Txt.s("Launch.Message.Starting"));
File workingDir = getWorkingDir(configuration); /* /data/vdt/runtime-EclipseApplication/x353 */ File workingDir = getWorkingDir(runConfig); /* /data/vdt/runtime-EclipseApplication/x353 */
Process p = exec(cmdLine, workingDir, envp); Process p = exec(cmdLine, workingDir, envp);
if (p == null) { if (p == null) {
VDTLaunchUtil.getRunner().abortLaunch(runConfig.getOriginalConsoleName());
return null; return null;
} }
// check for cancellation // check for cancellation
if (monitor.isCanceled()) { if (monitor.isCanceled()) {
p.destroy(); p.destroy();
VDTLaunchUtil.getRunner().abortLaunch(runConfig.getOriginalConsoleName());
return null; return null;
} }
...@@ -191,10 +194,10 @@ public class VDTProgramRunner { ...@@ -191,10 +194,10 @@ public class VDTProgramRunner {
/* IProcess may set/get client parameters */ /* IProcess may set/get client parameters */
IProcess process= newProcess( launch IProcess process= newProcess( launch
, p , p
, consoleLabel // renderProcessLabel(configuration.getToolName()) , consoleLabel // renderProcessLabel(runConfig.getToolName())
, getDefaultProcessAttrMap(configuration)); , getDefaultProcessAttrMap(runConfig));
parser.parserSetup( parser.parserSetup(
configuration, runConfig,
process, process,
patternErrors, patternErrors,
patternWarnings, patternWarnings,
......
...@@ -18,31 +18,16 @@ ...@@ -18,31 +18,16 @@
package com.elphel.vdt.core.launching; package com.elphel.vdt.core.launching;
import java.io.File;
import java.io.IOException;
import java.text.DateFormat; import java.text.DateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
import org.eclipse.debug.internal.ui.views.console.ProcessConsole;
//import org.eclipse.core.resources.IProject;
//import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.IStreamListener;
//import org.eclipse.debug.core.ILaunchConfiguration; //import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.model.IProcess; import org.eclipse.debug.core.model.IProcess;
//import org.eclipse.debug.ui.DebugUITools; //import org.eclipse.debug.ui.DebugUITools;
...@@ -69,6 +54,8 @@ import org.eclipse.ui.console.IOConsoleOutputStream; ...@@ -69,6 +54,8 @@ import org.eclipse.ui.console.IOConsoleOutputStream;
import com.elphel.vdt.Txt; import com.elphel.vdt.Txt;
import com.elphel.vdt.core.tools.ToolsCore; import com.elphel.vdt.core.tools.ToolsCore;
import com.elphel.vdt.core.tools.contexts.BuildParamsItem; import com.elphel.vdt.core.tools.contexts.BuildParamsItem;
import com.elphel.vdt.core.tools.params.Tool;
import com.elphel.vdt.core.tools.params.Tool.TOOL_STATE;
import com.elphel.vdt.ui.MessageUI; import com.elphel.vdt.ui.MessageUI;
//import com.elphel.vdt.VDTPlugin; //import com.elphel.vdt.VDTPlugin;
import com.elphel.vdt.veditor.VerilogPlugin; import com.elphel.vdt.veditor.VerilogPlugin;
...@@ -78,6 +65,10 @@ import com.elphel.vdt.veditor.preference.PreferenceStrings; ...@@ -78,6 +65,10 @@ import com.elphel.vdt.veditor.preference.PreferenceStrings;
//import com.elphel.vdt.core.Utils; //import com.elphel.vdt.core.Utils;
import org.eclipse.ui.console.IConsoleListener; import org.eclipse.ui.console.IConsoleListener;
...@@ -98,6 +89,18 @@ public class VDTRunner { ...@@ -98,6 +89,18 @@ public class VDTRunner {
return runningBuilds; return runningBuilds;
} }
public void abortLaunch(String consoleName){
final VDTRunnerConfiguration runConfig=runningBuilds.resumeConfiguration(consoleName);
Tool tool=ToolsCore.getTool(runConfig.getToolName());
tool.setDirty(false);
tool.setState(TOOL_STATE.FAILURE);
tool.setRunning(false);
tool.setFinishTimeStamp();
tool.updateViewStateIcon();
//removeConfiguration
runningBuilds.removeConfiguration(runConfig.getOriginalConsoleName());
}
public void resumeLaunch(String consoleName) throws CoreException { public void resumeLaunch(String consoleName) throws CoreException {
try { try {
doResumeLaunch(consoleName); doResumeLaunch(consoleName);
...@@ -115,12 +118,14 @@ public class VDTRunner { ...@@ -115,12 +118,14 @@ public class VDTRunner {
if (runConfig==null){ if (runConfig==null){
System.out.println("Turned out nothing to do. Probably a bug"); System.out.println("Turned out nothing to do. Probably a bug");
abortLaunch(consoleName);
return; return;
} }
String playBackStamp=runConfig.getPlayBackStamp(); String playBackStamp=runConfig.getPlayBackStamp();
if (playBackStamp!=null){ if (playBackStamp!=null){
System.out.println("doResumeLaunch(): wrong, it should be playback, not run, as playBackStamp = "+playBackStamp+ "(not null)"); System.out.println("doResumeLaunch(): wrong, it should be playback, not run, as playBackStamp = "+playBackStamp+ "(not null)");
abortLaunch(consoleName);
return; return;
} }
...@@ -152,8 +157,6 @@ public class VDTRunner { ...@@ -152,8 +157,6 @@ public class VDTRunner {
if (debugPrint) System.out.println("Skipping parser "+argumentsItemsArray[numItem].getNameAsParser()); if (debugPrint) System.out.println("Skipping parser "+argumentsItemsArray[numItem].getNameAsParser());
continue; continue;
} }
// Launch the configuration - 1 unit of work
// VDTRunner runner = VDTLaunchUtil.getRunner();
// IProcess process=run( // IProcess process=run(
IProcess process=runConfig.getProgramRunner().run( IProcess process=runConfig.getProgramRunner().run(
runConfig, runConfig,
...@@ -163,26 +166,12 @@ public class VDTRunner { ...@@ -163,26 +166,12 @@ public class VDTRunner {
numItem numItem
); );
//Andrey: if there is a single item - launch asynchronously, if more - verify queue is empty
// check for cancellation // check for cancellation
if (monitor.isCanceled() || (process==null)) { if (monitor.isCanceled() || (process==null)) {
runningBuilds.removeConfiguration(consoleName); abortLaunch(consoleName);
return; return;
} }
// if (numItem<(argumentsItemsArray.length-1)){ // Not for the last
// find out if there are any non-parsers left
/*
boolean moreToProcess=false;
for (int i=numItem+1;i<argumentsItemsArray.length;numItem++)
if (argumentsItemsArray[numItem].getNameAsParser()==null) {
moreToProcess=true;
break;
}
moreToProcess=true; // TODO: remove later - should always wait if keep is not set
if (moreToProcess){
*/
IOConsole iCons= (IOConsole) DebugUITools.getConsole(process); // had non-null fPatternMatcher , fType="org.eclipse.debug.ui.ProcessConsoleType" IOConsole iCons= (IOConsole) DebugUITools.getConsole(process); // had non-null fPatternMatcher , fType="org.eclipse.debug.ui.ProcessConsoleType"
if (iCons==null){ if (iCons==null){
System.out.println("Could not get console for the specified process"); System.out.println("Could not get console for the specified process");
...@@ -228,6 +217,7 @@ public class VDTRunner { ...@@ -228,6 +217,7 @@ public class VDTRunner {
int timeout=argumentsItemsArray[numItem].getTimeout(); int timeout=argumentsItemsArray[numItem].getTimeout();
//keepOpen() //keepOpen()
final boolean fKeepOpen=argumentsItemsArray[numItem].keepOpen(); final boolean fKeepOpen=argumentsItemsArray[numItem].keepOpen();
if (fKeepOpen) runConfig.setKeptOpen(true);
if (fKeepOpen && (timeout<1)) timeout=1; // some minimal timeout if (fKeepOpen && (timeout<1)) timeout=1; // some minimal timeout
if (timeout>0){ if (timeout>0){
if (debugPrint) System.out.println ("timeout="+timeout+"s, keep-open="+ fKeepOpen); if (debugPrint) System.out.println ("timeout="+timeout+"s, keep-open="+ fKeepOpen);
...@@ -237,14 +227,14 @@ public class VDTRunner { ...@@ -237,14 +227,14 @@ public class VDTRunner {
final int fTimeout = timeout; final int fTimeout = timeout;
final IProcess fProcess=process; final IProcess fProcess=process;
// new Timer().schedule(new TimerTask() { // new Timer().schedule(new TimerTask() {
System.out.println("VDTRunner(): setting old timer "+fTimeout*1000);
argumentsItemsArray[numItem].getTimer().schedule(new TimerTask() { argumentsItemsArray[numItem].getTimer().schedule(new TimerTask() {
@Override @Override
public void run() { public void run() {
if (debugPrint) System.out.println(">> Got timeout after "+fTimeout+"sec <<"); if (debugPrint) System.out.println(">> Got timeout after "+fTimeout+"sec <<");
if (fKeepOpen) { if (fKeepOpen) {
fiCons.removePropertyChangeListener(fListener); fiCons.removePropertyChangeListener(fListener);
if (debugPrint) System.out.println("Timeout-initialted firePropertyChange on "+fConsoleName); if (debugPrint) System.out.println("Timeout-initialted resumeLaunch on "+fConsoleName);
Display.getDefault().syncExec(new Runnable() { Display.getDefault().syncExec(new Runnable() {
public void run() { public void run() {
try { try {
...@@ -273,9 +263,15 @@ public class VDTRunner { ...@@ -273,9 +263,15 @@ public class VDTRunner {
} //for (;numItem<argumentsItemsArray.length;numItem++){ } //for (;numItem<argumentsItemsArray.length;numItem++){
if (debugPrint) System.out.println("All finished"); if (debugPrint) System.out.println("All finished");
monitor.done(); monitor.done();
ToolsCore.getTool(runConfig.getToolName()).setRunning(false); Tool tool=ToolsCore.getTool(runConfig.getToolName());
ToolsCore.getTool(runConfig.getToolName()).setFinishTimeStamp(); tool.setRunning(false);
ToolsCore.getTool(runConfig.getToolName()).updateViewStateIcon(); tool.setFinishTimeStamp();
if ((tool.getState()==TOOL_STATE.SUCCESS) && runConfig.isKeptOpen()) {
tool.setState(TOOL_STATE.KEPT_OPEN);
} else { // failure on not
runningBuilds.removeConfiguration(consoleName);
}
tool.updateViewStateIcon();
} }
public void logPlaybackLaunch(String consoleName) throws CoreException { public void logPlaybackLaunch(String consoleName) throws CoreException {
......
...@@ -21,6 +21,7 @@ import java.util.HashSet; ...@@ -21,6 +21,7 @@ import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException; import java.util.regex.PatternSyntaxException;
...@@ -107,14 +108,11 @@ public class VDTRunnerConfiguration { ...@@ -107,14 +108,11 @@ public class VDTRunnerConfiguration {
private int maxLength=extraChars; private int maxLength=extraChars;
private Pattern patternGood=null; private Pattern patternGood=null;
private Pattern patternBad=null; private Pattern patternBad=null;
private AtomicBoolean gotFinish;
private boolean keptOpen;
private String playBackStamp=null; // timestamp of the logs to play back ("" for latest), or private String playBackStamp=null; // timestamp of the logs to play back ("" for latest), or
// null for normal running tools // null for normal running tools
private Set<IConsole> consoles=null; // parser consoles opened for this console
private Map<IConsole,MonListener> parserListeners=null; // consoles mapped to pairs of monitors and listeners
// that should be disconnected when parser is terminated
private VDTConsoleRunner consoleRunner=null; private VDTConsoleRunner consoleRunner=null;
...@@ -122,6 +120,17 @@ public class VDTRunnerConfiguration { ...@@ -122,6 +120,17 @@ public class VDTRunnerConfiguration {
private VDTConsolePlayback consolePlayback=null; private VDTConsolePlayback consolePlayback=null;
private IConsole iConsole;
public IConsole getIConsole() {
return iConsole;
}
public void setIConsole(IConsole iConsole) {
this.iConsole = iConsole;
}
public BuildParamsItem[] getArgumentsItemsArray(){ public BuildParamsItem[] getArgumentsItemsArray(){
return argumentsItemsArray; return argumentsItemsArray;
} }
...@@ -156,29 +165,20 @@ public class VDTRunnerConfiguration { ...@@ -156,29 +165,20 @@ public class VDTRunnerConfiguration {
this.playBackStamp=null; this.playBackStamp=null;
this.consoleBuffer=""; this.consoleBuffer="";
this.consoles= new HashSet<IConsole>(); this.gotFinish=new AtomicBoolean(false);
this.parserListeners= new ConcurrentHashMap<IConsole,MonListener>();
this.consoleRunner= new VDTConsoleRunner(this); // arguments here? this.consoleRunner= new VDTConsoleRunner(this); // arguments here?
this.programRunner=new VDTProgramRunner(); // arguments here? this.programRunner=new VDTProgramRunner(); // arguments here?
this.consolePlayback=new VDTConsolePlayback(this); this.consolePlayback=new VDTConsolePlayback(this);
this.keptOpen=false;
this.iConsole=null;
} }
public void addMonListener(IConsole parserConsole, IStreamMonitor monitor, IStreamListener listener){ public void setKeptOpen(boolean keepOpen){
parserListeners.put(parserConsole, new MonListener(monitor, listener)); this.keptOpen=keepOpen;
}
public void removeMonListener(IConsole parserConsole){
MonListener monListener=parserListeners.remove(parserConsole);
if (monListener!=null){
try {
monListener.finalize();
} catch (Throwable e) {
System.out.println("Failed to finalize monListener for console "+parserConsole.getName());
e.printStackTrace();
}
} }
public boolean isKeptOpen(){
return this.keptOpen;
} }
public void setPlayBackStamp(String str){ public void setPlayBackStamp(String str){
playBackStamp=str; playBackStamp=str;
} }
...@@ -197,24 +197,20 @@ public class VDTRunnerConfiguration { ...@@ -197,24 +197,20 @@ public class VDTRunnerConfiguration {
public VDTProgramRunner getProgramRunner(){ public VDTProgramRunner getProgramRunner(){
return this.programRunner; return this.programRunner;
} }
/*
public void addConsole(IConsole console){ // not used public void addConsole(IConsole console){ // not used
consoles.add(console); consoles.add(console);
} }
public void removeConsole(IConsole console){ // from VDTRunnerConfiguration public void removeConsole(IConsole console){ // from VDTRunnerConfiguration
consoles.remove(console); consoles.remove(console);
} }
//TODO: add Map<IConsole,
public boolean noConsoles(){ public boolean noConsoles(){
return consoles.isEmpty(); return consoles.isEmpty();
} }
public boolean hasConsole(IConsole console){ public boolean hasConsole(IConsole console){
return consoles.contains(console); return consoles.contains(console);
} }
*/
public void setConsoleFinish(String consoleFinish){ public void setConsoleFinish(String consoleFinish){
this.consoleFinish=consoleFinish; this.consoleFinish=consoleFinish;
if ((this.consoleFinish!=null) && ((this.consoleFinish.length()+extraChars) > maxLength)){ if ((this.consoleFinish!=null) && ((this.consoleFinish.length()+extraChars) > maxLength)){
...@@ -298,19 +294,19 @@ public class VDTRunnerConfiguration { ...@@ -298,19 +294,19 @@ public class VDTRunnerConfiguration {
if (consoleBuffer.length()>(maxLength)){ if (consoleBuffer.length()>(maxLength)){
consoleBuffer=consoleBuffer.substring(consoleBuffer.length()-maxLength); consoleBuffer=consoleBuffer.substring(consoleBuffer.length()-maxLength);
} }
if ((patternBad!=null) && patternBad.matcher(consoleBuffer).matches()){ if ((patternBad!=null) && patternBad.matcher(consoleBuffer).find()){
hasBad=true; hasBad=true;
return true; return !gotFinish.getAndSet(true); // return true;
} else { } else {
if ((consoleBad!=null) && (consoleBuffer.indexOf(consoleBad)>=0)) { if ((consoleBad!=null) && (consoleBuffer.indexOf(consoleBad)>=0)) {
hasBad=true; hasBad=true;
// Should we return true immediately or still wait for consoleFinish? // Should we return true immediately or still wait for consoleFinish?
// Or only return true if (consoleFinish==null) ?? // Or only return true if (consoleFinish==null) ??
// resetConsoleText(); // resetConsoleText();
return true; // return as soon as got failure - anyway there will be no next tools running return !gotFinish.getAndSet(true); //return true; // return as soon as got failure - anyway there will be no next tools running
} }
} }
if ((patternGood!=null) && patternGood.matcher(consoleBuffer).matches()){ if ((patternGood!=null) && patternGood.matcher(consoleBuffer).find()){
hasGood=true; hasGood=true;
} else { } else {
if ((consoleGood!=null) && (consoleBuffer.indexOf(consoleGood)>=0)) { if ((consoleGood!=null) && (consoleBuffer.indexOf(consoleGood)>=0)) {
...@@ -323,7 +319,7 @@ public class VDTRunnerConfiguration { ...@@ -323,7 +319,7 @@ public class VDTRunnerConfiguration {
} }
if (consoleBuffer.indexOf(consoleFinish)>=0){ if (consoleBuffer.indexOf(consoleFinish)>=0){
// resetConsoleText(); // resetConsoleText();
return true; return !gotFinish.getAndSet(true); //return true;
} }
return false; return false;
} }
......
...@@ -160,6 +160,7 @@ public class BuildParamsItem implements Cloneable{ ...@@ -160,6 +160,7 @@ public class BuildParamsItem implements Cloneable{
public Timer getTimer(){ public Timer getTimer(){
if (timer==null){ if (timer==null){
timer=new Timer(); timer=new Timer();
System.out.println("BuildParamsitem(): : making new timer");
} }
return timer; return timer;
} }
...@@ -167,6 +168,7 @@ public class BuildParamsItem implements Cloneable{ ...@@ -167,6 +168,7 @@ public class BuildParamsItem implements Cloneable{
if (timer==null) return; if (timer==null) return;
timer.cancel(); timer.cancel();
timer=null; timer=null;
System.out.println("BuildParamsitem(): canceled and nulled timer");
} }
public void finalize() throws Throwable{ public void finalize() throws Throwable{
......
...@@ -129,7 +129,8 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -129,7 +129,8 @@ public class Tool extends Context implements Cloneable, Inheritable {
NEW, NEW,
UNKNOWN, UNKNOWN,
FAILURE, FAILURE,
SUCCESS //, SUCCESS,
KEPT_OPEN//,
// RUNNING // RUNNING
} }
......
...@@ -84,6 +84,8 @@ public class VDTPluginImages { ...@@ -84,6 +84,8 @@ public class VDTPluginImages {
public static final String ICON_TOOLSTATE_WTF = "obj16"+File.separator+"question.png"; public static final String ICON_TOOLSTATE_WTF = "obj16"+File.separator+"question.png";
public static final String ICON_TOOLSTATE_WTF_OLD = "obj16"+File.separator+"question_dim.png"; public static final String ICON_TOOLSTATE_WTF_OLD = "obj16"+File.separator+"question_dim.png";
public static final String ICON_TOOLSTATE_RUNNING = "obj16"+File.separator+"spinning.gif"; public static final String ICON_TOOLSTATE_RUNNING = "obj16"+File.separator+"spinning.gif";
// public static final String ICON_TOOLSTATE_KEPT_OPEN= "obj16"+File.separator+"heart.gif";
public static final String ICON_TOOLSTATE_KEPT_OPEN= "obj16"+File.separator+"beat.gif";
public static final String KEY_TOOLSTATE_NEW = "TOOLSTATE_NEW"; public static final String KEY_TOOLSTATE_NEW = "TOOLSTATE_NEW";
public static final String KEY_TOOLSTATE_BAD = "TOOLSTATE_BAD"; public static final String KEY_TOOLSTATE_BAD = "TOOLSTATE_BAD";
...@@ -93,6 +95,7 @@ public class VDTPluginImages { ...@@ -93,6 +95,7 @@ public class VDTPluginImages {
public static final String KEY_TOOLSTATE_WTF = "TOOLSTATE_WTF"; public static final String KEY_TOOLSTATE_WTF = "TOOLSTATE_WTF";
public static final String KEY_TOOLSTATE_WTF_OLD = "TOOLSTATE_WTF_OLD"; public static final String KEY_TOOLSTATE_WTF_OLD = "TOOLSTATE_WTF_OLD";
public static final String KEY_TOOLSTATE_RUNNING = "TOOLSTATE_RUNNING"; public static final String KEY_TOOLSTATE_RUNNING = "TOOLSTATE_RUNNING";
public static final String KEY_TOOLSTATE_KEPT_OPEN ="TOOLSTATE_KEPT_OPEN";
public static final String CHECKBOX_ON = "CHECKBOX_ON"; public static final String CHECKBOX_ON = "CHECKBOX_ON";
......
...@@ -331,6 +331,10 @@ public class DesignMenuModel { ...@@ -331,6 +331,10 @@ public class DesignMenuModel {
key= VDTPluginImages.KEY_TOOLSTATE_GOOD; key= VDTPluginImages.KEY_TOOLSTATE_GOOD;
} }
break; break;
case KEPT_OPEN:
iconName=VDTPluginImages.ICON_TOOLSTATE_KEPT_OPEN;
key= VDTPluginImages.KEY_TOOLSTATE_KEPT_OPEN;
break;
default: default:
if (dirty){ if (dirty){
iconName=VDTPluginImages.ICON_TOOLSTATE_WTF_OLD; iconName=VDTPluginImages.ICON_TOOLSTATE_WTF_OLD;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment