Commit f88dd96e authored by Andrey Filippov's avatar Andrey Filippov

Implemented multiple-choice launch actions

parent 216443b3
...@@ -145,5 +145,6 @@ public class VDT { ...@@ -145,5 +145,6 @@ public class VDT {
public static final String GENERATOR_ID_CURRENT_FILE = "CurrentFile"; public static final String GENERATOR_ID_CURRENT_FILE = "CurrentFile";
public static final String GENERATOR_ID_SELECTED_FILE = "SelectedFile"; public static final String GENERATOR_ID_SELECTED_FILE = "SelectedFile";
public static final String GENERATOR_ID_CURRENT_BASE = "CurrentFileBase"; public static final String GENERATOR_ID_CURRENT_BASE = "CurrentFileBase";
public static final String GENERATOR_ID_CHOSEN_ACTION = "ChosenActionIndex";
public static final String GENERATOR_ID_OS_NAME = "OS"; public static final String GENERATOR_ID_OS_NAME = "OS";
} // class VDT } // class VDT
...@@ -100,8 +100,8 @@ public class VerilogUtils { ...@@ -100,8 +100,8 @@ public class VerilogUtils {
* Returns the top module(s) for given verilog file. * Returns the top module(s) for given verilog file.
*/ */
public static String[] getTopModuleNames(IFile file) { public static String[] getTopModuleNames(IFile file) { //L/x353/data/vdt/workspace_11-runtime/x353/x353_1.tf
OutlineElement[] outlineElements= getTopModulesVeditor(file); OutlineElement[] outlineElements= getTopModulesVeditor(file); // empty inside
if (outlineElements==null) return null; if (outlineElements==null) return null;
String [] list = new String[outlineElements.length]; String [] list = new String[outlineElements.length];
for (int i=0;i<list.length;i++) { for (int i=0;i<list.length;i++) {
......
...@@ -73,7 +73,13 @@ public class ParamBasedOption extends Option { ...@@ -73,7 +73,13 @@ public class ParamBasedOption extends Option {
} }
public String doLoadDefault() { public String doLoadDefault() {
String value = param.getDefaultValue().get(0); String value = param.getDefaultValue(true).get(0); // Andrey: ignore faults in TopModuleName generator
doClear();
return value;
}
public String doLoadDefault(boolean menuMode) {
String value = param.getDefaultValue(menuMode).get(0);
doClear(); doClear();
return value; return value;
} }
......
...@@ -990,28 +990,29 @@ public class XMLConfig extends Config { ...@@ -990,28 +990,29 @@ public class XMLConfig extends Config {
for(Iterator<Node> n = runForNodes.iterator(); n.hasNext();) { for(Iterator<Node> n = runForNodes.iterator(); n.hasNext();) {
Node node = (Node)n.next(); Node node = (Node)n.next();
boolean checkExtension=false; // for empty resource field - do not check file or extensions
boolean checkExistence=false;
String label = getAttributeValue(node, CONTEXT_TOOL_ACTION_LABEL); String label = getAttributeValue(node, CONTEXT_TOOL_ACTION_LABEL);
if (label == null) if (label == null)
label=CONTEXT_TOOL_DFLT_ACTION_LABEL; label=CONTEXT_TOOL_DFLT_ACTION_LABEL;
String resource = getAttributeValue(node, CONTEXT_TOOL_ACTION_RESOURCE); String resource = getAttributeValue(node, CONTEXT_TOOL_ACTION_RESOURCE);
if (resource == null) if ((resource == null) || (resource.length()==0)) {
resource= CONTEXT_TOOL_DFLT_ACTION_RESOURCE; // resource= CONTEXT_TOOL_DFLT_ACTION_RESOURCE;
resource = "";
String checkExtensionAttr=getAttributeValue(node, CONTEXT_TOOL_ACTION_CHECK_EXTENSION); } else {
if (checkExtensionAttr==null){ String checkExtensionAttr=getAttributeValue(node, CONTEXT_TOOL_ACTION_CHECK_EXTENSION);
checkExtensionAttr=CONTEXT_TOOL_DFLT_ACTION_CHECK_EXTENSION; if (checkExtensionAttr==null){
} checkExtensionAttr=CONTEXT_TOOL_DFLT_ACTION_CHECK_EXTENSION;
checkBoolAttr(checkExtensionAttr, CONTEXT_TOOL_ACTION_CHECK_EXTENSION); }
boolean checkExtension=getBoolAttrValue(checkExtensionAttr); checkBoolAttr(checkExtensionAttr, CONTEXT_TOOL_ACTION_CHECK_EXTENSION);
checkExtension=getBoolAttrValue(checkExtensionAttr);
String checkExistenceAttr=getAttributeValue(node, CONTEXT_TOOL_ACTION_CHECK_EXISTENCE);
String checkExistenceAttr=getAttributeValue(node, CONTEXT_TOOL_ACTION_CHECK_EXISTENCE); if (checkExistenceAttr==null){
if (checkExistenceAttr==null){ checkExistenceAttr=CONTEXT_TOOL_DFLT_ACTION_CHECK_EXISTENCE;
checkExistenceAttr=CONTEXT_TOOL_DFLT_ACTION_CHECK_EXISTENCE; }
checkBoolAttr(checkExistenceAttr, CONTEXT_TOOL_ACTION_CHECK_EXISTENCE);
checkExistence=getBoolAttrValue(checkExistenceAttr);
} }
checkBoolAttr(checkExistenceAttr, CONTEXT_TOOL_ACTION_CHECK_EXISTENCE);
boolean checkExistence=getBoolAttrValue(checkExistenceAttr);
runForList.add(new RunFor(label, resource, checkExtension, checkExistence)); runForList.add(new RunFor(label, resource, checkExtension, checkExistence));
} }
} }
......
...@@ -31,7 +31,7 @@ public abstract class AbstractGenerator { ...@@ -31,7 +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 private boolean menuMode=false; // managing menu items, not running tool. Ignore Generator errors
public AbstractGenerator() { public AbstractGenerator() {
this(false); this(false);
...@@ -119,8 +119,11 @@ public abstract class AbstractGenerator { ...@@ -119,8 +119,11 @@ public abstract class AbstractGenerator {
return output; return output;
} }
protected void fault(String message) { protected String fault(String message) {
if (menuMode)
return "";
MessageUI.error("Generator '" + getName() + "' fault: " + message); MessageUI.error("Generator '" + getName() + "' fault: " + message);
return null;
} }
protected abstract String[] getStringValues(); protected abstract String[] getStringValues();
......
...@@ -17,8 +17,9 @@ ...@@ -17,8 +17,9 @@
*******************************************************************************/ *******************************************************************************/
package com.elphel.vdt.core.tools.generators; 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;
...@@ -31,13 +32,17 @@ public class CurrentFileBaseGenerator extends AbstractGenerator { ...@@ -31,13 +32,17 @@ public class CurrentFileBaseGenerator extends AbstractGenerator {
} }
protected String[] getStringValues() { protected String[] getStringValues() {
IResource resource = SelectedResourceManager.getDefault().getSelectedResource(); // IResource resource = SelectedResourceManager.getDefault().getSelectedResource();
String fullName=SelectedResourceManager.getDefault().getChosenTarget();
if((resource != null) && (resource.getType() == IResource.FILE)) { // if((resource != null) && (resource.getType() == IResource.FILE)) {
String fullName=((IFile)resource).getLocation().toOSString(); // String fullName=((IFile)resource).getLocation().toOSString();
if (fullName!=null){
int dot = fullName.lastIndexOf('.'); int dot = fullName.lastIndexOf('.');
return new String[] { (dot <0) ? fullName : fullName.substring(0, dot) }; return new String[] { (dot <0) ? fullName : fullName.substring(0, dot) };
} }
return new String[] { "" }; return new String[] { "" };
} }
} }
...@@ -44,12 +44,13 @@ public class CurrentFileGenerator extends AbstractGenerator { ...@@ -44,12 +44,13 @@ public class CurrentFileGenerator extends AbstractGenerator {
*/ */
protected String[] getStringValues() { protected String[] getStringValues() {
IResource resource; IResource resource;
if (getMenuMode()) resource = SelectedResourceManager.getDefault().getViewSelectedResource(IPageLayout.ID_RES_NAV); if (getMenuMode()) {
else resource = SelectedResourceManager.getDefault().getSelectedResource(); resource = SelectedResourceManager.getDefault().getViewSelectedResource(IPageLayout.ID_RES_NAV);
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() }; } else {
return new String[] { SelectedResourceManager.getDefault().getChosenTarget()};
}
return new String[] { "" }; return new String[] { "" };
} }
} }
...@@ -52,9 +52,10 @@ public class SourceListGenerator extends AbstractGenerator { ...@@ -52,9 +52,10 @@ public class SourceListGenerator extends AbstractGenerator {
protected String[] getStringValues() { protected String[] getStringValues() {
String[] file_names = null; String[] file_names = null;
IResource resource = SelectedResourceManager.getDefault().getSelectedVerilogFile(); // IResource resource = SelectedResourceManager.getDefault().getSelectedVerilogFile();
IResource resource = SelectedResourceManager.getDefault().getChosenVerilogFile();
if (resource != null && resource.getType() == IResource.FILE) { if (resource != null && resource.getType() == IResource.FILE) {
IFile[] files = VerilogUtils.getDependencies((IFile)resource); IFile[] files = VerilogUtils.getDependencies((IFile)resource); // returned just the same x353_1.tf
file_names = new String[files.length]; file_names = new String[files.length];
for (int i=0; i < files.length; i++) for (int i=0; i < files.length; i++)
file_names[i] = files[i].getProjectRelativePath().toOSString(); //.getName(); file_names[i] = files[i].getProjectRelativePath().toOSString(); //.getName();
......
...@@ -37,7 +37,8 @@ public class TopModuleNameGenerator extends AbstractGenerator { ...@@ -37,7 +37,8 @@ public class TopModuleNameGenerator extends AbstractGenerator {
return NAME; return NAME;
} }
protected String[] getStringValues() { protected String[] getStringValues() {
IResource resource = SelectedResourceManager.getDefault().getSelectedVerilogFile(); // IResource resource = SelectedResourceManager.getDefault().getSelectedVerilogFile();
IResource resource = SelectedResourceManager.getDefault().getChosenVerilogFile();
if ((resource != null) && (resource.getType() == IResource.FILE)) { if ((resource != null) && (resource.getType() == IResource.FILE)) {
String[] outlineElementsNames= VerilogUtils.getTopModuleNames((IFile)resource); String[] outlineElementsNames= VerilogUtils.getTopModuleNames((IFile)resource);
if ((outlineElementsNames!=null) && (outlineElementsNames.length>0)) return new String[] {outlineElementsNames[0]}; if ((outlineElementsNames!=null) && (outlineElementsNames.length>0)) return new String[] {outlineElementsNames[0]};
......
...@@ -45,7 +45,8 @@ public class TopModulesNameGenerator extends AbstractGenerator { ...@@ -45,7 +45,8 @@ public class TopModulesNameGenerator extends AbstractGenerator {
return NAME; return NAME;
} }
protected String[] getStringValues() { protected String[] getStringValues() {
IResource resource = SelectedResourceManager.getDefault().getSelectedVerilogFile(); // IResource resource = SelectedResourceManager.getDefault().getSelectedVerilogFile();
IResource resource = SelectedResourceManager.getDefault().getChosenVerilogFile();
if ((resource != null) && (resource.getType() == IResource.FILE)) { if ((resource != null) && (resource.getType() == IResource.FILE)) {
String[] outlineElementsNames= VerilogUtils.getTopModuleNames((IFile)resource); String[] outlineElementsNames= VerilogUtils.getTopModuleNames((IFile)resource);
if ((outlineElementsNames!=null) && (outlineElementsNames.length>0)) return outlineElementsNames; if ((outlineElementsNames!=null) && (outlineElementsNames.length>0)) return outlineElementsNames;
......
...@@ -122,9 +122,11 @@ public class Parameter implements Cloneable, Updateable { ...@@ -122,9 +122,11 @@ 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 if (id.equals("SimulationTopFile")){ // Andrey
System.out.println("Creating parameter SimulationTopFile, defaultValue="+defaultValue); System.out.println("Creating parameter SimulationTopFile, defaultValue="+defaultValue);
} }
*/
} }
protected Parameter(Parameter param) { protected Parameter(Parameter param) {
this(param.id, this(param.id,
...@@ -167,10 +169,11 @@ public class Parameter implements Cloneable, Updateable { ...@@ -167,10 +169,11 @@ public class Parameter implements Cloneable, Updateable {
this.context = context; this.context = context;
*/ */
/*
if (id.equals("SimulationTopFile")){ // Andrey if (id.equals("SimulationTopFile")){ // Andrey
System.out.println("Initializing parameter SimulationTopFile, defaultValue="+defaultValue); System.out.println("Initializing parameter SimulationTopFile, defaultValue="+defaultValue);
} }
*/
// Andrey: replacing with // Andrey: replacing with
if(this.context == context) { if(this.context == context) {
...@@ -312,9 +315,9 @@ public class Parameter implements Cloneable, Updateable { ...@@ -312,9 +315,9 @@ 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 // if (id.equals("SimulationTopFile")){ // Andrey
System.out.println("setCurrentValue() SimulationTopFile, value="+value); // 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");
...@@ -328,9 +331,9 @@ public class Parameter implements Cloneable, Updateable { ...@@ -328,9 +331,9 @@ 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 // if (id.equals("SimulationTopFile")){ // Andrey
System.out.println("setCurrentValue() SimulationTopFile a list value"); // 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");
...@@ -352,8 +355,11 @@ public class Parameter implements Cloneable, Updateable { ...@@ -352,8 +355,11 @@ public class Parameter implements Cloneable, Updateable {
return currentValue; return currentValue;
} }
public List<String> getDefaultValue() { public List<String> getDefaultValue() {
return getDefaultValue(false);
}
public List<String> getDefaultValue(boolean menuMode) {
String resolvedDefaultValue = ConditionUtils.resolveContextCondition(context, defaultValue); String resolvedDefaultValue = ConditionUtils.resolveContextCondition(context, defaultValue);
String errmsg = "Parameter '" + id + String errmsg = "Parameter '" + id +
"' of context '" + context.getName() + "' of context '" + context.getName() +
...@@ -363,7 +369,7 @@ public class Parameter implements Cloneable, Updateable { ...@@ -363,7 +369,7 @@ public class Parameter implements Cloneable, Updateable {
FormatProcessor processor = new FormatProcessor(new Recognizer[] { FormatProcessor processor = new FormatProcessor(new Recognizer[] {
//new RepeaterRecognizer(), //new RepeaterRecognizer(),
new SimpleGeneratorRecognizer(), new SimpleGeneratorRecognizer(menuMode),
new ContextParamRecognizer(context) new ContextParamRecognizer(context)
}); });
...@@ -386,10 +392,11 @@ public class Parameter implements Cloneable, Updateable { ...@@ -386,10 +392,11 @@ 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 if (id.equals("SimulationTopFile")){ // Andrey
System.out.println("getValue() SimulationTopFile"); System.out.println("getValue() SimulationTopFile");
} }
*/
if(!currentValue.isEmpty()) if(!currentValue.isEmpty())
return currentValue; return currentValue;
...@@ -399,10 +406,11 @@ public class Parameter implements Cloneable, Updateable { ...@@ -399,10 +406,11 @@ 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 if (id.equals("SimulationTopFile")){ // Andrey
System.out.println("getExternalValueForm() SimulationTopFile"); 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();) {
......
...@@ -44,6 +44,7 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -44,6 +44,7 @@ public class Tool extends Context implements Cloneable, Inheritable {
private List<String> extensions; private List<String> extensions;
private List<RunFor> runfor; private List<RunFor> runfor;
private int choice; // selected variant for runfor
private Tool baseTool; private Tool baseTool;
...@@ -94,11 +95,19 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -94,11 +95,19 @@ public class Tool extends Context implements Cloneable, Inheritable {
this.toolErrors = toolErrors; this.toolErrors = toolErrors;
this.toolWarnings = toolWarnings; this.toolWarnings = toolWarnings;
this.toolInfo = toolInfo; this.toolInfo = toolInfo;
this.choice=0;
} }
public List<RunFor> getRunFor(){ public List<RunFor> getRunFor(){
return runfor; return runfor;
} }
public int getChoice(){
return choice;
}
public void setChoice(int choice){
this.choice=choice;
}
public void init(Config config) throws ConfigException { public void init(Config config) throws ConfigException {
if(initialized) if(initialized)
...@@ -231,7 +240,7 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -231,7 +240,7 @@ public class Tool extends Context implements Cloneable, Inheritable {
public RunFor[] getMenuActions(IProject project) { public RunFor[] getMenuActions(IProject project) {
if(runfor == null) if(runfor == null)
return null; return null;
updateContextOptions (project); // Fill in parameters updateContextOptions(project); // Fill in parameters - it parses here too - at least some parameters? (not in menu mode)
// Can be two different processors for labels and resources // Can be two different processors for labels and resources
//SimpleGeneratorRecognizer(true) may be not needed, as current file is already set here //SimpleGeneratorRecognizer(true) may be not needed, as current file is already set here
...@@ -277,27 +286,46 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -277,27 +286,46 @@ public class Tool extends Context implements Cloneable, Inheritable {
PackageContext packageContext = getParentPackage(); PackageContext packageContext = getParentPackage();
if (packageContext != null) { if (packageContext != null) {
OptionsCore.doLoadContextOptions(packageContext); OptionsCore.doLoadContextOptions(packageContext);
/*
try { try {
packageContext.buildParams(); packageContext.buildParams();
} catch (ToolException e) { // Do nothing here } catch (ToolException e) { // Do nothing here
System.out.println("updateContextOptions ToolException for Package Context="+e.getMessage()); System.out.println("updateContextOptions ToolException for Package Context="+e.getMessage());
} catch (NullPointerException e) { // Do nothing here Or make it "finally" to ignore all parameters parsing here?
System.out.println("updateContextOptions NullPointerException for Package Context="+e.getMessage());
} finally {
System.out.println("updateContextOptions for Package Context - other error");
} }
*/
} }
Context context = getParentProject(); Context context = getParentProject();
if (context != null) { if (context != null) {
OptionsCore.doLoadContextOptions(context, project); OptionsCore.doLoadContextOptions(context, project);
/*
try { try {
context.buildParams(); context.buildParams();
} catch (ToolException e) { // Do nothing here } catch (ToolException e) { // Do nothing here Or make it "finally" to ignore all parameters parsing here?
System.out.println("updateContextOptions ToolException for Project Context="+e.getMessage()); System.out.println("updateContextOptions ToolException for Project Context="+e.getMessage());
} catch (NullPointerException e) { // Do nothing here Or make it "finally" to ignore all parameters parsing here?
System.out.println("updateContextOptions NullPointerException for Project Context="+e.getMessage());
} finally {
System.out.println("updateContextOptions for Project Context - other error");
} }
*/
} }
//NullPointerException
OptionsCore.doLoadContextOptions(this, project); OptionsCore.doLoadContextOptions(this, project);
/*
try { try {
buildParams(); buildParams();
} catch (ToolException e) { // Do nothing here } catch (ToolException e) { // Do nothing here
System.out.println("updateContextOptions ToolException for Tool Context="+e.getMessage()); System.out.println("updateContextOptions ToolException for Tool Context="+e.getMessage());
} catch (NullPointerException e) { // Do nothing here Or make it "finally" to ignore all parameters parsing here?
System.out.println("updateContextOptions NullPointerException for Tool Context="+e.getMessage());
} finally {
System.out.println("updateContextOptions for Tool Context - other error");
} }
*/
} }
...@@ -321,10 +349,11 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -321,10 +349,11 @@ public class Tool extends Context implements Cloneable, Inheritable {
* processing that inheritance is ignored * processing that inheritance is ignored
*/ */
// if(param != null) // Was before the change described above // if(param != null) // Was before the change described above
/*
if ((param != null) &&(param.getID().equals("SimulationTopFile"))){ // Andrey if ((param != null) &&(param.getID().equals("SimulationTopFile"))){ // Andrey
System.out.println("Initializing parameter SimulationTopFile, isChild="+param.getIsChild()); System.out.println("Initializing parameter SimulationTopFile, isChild="+param.getIsChild());
} }
*/
if ((param != null) && !param.getIsChild()) if ((param != null) && !param.getIsChild())
return param; return param;
......
...@@ -30,9 +30,10 @@ public class SimpleGeneratorRecognizer implements Recognizer { ...@@ -30,9 +30,10 @@ public class SimpleGeneratorRecognizer implements Recognizer {
new ProjectNameGenerator(), new ProjectNameGenerator(),
new ProjectPathGenerator(), new ProjectPathGenerator(),
new TopModuleNameGenerator(), new TopModuleNameGenerator(),
new SelectedFileGenerator(),
new CurrentFileGenerator(), new CurrentFileGenerator(),
// new ViewSelectedFileGenerator(), new CurrentFileBaseGenerator(),
new CurrentFileBaseGenerator() new ChosenActionGenerator()
}; };
public SimpleGeneratorRecognizer(){ public SimpleGeneratorRecognizer(){
......
...@@ -44,6 +44,7 @@ public class RunFor implements Cloneable{ ...@@ -44,6 +44,7 @@ public class RunFor implements Cloneable{
public String getResource(){ public String getResource(){
return resource; return resource;
} }
public boolean getCheckExtension(){ public boolean getCheckExtension(){
return checkExtension; return checkExtension;
} }
......
...@@ -21,10 +21,14 @@ import java.util.Stack; ...@@ -21,10 +21,14 @@ import java.util.Stack;
import com.elphel.vdt.VerilogUtils; import com.elphel.vdt.VerilogUtils;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.IStructuredSelection;
...@@ -58,6 +62,10 @@ public class SelectedResourceManager implements IWindowListener, ISelectionListe ...@@ -58,6 +62,10 @@ public class SelectedResourceManager implements IWindowListener, ISelectionListe
private ITextSelection fSelectedText = null; private ITextSelection fSelectedText = null;
private Stack<IWorkbenchWindow> fWindowStack = new Stack<IWorkbenchWindow>(); private Stack<IWorkbenchWindow> fWindowStack = new Stack<IWorkbenchWindow>();
//Andrey
private String fChosenTarget=null; // full path of the chosen (for action) resource or any string. Used to calculate CurrentFile, verilog file, ...
private IResource fChosenVerilogFile = null; // to keep fSelectedVerilogFile
private int fChosenAction=0; // Chosen variant of running the tool
private SelectedResourceManager() { private SelectedResourceManager() {
IWorkbench workbench = PlatformUI.getWorkbench(); IWorkbench workbench = PlatformUI.getWorkbench();
...@@ -204,6 +212,7 @@ public class SelectedResourceManager implements IWindowListener, ISelectionListe ...@@ -204,6 +212,7 @@ public class SelectedResourceManager implements IWindowListener, ISelectionListe
* @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
*/ */
public void selectionChanged(IWorkbenchPart part, ISelection selection) { public void selectionChanged(IWorkbenchPart part, ISelection selection) {
// System.out.println("SelectedResourceManager.selectionChanged()");
IWorkbenchWindow window = part.getSite().getWorkbenchWindow(); IWorkbenchWindow window = part.getSite().getWorkbenchWindow();
if (fWindowStack.isEmpty() || !fWindowStack.peek().equals(window)) { if (fWindowStack.isEmpty() || !fWindowStack.peek().equals(window)) {
// selection is not in the active window // selection is not in the active window
...@@ -212,15 +221,54 @@ public class SelectedResourceManager implements IWindowListener, ISelectionListe ...@@ -212,15 +221,54 @@ public class SelectedResourceManager implements IWindowListener, ISelectionListe
IResource selectedResource = getSelectedResource(part, selection); IResource selectedResource = getSelectedResource(part, selection);
if (selectedResource != null) { if (selectedResource != null) {
fSelectedResource = selectedResource; fSelectedResource = selectedResource;
if ((selectedResource.getType()==IResource.FILE) && (VerilogUtils.isHhdlFile((IFile)fSelectedResource))) // System.out.println("SelectedResourceManager.selectionChanged(): fSelectedResource changed to "+fSelectedResource.getName());
// if (selectedResource.getName().endsWith(".v"))
if ((selectedResource.getType()==IResource.FILE) && (VerilogUtils.isHhdlFile((IFile)fSelectedResource))){
fSelectedVerilogFile = selectedResource; /* Maybe same will work for vhdl too? */ fSelectedVerilogFile = selectedResource; /* Maybe same will work for vhdl too? */
// System.out.println("SelectedResourceManager.selectionChanged(): fSelectedVerilogFile changed to "+fSelectedVerilogFile.getName());
}
} }
if (selection instanceof ITextSelection) { if (selection instanceof ITextSelection) {
fSelectedText = (ITextSelection)selection; fSelectedText = (ITextSelection)selection;
} }
} // selectionChanged() } // selectionChanged()
//TODO: Make them project-relative
public String tryRelativePath(String path){
if (path==null)
return null;
if (getSelectedProject()==null) return path;
IProject project=getSelectedProject();
if (path.startsWith(project.getLocation().toString()))
return path.substring(project.getLocation().toString().length()+1);
return path;
}
public void updateActionChoice(String chosenTarget, int choice){
fChosenAction=choice;
fChosenTarget=tryRelativePath(chosenTarget);
IProject project=getSelectedProject();
if (project==null) return;
IPath path = new Path(fChosenTarget);
IFile file = (path==null)?null:project.getFile(path);
if ((file != null) && (VerilogUtils.isHhdlFile(file)))
fChosenVerilogFile=file;
else if (fChosenVerilogFile==null)
fChosenVerilogFile=fSelectedVerilogFile;
}
public String getChosenTarget() {
return fChosenTarget;
}
public IResource getChosenVerilogFile() {
return (fChosenVerilogFile!=null)?fChosenVerilogFile:fSelectedVerilogFile;
}
public int getChosenAction() {
return fChosenAction;
}
/** /**
......
...@@ -88,7 +88,8 @@ public class VerilogResolver implements IDynamicVariableResolver { ...@@ -88,7 +88,8 @@ public class VerilogResolver implements IDynamicVariableResolver {
* @throws CoreException if there is no selection * @throws CoreException if there is no selection
*/ */
protected IResource getSelectedResource(IDynamicVariable variable) throws CoreException { protected IResource getSelectedResource(IDynamicVariable variable) throws CoreException {
IResource resource = SelectedResourceManager.getDefault().getSelectedVerilogFile(); // IResource resource = SelectedResourceManager.getDefault().getSelectedVerilogFile();
IResource resource = SelectedResourceManager.getDefault().getChosenVerilogFile();
if (resource == null) { if (resource == null) {
abort(Txt.s("Error.Variable.Verilog.NoSelection", new String[]{getReferenceExpression(variable, null)}), null); abort(Txt.s("Error.Variable.Verilog.NoSelection", new String[]{getReferenceExpression(variable, null)}), null);
} }
......
...@@ -29,10 +29,12 @@ import org.eclipse.jface.action.*; ...@@ -29,10 +29,12 @@ import org.eclipse.jface.action.*;
import org.eclipse.ui.*; import org.eclipse.ui.*;
import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import com.elphel.vdt.core.Utils; import com.elphel.vdt.core.Utils;
...@@ -48,6 +50,7 @@ import com.elphel.vdt.Txt; ...@@ -48,6 +50,7 @@ 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.veditor.preference.PreferenceStrings;
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;
...@@ -86,9 +89,9 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -86,9 +89,9 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
private TreeViewer viewer; private TreeViewer viewer;
private DrillDownAdapter drillDownAdapter; private DrillDownAdapter drillDownAdapter;
private Action showLaunchConfigAction; private Action showLaunchConfigAction;
private Action launchAction; // private Action launchAction;
private Action [] launchActions;
private Action showInstallationPropertiesAction; private Action showInstallationPropertiesAction;
private ClearAction clearInstallationPropertiesAction; private ClearAction clearInstallationPropertiesAction;
...@@ -116,6 +119,9 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -116,6 +119,9 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
private IMemento memento; private IMemento memento;
IDoubleClickListener doubleClickListener=null;
private Action [] launchActions;
/** /**
* The constructor. * The constructor.
*/ */
...@@ -162,7 +168,7 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -162,7 +168,7 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
makeActions(); makeActions();
hookContextMenu(); hookContextMenu();
hookDoubleClickAction(); /**+ hookDoubleClickAction(); */
contributeToActionBars(); contributeToActionBars();
if (memento != null) if (memento != null)
...@@ -183,7 +189,7 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -183,7 +189,7 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
viewer.setInput(designMenu); viewer.setInput(designMenu);
List<Context> packages = ToolsCore.getDesignMenuManager().getPackageContexts(designMenu); List<Context> packages = ToolsCore.getDesignMenuManager().getPackageContexts(designMenu);
showPackagePropertiesToolbarAction.setContexts(packages); showPackagePropertiesToolbarAction.setContexts(packages);
clearPackagePropertiesAction.setContexts(packages); clearPackagePropertiesAction.setContexts(packages); // toolBarSeparator already null here
List<Context> projects = ToolsCore.getDesignMenuManager().getProjectContexts(designMenu); List<Context> projects = ToolsCore.getDesignMenuManager().getProjectContexts(designMenu);
showProjectPropertiesToolbarAction.setContexts(projects); showProjectPropertiesToolbarAction.setContexts(projects);
clearProjectPropertiesAction.setContexts(projects); clearProjectPropertiesAction.setContexts(projects);
...@@ -198,13 +204,12 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -198,13 +204,12 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
} }
} }
private void hookContextMenu() { private void hookContextMenu() {
MenuManager menuMgr = new MenuManager("#PopupMenu"); MenuManager menuMgr = new MenuManager("#PopupMenu");
menuMgr.setRemoveAllWhenShown(true); menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() { menuMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) { public void menuAboutToShow(IMenuManager manager) {
DesignFlowView.this.fillContextMenu(manager); DesignFlowView.this.fillContextMenu(manager); // context (right-click) menu
} }
}); });
Menu menu = menuMgr.createContextMenu(viewer.getControl()); Menu menu = menuMgr.createContextMenu(viewer.getControl());
...@@ -212,13 +217,15 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -212,13 +217,15 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
getSite().registerContextMenu(menuMgr, viewer); getSite().registerContextMenu(menuMgr, viewer);
} }
//
private void contributeToActionBars() { private void contributeToActionBars() {
IActionBars bars = getViewSite().getActionBars(); IActionBars bars = getViewSite().getActionBars();
fillLocalPullDown(bars.getMenuManager()); fillLocalPullDown(bars.getMenuManager()); // rightmost pull-down
fillLocalToolBar(bars.getToolBarManager()); fillLocalToolBar(bars.getToolBarManager()); // horizontal bar
} }
private void fillLocalPullDown(IMenuManager manager) { private void fillLocalPullDown(IMenuManager manager) { //rightmost pull-down
manager.add(clearInstallationPropertiesAction); manager.add(clearInstallationPropertiesAction);
manager.add(clearPackagePropertiesAction); manager.add(clearPackagePropertiesAction);
manager.add(clearProjectPropertiesAction); manager.add(clearProjectPropertiesAction);
...@@ -226,19 +233,21 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -226,19 +233,21 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
manager.add(new Separator()); manager.add(new Separator());
manager.add(selectDesignMenuAction); manager.add(selectDesignMenuAction);
} }
private void fillContextMenu(IMenuManager manager) { private void fillContextMenu(IMenuManager manager) { // context (right-click) menu
// Always come here after setting launchActions, so just add all launchActions here
/**+ manager.add(launchAction); */
manager.add(launchAction); if (launchActions!=null) {
for (Action action:launchActions){
// manager.add(new Separator()); // test manager.add(action); // No Separator??
// manager.add(launchAction); // test }
}
System.out.println("fillContextMenu(), launchActions="+launchActions);
// manager.add(new Separator()); // manager.add(new Separator());
// drillDownAdapter.addNavigationActions(manager); // drillDownAdapter.addNavigationActions(manager);
// Other plug-ins can contribute their actions here // Other plug-ins can contribute their actions here
manager.add(new Separator()); manager.add(new Separator());
manager.add(showInstallationPropertiesAction); manager.add(showInstallationPropertiesAction);
manager.add(showPackagePropertiesAction); manager.add(showPackagePropertiesAction);
manager.add(showProjectAction); manager.add(showProjectAction);
...@@ -248,18 +257,26 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -248,18 +257,26 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
} }
private void fillLocalToolBar(IToolBarManager manager) { // On Horizontal bar private void fillLocalToolBar(IToolBarManager manager) { // On Horizontal bar
manager.add(launchAction); /**+ manager.add(launchAction); */
if (launchActions!=null) {
for (Action action:launchActions){
manager.add(action); // No Separator??
}
}
// System.out.println("fillLocalToolBar(), launchActions="+launchActions);
// manager.add(launchAction); // test // manager.add(launchAction); // test
// manager.add(new Separator()); // manager.add(new Separator());
// drillDownAdapter.addNavigationActions(manager); // drillDownAdapter.addNavigationActions(manager);
manager.add(new Separator()); manager.add(new Separator("toolbar-separator"));
manager.add(showInstallationPropertiesAction); manager.add(showInstallationPropertiesAction);
manager.add(showPackagePropertiesToolbarAction); manager.add(showPackagePropertiesToolbarAction);
manager.add(showProjectPropertiesToolbarAction); manager.add(showProjectPropertiesToolbarAction);
manager.add(showPropertiesAction); manager.add(showPropertiesAction);
// manager.add(showLaunchConfigAction); manager.update(false); // (force) - added new, but removed project, tool and clear/change menu for Icarus (kept the same number of items) Need to update higher menu
getViewSite().getActionBars().updateActionBars();
} }
private void makeActions() { private void makeActions() {
showInstallationPropertiesAction = new Action() { showInstallationPropertiesAction = new Action() {
public void run() { public void run() {
...@@ -360,13 +377,16 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -360,13 +377,16 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
} }
}; };
showLaunchConfigAction.setText("Launch configuration"); showLaunchConfigAction.setText("Launch configuration");
showLaunchConfigAction.setToolTipText("Open launch configuration dialog for this tool"+" ** DBG **"); showLaunchConfigAction.setToolTipText("Open launch configuration dialog for this tool");
showLaunchConfigAction.setImageDescriptor(VDTPluginImages.DESC_LAUNCH_CONFIG); showLaunchConfigAction.setImageDescriptor(VDTPluginImages.DESC_LAUNCH_CONFIG);
launchActions=null;
doubleClickListener=null;
/**+
launchAction = new Action() { launchAction = new Action() {
public void run() { public void run() {
try { try {
launchTool(selectedItem); launchTool(selectedItem,0);
} catch (Exception e) { } catch (Exception e) {
MessageUI.error( Txt.s("Action.ToolLaunch.Error", MessageUI.error( Txt.s("Action.ToolLaunch.Error",
new String[] {selectedItem.getLabel(), e.getMessage()}) new String[] {selectedItem.getLabel(), e.getMessage()})
...@@ -374,22 +394,42 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -374,22 +394,42 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
} }
} }
}; };
launchAction.setText(Txt.s("Action.ToolLaunch.Caption.Default")); launchAction.setText(Txt.s("Action.ToolLaunch.Caption.Default"));
launchAction.setToolTipText(Txt.s("Action.ToolLaunch.ToolTip.Default")+" **DEBUGGING**"); launchAction.setToolTipText(Txt.s("Action.ToolLaunch.ToolTip.Default")+" **DEBUGGING**");
launchAction.setImageDescriptor(VDTPluginImages.DESC_RUN_TOOL); launchAction.setImageDescriptor(VDTPluginImages.DESC_RUN_TOOL);
launchAction.setEnabled(false); launchAction.setEnabled(false);
*/
// launchAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages(). // launchAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
// getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK)); // getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
} // makeActions() } // makeActions()
private void removeDoubleClickAction() {
if (doubleClickListener!=null){
viewer.removeDoubleClickListener(doubleClickListener);
doubleClickListener=null;
}
}
private void hookDoubleClickAction() { private void hookDoubleClickAction() {
viewer.addDoubleClickListener(new IDoubleClickListener() { if ((launchActions==null) || (launchActions[0]==null)) return;
public void doubleClick(DoubleClickEvent event) { doubleClickListener=new IDoubleClickListener() {
launchAction.run(); public void doubleClick(DoubleClickEvent event) {
} launchActions[0].run(); // Andrey: will go to launchAction[0].run
}); }
};
viewer.addDoubleClickListener(doubleClickListener);
} }
/**+
private void hookDoubleClickAction() {
viewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
launchAction.run(); // Andrey: will go to launchAction[0].run
}
});
}
*/
// private void showMessage(String message) { // private void showMessage(String message) {
// MessageDialog.openInformation( viewer.getControl().getShell() // MessageDialog.openInformation( viewer.getControl().getShell()
// , "Design Flow" // , "Design Flow"
...@@ -415,6 +455,8 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -415,6 +455,8 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
/* Method declared on ISelectionListener */ /* Method declared on ISelectionListener */
public void selectionChanged(IWorkbenchPart part, ISelection selection) { public void selectionChanged(IWorkbenchPart part, ISelection selection) {
// System.out.println("DesignFlowView.selectionChanged()");
IResource oldSelection = selectedResource; IResource oldSelection = selectedResource;
selectedResource = SelectedResourceManager.getDefault().getSelectedResource(part, selection); selectedResource = SelectedResourceManager.getDefault().getSelectedResource(part, selection);
IProject newProject = selectedResource == null IProject newProject = selectedResource == null
...@@ -430,6 +472,8 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -430,6 +472,8 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
} // selectionChanged() } // selectionChanged()
private void updateLaunchAction() { private void updateLaunchAction() {
// System.out.println("DesignFlowView.updateLaunchAction()");
IProject project = selectedResource == null IProject project = selectedResource == null
? null ? null
: selectedResource.getProject(); : selectedResource.getProject();
...@@ -438,33 +482,97 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -438,33 +482,97 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
// Selected item should be not null, but resource - may be // Selected item should be not null, but resource - may be
// RunFor[] getMenuActions() // RunFor[] getMenuActions()
RunFor [] runFor=null;
if (selectedItem != null){ if (selectedItem != null){
Tool tool= selectedItem.getTool(); Tool tool= selectedItem.getTool();
if (tool!=null){ if (tool!=null){
RunFor [] runFor=tool.getMenuActions(project); runFor=tool.getMenuActions(project);
System.out.println("Got Runfor["+((runFor!=null)?runFor.length:"null")+"]"); if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER)) {
if (runFor!=null){ System.out.println("Got Runfor["+((runFor!=null)?runFor.length:"null")+"]");
for (int i=0;i<runFor.length;i++){ if (runFor!=null){
System.out.println( for (int i=0;i<runFor.length;i++){
" label='"+runFor[i].getLabel()+ System.out.println(
"', resource='"+runFor[i].getResource()+ " label='"+runFor[i].getLabel()+
"', checkExtension='"+runFor[i].getCheckExtension()+ "', resource='"+runFor[i].getResource()+
"', checkExistence='"+runFor[i].getCheckExistence()+ "', checkExtension='"+runFor[i].getCheckExtension()+
"'"); "', checkExistence='"+runFor[i].getCheckExistence()+
"'");
}
} }
} }
} }
} }
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));
// Deal with new menus
// removeLaunchActions();
removeDoubleClickAction();
launchActions=null;
if ((runFor!=null) && (project!=null)){
launchActions=new Action [runFor.length];
for (int i=0;i<runFor.length;i++){
// String name=runFor[i].getResource();
String name=SelectedResourceManager.getDefault().tryRelativePath(runFor[i].getResource());
String shortName=name;
String fullPath=name;
enabled=(selectedItem != null);
if (enabled && runFor[i].getCheckExistence()){
IPath path = new Path(name);
IFile file = (path==null)?null:project.getFile(path);
if (file==null){
// System.out.println(name+" does not exist");
enabled=false;
} else {
shortName=file.getName();
// fullPath=file.getFullPath().toString(); // What is different?
fullPath=file.getLocation().toOSString(); // that matches generators
}
}
if (enabled && runFor[i].getCheckExtension()){
enabled= selectedItem.isEnabled(name);
if (enabled && !runFor[i].getCheckExistence()) { // try to get resource and full path name, but no error if it fails
IPath path = new Path(name);
IFile file = (path==null)?null:project.getFile(path);
if (file!=null){
shortName=file.getName();
// fullPath=file.getFullPath().toString(); // What is different?
fullPath=file.getLocation().toOSString(); // that matches generators
}
}
}
final int finalI=i;
final String fFullPath=fullPath;
launchActions[i] = new Action() {
public void run() {
try {
launchTool(selectedItem,finalI,fFullPath);
} catch (Exception e) {
MessageUI.error( Txt.s("Action.ToolLaunch.Error",
new String[] {selectedItem.getLabel(), e.getMessage()})
, e);
}
}
};
launchActions[i].setToolTipText(i+": "+runFor[i].getLabel()+" "+shortName);
launchActions[i].setText(runFor[i].getLabel()+" "+shortName);
launchActions[i].setEnabled(enabled);
launchActions[i].setImageDescriptor(VDTPluginImages.DESC_RUN_TOOL);
}
IToolBarManager toolbarManager= getViewSite().getActionBars().getToolBarManager();
toolbarManager.removeAll();
fillLocalToolBar(toolbarManager);
hookDoubleClickAction();
}
/**+
launchAction.setEnabled(enabled); launchAction.setEnabled(enabled);
if (enabled){ if (enabled){
/* Andrey: Next apperas on right-click (context) menu for selected tool */ // Andrey: Next appears on right-click (context) menu for selected tool
launchAction.setText(Txt.s("Action.ToolLaunch.Caption", new String[]{selectedResource.getName()})+"<<<<<"); launchAction.setText(Txt.s("Action.ToolLaunch.Caption", new String[]{selectedResource.getName()})+"<<<<<");
/* Andrey: below sets tooltip on the horizontal bar */ // Andrey: below sets tooltip on the horizontal bar
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()}));
Tool tool = selectedItem.getTool(); Tool tool = selectedItem.getTool();
if (tool!=null){ if (tool!=null){
...@@ -475,7 +583,7 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -475,7 +583,7 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
launchAction.setText(Txt.s("Action.ToolLaunch.Caption.Default")); launchAction.setText(Txt.s("Action.ToolLaunch.Caption.Default"));
launchAction.setToolTipText(Txt.s("Action.ToolLaunch.ToolTip.Default")); launchAction.setToolTipText(Txt.s("Action.ToolLaunch.ToolTip.Default"));
} }
*/
enabled = (selectedItem != null) enabled = (selectedItem != null)
&& (selectedResource != null) && (selectedResource != null)
&& (selectedItem.getPackageContext() != null); && (selectedItem.getPackageContext() != null);
...@@ -509,14 +617,17 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -509,14 +617,17 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
showPropertiesAction.setEnabled(enabled); showPropertiesAction.setEnabled(enabled);
clearToolPropertiesAction.setEnabled(enabled); clearToolPropertiesAction.setEnabled(enabled);
} // updateLaunchAction() } // updateLaunchAction()
private void launchTool(DesignMenuModel.Item item) throws CoreException { private void launchTool(DesignMenuModel.Item item, int choice, String fullPath) throws CoreException {
Tool tool = selectedItem.getTool(); Tool tool = selectedItem.getTool();
if (tool != null) { if (tool != null) {
tool.setChoice(0);
SelectedResourceManager.getDefault().updateActionChoice(fullPath, choice); // Andrey
LaunchCore.launch( tool LaunchCore.launch( tool
, selectedResource.getProject() , selectedResource.getProject()
, selectedResource.getFullPath().toString() ); // , selectedResource.getFullPath().toString() );
, fullPath);
} else if (selectedItem.hasChildren()) { } else if (selectedItem.hasChildren()) {
if (viewer.getExpandedState(selectedItem)) if (viewer.getExpandedState(selectedItem))
viewer.collapseToLevel(selectedItem, AbstractTreeViewer.ALL_LEVELS); viewer.collapseToLevel(selectedItem, AbstractTreeViewer.ALL_LEVELS);
......
...@@ -81,6 +81,9 @@ public class DesignMenuModel { ...@@ -81,6 +81,9 @@ public class DesignMenuModel {
public boolean isEnabled(IResource resource) { public boolean isEnabled(IResource resource) {
return false; return false;
} }
public boolean isEnabled(String path) {
return false;
}
public Object getParent() { public Object getParent() {
return parent; return parent;
...@@ -138,7 +141,6 @@ public class DesignMenuModel { ...@@ -138,7 +141,6 @@ public class DesignMenuModel {
String extensions[] = tool.getExtensions(); String extensions[] = tool.getExtensions();
if (extensions == null) if (extensions == null)
return true; return true;
String resourceExt = resource.getFileExtension(); String resourceExt = resource.getFileExtension();
if (resourceExt == null) if (resourceExt == null)
return false; return false;
...@@ -148,8 +150,25 @@ public class DesignMenuModel { ...@@ -148,8 +150,25 @@ public class DesignMenuModel {
return true; return true;
} }
return false; return false;
} // isEnabled() } // isEnabled(IResource)
public boolean isEnabled(String path) {
if (path == null)
return false;
String extensions[] = tool.getExtensions();
if (extensions == null)
return true;
int index=path.indexOf(".");
if (index<0) return false;
String resourceExt = path.substring(index+1);
for (int i=0; i < extensions.length; i++) {
if (resourceExt.equalsIgnoreCase(extensions[i]))
return true;
}
return false;
} // isEnabled(String)
public Tool getTool() { public Tool getTool() {
return tool; return tool;
} }
......
...@@ -55,28 +55,21 @@ ...@@ -55,28 +55,21 @@
<!-- Actually used --> <!-- Actually used -->
<syntax name = "JustValueSyntax" <syntax name="JustValueSyntax" format="%%ParamValue"></syntax>
format = "%%ParamValue"></syntax> <syntax name="TopModuleSyntax" format="-s%%TopModule" />
<syntax name = "TopModuleSyntax" <syntax name="TopModulesOtherSyntax" format="%(-s%%ParamValue%| %)" />
format = "-s%%TopModule"/> <syntax name="ModuleLibrarySyntax" format="%(-y%%ParamValue%| %)" />
<syntax name = "TopModulesOtherSyntax" <syntax name="SourceListSyntax" format="%(%%SourceList%| %)" />
format = "%(-s%%ParamValue%| %)"/> <syntax name="ExtraFilesSyntax" format="%(%%ParamValue%| %)" />
<syntax name = "ModuleLibrarySyntax" <syntax name="exeFileSyntax" format="%%ParamValue" />
format = "%(-y%%ParamValue%| %)"/> <syntax name="SwitchSyntax" format="-%%ParamName" />
<syntax name = "SourceListSyntax"
format = "%(%%SourceList%| %)"/>
<syntax name = "ExtraFilesSyntax" <syntax name="DbgCurrentFileSyntax" format="echo &quot;%%CurrentFile&quot; ;" />
format = "%(%%ParamValue%| %)"/> <syntax name="DbgChosenActionIndexSyntax" format="echo &quot;index=%%ChosenActionIndex&quot; ;" />
<syntax name = "exeFileSyntax"
format = "%%ParamValue"/>
<syntax name = "SwitchSyntax"
format = "-%%ParamName"/>
ChosenActionIndex
<!-- typedef --> <!-- typedef -->
...@@ -178,7 +171,7 @@ ...@@ -178,7 +171,7 @@
<action-menu> <action-menu>
<action label="Simulate" resource="%SimulationTopFile" check-extension="false" check-existence="true" /> <action label="Simulate" resource="%SimulationTopFile" check-extension="false" check-existence="true" />
<action label="Simulate for" resource="%%CurrentFile" check-extension="true"/> <action label="Simulate for" resource="%%SelectedFile" check-extension="true" check-existence="true"/>
<action label="Empty" resource="" /> <action label="Empty" resource="" />
<action label="Just try for" resource="%%OS" /> <action label="Just try for" resource="%%OS" />
</action-menu> </action-menu>
...@@ -293,6 +286,25 @@ ...@@ -293,6 +286,25 @@
default = "2&gt;&amp;1 | tee iverilog.log | grep --line-buffered -E 'error|warning' | grep --line-buffered -v &quot;(null):0&quot;" default = "2&gt;&amp;1 | tee iverilog.log | grep --line-buffered -E 'error|warning' | grep --line-buffered -v &quot;(null):0&quot;"
readonly = "false" readonly = "false"
visible = "true"/> visible = "true"/>
<parameter id = "DbgCurrentFile"
label = "DbgCurrentFile"
type = "StringType"
format = "DbgCurrentFileSyntax"
default = ""
readonly = "false"
visible = "true"/>
<parameter id = "ChosenActionIndex"
label = "ChosenActionIndex"
type = "StringType"
format = "DbgChosenActionIndexSyntax"
default = ""
readonly = "false"
visible = "true"/>
<!-- intentional error below - duplicate --> <!-- intentional error below - duplicate -->
<parameter id = "BuildDir" <parameter id = "BuildDir"
label = "project build directory" label = "project build directory"
...@@ -325,7 +337,10 @@ ...@@ -325,7 +337,10 @@
<output> <output>
<line name="command_line" sep=" "> <line name="command_line" sep=" ">
"%Param_Shell_Options" "%Param_Shell_Options"
"%DbgCurrentFile"
"%ChosenActionIndex"
"echo BuildDir=%BuildDir ;" "echo BuildDir=%BuildDir ;"
"echo CurrentFile=%%CurrentFile ;"
"echo SimulationTopFile=%SimulationTopFile ;" "echo SimulationTopFile=%SimulationTopFile ;"
"echo SimulationTopModule=%SimulationTopModule ;" "echo SimulationTopModule=%SimulationTopModule ;"
"%Param_PreExe" "%Param_PreExe"
......
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