Commit e24caf8d authored by Andrey Filippov's avatar Andrey Filippov

ADding access to the current tool from the generators, debugging

parent c3b3f877
......@@ -153,6 +153,8 @@ public class VDTLaunchConfigurationDelegate implements ILaunchConfigurationDeleg
, IProgressMonitor monitor
) throws CoreException
{
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_THREAD_CONFICT))
System.out.println("-=-=-=- launch: "+VDTLaunchUtil.getToolName(configuration)+" threadID="+Thread.currentThread().getId());
try {
doLaunch(configuration, mode, launch, monitor);
} catch(Exception e) {
......
......@@ -436,8 +436,10 @@ public abstract class Context {
protected List<String> buildCommandString(String paramStringTemplate, FormatProcessor topProcessor)
throws ToolException
{
if (topProcessor==null) topProcessor=new FormatProcessor(this); // or use "context"
else topProcessor.setCurrentTool(this); // or use "context"
FormatProcessor processor = new FormatProcessor(new Recognizer[] {
new SimpleGeneratorRecognizer(),
new SimpleGeneratorRecognizer(topProcessor),
new RepeaterRecognizer()
// new ContextParamRecognizer(this),
// new ContextParamRepeaterRecognizer(this)
......@@ -451,12 +453,16 @@ public abstract class Context {
throws ToolException
{
if (stringTemplate==null) return null;
if (topProcessor==null) topProcessor=new FormatProcessor(this); // or use "context"
else topProcessor.setCurrentTool(this); // or use "context"
Parameter parName=findParam(stringTemplate);
if (parName!=null){
return parName.getValue(topProcessor).get(0).trim(); // get parameter
}
FormatProcessor processor = new FormatProcessor(new Recognizer[] {
new SimpleGeneratorRecognizer(),
new SimpleGeneratorRecognizer(topProcessor),
new RepeaterRecognizer()
// new ContextParamRecognizer(this),
// new ContextParamRepeaterRecognizer(this)
......
......@@ -34,7 +34,7 @@ public abstract class AbstractGenerator {
protected String separator;
private final boolean forcedMultiline;
private boolean menuMode=false; // managing menu items, not running tool. Ignore Generator errors
protected Tool tool0; // "tool" was already used in ToolParamRecognizer / Andrey
// protected Tool tool0; // "tool" was already used in ToolParamRecognizer / Andrey
protected FormatProcessor topProcessor; // to protect from cycles in recursion, replacing static in FormatProcessor / Andrey
public AbstractGenerator(FormatProcessor processor) {
......@@ -69,14 +69,23 @@ public abstract class AbstractGenerator {
}
topProcessor=processor;
}
public void setTopProcessor(FormatProcessor processor){
topProcessor=processor;
}
public void setMenuMode(boolean menuMode){
this.menuMode=menuMode;
}
public boolean getMenuMode(){
return menuMode;
}
public void setTool(Tool tool){
this.tool0=tool;
// public void setTool(Tool tool){
// this.tool0=tool;
// }
public Tool getCurrentTool(){
if (topProcessor==null) return null;
return topProcessor.getCurrentTool();
}
protected FormatProcessor getTopProcessor(){return topProcessor;}
......
......@@ -18,6 +18,7 @@
package com.elphel.vdt.core.tools.generators;
import com.elphel.vdt.VDT;
import com.elphel.vdt.core.tools.params.FormatProcessor;
import com.elphel.vdt.ui.variables.SelectedResourceManager;
public class BuildStampGenerator extends AbstractGenerator {
......@@ -26,16 +27,16 @@ public class BuildStampGenerator extends AbstractGenerator {
return NAME;
}
public BuildStampGenerator()
public BuildStampGenerator(FormatProcessor topProcessor)
{
super(null); // null for topFormatProcessor - this generator can not reference other parameters
super(topProcessor); // null for topFormatProcessor - this generator can not reference other parameters
}
protected String[] getStringValues() {
// if ( return new String[] {(tool0!=null)?tool0.getStateFile(): ""};
// System.out.println("#### BuildStampGenerator(): tool0="+
//((tool0!=null)?(tool0.getName()+" state="+tool0.getState()+" mode="+tool0.getMode()):"null"));
String stamp=(tool0!=null)?tool0.getTimeStamp(): null;
String stamp=(getCurrentTool()!=null)?getCurrentTool().getTimeStamp(): null;
if (stamp==null) stamp=SelectedResourceManager.getDefault().getBuildStamp();
return new String[] {stamp};
}
......
......@@ -31,8 +31,12 @@ import org.eclipse.core.resources.IResource;
//import com.elphel.vdt.VDT;
import com.elphel.vdt.VerilogUtils;
import com.elphel.vdt.core.tools.params.FormatProcessor;
import com.elphel.vdt.core.tools.params.Tool;
import com.elphel.vdt.ui.MessageUI;
//import com.elphel.vdt.core.verilog.VerilogUtils;
import com.elphel.vdt.ui.variables.SelectedResourceManager;
......@@ -52,9 +56,10 @@ public class FilteredSourceListGenerator extends AbstractGenerator {
public FilteredSourceListGenerator(String prefix,
String suffix,
String separator)
String separator,
FormatProcessor topProcessor)
{
super(prefix, suffix, separator, null ); // null for topFormatProcessor - this generator can not reference other parameters
super(prefix, suffix, separator, topProcessor );
}
public String getName() {
......@@ -62,9 +67,25 @@ public class FilteredSourceListGenerator extends AbstractGenerator {
}
protected String[] getStringValues() {
String ignoreFilter= SelectedResourceManager.getDefault().getFilter(); // old version
// System.out.println("FilteredSourceListGenerator(), tool0="+((tool0==null)?null:(tool0.getName()+tool0.getIgnoreFilter())));
// System.out.print("FilteredSourceListGenerator(): ");
if (topProcessor!=null){
Tool tool=topProcessor.getCurrentTool();
// System.out.println(", tool="+tool+" tool name="+((tool!=null)?tool.getName():null));
if (tool != null) {
ignoreFilter=tool.getIgnoreFilter();
// System.out.println(" tool="+tool.getName()+", ignoreFilter="+ignoreFilter);
} else {
System.out.println("FilteredSourceListGenerator(): topProcessor.getCurrentTool() is null");
}
} else {
System.out.println("FilteredSourceListGenerator(): topProcessor is null");
}
String[] file_names = null;
IResource resource = SelectedResourceManager.getDefault().getChosenVerilogFile();
String ignoreFilter= SelectedResourceManager.getDefault().getFilter();
Pattern ignorePattern = null;
if (ignoreFilter!=null){
try {
......
......@@ -18,6 +18,7 @@
package com.elphel.vdt.core.tools.generators;
import com.elphel.vdt.VDT;
import com.elphel.vdt.core.tools.params.FormatProcessor;
import com.elphel.vdt.ui.variables.SelectedResourceManager;
......@@ -27,9 +28,9 @@ import com.elphel.vdt.ui.variables.SelectedResourceManager;
*/
public class StateBaseGenerator extends AbstractGenerator {
public static final String NAME = VDT.GENERATOR_ID_STATE_FILE;
public StateBaseGenerator()
public StateBaseGenerator(FormatProcessor topProcessor)
{
super(null); // null for topFormatProcessor - this generator can not reference other parameters
super(topProcessor); // null for topFormatProcessor - this generator can not reference other parameters
}
public String getName() {
......@@ -37,7 +38,8 @@ public class StateBaseGenerator extends AbstractGenerator {
}
protected String[] getStringValues() {
String base=(tool0!=null)?tool0.getStateFile(): "";
// String base=(tool0!=null)?tool0.getStateFile(): "";
String base=(getCurrentTool()!=null)?getCurrentTool().getStateFile(): "";
if (base.lastIndexOf('.')>=0) base=base.substring(0,base.lastIndexOf('.'));
return new String[] {base};
}
......
......@@ -18,18 +18,27 @@
package com.elphel.vdt.core.tools.generators;
import com.elphel.vdt.VDT;
import com.elphel.vdt.core.tools.params.FormatProcessor;
import com.elphel.vdt.ui.MessageUI;
public class StateDirGenerator extends AbstractGenerator {
public static final String NAME = VDT.GENERATOR_ID_STATE_DIR;
public StateDirGenerator()
public StateDirGenerator(FormatProcessor topProcessor)
{
super(null); // null for topFormatProcessor - this generator can not reference other parameters
super(topProcessor); // null for topFormatProcessor - this generator can not reference other parameters
}
public String getName() {
return NAME;
}
protected String[] getStringValues() {
return new String[] {(tool0!=null)?tool0.getStateDir(): ""};
// return new String[] {(tool0!=null)?tool0.getStateDir(): ""};
String stateDir=(getCurrentTool()!=null)?getCurrentTool().getStateDir(): "";
if (getCurrentTool()==null){
MessageUI.error("StateDirGenerator(): getCurrentTool()==null");
System.out.println("StateDirGenerator(): getCurrentTool()==null");
}
return new String[] {stateDir};
}
}
......@@ -18,13 +18,14 @@
package com.elphel.vdt.core.tools.generators;
import com.elphel.vdt.VDT;
import com.elphel.vdt.core.tools.params.FormatProcessor;
import com.elphel.vdt.ui.variables.SelectedResourceManager;
public class StateFileGenerator extends AbstractGenerator {
public static final String NAME = VDT.GENERATOR_ID_STATE_FILE;
public StateFileGenerator()
public StateFileGenerator(FormatProcessor topProcessor)
{
super(null); // null for topFormatProcessor - this generator can not reference other parameters
super(topProcessor);
}
public String getName() {
......@@ -32,6 +33,7 @@ public class StateFileGenerator extends AbstractGenerator {
}
protected String[] getStringValues() {
return new String[] {(tool0!=null)?tool0.getStateFile(): ""};
// return new String[] {(tool0!=null)?tool0.getStateFile(): ""};
return new String[] {(getCurrentTool()!=null)?getCurrentTool().getStateFile(): ""};
}
}
......@@ -51,7 +51,8 @@ public class ValueGenerator extends AbstractGenerator {
public String[] generate() {
if (!param.getType().isList()) {
List<String> rslt=param.getValue(topProcessor);
// List<String> rslt=param.getValue(topProcessor);
List<String> rslt=new ArrayList<String>(param.getValue(topProcessor));
if (rslt.isEmpty()){
System.out.println("BUG in ValueGenerator.java#generate: param.getValue() isEmpty for "+param.getID());
return new String[]{prefix + "" + suffix};
......
......@@ -20,6 +20,7 @@ package com.elphel.vdt.core.tools.params;
import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
import com.elphel.vdt.core.tools.contexts.Context;
import com.elphel.vdt.core.tools.generators.AbstractGenerator;
import com.elphel.vdt.core.tools.params.recognizers.Recognizer;
import com.elphel.vdt.core.tools.params.recognizers.RecognizerResult;
......@@ -42,6 +43,7 @@ public class FormatProcessor {
private String initialTemplate;
private FormatProcessor topProcessor=null;
private Tool currentTool; //current tool - used for FilteredSourceListGenerator();
// private static int callCount = 0;
private int callCount = 0; // only valid for topProcessor
......@@ -85,6 +87,31 @@ public class FormatProcessor {
return outputLines;
}
public FormatProcessor(Context context){
this (null,null);
setCurrentTool(context);
//else if (context instanceof Tool)
}
public Tool getCurrentTool(){
if (!topProcessor.equals(this)){
System.out.println("Warning: trying to get tool not from the topProcessor");
return topProcessor.getCurrentTool();
}
return currentTool;
}
public void setCurrentTool(Context context){
if (context instanceof Tool) {
if (!topProcessor.equals(this)){
System.out.println("Warning: trying to set tool not on the topProcessor");
topProcessor.setCurrentTool(context);
return;
}
currentTool=(Tool) context;
}
}
private List<String> processTemplate(String template)
throws ToolException
{
......
......@@ -302,12 +302,15 @@ public class Parameter implements Cloneable, Updateable {
if(type.isList())
throw new ToolException("Assigning a non-list value to list parameter");
checkValue(value);
currentValue.clear();
currentValue.add(value);
canonicalizeValue(currentValue);
checkValue(value);
// currentValue.clear();
// currentValue.add(value);
// canonicalizeValue(currentValue);
List<String> newValue=new ArrayList<String>();
newValue.add(value);
canonicalizeValue(newValue);
currentValue = newValue;
}
public void setCurrentValue(List<String> value) throws ToolException {
......@@ -318,11 +321,14 @@ public class Parameter implements Cloneable, Updateable {
if(!type.isList())
throw new ToolException("Assigning a list value to non-list parameter");
checkValue(value);
// checkValue(value);
// currentValue = new ArrayList<String>(value);
// canonicalizeValue(currentValue);
currentValue = new ArrayList<String>(value);
canonicalizeValue(currentValue);
List<String> copyValue=new ArrayList<String>(value);
checkValue(copyValue);
canonicalizeValue(copyValue);
currentValue = copyValue;
}
public List<String> getCurrentValue() {
......@@ -350,13 +356,14 @@ public class Parameter implements Cloneable, Updateable {
// }
List<String> processedDefaultValue = null;
if (topProcessor==null) topProcessor=new FormatProcessor(null,null);
if (topProcessor==null) topProcessor=new FormatProcessor(context);
else topProcessor.setCurrentTool(context);
FormatProcessor processor = new FormatProcessor(new Recognizer[] {
//new RepeaterRecognizer(),
new SimpleGeneratorRecognizer(menuMode),
new SimpleGeneratorRecognizer(menuMode,topProcessor),
new ContextParamListRecognizer(context, topProcessor), // Andrey: returning list as the source parameter
// new ContextParamRecognizer(context)
new DefaultListGeneratorRecognizer(menuMode)
new DefaultListGeneratorRecognizer(menuMode, topProcessor)
}, topProcessor);
try {
......@@ -529,11 +536,12 @@ public class Parameter implements Cloneable, Updateable {
}
String format = syntax.getFormat();
if (topProcessor==null) topProcessor=new FormatProcessor(null,null);
if (topProcessor==null) topProcessor=new FormatProcessor(context);
else topProcessor.setCurrentTool(context);
FormatProcessor processor = new FormatProcessor(new Recognizer[] {
new ParamFormatRecognizer(this),
new ParamRepeaterRecognizer(this),
new SimpleGeneratorRecognizer(),
new SimpleGeneratorRecognizer(topProcessor),
new RepeaterRecognizer(),
},topProcessor);
......@@ -634,10 +642,11 @@ public class Parameter implements Cloneable, Updateable {
//
private String getOmitValue(FormatProcessor topProcessor) {
if (topProcessor==null) topProcessor=new FormatProcessor(null,null);
if (topProcessor==null) topProcessor=new FormatProcessor(context);
else topProcessor.setCurrentTool(context);
FormatProcessor processor = new FormatProcessor(new Recognizer[] {
new ContextParamRecognizer(context, topProcessor),
new SimpleGeneratorRecognizer()
new SimpleGeneratorRecognizer(topProcessor)
}, false,topProcessor);
String resolvedOmitValue = ConditionUtils.resolveContextCondition(context, omitValue, topProcessor);
......@@ -669,8 +678,16 @@ public class Parameter implements Cloneable, Updateable {
}
private void canonicalizeValue(List<String> value) {
for(int i = 0; i < value.size(); i++)
int oldSize=value.size();
for(int i = 0; i < value.size(); i++) {
try { // just catching a BUG, normally not needed
value.set(i, type.canonicalizeValue(value.get(i)));
} catch (Exception e){
MessageUI.error("Catching a bug in Parameter.jave, value.size="+value.size()+" oldSize="+oldSize+" threadID="+Thread.currentThread().getId());
System.out.println("Catching a bug, value.size="+value.size()+" oldSize="+oldSize+" threadID="+Thread.currentThread().getId());
System.out.println("value="+value.toString());
}
}
}
private void checkBoolInitialValue(String boolAttr, String attrName)
......
......@@ -1084,7 +1084,7 @@ public class Tool extends Context implements Cloneable, Inheritable {
public String[] getExtensions() {
if(extensions == null)
return null;
FormatProcessor topProcessor=new FormatProcessor(null,null);
FormatProcessor topProcessor=new FormatProcessor(this);
FormatProcessor processor = new FormatProcessor(
new Recognizer[] {
new ContextParamRecognizer(this,topProcessor),
......@@ -1117,11 +1117,11 @@ public class Tool extends Context implements Cloneable, Inheritable {
// Can be two different processors for labels and resources
//SimpleGeneratorRecognizer(true) may be not needed, as current file is already set here
FormatProcessor topProcessor=new FormatProcessor(null,null);
FormatProcessor topProcessor=new FormatProcessor(this);
FormatProcessor processor = new FormatProcessor(
new Recognizer[] {
new ContextParamRecognizer(this,topProcessor),
new SimpleGeneratorRecognizer(true) // in menuMode
new SimpleGeneratorRecognizer(true,topProcessor) // in menuMode
// new SimpleGeneratorRecognizer(false) // in menuMode
},topProcessor); // null for topFormatProcessor - this generator can not reference other parameters
......@@ -1158,11 +1158,11 @@ public class Tool extends Context implements Cloneable, Inheritable {
// Should be called after getMenuActions to have updateContextOptions() already ran
public String getIgnoreFilter(){ // calculate and get
if (ignoreFilter==null) return null;
FormatProcessor topProcessor=new FormatProcessor(null,null);
FormatProcessor topProcessor=new FormatProcessor(this);
FormatProcessor processor = new FormatProcessor(
new Recognizer[] {
new ContextParamRecognizer(this,topProcessor),
new SimpleGeneratorRecognizer(true) // in menuMode
new SimpleGeneratorRecognizer(true,topProcessor) // in menuMode
// new SimpleGeneratorRecognizer(false) // in menuMode
},topProcessor); // null for topFormatProcessor - this generator can not reference other parameters
List<String> results=null;
......@@ -1306,11 +1306,13 @@ public class Tool extends Context implements Cloneable, Inheritable {
protected List<String> buildCommandString(String paramStringTemplate, FormatProcessor topProcessor)
throws ToolException
{
if (topProcessor==null) topProcessor=new FormatProcessor(null,null);
if (topProcessor==null) topProcessor=new FormatProcessor(this);
else topProcessor.setCurrentTool(this);
FormatProcessor processor = new FormatProcessor(new Recognizer[] {
new ToolParamRecognizer(this,topProcessor),
// new SimpleGeneratorRecognizer(),
new SimpleGeneratorRecognizer(this),
// new SimpleGeneratorRecognizer(this),
new SimpleGeneratorRecognizer(topProcessor),
new RepeaterRecognizer(),
new ContextParamRecognizer(this,topProcessor),
new ContextParamRepeaterRecognizer(this)
......
......@@ -31,6 +31,7 @@ import com.elphel.vdt.Txt;
import com.elphel.vdt.VDT;
import com.elphel.vdt.core.launching.LaunchCore;
import com.elphel.vdt.core.launching.ToolLogFile;
import com.elphel.vdt.core.launching.VDTLaunchUtil;
import com.elphel.vdt.core.tools.ToolsCore;
import com.elphel.vdt.core.tools.params.Tool.TOOL_MODE;
import com.elphel.vdt.core.tools.params.Tool.TOOL_STATE;
......@@ -133,9 +134,11 @@ public class ToolSequence {
public void toolFinished(Tool tool){
if (tool!=null) doToolFinished(tool);
if (designFlowView!=null){
// System.out.print("1.designFlowView.updateLaunchAction() threadID="+Thread.currentThread().getId());
Display.getDefault().syncExec(new Runnable() {
public void run() {
designFlowView.updateLaunchAction(); // Run from Display thread to prevent "invalid thread access" when called from Runner
// System.out.println(" 2.designFlowView.updateLaunchAction() threadID="+Thread.currentThread().getId());
}
});
}
......@@ -179,7 +182,7 @@ public class ToolSequence {
if (isStop()){
Tool waitingTool=findWaitingTool();
if (waitingTool!=null){
waitingTool.setState(TOOL_STATE.FAILURE);
// waitingTool.setState(TOOL_STATE.FAILURE);
DEBUG_PRINT("doToolFinished("+tool.getName()+") "+tool.toString()+" state="+tool.getState()+" threadID="+Thread.currentThread().getId());
waitingTool.setMode(TOOL_MODE.STOP);
}
......@@ -275,7 +278,8 @@ public class ToolSequence {
twa.getIgnoreFilter()); //ignoreFilter);
tool.setMode(twa.getMode()) ; //TOOL_MODE.RUN);
tool.setChoice(twa.getChoice());
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_THREAD_CONFICT))
System.out.println(">>>>>>>> launching: "+tool.getName()+" threadID="+Thread.currentThread().getId());
LaunchCore.launch( tool,
SelectedResourceManager.getDefault().getSelectedProject(),
twa.getFullPath(),
......@@ -289,6 +293,8 @@ public class ToolSequence {
// SelectedResourceManager.getDefault().updateActionChoice(fullPath, choice, ignoreFilter); // Andrey
// SelectedResourceManager.getDefault().setBuildStamp(); // Andrey
// apply designFlowView to the tool itself
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_THREAD_CONFICT))
System.out.println(">>>>>>>> launching 2: "+tool.getName()+" threadID="+Thread.currentThread().getId());
LaunchCore.launch( tool,
SelectedResourceManager.getDefault().getSelectedProject(),
SelectedResourceManager.getDefault().getChosenTarget(),
......@@ -534,6 +540,8 @@ public class ToolSequence {
System.out.println("Failed to initiate continueRunningTools() for tool="+tool.getName());
}
} else {
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_THREAD_CONFICT))
System.out.println(">>>>>>>> launching 3: "+tool.getName()+" threadID="+Thread.currentThread().getId());
LaunchCore.launch( tool,
SelectedResourceManager.getDefault().getSelectedProject(),
fullPath,
......@@ -557,6 +565,8 @@ public class ToolSequence {
tool.setChoice(0);
SelectedResourceManager.getDefault().updateActionChoice(fullPath, 0, null); // Andrey
SelectedResourceManager.getDefault().setBuildStamp(); // OK - even for log? Or use old/selected one?
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_THREAD_CONFICT))
System.out.println(">>>>>>>> launching 4: "+tool.getName()+" threadID="+Thread.currentThread().getId());
// apply designFlowView to the tool itself
LaunchCore.launch(tool,
SelectedResourceManager.getDefault().getSelectedProject(),
......@@ -614,6 +624,7 @@ public class ToolSequence {
return;
}
tryAutoSave(toolsToSave.get(0)); // launch autosave and trigger toolFinished() when done
releaseSave();
}
}
public void releaseSave(){
......@@ -629,6 +640,7 @@ public class ToolSequence {
return saveOn;
}
public boolean isSaveEnabled(){
// System.out.println("isSaveEnabled(): "+!getToolsToSave().isEmpty());
return !getToolsToSave().isEmpty();
}
......@@ -861,6 +873,8 @@ public class ToolSequence {
// apply designFlowView to the tool itself
Display.getDefault().asyncExec(new Runnable() {
public void run() {
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_THREAD_CONFICT))
System.out.println(">>>>>>>> launching 5: "+fTool.getName()+" threadID="+Thread.currentThread().getId());
try {
LaunchCore.launch( fTool,
fProject,
......@@ -881,7 +895,7 @@ public class ToolSequence {
DEBUG_PRINT("Finished (auto)save tool "+tool.getName()+" for "+tool.getName());
if (isSave()) { // more to save?
List<Tool> toolsToSave=getToolsToSave(); // find if there are any sessions in unsaved state - returns list (not yet processed)
if ((toolsToSave!=null) && (toolsToSave.size()>=0)){
if ((toolsToSave!=null) && !toolsToSave.isEmpty()){
if (toolsToSave.get(0).getSaveMaster()!=null){
System.out.println("Seems to be a BUG that might cause infinite attempts to save while processing tool "+
tool.getName()+", first save tool "+toolsToSave.get(0).getName()+
......
......@@ -31,7 +31,7 @@ import com.elphel.vdt.ui.MessageUI;
public class StringComparison extends Comparison {
private Context context;
private String left, right;
private FormatProcessor topProcessor;
// private FormatProcessor topProcessor;
// constructor should not reference topProcessor (it is only used at startup)
public StringComparison(COMPARE_OP op, String left, String right) {
......@@ -66,11 +66,12 @@ public class StringComparison extends Comparison {
String actualRight = right;
if(context != null) {
if (topProcessor==null) topProcessor=new FormatProcessor(null,null);
if (topProcessor==null) topProcessor=new FormatProcessor(context);
else topProcessor.setCurrentTool(context);
FormatProcessor processor =
new FormatProcessor(new Recognizer[] {
new ContextParamRecognizer(context,topProcessor),
new SimpleGeneratorRecognizer()
new SimpleGeneratorRecognizer(topProcessor)
},topProcessor);
try {
......
......@@ -26,35 +26,31 @@ import com.elphel.vdt.core.tools.params.Tool;
public class DefaultListGeneratorRecognizer implements Recognizer {
private static final String CONTROL_SEQ = "%";
private static final int CONTROL_SEQ_LEN = CONTROL_SEQ.length();
private static AbstractGenerator[] generators = new AbstractGenerator[] {
private AbstractGenerator[] generators;
// public DefaultListGeneratorRecognizer(boolean menuMode, Tool tool,FormatProcessor topProcessor){
public DefaultListGeneratorRecognizer(boolean menuMode, FormatProcessor topProcessor){
super();
AbstractGenerator[] generators= new AbstractGenerator[]{
new SourceListGenerator("","",null),
new FilteredSourceListGenerator("","",null),
new FilteredSourceListGenerator("","",null, topProcessor),
new FileListGenerator("","",null)
};
public DefaultListGeneratorRecognizer(){
super();
}
public DefaultListGeneratorRecognizer(boolean menuMode){
super();
for (int i=0;i<generators.length;i++){
generators[i].setMenuMode(menuMode);
}
}
public DefaultListGeneratorRecognizer(boolean menuMode, Tool tool){
super();
this.generators=generators;
for (int i=0;i<generators.length;i++){
generators[i].setMenuMode(menuMode);
generators[i].setTool(tool);
// generators[i].setTool(tool);
}
}
public DefaultListGeneratorRecognizer(Tool tool){
super();
for (int i=0;i<generators.length;i++){
generators[i].setTool(tool);
}
public DefaultListGeneratorRecognizer(FormatProcessor topProcessor){
this(false,topProcessor);
}
// public DefaultListGeneratorRecognizer(boolean menuMode,FormatProcessor topProcessor){
// this(menuMode,null,topProcessor);
// }
// public DefaultListGeneratorRecognizer(Tool tool, FormatProcessor topProcessor){
// public DefaultListGeneratorRecognizer(Tool tool, FormatProcessor topProcessor){
// this(false,tool,topProcessor);
// }
public RecognizerResult recognize(String template, int startPos, FormatProcessor topProcessor) {
RecognizerResult result = new RecognizerResult();
......
......@@ -60,7 +60,7 @@ public class ParamRepeaterRecognizer extends RepeaterRecognizer {
return new ValueGenerator(param, repPrefix, repSuffix, separator, topProcessor);
/* Trying to put these here */
if(genName.equals(FilteredSourceListGenerator.NAME))
return new FilteredSourceListGenerator(repPrefix, repSuffix, separator);
return new FilteredSourceListGenerator(repPrefix, repSuffix, separator, topProcessor);
else if(genName.equals(SourceListGenerator.NAME))
return new SourceListGenerator(repPrefix, repSuffix, separator);
else if(genName.equals(FileListGenerator.NAME))
......
......@@ -105,7 +105,7 @@ public class RepeaterRecognizer implements Recognizer {
FormatProcessor topProcessor)
{
System.out.println("Ever get here? RepeaterRecognizer.java:findGenerator()"); // yes, sure
AbstractGenerator gen=new FilteredSourceListGenerator(repPrefix, repSuffix, separator);
AbstractGenerator gen=new FilteredSourceListGenerator(repPrefix, repSuffix, separator,topProcessor);
if (genName.equals(gen.getName())) return gen;
gen=new SourceListGenerator(repPrefix, repSuffix, separator);
if (genName.equals(gen.getName())) return gen;
......
......@@ -27,7 +27,11 @@ public class SimpleGeneratorRecognizer implements Recognizer {
private static final String CONTROL_SEQ = "%";
private static final int CONTROL_SEQ_LEN = CONTROL_SEQ.length();
private static AbstractGenerator[] generators = new AbstractGenerator[] {
private AbstractGenerator[] generators;
public SimpleGeneratorRecognizer(FormatProcessor processor){
super();
AbstractGenerator[] templateGenerators = new AbstractGenerator[] {
new OSNameGenerator(),
new ProjectNameGenerator(),
new ProjectPathGenerator(),
......@@ -36,35 +40,23 @@ public class SimpleGeneratorRecognizer implements Recognizer {
new CurrentFileGenerator(),
new CurrentFileBaseGenerator(),
new ChosenActionGenerator(),
new BuildStampGenerator(),
new BuildStampGenerator(processor),
new UserNameGenerator(),
new StateDirGenerator(),
new StateFileGenerator(),
new StateBaseGenerator()
new StateDirGenerator(processor),
new StateFileGenerator(processor),
new StateBaseGenerator(processor)
// new SourceListGenerator("","",""),
// new FilteredSourceListGenerator("","","")
};
public SimpleGeneratorRecognizer(){
super();
}
public SimpleGeneratorRecognizer(boolean menuMode){
super();
generators=templateGenerators;
for (int i=0;i<generators.length;i++){
generators[i].setMenuMode(menuMode);
generators[i].setTopProcessor(processor);
}
}
public SimpleGeneratorRecognizer(boolean menuMode, Tool tool){
super();
public SimpleGeneratorRecognizer(boolean menuMode, FormatProcessor processor){
this(processor);
for (int i=0;i<generators.length;i++){
generators[i].setMenuMode(menuMode);
generators[i].setTool(tool);
}
}
public SimpleGeneratorRecognizer(Tool tool){
super();
for (int i=0;i<generators.length;i++){
generators[i].setTool(tool);
}
}
public RecognizerResult recognize(String template, int startPos, FormatProcessor topProcessor) {
......
......@@ -397,6 +397,7 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
toggleLinkedTools.setImageDescriptor(VDTPluginImages.DESC_TOOLS_LINKED);
}
toolSequence.setToolsDirtyFlag(false); //boolean update) - recalculate dirty flags
fDesignFlowView.updateLaunchAction();
}
};
toggleLinkedTools.setToolTipText("Toggle tool dependency");
......@@ -412,6 +413,8 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
toggleSaveTools.setToolTipText("Save tool state");
toggleSaveTools.setImageDescriptor(VDTPluginImages.DESC_TOOLS_SAVE);
//isSaveEnabled()
toggleStopTools= new Action("Stop tools", Action.AS_CHECK_BOX) {
public void run() {
......@@ -906,36 +909,10 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
&& (selectedItem.getTool() != null);
showPropertiesAction.setEnabled(enabled);
clearToolPropertiesAction.setEnabled(enabled);
toggleSaveTools.setEnabled(toolSequence.isSaveEnabled());
((ViewLabelProvider) viewer.getLabelProvider()).fireChanged();
/*
viewer.getTree().update();
viewer.refresh();
System.out.println("DesignFlowView: should update now");
// Display.update();
compositeParent.getDisplay().update();
String menuTitle=getMenuTitle();
if (menuTitle.endsWith("*")){
changeMenuTitle(menuTitle.substring(0,menuTitle.length()-1));
}else {
changeMenuTitle(menuTitle+"*");
}
// changeMenuTitle(menuTitle+"***");
compositeParent.redraw(); // widget is disposed
compositeParent.update();
// changeMenuTitle(menuTitle+"");
//Well you need to determine the row position range for the child rows you want to refresh and then fire a RowVisualChangeEvent.
// That should do the trick.
// System.out.println("count="+viewer.get)
Tree tree=viewer.getTree();
System.out.println("count="+tree.getItemCount());
TreeItem [] items=tree.getItems();
for (TreeItem ti:items){
System.out.println("--- "+ti.getText());
}
// ((BaseLabelProvider) viewer.getLabelProvider()).fireLabelProviderChanged(new LabelProviderChangedEvent( null));
((ViewLabelProvider) viewer.getLabelProvider()).fireChanged();
*/
} // updateLaunchAction()
private void launchTool(
......
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