Commit 216443b3 authored by Andrey Filippov's avatar Andrey Filippov

Continue with tool launch menus

parent e52ad884
......@@ -104,6 +104,13 @@ public class XMLConfig extends Config {
static final String CONTEXT_TOOL_ACTION_TAG = "action";
static final String CONTEXT_TOOL_ACTION_LABEL = "label";
static final String CONTEXT_TOOL_ACTION_RESOURCE = "resource";
static final String CONTEXT_TOOL_ACTION_CHECK_EXTENSION = "check-extension";
static final String CONTEXT_TOOL_ACTION_CHECK_EXISTENCE = "check-existence";
static final String CONTEXT_TOOL_DFLT_ACTION_LABEL = "Run for";
static final String CONTEXT_TOOL_DFLT_ACTION_RESOURCE = "%%CurrentFile";
static final String CONTEXT_TOOL_DFLT_ACTION_CHECK_EXTENSION = "true";
static final String CONTEXT_TOOL_DFLT_ACTION_CHECK_EXISTENCE = "false";
static final String CONTEXT_TOOL_EXTENSION_MASK_ATTR = "mask";
static final String CONTEXT_TOOL_SYNTAX_ERRORS = "errors";
......@@ -957,38 +964,58 @@ public class XMLConfig extends Config {
return extList;
}
private List<RunFor> readToolRunForList(Node toolNode, String toolName)
throws ConfigException
{
String toolInfo = "Tool '" + toolName + "'";
List<RunFor> runForList = new ArrayList<RunFor>();
List<Node> runForNodesList = findChildNodes(toolNode, CONTEXT_TOOL_ACTION_LIST_TAG);
if(runForNodesList.isEmpty())
return null;
if(runForNodesList.size() > 1)
throw new ConfigException(toolInfo +
" definition cannot contain several '" +
CONTEXT_OUTPUT_SECTION_TAG +
"' nodes");
Node runForNode = runForNodesList.get(0);
List<Node> runForNodes = findChildNodes(runForNode, CONTEXT_TOOL_ACTION_TAG);
for(Iterator<Node> n = runForNodes.iterator(); n.hasNext();) {
Node node = (Node)n.next();
String label = getAttributeValue(node, CONTEXT_TOOL_ACTION_LABEL);
if (label == null)
throw new ConfigException(toolInfo + ": Attribute '" + CONTEXT_TOOL_ACTION_LABEL + "' is absent");
String resource = getAttributeValue(node, CONTEXT_TOOL_ACTION_RESOURCE);
if (resource == null)
throw new ConfigException(toolInfo + ": Attribute '" + CONTEXT_TOOL_ACTION_RESOURCE + "' is absent");
runForList.add(new RunFor(label, resource));
}
return runForList;
private List<RunFor> readToolRunForList(Node toolNode, String toolName) throws ConfigException {
String toolInfo = "Tool '" + toolName + "'";
List<RunFor> runForList = new ArrayList<RunFor>();
List<Node> runForNodesList = findChildNodes(toolNode, CONTEXT_TOOL_ACTION_LIST_TAG);
if(runForNodesList.isEmpty()) {
runForList.add(new RunFor(
CONTEXT_TOOL_DFLT_ACTION_LABEL,
CONTEXT_TOOL_DFLT_ACTION_RESOURCE,
getBoolAttrValue(CONTEXT_TOOL_DFLT_ACTION_CHECK_EXTENSION),
getBoolAttrValue(CONTEXT_TOOL_DFLT_ACTION_CHECK_EXISTENCE)));
} else {
if(runForNodesList.size() > 1)
throw new ConfigException(toolInfo +
" definition cannot contain several '" +
CONTEXT_TOOL_ACTION_LIST_TAG +
"' nodes");
Node runForNode = runForNodesList.get(0);
List<Node> runForNodes = findChildNodes(runForNode, CONTEXT_TOOL_ACTION_TAG);
for(Iterator<Node> n = runForNodes.iterator(); n.hasNext();) {
Node node = (Node)n.next();
String label = getAttributeValue(node, CONTEXT_TOOL_ACTION_LABEL);
if (label == null)
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;
}
checkBoolAttr(checkExistenceAttr, CONTEXT_TOOL_ACTION_CHECK_EXISTENCE);
boolean checkExistence=getBoolAttrValue(checkExistenceAttr);
runForList.add(new RunFor(label, resource, checkExtension, checkExistence));
}
}
return runForList;
}
private List<Parameter> readParameters(Node node, Context context)
......
......@@ -83,7 +83,7 @@ public class Tool extends Context implements Cloneable, Inheritable {
params,
paramGroups,
commandLinesBlocks);
this.runfor=runfor;
this.runfor=runfor; // should it be cloned?
this.baseToolName = baseToolName;
this.label = label;
this.parentPackageName = parentPackageName;
......@@ -264,7 +264,11 @@ public class Tool extends Context implements Cloneable, Inheritable {
assert ((resources==null) || (resources.size() == 1));
resource = resources.get(0);
}
actualActions[i] = new RunFor(labels.get(0), resource);
actualActions[i] = new RunFor(
labels.get(0),
resource,
runfor.get(i).getCheckExtension(),
runfor.get(i).getCheckExistence());
}
return actualActions;
}
......
......@@ -18,17 +18,39 @@
package com.elphel.vdt.core.tools.params.types;
public class RunFor{
public class RunFor implements Cloneable{
public String label;
public String resource;
public RunFor(String label, String resource){
public boolean checkExtension;
public boolean checkExistence;
public RunFor(String label, String resource, boolean checkExtension, boolean checkExistence){
this.label=label;
this.resource=resource;
this.checkExtension=checkExtension;
this.checkExistence=checkExistence;
}
public RunFor(RunFor runFor){
this (
runFor.label,
runFor.resource,
runFor.checkExtension,
runFor.checkExistence);
}
public String getLabel(){
return label;
}
public String getResource(){
return resource;
}
public boolean getCheckExtension(){
return checkExtension;
}
public boolean getCheckExistence(){
return checkExistence;
}
public Object clone() { // did not clone context (intentionally)
return new RunFor(this);
}
}
......@@ -87,6 +87,8 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
private DrillDownAdapter drillDownAdapter;
private Action showLaunchConfigAction;
private Action launchAction;
private Action [] launchActions;
private Action showInstallationPropertiesAction;
private ClearAction clearInstallationPropertiesAction;
......@@ -176,7 +178,7 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
}
private void doLoadDesignMenu(String menuName) {
if (menuName != null) {
if (menuName != null) { // Horizontal menu bar
DesignMenu designMenu = ToolsCore.getDesignMenuManager().findDesignMenu(menuName);
viewer.setInput(designMenu);
List<Context> packages = ToolsCore.getDesignMenuManager().getPackageContexts(designMenu);
......@@ -226,10 +228,16 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
}
private void fillContextMenu(IMenuManager manager) {
manager.add(launchAction);
// manager.add(new Separator());
// manager.add(new Separator()); // test
// manager.add(launchAction); // test
// manager.add(new Separator());
// drillDownAdapter.addNavigationActions(manager);
// Other plug-ins can contribute there actions here
// Other plug-ins can contribute their actions here
manager.add(new Separator());
manager.add(showInstallationPropertiesAction);
manager.add(showPackagePropertiesAction);
......@@ -239,8 +247,9 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
}
private void fillLocalToolBar(IToolBarManager manager) {
manager.add(launchAction);
private void fillLocalToolBar(IToolBarManager manager) { // On Horizontal bar
manager.add(launchAction);
// manager.add(launchAction); // test
// manager.add(new Separator());
// drillDownAdapter.addNavigationActions(manager);
manager.add(new Separator());
......@@ -351,7 +360,7 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
}
};
showLaunchConfigAction.setText("Launch configuration");
showLaunchConfigAction.setToolTipText("Open launch configuration dialog for this tool");
showLaunchConfigAction.setToolTipText("Open launch configuration dialog for this tool"+" ** DBG **");
showLaunchConfigAction.setImageDescriptor(VDTPluginImages.DESC_LAUNCH_CONFIG);
launchAction = new Action() {
......@@ -366,7 +375,7 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
}
};
launchAction.setText(Txt.s("Action.ToolLaunch.Caption.Default"));
launchAction.setToolTipText(Txt.s("Action.ToolLaunch.ToolTip.Default"));
launchAction.setToolTipText(Txt.s("Action.ToolLaunch.ToolTip.Default")+" **DEBUGGING**");
launchAction.setImageDescriptor(VDTPluginImages.DESC_RUN_TOOL);
launchAction.setEnabled(false);
// launchAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
......@@ -436,7 +445,12 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
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()+"'");
System.out.println(
" label='"+runFor[i].getLabel()+
"', resource='"+runFor[i].getResource()+
"', checkExtension='"+runFor[i].getCheckExtension()+
"', checkExistence='"+runFor[i].getCheckExistence()+
"'");
}
}
}
......@@ -447,9 +461,10 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
&& (selectedItem.isEnabled(selectedResource));
launchAction.setEnabled(enabled);
if (enabled){
launchAction.setText(Txt.s("Action.ToolLaunch.Caption", new String[]{selectedResource.getName()}));
/* Andrey: Next apperas 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 */
launchAction.setToolTipText(Txt.s("Action.ToolLaunch.ToolTip", new String[]{selectedItem.getLabel(), selectedResource.getName()}));
Tool tool = selectedItem.getTool();
if (tool!=null){
......
......@@ -177,8 +177,8 @@
</extensions-list>
<action-menu>
<action label="Simulate" resource="%SimulationTopFile" />
<action label="Simulate for" resource="%%CurrentFile" />
<action label="Simulate" resource="%SimulationTopFile" check-extension="false" check-existence="true" />
<action label="Simulate for" resource="%%CurrentFile" check-extension="true"/>
<action label="Empty" resource="" />
<action label="Just try for" resource="%%OS" />
</action-menu>
......
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