Commit f88dd96e authored by Andrey Filippov's avatar Andrey Filippov

Implemented multiple-choice launch actions

parent 216443b3
......@@ -145,5 +145,6 @@ public class VDT {
public static final String GENERATOR_ID_CURRENT_FILE = "CurrentFile";
public static final String GENERATOR_ID_SELECTED_FILE = "SelectedFile";
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";
} // class VDT
......@@ -100,8 +100,8 @@ public class VerilogUtils {
* Returns the top module(s) for given verilog file.
*/
public static String[] getTopModuleNames(IFile file) {
OutlineElement[] outlineElements= getTopModulesVeditor(file);
public static String[] getTopModuleNames(IFile file) { //L/x353/data/vdt/workspace_11-runtime/x353/x353_1.tf
OutlineElement[] outlineElements= getTopModulesVeditor(file); // empty inside
if (outlineElements==null) return null;
String [] list = new String[outlineElements.length];
for (int i=0;i<list.length;i++) {
......
......@@ -73,7 +73,13 @@ public class ParamBasedOption extends Option {
}
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();
return value;
}
......
......@@ -990,28 +990,29 @@ public class XMLConfig extends Config {
for(Iterator<Node> n = runForNodes.iterator(); n.hasNext();) {
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);
if (label == null)
label=CONTEXT_TOOL_DFLT_ACTION_LABEL;
String resource = getAttributeValue(node, CONTEXT_TOOL_ACTION_RESOURCE);
if (resource == null)
resource= CONTEXT_TOOL_DFLT_ACTION_RESOURCE;
String checkExtensionAttr=getAttributeValue(node, CONTEXT_TOOL_ACTION_CHECK_EXTENSION);
if (checkExtensionAttr==null){
checkExtensionAttr=CONTEXT_TOOL_DFLT_ACTION_CHECK_EXTENSION;
}
checkBoolAttr(checkExtensionAttr, CONTEXT_TOOL_ACTION_CHECK_EXTENSION);
boolean checkExtension=getBoolAttrValue(checkExtensionAttr);
String checkExistenceAttr=getAttributeValue(node, CONTEXT_TOOL_ACTION_CHECK_EXISTENCE);
if (checkExistenceAttr==null){
checkExistenceAttr=CONTEXT_TOOL_DFLT_ACTION_CHECK_EXISTENCE;
if ((resource == null) || (resource.length()==0)) {
// resource= CONTEXT_TOOL_DFLT_ACTION_RESOURCE;
resource = "";
} else {
String checkExtensionAttr=getAttributeValue(node, CONTEXT_TOOL_ACTION_CHECK_EXTENSION);
if (checkExtensionAttr==null){
checkExtensionAttr=CONTEXT_TOOL_DFLT_ACTION_CHECK_EXTENSION;
}
checkBoolAttr(checkExtensionAttr, CONTEXT_TOOL_ACTION_CHECK_EXTENSION);
checkExtension=getBoolAttrValue(checkExtensionAttr);
String checkExistenceAttr=getAttributeValue(node, CONTEXT_TOOL_ACTION_CHECK_EXISTENCE);
if (checkExistenceAttr==null){
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));
}
}
......
......@@ -31,7 +31,7 @@ public abstract class AbstractGenerator {
protected final String prefix, suffix;
protected String separator;
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() {
this(false);
......@@ -119,8 +119,11 @@ public abstract class AbstractGenerator {
return output;
}
protected void fault(String message) {
protected String fault(String message) {
if (menuMode)
return "";
MessageUI.error("Generator '" + getName() + "' fault: " + message);
return null;
}
protected abstract String[] getStringValues();
......
......@@ -17,8 +17,9 @@
*******************************************************************************/
package com.elphel.vdt.core.tools.generators;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
//import org.eclipse.core.resources.IFile;
//import org.eclipse.core.resources.IResource;
//import org.eclipse.ui.IPageLayout;
import com.elphel.vdt.VDT;
import com.elphel.vdt.ui.variables.SelectedResourceManager;
......@@ -31,13 +32,17 @@ public class CurrentFileBaseGenerator extends AbstractGenerator {
}
protected String[] getStringValues() {
IResource resource = SelectedResourceManager.getDefault().getSelectedResource();
if((resource != null) && (resource.getType() == IResource.FILE)) {
String fullName=((IFile)resource).getLocation().toOSString();
// IResource resource = SelectedResourceManager.getDefault().getSelectedResource();
String fullName=SelectedResourceManager.getDefault().getChosenTarget();
// if((resource != null) && (resource.getType() == IResource.FILE)) {
// String fullName=((IFile)resource).getLocation().toOSString();
if (fullName!=null){
int dot = fullName.lastIndexOf('.');
return new String[] { (dot <0) ? fullName : fullName.substring(0, dot) };
}
return new String[] { "" };
}
}
......@@ -44,12 +44,13 @@ public class CurrentFileGenerator extends AbstractGenerator {
*/
protected String[] getStringValues() {
IResource resource;
if (getMenuMode()) resource = SelectedResourceManager.getDefault().getViewSelectedResource(IPageLayout.ID_RES_NAV);
else resource = SelectedResourceManager.getDefault().getSelectedResource();
if((resource != null) && (resource.getType() == IResource.FILE))
return new String[] { ((IFile)resource).getLocation().toOSString() };
if (getMenuMode()) {
resource = SelectedResourceManager.getDefault().getViewSelectedResource(IPageLayout.ID_RES_NAV);
if((resource != null) && (resource.getType() == IResource.FILE))
return new String[] { ((IFile)resource).getLocation().toOSString() };
} else {
return new String[] { SelectedResourceManager.getDefault().getChosenTarget()};
}
return new String[] { "" };
}
}
......@@ -52,9 +52,10 @@ public class SourceListGenerator extends AbstractGenerator {
protected String[] getStringValues() {
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) {
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];
for (int i=0; i < files.length; i++)
file_names[i] = files[i].getProjectRelativePath().toOSString(); //.getName();
......
......@@ -37,7 +37,8 @@ public class TopModuleNameGenerator extends AbstractGenerator {
return NAME;
}
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)) {
String[] outlineElementsNames= VerilogUtils.getTopModuleNames((IFile)resource);
if ((outlineElementsNames!=null) && (outlineElementsNames.length>0)) return new String[] {outlineElementsNames[0]};
......
......@@ -45,7 +45,8 @@ public class TopModulesNameGenerator extends AbstractGenerator {
return NAME;
}
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)) {
String[] outlineElementsNames= VerilogUtils.getTopModuleNames((IFile)resource);
if ((outlineElementsNames!=null) && (outlineElementsNames.length>0)) return outlineElementsNames;
......
......@@ -122,9 +122,11 @@ public class Parameter implements Cloneable, Updateable {
this.relevant = relevant;
this.hasDependentParameters = false;
this.sourceXML=sourceXML;
/*
if (id.equals("SimulationTopFile")){ // Andrey
System.out.println("Creating parameter SimulationTopFile, defaultValue="+defaultValue);
}
*/
}
protected Parameter(Parameter param) {
this(param.id,
......@@ -167,10 +169,11 @@ public class Parameter implements Cloneable, Updateable {
this.context = context;
*/
/*
if (id.equals("SimulationTopFile")){ // Andrey
System.out.println("Initializing parameter SimulationTopFile, defaultValue="+defaultValue);
}
*/
// Andrey: replacing with
if(this.context == context) {
......@@ -312,9 +315,9 @@ public class Parameter implements Cloneable, Updateable {
//
public void setCurrentValue(String value) throws ToolException {
if (id.equals("SimulationTopFile")){ // Andrey
System.out.println("setCurrentValue() SimulationTopFile, value="+value);
}
// if (id.equals("SimulationTopFile")){ // Andrey
// System.out.println("setCurrentValue() SimulationTopFile, value="+value);
// }
if(type.isList())
throw new ToolException("Assigning a non-list value to list parameter");
......@@ -328,9 +331,9 @@ public class Parameter implements Cloneable, Updateable {
}
public void setCurrentValue(List<String> value) throws ToolException {
if (id.equals("SimulationTopFile")){ // Andrey
System.out.println("setCurrentValue() SimulationTopFile a list value");
}
// if (id.equals("SimulationTopFile")){ // Andrey
// System.out.println("setCurrentValue() SimulationTopFile a list value");
// }
if(!type.isList())
throw new ToolException("Assigning a list value to non-list parameter");
......@@ -352,8 +355,11 @@ public class Parameter implements Cloneable, Updateable {
return currentValue;
}
public List<String> getDefaultValue() {
return getDefaultValue(false);
}
public List<String> getDefaultValue(boolean menuMode) {
String resolvedDefaultValue = ConditionUtils.resolveContextCondition(context, defaultValue);
String errmsg = "Parameter '" + id +
"' of context '" + context.getName() +
......@@ -363,7 +369,7 @@ public class Parameter implements Cloneable, Updateable {
FormatProcessor processor = new FormatProcessor(new Recognizer[] {
//new RepeaterRecognizer(),
new SimpleGeneratorRecognizer(),
new SimpleGeneratorRecognizer(menuMode),
new ContextParamRecognizer(context)
});
......@@ -386,10 +392,11 @@ public class Parameter implements Cloneable, Updateable {
// returns current value if it is set
// otherwise returns default value
public List<String> getValue() {
/*
if (id.equals("SimulationTopFile")){ // Andrey
System.out.println("getValue() SimulationTopFile");
}
*/
if(!currentValue.isEmpty())
return currentValue;
......@@ -399,10 +406,11 @@ public class Parameter implements Cloneable, Updateable {
// returns external form of the current value unless it equals null;
// otherwise returns external form of the default value
public List<String> getExternalValueForm() {
/*
if (id.equals("SimulationTopFile")){ // Andrey
System.out.println("getExternalValueForm() SimulationTopFile");
}
*/
List<String> externalFormValue = new ArrayList<String>();
for(Iterator<String> i = getValue().iterator(); i.hasNext();) {
......
......@@ -44,6 +44,7 @@ public class Tool extends Context implements Cloneable, Inheritable {
private List<String> extensions;
private List<RunFor> runfor;
private int choice; // selected variant for runfor
private Tool baseTool;
......@@ -94,11 +95,19 @@ public class Tool extends Context implements Cloneable, Inheritable {
this.toolErrors = toolErrors;
this.toolWarnings = toolWarnings;
this.toolInfo = toolInfo;
this.choice=0;
}
public List<RunFor> getRunFor(){
return runfor;
}
public int getChoice(){
return choice;
}
public void setChoice(int choice){
this.choice=choice;
}
public void init(Config config) throws ConfigException {
if(initialized)
......@@ -231,7 +240,7 @@ public class Tool extends Context implements Cloneable, Inheritable {
public RunFor[] getMenuActions(IProject project) {
if(runfor == 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
//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 {
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());
} 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();
if (context != null) {
OptionsCore.doLoadContextOptions(context, project);
/*
try {
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());
} 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);
/*
try {
buildParams();
} catch (ToolException e) { // Do nothing here
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 {
* 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) && !param.getIsChild())
return param;
......
......@@ -30,9 +30,10 @@ public class SimpleGeneratorRecognizer implements Recognizer {
new ProjectNameGenerator(),
new ProjectPathGenerator(),
new TopModuleNameGenerator(),
new SelectedFileGenerator(),
new CurrentFileGenerator(),
// new ViewSelectedFileGenerator(),
new CurrentFileBaseGenerator()
new CurrentFileBaseGenerator(),
new ChosenActionGenerator()
};
public SimpleGeneratorRecognizer(){
......
......@@ -44,6 +44,7 @@ public class RunFor implements Cloneable{
public String getResource(){
return resource;
}
public boolean getCheckExtension(){
return checkExtension;
}
......
......@@ -21,10 +21,14 @@ import java.util.Stack;
import com.elphel.vdt.VerilogUtils;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
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.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
......@@ -58,6 +62,10 @@ public class SelectedResourceManager implements IWindowListener, ISelectionListe
private ITextSelection fSelectedText = null;
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() {
IWorkbench workbench = PlatformUI.getWorkbench();
......@@ -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)
*/
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
// System.out.println("SelectedResourceManager.selectionChanged()");
IWorkbenchWindow window = part.getSite().getWorkbenchWindow();
if (fWindowStack.isEmpty() || !fWindowStack.peek().equals(window)) {
// selection is not in the active window
......@@ -212,15 +221,54 @@ public class SelectedResourceManager implements IWindowListener, ISelectionListe
IResource selectedResource = getSelectedResource(part, selection);
if (selectedResource != null) {
fSelectedResource = selectedResource;
if ((selectedResource.getType()==IResource.FILE) && (VerilogUtils.isHhdlFile((IFile)fSelectedResource)))
// if (selectedResource.getName().endsWith(".v"))
// System.out.println("SelectedResourceManager.selectionChanged(): fSelectedResource changed to "+fSelectedResource.getName());
if ((selectedResource.getType()==IResource.FILE) && (VerilogUtils.isHhdlFile((IFile)fSelectedResource))){
fSelectedVerilogFile = selectedResource; /* Maybe same will work for vhdl too? */
// System.out.println("SelectedResourceManager.selectionChanged(): fSelectedVerilogFile changed to "+fSelectedVerilogFile.getName());
}
}
if (selection instanceof ITextSelection) {
fSelectedText = (ITextSelection)selection;
}
} // 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 {
* @throws CoreException if there is no selection
*/
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) {
abort(Txt.s("Error.Variable.Verilog.NoSelection", new String[]{getReferenceExpression(variable, null)}), null);
}
......
......@@ -29,10 +29,12 @@ import org.eclipse.jface.action.*;
import org.eclipse.ui.*;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.SWT;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import com.elphel.vdt.core.Utils;
......@@ -48,6 +50,7 @@ import com.elphel.vdt.Txt;
import com.elphel.vdt.VDT;
//import com.elphel.vdt.VDTPlugin;
import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.veditor.preference.PreferenceStrings;
import com.elphel.vdt.ui.MessageUI;
import com.elphel.vdt.ui.VDTPluginImages;
import com.elphel.vdt.ui.variables.SelectedResourceManager;
......@@ -86,9 +89,9 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
private TreeViewer viewer;
private DrillDownAdapter drillDownAdapter;
private Action showLaunchConfigAction;
private Action launchAction;
// private Action launchAction;
private Action [] launchActions;
private Action showInstallationPropertiesAction;
private ClearAction clearInstallationPropertiesAction;
......@@ -116,6 +119,9 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
private IMemento memento;
IDoubleClickListener doubleClickListener=null;
private Action [] launchActions;
/**
* The constructor.
*/
......@@ -162,7 +168,7 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
makeActions();
hookContextMenu();
hookDoubleClickAction();
/**+ hookDoubleClickAction(); */
contributeToActionBars();
if (memento != null)
......@@ -183,7 +189,7 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
viewer.setInput(designMenu);
List<Context> packages = ToolsCore.getDesignMenuManager().getPackageContexts(designMenu);
showPackagePropertiesToolbarAction.setContexts(packages);
clearPackagePropertiesAction.setContexts(packages);
clearPackagePropertiesAction.setContexts(packages); // toolBarSeparator already null here
List<Context> projects = ToolsCore.getDesignMenuManager().getProjectContexts(designMenu);
showProjectPropertiesToolbarAction.setContexts(projects);
clearProjectPropertiesAction.setContexts(projects);
......@@ -198,13 +204,12 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
}
}
private void hookContextMenu() {
MenuManager menuMgr = new MenuManager("#PopupMenu");
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
DesignFlowView.this.fillContextMenu(manager);
DesignFlowView.this.fillContextMenu(manager); // context (right-click) menu
}
});
Menu menu = menuMgr.createContextMenu(viewer.getControl());
......@@ -212,13 +217,15 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
getSite().registerContextMenu(menuMgr, viewer);
}
//
private void contributeToActionBars() {
IActionBars bars = getViewSite().getActionBars();
fillLocalPullDown(bars.getMenuManager());
fillLocalToolBar(bars.getToolBarManager());
fillLocalPullDown(bars.getMenuManager()); // rightmost pull-down
fillLocalToolBar(bars.getToolBarManager()); // horizontal bar
}
private void fillLocalPullDown(IMenuManager manager) {
private void fillLocalPullDown(IMenuManager manager) { //rightmost pull-down
manager.add(clearInstallationPropertiesAction);
manager.add(clearPackagePropertiesAction);
manager.add(clearProjectPropertiesAction);
......@@ -226,19 +233,21 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
manager.add(new Separator());
manager.add(selectDesignMenuAction);
}
private void fillContextMenu(IMenuManager manager) {
manager.add(launchAction);
// manager.add(new Separator()); // test
// manager.add(launchAction); // test
private void fillContextMenu(IMenuManager manager) { // context (right-click) menu
// Always come here after setting launchActions, so just add all launchActions here
/**+ manager.add(launchAction); */
if (launchActions!=null) {
for (Action action:launchActions){
manager.add(action); // No Separator??
}
}
System.out.println("fillContextMenu(), launchActions="+launchActions);
// manager.add(new Separator());
// drillDownAdapter.addNavigationActions(manager);
// Other plug-ins can contribute their actions here
manager.add(new Separator());
manager.add(new Separator());
manager.add(showInstallationPropertiesAction);
manager.add(showPackagePropertiesAction);
manager.add(showProjectAction);
......@@ -248,18 +257,26 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
}
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(new Separator());
// drillDownAdapter.addNavigationActions(manager);
manager.add(new Separator());
manager.add(new Separator("toolbar-separator"));
manager.add(showInstallationPropertiesAction);
manager.add(showPackagePropertiesToolbarAction);
manager.add(showProjectPropertiesToolbarAction);
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() {
showInstallationPropertiesAction = new Action() {
public void run() {
......@@ -360,13 +377,16 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
}
};
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);
launchActions=null;
doubleClickListener=null;
/**+
launchAction = new Action() {
public void run() {
try {
launchTool(selectedItem);
launchTool(selectedItem,0);
} catch (Exception e) {
MessageUI.error( Txt.s("Action.ToolLaunch.Error",
new String[] {selectedItem.getLabel(), e.getMessage()})
......@@ -374,22 +394,42 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
}
}
};
launchAction.setText(Txt.s("Action.ToolLaunch.Caption.Default"));
launchAction.setToolTipText(Txt.s("Action.ToolLaunch.ToolTip.Default")+" **DEBUGGING**");
launchAction.setImageDescriptor(VDTPluginImages.DESC_RUN_TOOL);
launchAction.setEnabled(false);
*/
// launchAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
// getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
} // makeActions()
private void removeDoubleClickAction() {
if (doubleClickListener!=null){
viewer.removeDoubleClickListener(doubleClickListener);
doubleClickListener=null;
}
}
private void hookDoubleClickAction() {
viewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
launchAction.run();
}
});
if ((launchActions==null) || (launchActions[0]==null)) return;
doubleClickListener=new IDoubleClickListener() {
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) {
// MessageDialog.openInformation( viewer.getControl().getShell()
// , "Design Flow"
......@@ -415,6 +455,8 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
/* Method declared on ISelectionListener */
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
// System.out.println("DesignFlowView.selectionChanged()");
IResource oldSelection = selectedResource;
selectedResource = SelectedResourceManager.getDefault().getSelectedResource(part, selection);
IProject newProject = selectedResource == null
......@@ -430,6 +472,8 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
} // selectionChanged()
private void updateLaunchAction() {
// System.out.println("DesignFlowView.updateLaunchAction()");
IProject project = selectedResource == null
? null
: selectedResource.getProject();
......@@ -438,33 +482,97 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
// Selected item should be not null, but resource - may be
// RunFor[] getMenuActions()
RunFor [] runFor=null;
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()+
"', checkExtension='"+runFor[i].getCheckExtension()+
"', checkExistence='"+runFor[i].getCheckExistence()+
"'");
runFor=tool.getMenuActions(project);
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER)) {
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()+
"', checkExtension='"+runFor[i].getCheckExtension()+
"', checkExistence='"+runFor[i].getCheckExistence()+
"'");
}
}
}
}
}
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
&& (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);
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()})+"<<<<<");
/* 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()}));
Tool tool = selectedItem.getTool();
if (tool!=null){
......@@ -475,7 +583,7 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
launchAction.setText(Txt.s("Action.ToolLaunch.Caption.Default"));
launchAction.setToolTipText(Txt.s("Action.ToolLaunch.ToolTip.Default"));
}
*/
enabled = (selectedItem != null)
&& (selectedResource != null)
&& (selectedItem.getPackageContext() != null);
......@@ -509,14 +617,17 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
showPropertiesAction.setEnabled(enabled);
clearToolPropertiesAction.setEnabled(enabled);
} // updateLaunchAction()
private void launchTool(DesignMenuModel.Item item) throws CoreException {
Tool tool = selectedItem.getTool();
private void launchTool(DesignMenuModel.Item item, int choice, String fullPath) throws CoreException {
Tool tool = selectedItem.getTool();
if (tool != null) {
tool.setChoice(0);
SelectedResourceManager.getDefault().updateActionChoice(fullPath, choice); // Andrey
LaunchCore.launch( tool
, selectedResource.getProject()
, selectedResource.getFullPath().toString() );
// , selectedResource.getFullPath().toString() );
, fullPath);
} else if (selectedItem.hasChildren()) {
if (viewer.getExpandedState(selectedItem))
viewer.collapseToLevel(selectedItem, AbstractTreeViewer.ALL_LEVELS);
......
......@@ -81,6 +81,9 @@ public class DesignMenuModel {
public boolean isEnabled(IResource resource) {
return false;
}
public boolean isEnabled(String path) {
return false;
}
public Object getParent() {
return parent;
......@@ -138,7 +141,6 @@ public class DesignMenuModel {
String extensions[] = tool.getExtensions();
if (extensions == null)
return true;
String resourceExt = resource.getFileExtension();
if (resourceExt == null)
return false;
......@@ -148,8 +150,25 @@ public class DesignMenuModel {
return true;
}
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() {
return tool;
}
......
......@@ -55,28 +55,21 @@
<!-- Actually used -->
<syntax name = "JustValueSyntax"
format = "%%ParamValue"></syntax>
<syntax name = "TopModuleSyntax"
format = "-s%%TopModule"/>
<syntax name = "TopModulesOtherSyntax"
format = "%(-s%%ParamValue%| %)"/>
<syntax name = "ModuleLibrarySyntax"
format = "%(-y%%ParamValue%| %)"/>
<syntax name = "SourceListSyntax"
format = "%(%%SourceList%| %)"/>
<!-- Actually used -->
<syntax name="JustValueSyntax" format="%%ParamValue"></syntax>
<syntax name="TopModuleSyntax" format="-s%%TopModule" />
<syntax name="TopModulesOtherSyntax" format="%(-s%%ParamValue%| %)" />
<syntax name="ModuleLibrarySyntax" format="%(-y%%ParamValue%| %)" />
<syntax name="SourceListSyntax" format="%(%%SourceList%| %)" />
<syntax name="ExtraFilesSyntax" format="%(%%ParamValue%| %)" />
<syntax name="exeFileSyntax" format="%%ParamValue" />
<syntax name="SwitchSyntax" format="-%%ParamName" />
<syntax name = "ExtraFilesSyntax"
format = "%(%%ParamValue%| %)"/>
<syntax name = "exeFileSyntax"
format = "%%ParamValue"/>
<syntax name = "SwitchSyntax"
format = "-%%ParamName"/>
<syntax name="DbgCurrentFileSyntax" format="echo &quot;%%CurrentFile&quot; ;" />
<syntax name="DbgChosenActionIndexSyntax" format="echo &quot;index=%%ChosenActionIndex&quot; ;" />
ChosenActionIndex
<!-- typedef -->
......@@ -178,7 +171,7 @@
<action-menu>
<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="Just try for" resource="%%OS" />
</action-menu>
......@@ -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;"
readonly = "false"
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 -->
<parameter id = "BuildDir"
label = "project build directory"
......@@ -325,7 +337,10 @@
<output>
<line name="command_line" sep=" ">
"%Param_Shell_Options"
"%DbgCurrentFile"
"%ChosenActionIndex"
"echo BuildDir=%BuildDir ;"
"echo CurrentFile=%%CurrentFile ;"
"echo SimulationTopFile=%SimulationTopFile ;"
"echo SimulationTopModule=%SimulationTopModule ;"
"%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