Commit e52ad884 authored by Andrey Filippov's avatar Andrey Filippov

Working on view menu to start multiple targets for the same tool

parent 02c3694d
...@@ -22,8 +22,7 @@ import java.util.ArrayList; ...@@ -22,8 +22,7 @@ import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import com.elphel.vdt.core.tools.config.ConfigException; import com.elphel.vdt.core.tools.config.ConfigException;
//TODO: Andrey: Now Parameter has file name
public class Checks { public class Checks {
public static void checkCyclicInheritance(Inheritable inheritanceChainMember, String entityName) public static void checkCyclicInheritance(Inheritable inheritanceChainMember, String entityName)
throws ConfigException throws ConfigException
......
...@@ -33,6 +33,8 @@ import com.elphel.vdt.core.tools.config.*; ...@@ -33,6 +33,8 @@ import com.elphel.vdt.core.tools.config.*;
import com.elphel.vdt.core.tools.contexts.*; import com.elphel.vdt.core.tools.contexts.*;
import com.elphel.vdt.core.tools.menu.*; import com.elphel.vdt.core.tools.menu.*;
import com.elphel.vdt.ui.MessageUI; import com.elphel.vdt.ui.MessageUI;
import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.veditor.preference.PreferenceStrings;
public class XMLConfig extends Config { public class XMLConfig extends Config {
...@@ -98,6 +100,11 @@ public class XMLConfig extends Config { ...@@ -98,6 +100,11 @@ public class XMLConfig extends Config {
static final String CONTEXT_TOOL_SHELL_ATTR = "shell"; static final String CONTEXT_TOOL_SHELL_ATTR = "shell";
static final String CONTEXT_TOOL_EXTENSIONS_LIST_TAG = "extensions-list"; static final String CONTEXT_TOOL_EXTENSIONS_LIST_TAG = "extensions-list";
static final String CONTEXT_TOOL_EXTENSION_TAG = "extension"; static final String CONTEXT_TOOL_EXTENSION_TAG = "extension";
static final String CONTEXT_TOOL_ACTION_LIST_TAG = "action-menu";
static final String CONTEXT_TOOL_ACTION_TAG = "action";
static final String CONTEXT_TOOL_ACTION_LABEL = "label";
static final String CONTEXT_TOOL_ACTION_RESOURCE = "resource";
static final String CONTEXT_TOOL_EXTENSION_MASK_ATTR = "mask"; static final String CONTEXT_TOOL_EXTENSION_MASK_ATTR = "mask";
static final String CONTEXT_TOOL_SYNTAX_ERRORS = "errors"; static final String CONTEXT_TOOL_SYNTAX_ERRORS = "errors";
static final String CONTEXT_TOOL_SYNTAX_WARNINGS= "warnings"; static final String CONTEXT_TOOL_SYNTAX_WARNINGS= "warnings";
...@@ -374,6 +381,7 @@ public class XMLConfig extends Config { ...@@ -374,6 +381,7 @@ public class XMLConfig extends Config {
SAXException, SAXException,
IOException IOException
{ {
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER))
System.out.println("Reading file '" + configFile + "'"); System.out.println("Reading file '" + configFile + "'");
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
...@@ -424,6 +432,7 @@ public class XMLConfig extends Config { ...@@ -424,6 +432,7 @@ public class XMLConfig extends Config {
List<DesignMenu> menuComponents = readDesignMenu(document); List<DesignMenu> menuComponents = readDesignMenu(document);
designMenuManager.addDesignMenuComponents(menuComponents); designMenuManager.addDesignMenuComponents(menuComponents);
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER))
System.out.println("Done reading file '" + configFile + "'"); System.out.println("Done reading file '" + configFile + "'");
} }
...@@ -567,15 +576,19 @@ public class XMLConfig extends Config { ...@@ -567,15 +576,19 @@ public class XMLConfig extends Config {
// if(toolShell == null) toolShell=""; // if(toolShell == null) toolShell="";
List<String> toolExtensionsList = readToolExtensionsList(contextNode, contextName); List<String> toolExtensionsList = readToolExtensionsList(contextNode, contextName);
List<RunFor> toolRunfor= readToolRunForList(contextNode, contextName);
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER)) {
System.out.println("contextNode.getNodeValue()="+contextNode.getNodeValue()); System.out.println("contextNode.getNodeValue()="+contextNode.getNodeValue());
System.out.println("toolPackage="+toolPackage); System.out.println("toolPackage="+toolPackage);
System.out.println("toolProject="+toolProject); System.out.println("toolProject="+toolProject);
System.out.println("toolExe="+toolExe); System.out.println("toolExe="+toolExe);
System.out.println("toolShell="+toolShell); System.out.println("toolShell="+toolShell);
if (toolRunfor!=null){
List<Tool.RunFor> toolRunfor= readToolRunForList(contextNode, contextName); System.out.println("got toolRunfor.size()="+toolRunfor.size());
}
}
context = new Tool(contextName, context = new Tool(contextName,
contextInterfaceName, contextInterfaceName,
...@@ -610,9 +623,11 @@ public class XMLConfig extends Config { ...@@ -610,9 +623,11 @@ public class XMLConfig extends Config {
List<CommandLinesBlock> contextCommandLinesBlocks = readCommandLinesBlocks(contextNode, context); // Correct? for "project_parameters" in /vdt/tools/Verilog/IVerilog.xml List<CommandLinesBlock> contextCommandLinesBlocks = readCommandLinesBlocks(contextNode, context); // Correct? for "project_parameters" in /vdt/tools/Verilog/IVerilog.xml
// Each of contextParams (3 total, correct) has null context. Probably OK, same for the tool context // Each of contextParams (3 total, correct) has null context. Probably OK, same for the tool context
ContextInputDefinition contextInputDefinition = readContextInputDefinition(contextNode, context); ContextInputDefinition contextInputDefinition = readContextInputDefinition(contextNode, context);
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER)) {
if (contextKind==ContextKind.PROJECT){ if (contextKind==ContextKind.PROJECT){
System.out.println("processing project context"); System.out.println("processing project context");
} }
}
context.setParams(contextParams); context.setParams(contextParams);
context.setParamGroups(contextInputDefinition.getParamGroups()); // "Project Properties", "General" context.setParamGroups(contextInputDefinition.getParamGroups()); // "Project Properties", "General"
context.setInputDialogLabel(contextInputDefinition.getLabel()); context.setInputDialogLabel(contextInputDefinition.getLabel());
...@@ -943,11 +958,37 @@ public class XMLConfig extends Config { ...@@ -943,11 +958,37 @@ public class XMLConfig extends Config {
} }
private List<Tool.RunFor> readToolRunForList(Node toolNode, String toolName){ private List<RunFor> readToolRunForList(Node toolNode, String toolName)
if (toolNode.getNodeValue()==null) return null; throws ConfigException
System.out.println("FIXME: readToolRunForList("+toolNode.getNodeName() +", "+toolName+")"+ {
" rootNode="+rootNode.getNodeName()+" filename="+currentConfigFileName); String toolInfo = "Tool '" + toolName + "'";
List<RunFor> runForList = new ArrayList<RunFor>();
List<Node> runForNodesList = findChildNodes(toolNode, CONTEXT_TOOL_ACTION_LIST_TAG);
if(runForNodesList.isEmpty())
return null; return null;
if(runForNodesList.size() > 1)
throw new ConfigException(toolInfo +
" definition cannot contain several '" +
CONTEXT_OUTPUT_SECTION_TAG +
"' nodes");
Node runForNode = runForNodesList.get(0);
List<Node> runForNodes = findChildNodes(runForNode, CONTEXT_TOOL_ACTION_TAG);
for(Iterator<Node> n = runForNodes.iterator(); n.hasNext();) {
Node node = (Node)n.next();
String label = getAttributeValue(node, CONTEXT_TOOL_ACTION_LABEL);
if (label == null)
throw new ConfigException(toolInfo + ": Attribute '" + CONTEXT_TOOL_ACTION_LABEL + "' is absent");
String resource = getAttributeValue(node, CONTEXT_TOOL_ACTION_RESOURCE);
if (resource == null)
throw new ConfigException(toolInfo + ": Attribute '" + CONTEXT_TOOL_ACTION_RESOURCE + "' is absent");
runForList.add(new RunFor(label, resource));
}
return runForList;
} }
private List<Parameter> readParameters(Node node, Context context) private List<Parameter> readParameters(Node node, Context context)
......
...@@ -31,6 +31,7 @@ public abstract class AbstractGenerator { ...@@ -31,6 +31,7 @@ public abstract class AbstractGenerator {
protected final String prefix, suffix; protected final String prefix, suffix;
protected String separator; protected String separator;
private final boolean forcedMultiline; private final boolean forcedMultiline;
private boolean menuMode=false; // managing menu items, not running tool
public AbstractGenerator() { public AbstractGenerator() {
this(false); this(false);
...@@ -60,6 +61,13 @@ public abstract class AbstractGenerator { ...@@ -60,6 +61,13 @@ public abstract class AbstractGenerator {
separator = separator.replace("\\n", "\n"); separator = separator.replace("\\n", "\n");
separator = separator.replace("\\t", "\t"); separator = separator.replace("\\t", "\t");
} }
public void setMenuMode(boolean menuMode){
this.menuMode=menuMode;
}
public boolean getMenuMode(){
return menuMode;
}
public abstract String getName(); public abstract String getName();
......
...@@ -19,19 +19,33 @@ package com.elphel.vdt.core.tools.generators; ...@@ -19,19 +19,33 @@ package com.elphel.vdt.core.tools.generators;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.ui.IPageLayout;
import com.elphel.vdt.VDT; import com.elphel.vdt.VDT;
import com.elphel.vdt.ui.variables.SelectedResourceManager; import com.elphel.vdt.ui.variables.SelectedResourceManager;
public class CurrentFileGenerator extends AbstractGenerator { public class CurrentFileGenerator extends AbstractGenerator {
private static final String NAME = VDT.GENERATOR_ID_CURRENT_FILE; private static final String NAME = VDT.GENERATOR_ID_CURRENT_FILE;
// private boolean menuMode=false; // managing menu items, not running tool
public String getName() { public String getName() {
return NAME; return NAME;
} }
/*
public CurrentFileGenerator(boolean menuMode){
super();
this.menuMode=menuMode;
}
*/
/*
public void setMenuMode(boolean menuMode){
this.menuMode=menuMode;
}
*/
protected String[] getStringValues() { protected String[] getStringValues() {
IResource resource = SelectedResourceManager.getDefault().getSelectedResource(); IResource resource;
if (getMenuMode()) resource = SelectedResourceManager.getDefault().getViewSelectedResource(IPageLayout.ID_RES_NAV);
else resource = SelectedResourceManager.getDefault().getSelectedResource();
if((resource != null) && (resource.getType() == IResource.FILE)) if((resource != null) && (resource.getType() == IResource.FILE))
return new String[] { ((IFile)resource).getLocation().toOSString() }; return new String[] { ((IFile)resource).getLocation().toOSString() };
......
...@@ -23,11 +23,7 @@ import com.elphel.vdt.core.tools.Updateable; ...@@ -23,11 +23,7 @@ import com.elphel.vdt.core.tools.Updateable;
import com.elphel.vdt.core.tools.config.ConfigException; import com.elphel.vdt.core.tools.config.ConfigException;
public class EntityUtilsMarkChildren { public class EntityUtilsMarkChildren {
// Updating tool context (to) from project context (from), items in to have now null context, in from - ProjectContext //Andrey debugging: Updating tool context (to) from project context (from), items in to have now null context, in from - ProjectContext
/*
* Andrey: Seems there should be only one instance of each parameter, no cloning?
*/
public static <T extends Updateable> void update(List<Parameter> from, List<Parameter> to) public static <T extends Updateable> void update(List<Parameter> from, List<Parameter> to)
throws ConfigException throws ConfigException
{ {
......
...@@ -122,6 +122,9 @@ public class Parameter implements Cloneable, Updateable { ...@@ -122,6 +122,9 @@ public class Parameter implements Cloneable, Updateable {
this.relevant = relevant; this.relevant = relevant;
this.hasDependentParameters = false; this.hasDependentParameters = false;
this.sourceXML=sourceXML; this.sourceXML=sourceXML;
if (id.equals("SimulationTopFile")){ // Andrey
System.out.println("Creating parameter SimulationTopFile, defaultValue="+defaultValue);
}
} }
protected Parameter(Parameter param) { protected Parameter(Parameter param) {
this(param.id, this(param.id,
...@@ -164,26 +167,43 @@ public class Parameter implements Cloneable, Updateable { ...@@ -164,26 +167,43 @@ public class Parameter implements Cloneable, Updateable {
this.context = context; this.context = context;
*/ */
if (id.equals("SimulationTopFile")){ // Andrey
System.out.println("Initializing parameter SimulationTopFile, defaultValue="+defaultValue);
}
// replacing: // Andrey: replacing with
if(this.context == context) if(this.context == context) {
throw new ConfigException("Parameter ('" + id + "') cannot be re-initialized on the same context level"); // wrong file name, should be per-parameter // That kind of check never happens, same id parameter fro the same tool (not inherited) is silently ignored
if(this.context == null) { throw new ConfigException("Parameter ('" + id + "') cannot be re-initialized on the same context level in "+sourceXML); // wrong file name, should be per-parameter
}
if(this.context != null) {
/*
System.out.println ("Andrey: Trying to use already defined context for parameter '"+id+"', context='"+this.context.getName()+
"' instead of the currently processed '"+context.getName()+"' for parameter '"+this.getID()+"'"+
" isChild="+getIsChild());
*/
setIsChild(true); // Still does not work with EntityUtils.update(), only with EntityUtilsMarkChildren.update()
return; // this parameter is inherited, already processed
}
this.context = context; this.context = context;
} else { if (getIsChild()){
System.out.println ("Andrey: Trying to use already defined context '"+this.context.getName()+ /*
"' instead of the currently processed '"+context.getName()+"' for parameter '"+this.getID()+"'"); System.out.println ("Andrey: isChild is set for parameter '"+id+"' context '"+this.context.getName()+
// Andrey: Not sure if initialization is still needed - it is probably done before cloning
// System.out.println("Skipping initialization - it is already done"); "' instead of the currently processed '"+context.getName()+"' for parameter '"+this.getID()+"'"+
// return; " isChild="+getIsChild());
*/
} }
this.context = context;
String contextInfo = "Context '" + context.getName() + "'"; String contextInfo = "Context '" + context.getName() + "'";
if(typeName == null) if(typeName == null)
throw new ConfigException(contextInfo + ": Type name of parameter '" + id + "' is absent"); throw new ConfigException(contextInfo + ": Type name of parameter '" + id + "' is absent in "+sourceXML);
else if(syntaxName == null) else if(syntaxName == null)
throw new ConfigException(contextInfo + ": Syntax name of parameter '" + id + "' is absent"); throw new ConfigException(contextInfo + ": Syntax name of parameter '" + id + "' is absent in "+sourceXML);
else if(defaultValue == null) else if(defaultValue == null)
throw new ConfigException(contextInfo + ": Default value of parameter '" + id + "' is absent"); throw new ConfigException(contextInfo + ": Default value of parameter '" + id + "' is absent in "+sourceXML);
if(readonly == null) if(readonly == null)
readonly = new String(BooleanUtils.VALUE_FALSE); readonly = new String(BooleanUtils.VALUE_FALSE);
...@@ -199,7 +219,7 @@ public class Parameter implements Cloneable, Updateable { ...@@ -199,7 +219,7 @@ public class Parameter implements Cloneable, Updateable {
if(label == null) if(label == null)
throw new ConfigException(contextInfo + ": Label of the parameter '" + id + throw new ConfigException(contextInfo + ": Label of the parameter '" + id +
"' is absent, while visible attribute is not " + "' is absent, while visible attribute is not " +
BooleanUtils.VALUE_FALSE); BooleanUtils.VALUE_FALSE+" in "+sourceXML);
} }
// this.type = context.getControlInterface().findParamType(typeName); // this.type = context.getControlInterface().findParamType(typeName);
...@@ -209,7 +229,7 @@ public class Parameter implements Cloneable, Updateable { ...@@ -209,7 +229,7 @@ public class Parameter implements Cloneable, Updateable {
throw new ConfigException(contextInfo + ": Parameter type '" + typeName + throw new ConfigException(contextInfo + ": Parameter type '" + typeName +
// "' doesn't exist in control interface '" + context.getControlInterface().getName() + // "' doesn't exist in control interface '" + context.getControlInterface().getName() +
"' doesn't exist in control interface '" + this.context.getControlInterface().getName() + "' doesn't exist in control interface '" + this.context.getControlInterface().getName() +
"'"); "' in "+sourceXML);
// this.syntax = context.getControlInterface().findSyntax(syntaxName); // this.syntax = context.getControlInterface().findSyntax(syntaxName);
this.syntax = this.context.getControlInterface().findSyntax(syntaxName); this.syntax = this.context.getControlInterface().findSyntax(syntaxName);
...@@ -218,7 +238,7 @@ public class Parameter implements Cloneable, Updateable { ...@@ -218,7 +238,7 @@ public class Parameter implements Cloneable, Updateable {
throw new ConfigException(contextInfo + ": Syntax '" + syntaxName + throw new ConfigException(contextInfo + ": Syntax '" + syntaxName +
// "' doesn't exist in control interface '" + context.getControlInterface().getName() + // "' doesn't exist in control interface '" + context.getControlInterface().getName() +
"' doesn't exist in control interface '" + this.context.getControlInterface().getName() + "' doesn't exist in control interface '" + this.context.getControlInterface().getName() +
"'"); "' in "+sourceXML);
} }
// //
...@@ -292,6 +312,10 @@ public class Parameter implements Cloneable, Updateable { ...@@ -292,6 +312,10 @@ public class Parameter implements Cloneable, Updateable {
// //
public void setCurrentValue(String value) throws ToolException { public void setCurrentValue(String value) throws ToolException {
if (id.equals("SimulationTopFile")){ // Andrey
System.out.println("setCurrentValue() SimulationTopFile, value="+value);
}
if(type.isList()) if(type.isList())
throw new ToolException("Assigning a non-list value to list parameter"); throw new ToolException("Assigning a non-list value to list parameter");
...@@ -304,6 +328,10 @@ public class Parameter implements Cloneable, Updateable { ...@@ -304,6 +328,10 @@ public class Parameter implements Cloneable, Updateable {
} }
public void setCurrentValue(List<String> value) throws ToolException { public void setCurrentValue(List<String> value) throws ToolException {
if (id.equals("SimulationTopFile")){ // Andrey
System.out.println("setCurrentValue() SimulationTopFile a list value");
}
if(!type.isList()) if(!type.isList())
throw new ToolException("Assigning a list value to non-list parameter"); throw new ToolException("Assigning a list value to non-list parameter");
...@@ -315,6 +343,10 @@ public class Parameter implements Cloneable, Updateable { ...@@ -315,6 +343,10 @@ public class Parameter implements Cloneable, Updateable {
} }
public List<String> getCurrentValue() { public List<String> getCurrentValue() {
if (id.equals("SimulationTopFile")){ // Andrey
System.out.println("getCurrentValue() SimulationTopFile, value="+currentValue);
}
if(currentValue.isEmpty()) if(currentValue.isEmpty())
return null; return null;
...@@ -354,6 +386,10 @@ public class Parameter implements Cloneable, Updateable { ...@@ -354,6 +386,10 @@ public class Parameter implements Cloneable, Updateable {
// returns current value if it is set // returns current value if it is set
// otherwise returns default value // otherwise returns default value
public List<String> getValue() { public List<String> getValue() {
if (id.equals("SimulationTopFile")){ // Andrey
System.out.println("getValue() SimulationTopFile");
}
if(!currentValue.isEmpty()) if(!currentValue.isEmpty())
return currentValue; return currentValue;
...@@ -363,6 +399,10 @@ public class Parameter implements Cloneable, Updateable { ...@@ -363,6 +399,10 @@ public class Parameter implements Cloneable, Updateable {
// returns external form of the current value unless it equals null; // returns external form of the current value unless it equals null;
// otherwise returns external form of the default value // otherwise returns external form of the default value
public List<String> getExternalValueForm() { public List<String> getExternalValueForm() {
if (id.equals("SimulationTopFile")){ // Andrey
System.out.println("getExternalValueForm() SimulationTopFile");
}
List<String> externalFormValue = new ArrayList<String>(); List<String> externalFormValue = new ArrayList<String>();
for(Iterator<String> i = getValue().iterator(); i.hasNext();) { for(Iterator<String> i = getValue().iterator(); i.hasNext();) {
...@@ -425,8 +465,12 @@ public class Parameter implements Cloneable, Updateable { ...@@ -425,8 +465,12 @@ public class Parameter implements Cloneable, Updateable {
if(syntaxName == null) if(syntaxName == null)
syntaxName = param.syntaxName; syntaxName = param.syntaxName;
if(defaultValue == null) if(defaultValue == null) {
defaultValue = param.defaultValue; defaultValue = param.defaultValue;
if (id.equals("SimulationTopFile")){ // Andrey
System.out.println("Updating parameter SimulationTopFile, defaultValue="+defaultValue);
}
}
if(label == null) if(label == null)
label = param.label; label = param.label;
...@@ -543,7 +587,7 @@ public class Parameter implements Cloneable, Updateable { ...@@ -543,7 +587,7 @@ public class Parameter implements Cloneable, Updateable {
"' of parameter '" + id + "' of parameter '" + id +
"' has value that is neither " + BooleanUtils.VALUE_TRUE + "' has value that is neither " + BooleanUtils.VALUE_TRUE +
", nor " + BooleanUtils.VALUE_FALSE + ", nor " + BooleanUtils.VALUE_FALSE +
", nor a condition expression"); ", nor a condition expression in "+sourceXML);
} }
} }
...@@ -556,7 +600,7 @@ public class Parameter implements Cloneable, Updateable { ...@@ -556,7 +600,7 @@ public class Parameter implements Cloneable, Updateable {
"' of parameter '" + id + "' of parameter '" + id +
"' has value '" + boolValue + "' has value '" + boolValue +
"' that is neither " + BooleanUtils.VALUE_TRUE + "' that is neither " + BooleanUtils.VALUE_TRUE +
", nor " + BooleanUtils.VALUE_FALSE); ", nor " + BooleanUtils.VALUE_FALSE+" in "+sourceXML);
} }
} }
......
...@@ -20,11 +20,15 @@ package com.elphel.vdt.core.tools.params; ...@@ -20,11 +20,15 @@ package com.elphel.vdt.core.tools.params;
import java.util.*; import java.util.*;
import java.io.*; import java.io.*;
import org.eclipse.core.resources.IProject;
import com.elphel.vdt.core.options.OptionsCore;
import com.elphel.vdt.core.tools.*; import com.elphel.vdt.core.tools.*;
import com.elphel.vdt.core.tools.contexts.*; import com.elphel.vdt.core.tools.contexts.*;
import com.elphel.vdt.core.tools.config.*; import com.elphel.vdt.core.tools.config.*;
import com.elphel.vdt.core.tools.params.conditions.ConditionUtils; import com.elphel.vdt.core.tools.params.conditions.ConditionUtils;
import com.elphel.vdt.core.tools.params.recognizers.*; import com.elphel.vdt.core.tools.params.recognizers.*;
import com.elphel.vdt.core.tools.params.types.RunFor;
public class Tool extends Context implements Cloneable, Inheritable { public class Tool extends Context implements Cloneable, Inheritable {
...@@ -51,10 +55,6 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -51,10 +55,6 @@ public class Tool extends Context implements Cloneable, Inheritable {
private boolean isShell = false; /* Tool is a shell, preserve first argument, merge all others */ private boolean isShell = false; /* Tool is a shell, preserve first argument, merge all others */
private String projectPath=null; private String projectPath=null;
private boolean initialized = false; private boolean initialized = false;
public class RunFor{
String prompt;
String resource;
}
public Tool(String name, public Tool(String name,
String controlInterfaceName, String controlInterfaceName,
String label, String label,
...@@ -96,6 +96,10 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -96,6 +96,10 @@ public class Tool extends Context implements Cloneable, Inheritable {
this.toolInfo = toolInfo; this.toolInfo = toolInfo;
} }
public List<RunFor> getRunFor(){
return runfor;
}
public void init(Config config) throws ConfigException { public void init(Config config) throws ConfigException {
if(initialized) if(initialized)
return; return;
...@@ -200,7 +204,10 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -200,7 +204,10 @@ public class Tool extends Context implements Cloneable, Inheritable {
return null; return null;
FormatProcessor processor = new FormatProcessor( FormatProcessor processor = new FormatProcessor(
new Recognizer[] { new ContextParamRecognizer(this) }); new Recognizer[] {
new ContextParamRecognizer(this),
// new SimpleGeneratorRecognizer() // Andrey: Trying
});
String[] actualExtensions = new String[extensions.size()]; String[] actualExtensions = new String[extensions.size()];
...@@ -221,6 +228,76 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -221,6 +228,76 @@ public class Tool extends Context implements Cloneable, Inheritable {
return actualExtensions; return actualExtensions;
} }
public RunFor[] getMenuActions(IProject project) {
if(runfor == null)
return null;
updateContextOptions (project); // Fill in parameters
// Can be two different processors for labels and resources
//SimpleGeneratorRecognizer(true) may be not needed, as current file is already set here
FormatProcessor processor = new FormatProcessor(
new Recognizer[] {
new ContextParamRecognizer(this),
new SimpleGeneratorRecognizer(true) // in menuMode
// new SimpleGeneratorRecognizer(false) // in menuMode
});
RunFor[] actualActions = new RunFor[runfor.size()];
for(int i = 0; i < runfor.size(); i++) {
List<String> labels = null;
try {
labels = processor.process(runfor.get(i).getLabel());
} catch(ToolException e) {
assert false;
}
assert labels.size() == 1;
List<String> resources = null;
String resource=null;
try {
resources = processor.process(runfor.get(i).getResource());
} catch(ToolException e) {
// OK to be null;
}
if (resources!=null) {
assert ((resources==null) || (resources.size() == 1));
resource = resources.get(0);
}
actualActions[i] = new RunFor(labels.get(0), resource);
}
return actualActions;
}
private void updateContextOptions (IProject project){
PackageContext packageContext = getParentPackage();
if (packageContext != null) {
OptionsCore.doLoadContextOptions(packageContext);
try {
packageContext.buildParams();
} catch (ToolException e) { // Do nothing here
System.out.println("updateContextOptions ToolException for Package Context="+e.getMessage());
}
}
Context context = getParentProject();
if (context != null) {
OptionsCore.doLoadContextOptions(context, project);
try {
context.buildParams();
} catch (ToolException e) { // Do nothing here
System.out.println("updateContextOptions ToolException for Project Context="+e.getMessage());
}
}
OptionsCore.doLoadContextOptions(this, project);
try {
buildParams();
} catch (ToolException e) { // Do nothing here
System.out.println("updateContextOptions ToolException for Tool Context="+e.getMessage());
}
}
public List<Parameter> getParams() { public List<Parameter> getParams() {
return paramContainer.getParams(); return paramContainer.getParams();
} }
...@@ -235,8 +312,16 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -235,8 +312,16 @@ public class Tool extends Context implements Cloneable, Inheritable {
public Parameter findParam(String paramID) { public Parameter findParam(String paramID) {
Parameter param = super.findParam(paramID); //Andrey: happily finds ProjectContext parameter, thinks it is tool context Parameter param = super.findParam(paramID); //Andrey: happily finds ProjectContext parameter, thinks it is tool context
/*
* Andrey: Added isChild property to the Property, and still left static inheritance at XML parsing time. Then, during parameter
* processing that inheritance is ignored
*/
// if(param != null) // Was before the change described above
if ((param != null) &&(param.getID().equals("SimulationTopFile"))){ // Andrey
System.out.println("Initializing parameter SimulationTopFile, isChild="+param.getIsChild());
}
// if(param != null)
if ((param != null) && !param.getIsChild()) if ((param != null) && !param.getIsChild())
return param; return param;
......
...@@ -31,10 +31,19 @@ public class SimpleGeneratorRecognizer implements Recognizer { ...@@ -31,10 +31,19 @@ public class SimpleGeneratorRecognizer implements Recognizer {
new ProjectPathGenerator(), new ProjectPathGenerator(),
new TopModuleNameGenerator(), new TopModuleNameGenerator(),
new CurrentFileGenerator(), new CurrentFileGenerator(),
new ViewSelectedFileGenerator(), // new ViewSelectedFileGenerator(),
new CurrentFileBaseGenerator() new CurrentFileBaseGenerator()
}; };
public SimpleGeneratorRecognizer(){
super();
}
public SimpleGeneratorRecognizer(boolean menuMode){
super();
for (int i=0;i<generators.length;i++){
generators[i].setMenuMode(menuMode);
}
}
public RecognizerResult recognize(String template, int startPos) { public RecognizerResult recognize(String template, int startPos) {
RecognizerResult result = new RecognizerResult(); RecognizerResult result = new RecognizerResult();
......
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* Eclipse/VDT plug-in is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params.types;
public class RunFor{
public String label;
public String resource;
public RunFor(String label, String resource){
this.label=label;
this.resource=resource;
}
public String getLabel(){
return label;
}
public String getResource(){
return resource;
}
}
...@@ -43,15 +43,13 @@ import com.elphel.vdt.core.tools.ToolsCore; ...@@ -43,15 +43,13 @@ import com.elphel.vdt.core.tools.ToolsCore;
import com.elphel.vdt.core.tools.contexts.Context; import com.elphel.vdt.core.tools.contexts.Context;
import com.elphel.vdt.core.tools.menu.DesignMenu; import com.elphel.vdt.core.tools.menu.DesignMenu;
import com.elphel.vdt.core.tools.params.Tool; import com.elphel.vdt.core.tools.params.Tool;
import com.elphel.vdt.core.tools.params.types.RunFor;
import com.elphel.vdt.Txt; import com.elphel.vdt.Txt;
import com.elphel.vdt.VDT; import com.elphel.vdt.VDT;
//import com.elphel.vdt.VDTPlugin; //import com.elphel.vdt.VDTPlugin;
import com.elphel.vdt.veditor.VerilogPlugin; import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.ui.MessageUI; import com.elphel.vdt.ui.MessageUI;
import com.elphel.vdt.ui.VDTPluginImages; import com.elphel.vdt.ui.VDTPluginImages;
import com.elphel.vdt.ui.variables.SelectedResourceManager; import com.elphel.vdt.ui.variables.SelectedResourceManager;
import com.elphel.vdt.ui.views.DesignMenuModel; import com.elphel.vdt.ui.views.DesignMenuModel;
import com.elphel.vdt.ui.dialogs.DesignMenuSelectionDialog; import com.elphel.vdt.ui.dialogs.DesignMenuSelectionDialog;
...@@ -429,16 +427,27 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -429,16 +427,27 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
showProjectPropertiesToolbarAction.setProject(project); showProjectPropertiesToolbarAction.setProject(project);
clearProjectPropertiesAction.setProject(project); clearProjectPropertiesAction.setProject(project);
// Selected item should be not null, but resource - may be
// RunFor[] getMenuActions()
if (selectedItem != null){
Tool tool= selectedItem.getTool();
if (tool!=null){
RunFor [] runFor=tool.getMenuActions(project);
System.out.println("Got Runfor["+((runFor!=null)?runFor.length:"null")+"]");
if (runFor!=null){
for (int i=0;i<runFor.length;i++){
System.out.println(" label='"+runFor[i].getLabel()+"', resource='"+runFor[i].getResource()+"'");
}
}
}
}
boolean enabled = (selectedItem != null) // At startup null (twice went through this); Right Click - "Icarus Ver..." boolean enabled = (selectedItem != null) // At startup null (twice went through this); Right Click - "Icarus Ver..."
&& (selectedResource != null) // at startup x353_1.tf; Right Click - "L/x353/x353_1.tf && (selectedResource != null) // at startup x353_1.tf; Right Click - "L/x353/x353_1.tf
&& (selectedItem.isEnabled(selectedResource)); && (selectedItem.isEnabled(selectedResource));
launchAction.setEnabled(enabled); launchAction.setEnabled(enabled);
//Just trying
if (enabled){ if (enabled){
launchAction.setText(Txt.s("Action.ToolLaunch.Caption", new String[]{selectedResource.getName()})); launchAction.setText(Txt.s("Action.ToolLaunch.Caption", new String[]{selectedResource.getName()}));
launchAction.setToolTipText(Txt.s("Action.ToolLaunch.ToolTip", new String[]{selectedItem.getLabel(), selectedResource.getName()})); launchAction.setToolTipText(Txt.s("Action.ToolLaunch.ToolTip", new String[]{selectedItem.getLabel(), selectedResource.getName()}));
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
<parameter id = "SimulationTopFile" <parameter id = "SimulationTopFile"
label = "Project top simulation file" label = "Project top simulation file"
type = "FileType" type = "FileType"
default = "" default = "default_top (testing)"
format = "ValueSyntax" format = "ValueSyntax"
readonly= "false" /> readonly= "false" />
......
...@@ -129,7 +129,7 @@ ...@@ -129,7 +129,7 @@
<parameter id = "SimulationTopFile" <parameter id = "SimulationTopFile"
label = "Project top simulation file" label = "Project top simulation file"
type = "FileType" type = "FileType"
default = "" default = "default_top (testing)"
format = "ValueSyntax" format = "ValueSyntax"
readonly= "false" /> readonly= "false" />
...@@ -177,9 +177,10 @@ ...@@ -177,9 +177,10 @@
</extensions-list> </extensions-list>
<action-menu> <action-menu>
<option label="Simulate" resource="%SimulationTopFile" /> <action label="Simulate" resource="%SimulationTopFile" />
<option label="Simulate" resource="%%SelectedFile" /> <action label="Simulate for" resource="%%CurrentFile" />
<option label="Just try for" resource="%%OS" /> <action label="Empty" resource="" />
<action label="Just try for" resource="%%OS" />
</action-menu> </action-menu>
...@@ -190,6 +191,7 @@ ...@@ -190,6 +191,7 @@
default = "-c" default = "-c"
readonly = "false" readonly = "false"
visible = "true"/> visible = "true"/>
<!-- Intentional error: No, does not detect duplicates yet-->
<parameter id = "Param_PreExe" <parameter id = "Param_PreExe"
label = "Param_PreExe" label = "Param_PreExe"
...@@ -302,6 +304,7 @@ ...@@ -302,6 +304,7 @@
<input> <input>
<group name="files" label="Files"> <group name="files" label="Files">
<!-- "SimulationTopFile" -->
"Param_PreExe" "Param_PreExe"
"Param_Exe" "Param_Exe"
"Param_Shell_Options" "Param_Shell_Options"
...@@ -319,14 +322,12 @@ ...@@ -319,14 +322,12 @@
<!-- "SourceList" --> <!-- "SourceList" -->
</group> </group>
</input> </input>
<output> <output>
<line name="command_line" sep=" "> <line name="command_line" sep=" ">
"%Param_Shell_Options" "%Param_Shell_Options"
"echo BuildDir=%BuildDir ;" "echo BuildDir=%BuildDir ;"
"echo SimulationTopFile=%SimulationTopFile ;" "echo SimulationTopFile=%SimulationTopFile ;"
"echo SimulationTopModule=%SimulationTopModule ;" "echo SimulationTopModule=%SimulationTopModule ;"
"echo BuildDir=%BuildDir ;"
"%Param_PreExe" "%Param_PreExe"
"%Param_Exe" "%Param_Exe"
"%Param_TopModule" "%Param_TopModule"
...@@ -344,7 +345,7 @@ ...@@ -344,7 +345,7 @@
</output> </output>
</tool> </tool>
<!-- "echo %SimulationTopFile %%SelectedFile ;" --> <!-- "echo %SimulationTopFile %%CurrentFile ;" -->
<!-- <!--
"-s counter_tb" "-s counter_tb"
"%SourceList" --> "%SourceList" -->
......
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